/* INIZIO */

var nts = iex = ffx = false
if (document.layers){ //Netscape 4.x 
    nts = true;
} 
else if (document.all){ // Explorer 
    iex = true;
}
else if (document.getElementById){ //Netscape 6
    ffx = true;
}


function trim(stringa){
    while (stringa.substring(0,1) == ' '){
        stringa = stringa.substring(1, stringa.length);
    }
    while (stringa.substring(stringa.length-1, stringa.length) == ' '){
        stringa = stringa.substring(0,stringa.length-1);
    }
    return stringa;
}

function cleanField () {
    var arr_field = new Array("txNome","txCognome","txVia","txCitta","txNumero","txComune","txCap","txPrefisso","txTelefono","txEmail","txConfermaEmail","txProfessione","txTarga","txMarca","txModello","txAnnoimm");
    
    var arr_field_value = new Array("nome","cognome","via","citt"+String.fromCharCode(224),"numero","comune","cap","prefisso","telefono","email","conferma email","professione","targa","marca autoveicolo","modello autoveicolo","anno immatricolazione");
    
    for (a=0;a<=arr_field.length;a++){
       for (b=0;b<=arr_field_value.length;b++){
        if (document.getElementById("ctl00_cphContent_"+arr_field[a])){
            if (document.getElementById("ctl00_cphContent_"+arr_field[a]).value == arr_field_value[b]){
                document.getElementById("ctl00_cphContent_"+arr_field[a]).value = '';                
            }
          }
       }
    }
    
}

function show_submit_buttom() {
    
    if (document.getElementById('ctl00_cphContent_imgBtIscriviti')){
        document.getElementById('ctl00_cphContent_imgBtIscriviti').style.display = '';
    }
    
    if (document.getElementById('ctl00_cphContent_imgBtAttiva')){
        document.getElementById('ctl00_cphContent_imgBtAttiva').style.display = '';
    }
    

}

function customValidatorRequireField(oSrc, args) {

    var box_text = oSrc.parentNode.parentNode;
    var box_input = oSrc.parentNode;
    if (trim(args.Value) == "") {
        box_text.className = "box_text_error";
        box_input.className = "box_input_error";
        args.IsValid = false;
        show_submit_buttom();
    } else {       
        if (iex){
            var nxtSib = box_text.nextSibling;
            var countNode = box_text.parentNode.childNodes.length
        }else{
            var nxtSib = box_text.nextSibling.nextSibling ;
            var countNode = box_text.parentNode.childElementCount
        }
        
        if (countNode == 2 && nxtSib != null){
            box_text.className = "box_text_marg";
        }else{
             box_text.className = "box_text";
        }
        
        box_input.className = "box_input";
        args.IsValid = true;
    }
}
function customValidatorRequireShortField(oSrc, args) {

    var box_text = oSrc.parentNode.parentNode;
    var box_input = oSrc.parentNode;
    if (trim(args.Value) == "") {
        box_text.style.width = "80px"
        box_text.className = "box_text_error";
        box_input.className = "box_input_error";
        args.IsValid = false;
        show_submit_buttom();
    } else {       
        if (iex){
            var nxtSib = box_text.nextSibling;
            var countNode = box_text.parentNode.childNodes.length
        }else{
            var nxtSib = box_text.nextSibling.nextSibling ;
            var countNode = box_text.parentNode.childElementCount
        }
        
        if (countNode == 2 && nxtSib != null){
            box_text.className = "box_text_marg";
        }else{
             box_text.className = "box_text";
        }
        box_text.style.width = "90px"
        box_input.className = "box_input2";
        args.IsValid = true;
    }
}

function customValidatorRequireFieldSelect(oSrc, args) {

    if (trim(args.Value) == "") {
        args.IsValid = false;
        show_submit_buttom();
    } else {
        args.IsValid = true;
    }
}

function customValidatorEmailField(oSrc, args) {
    var espressione = /^[_a-z0-9+-/']+(\.[_a-z0-9+-/']+)*@[a-z0-9-]+(\.[a-z0-9-]+)+$/;
    var box_text = oSrc.parentNode.parentNode;
    var box_input = oSrc.parentNode;
    
    if (trim(args.Value) == "" || !espressione.test(args.Value)) {
        box_text.className = "box_text_error";
        box_input.className = "box_input_error";
        args.IsValid = false;
        show_submit_buttom();
    } else {
        box_text.className = "box_text";
        box_input.className = "box_input2";
        args.IsValid = true;
    }
}

function customValidatorEmailFieldLottomatica(oSrc, args) {
    var espressione = /^[_a-z0-9+-/']+(\.[_a-z0-9+-/']+)*@[a-z0-9-]+(\.[a-z0-9-]+)+$/;
    var box_text = oSrc.parentNode.parentNode;
    var box_input = oSrc.parentNode;
    
    if (trim(args.Value) == "" || !espressione.test(args.Value)) {
        box_text.className = "box_text_error";
        box_text.style.width = "180px";
        box_input.className = "box_input_error";
        args.IsValid = false;
        show_submit_buttom();
    } else {
        box_text.className = "box_text";
        box_text.style.width = "";
        box_input.className = "box_input";
        args.IsValid = true;
    }
}

