// JavaScript Document

var exp_emailtxt = /^[_0-9a-z\-\.]+$/;
var exp_email = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
var exp_num = /^\d+$/;
var exp_phone = /^[\d]{6,}$/;
var exp_addr = /^(.){6,}$/;
//var exp_pwd = /^.*(?=.{6,})(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[@#$%^&+=]).*$/;
var exp_pwd = /^[_0-9a-zA-Z\-\.@#$%\^&\+=]{6,}$/;

$(document).ready(
	function()
	{
	    $('#header a').click(function() {
            $('#header ul.navi a').removeClass('active');
            blackveilIn($(this).attr('href'));

            return false;
		});
		
        $('#header ul.navi a').click(function() {
            $('#header ul.navi a').removeClass('active');
            $(this).addClass('active');
            blackveilIn($(this).attr('href'));
            
            return false;
		});
		
		var scrsize = getScreenSize();
		var cont_h = $('#container')[0].offsetHeight;
		if (cont_h < scrsize.h) {
		    $('#container').css('height',scrsize.h + 'px');
		}
		//blackveilOut();
    }
);

$(window).load(
	function()
	{
		blackveilOut();
    }
);

function blackveilOut() {
	$('#blackveil').animate(
	    {opacity:0},
        1000 * 1,
        null, //jQuery.easing.def = 'easeInBounce',
    	function() {
    	    $('#blackveil').hide();
		}
	);
}
function blackveilIn(gohref) {
    $('#blackveil').stop();
    $('#blackveil').show();
	$('#blackveil').animate(
	    {opacity:1},
        1000 * 0.3,
        null,//jQuery.easing.def = 'easeInBounce',
    	function() {
    	    window.location.href = gohref;
		}
	);
}

function check_empty(arr_inputs) {
    var notfilled = 0;
    for (i=0; i<arr_inputs.length; i++ ) {
        if (arr_inputs[i].value == '') {
            notfilled++;
        }
    }

    return notfilled;
}

function callAjax(phpstring, callback) {
    $.ajax({
        type: "POST",
        url: "aj_dialer.php",
        dataType: 'json',
        data: phpstring,
        //Evento di riuscita
        success: callback
    });
}

function getScreenSize() {
    var myWidth = 0, myHeight = 0;
    if( typeof( window.innerWidth ) == 'number' ) {
        //Non-IE
        myWidth = window.innerWidth;
        myHeight = window.innerHeight;
    } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
        //IE 6+ in 'standards compliant mode'
        myWidth = document.documentElement.clientWidth;
        myHeight = document.documentElement.clientHeight;
    } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
        //IE 4 compatible
        myWidth = document.body.clientWidth;
        myHeight = document.body.clientHeight;
    }
    /*window.alert( 'Width = ' + myWidth );
    window.alert( 'Height = ' + myHeight );*/

    ret = new Object();
    ret.w = myWidth;
    ret.h = myHeight;

    return ret;
}