function RequiredPrivacy(oSrc, args){
  if (document.getElementById('ctl00_cphContent_cbPrivacy').checked == false) {
    args.IsValid = false;
    show_submit_buttom();
  }else{
    args.IsValid = true;
  }
 }
 
 
 function customValidatorCardField(oSrc, args) {

    var box_text = oSrc.parentNode.parentNode;
    var box_input = oSrc.parentNode;
    
    var card_number = args.Value
    if (trim(card_number) == "" || isNaN(card_number) || card_number.length != 8) {
        box_text.className = "box_text_error";
        box_input.className = "box_input_error";
        args.IsValid = false;
        show_submit_buttom();
    } else {       
        if (iex){
            var nxtSib = box_text.nextSibling;
            var countNode = box_text.parentNode.childNodes.length
        }else{
            var nxtSib = box_text.nextSibling.nextSibling ;
            var countNode = box_text.parentNode.childElementCount
        }
        
        if (countNode == 2 && nxtSib != null){
            box_text.className = "box_text_marg";
        }else{
             box_text.className = "box_text";
        }
        
        box_input.className = "box_input";
        args.IsValid = true;
    }
}

 function customValidatorCapField(oSrc, args) {

    var box_text = oSrc.parentNode.parentNode;
    var box_input = oSrc.parentNode;
    
    var card_number = args.Value
    if (trim(card_number) == "" || isNaN(card_number) || card_number.length != 5) {
        box_text.className = "box_text_error";
        box_input.className = "box_input_error";
        args.IsValid = false;
        show_submit_buttom();
    } else {       
        if (iex){
            var nxtSib = box_text.nextSibling;
            var countNode = box_text.parentNode.childNodes.length
        }else{
            var nxtSib = box_text.nextSibling.nextSibling ;
            var countNode = box_text.parentNode.childElementCount
        }
        
        if (countNode == 2 && nxtSib != null){
            box_text.className = "box_text_marg";
        }else{
             box_text.className = "box_text";
        }
        
        box_input.className = "box_input";
        args.IsValid = true;
    }
}

 function setErrorClass(id_div){
    
    if (document.getElementById(id_div)){
        document.getElementById(id_div).className = "box_text_error";
        document.getElementById(id_div+'_input').className = "box_input_error";
    }    
 }
 
 function CheckBoxListValidatorI(source, args)
    {
       var chkListaTipoModificaciones= document.getElementById ('ctl00_cphContent_wz_questionario_wz_I');
       var chkLista= chkListaTipoModificaciones.getElementsByTagName("input");
       for(var i=0;i<chkLista.length;i++)
        {  
            if(chkLista[i].checked)
            {
                args.IsValid = true;
                return;
            }
        }
      args.IsValid = false;
    }
    
 function CheckBoxListValidatorQ(source, args)
    {
       var chkListaTipoModificaciones= document.getElementById ('ctl00_cphContent_wz_questionario_wz_Q');
       var chkLista= chkListaTipoModificaciones.getElementsByTagName("input");
       for(var i=0;i<chkLista.length;i++)
        {  
            if(chkLista[i].checked)
            {
                args.IsValid = true;
                return;
            }
        }
      args.IsValid = false;
    }
    
function mostra_eta_figli(elem_check_si){
    
    if (elem_check_si && elem_check_si.checked){
    
        if (document.getElementById('eta_figli_left')){
            document.getElementById('eta_figli_left').style.display = ''
            document.getElementById('eta_figli_right').style.display = ''
        }
        if (document.getElementById('ctl00_cphContent_cbFigliNo')){
            document.getElementById('ctl00_cphContent_cbFigliNo').checked = false    
        }
    }else{
        if (document.getElementById('eta_figli_left')){
            document.getElementById('eta_figli_left').style.display = 'none'
            document.getElementById('eta_figli_right').style.display = 'none'
        }    
    }
    
}

function nascondi_eta_figli(elem_check_no){

   if (elem_check_no && elem_check_no.checked){
        if (document.getElementById('eta_figli_left')){
            document.getElementById('eta_figli_left').style.display = 'none'
            document.getElementById('eta_figli_right').style.display = 'none'
        }
        if (document.getElementById('ctl00_cphContent_cbFigliSi')){
            document.getElementById('ctl00_cphContent_cbFigliSi').checked = false    
        }
    }
}
 
/* FINE  */

/*$(document).ready(function(){
      if ($("div:login_top").is(":hidden")) {
        $("div:login_top").slideDown("slow");
      } else {
        $("div:login_top").hide();
      }
    });*/


$(document).ready(function(){
    
    $(".accedi_top").click(function () {
      $("#login_top").slideDown("slow");
    });

	$(".up").click(function () {
      $("#login_top").slideUp("slow");
    });
	

  });

  
$(document).ready(function(){
	//$(".example5").colorbox();
	try{
		$(".iframe").colorbox({iframe:true, innerWidth:490, innerHeight:320});
	    $(".iframe_lottomatica").colorbox({iframe:true, innerWidth:960, innerHeight:770});
	}catch (e){
	
	}
	

	
	//Example of preserving a JavaScript event for inline calls.
	$("#click").click(function(){ 
		$('#click').css({"background-color":"#f00", "color":"#fff", "cursor":"inherit"}).text("Open this window again and this message will still be here.");
		return false;
	});
});
		



/*$(document).ready(function() {
	$('input[type="text"]').addClass("idleField");
	$('input[type="text"]').focus(function() {
		$(this).removeClass("idleField").addClass("focusField");
	    if (this.value == this.defaultValue){ 
	    	this.value = '';
		}
		if(this.value != this.defaultValue){
			this.select();
		}
	});
	$('input[type="text"]').blur(function() {
		$(this).removeClass("focusField").addClass("idleField");
	    if ($.trim(this.value) == ''){
	    	this.value = (this.defaultValue ? this.defaultValue : '');
		}
	});
});	*/	