function checkAdesioneForm(form_id){
	var form = document.getElementById(form_id);
	
	if (form){
		var nocheck = true;
		for (i = 0; i < form.lot_id.length; i++) 
    	  	if (form.lot_id[i].checked) nocheck = false;
    		if (nocheck){
				alert("Per continuare seleziona un pacchetto!");
				return false;
			}
		
		if (form.toCompany.checked && form.company.value==""){
			alert("E' necessario inserire lo Studio Asociato!");
			return false;
		}
		if (form.address.value == "" || form.citta.value == ""|| form.cap.value == ""|| form.provincia.value == ""|| form.iva.value == ""|| form.iva.value == "0"){
			alert("E' necessario inserire tutti i dati per la fatturazione!");
			return false;
		}
		if (form.iva.value.length < 11 || form.iva.value.length > 11)
		{
            alert("La Partita Iva deve essere di 11 caratteri!");
            return false;
        }
		if (!form.accept_contract_terms.checked){
			alert("Per continuare devi accettare i termini del contratto!");
			return false;
		}
		if (!form.aprove_useof_personal_data.checked){
			alert("Per continuare devi approvare tutte le condizioni!");
			return false;
		}
	}
	
	return true;
}
function checkLibro(form_id)
{
	var form = document.getElementById(form_id);
	//alert("prova");
	//var sem = document.getElementById('Sem');
	//var semLibro = document.getElementById('SemLibro');
	if (!form.Sem.checked && !form.SemLibro.checked)
	{
		alert("Per procedere con l'acquisto \u00E8 necessario selezionare 'Seminario' o 'Seminario + libro'.");
		return false;
	}
	form.submit();
}
function checkLibroPerc(form_id)
{
	var form = document.getElementById(form_id);
	//alert("prova");
	//var sem = document.getElementById('Sem');
	//var semLibro = document.getElementById('SemLibro');
	if (!form.Sem.checked && !form.SemLibro.checked)
	{
		alert("Per procedere con l'acquisto \u00E8 necessario selezionare 'Percorso' o 'Percorso + libro'.");
		return false;
	}
	form.submit();
}
function checkFatturazioneFields(rb){
    document.getElementById('studio').disabled = false;
    document.getElementById('company').disabled = false;
    document.getElementById('iva_row').disabled = false;
    document.getElementById('iva').disabled = false;
    /*document.getElementById('cfsa_row').disabled = false;
    document.getElementById('ivasa').disabled = false;*/
	/*document.getElementById('country').disabled = false;*/
    switch(rb.id)
    {
        case 'toPerson':
            document.getElementById('studio').disabled = true;
            document.getElementById('company').disabled = true;
            document.getElementById('iva').disabled = true;
			/*document.getElementById('country').disabled = true;*/
           	document.getElementById('iva_row').disabled = true;
       	    /*document.getElementById('cfsa_row').disabled = true;
           	document.getElementById('ivasa').disabled = true;*/
            break;
        case 'toProf':
            document.getElementById('studio').disabled = true;
            document.getElementById('company').disabled = true;
            /*document.getElementById('cfsa_row').disabled = true;
            document.getElementById('ivasa').disabled = true;*/
            break;
        case 'toCompany':
            break;
    }

}

function selectAllFile(rb)
{
	//alert(rb.id);
	var form = document.getElementById('adesione');
	var cb = form.lotIdArray;
	//alert(cb.length);
	/*se ho scelto Tutto come pacchetto selezione tutte le checkbox*/
	if( rb.id == 'lot_2')
	{
		for(var i=0; i<cb.length; i++)
			cb[i].checked = true;
	}
		
}

function ctrlIva(s)
{
    if ( s == '00000000000' ){
        return false;
	}
    sumA=0;
    sumB=0;
    sum=0;
    for(i=0;i<=8;i+=2)
	{
	   sumA+=(s[i]-'0')
	}
	for(i=1;i<=9;i+=2)
	{
		j=((s[i]-'0'))*2
		if (j>9)
		{
			sumB+=(j/10)
			sumB+=j%10
		}
		else
			sumB+=j
	}
	sum=10-((sumA+sumB)%10)
	if(sum==10){
		sum=0
	}
	if((s[10]-'0') == sum){
		return true
	}
	return false
}

function formValidation(){
	var result=true
	var form = document.getElementById('userregister')
	if (form.toProf.checked || form.toCompany.checked){
		result = ctrlIva(document.getElementById('iva').value)
	}
	if (!form.accept_contract_terms.checked || !form.aprove_useof_personal_data.checked){
			alert('One of the contract terms not checked!')
			result = false
	}
	if(result){
  hide('acquista')
		form.submit()
	}else{
		alert('Partita Iva not valid!')
	}
	return true
}



function fillHiddenField(field_id, value){
            document.getElementById(field_id).value = value;
}

function checkHiddenFields(ckb_id,row_id){
	var ckb = document.getElementById(ckb_id);
	var tr = document.getElementById(row_id);
	if (ckb  && tr){
        if(chb_id == 'toPerson')
            Show(tr,!ckb.checked);
        else
			Show(tr,ckb.checked);
	}
}

function set_first_name(){
	document.getElementById('first_name').value = first_name
	alert (document.getElementById('first_name').value)
}

function showStudioField(ckb,row_id)
{
	var tr = document.getElementById(row_id);
	Show(tr,ckb.checked);
}

function hideFatturazione(ckb,row_id)
{
    var tr = document.getElementById(row_id);
    Show(tr,!ckb.checked);
}

function CheckRegistrationInfo()
{
	var user_account = document.getElementById('useraccount');
	var parola1 = document.getElementById('parola1');
	var parola2 = document.getElementById('parola2');
	var email = document.getElementById('email');
	var first_name = document.getElementById('first_name');
	var last_name = document.getElementById('last_name');
	var birth_place = document.getElementById('birth_place');
	var birth_date = document.getElementById('birth_date');
	var fiscal_code = document.getElementById('fiscal_code');
	var titolo = document.getElementById('titolo');
	var address = document.getElementById('address');
	var city = document.getElementById('city');
	var cap = document.getElementById('cap');
	var provincia = document.getElementById('provincia');
	var phone = document.getElementById('phone');
	var colegio = document.getElementById('colegio');
	var colegio_nr = document.getElementById('colegio_nr');
	var privacy_rules = document.getElementById('privacy_rules');
	var self_confirm = document.getElementById('self_confirm');
	
	var mesaj = "Inserisci un valore corretto nei campi obbligatori: \n\n";
	var valid = true;
	
	if (user_account.value == ""){mesaj+="Nome utente non valido \n"; valid=false;}
	if (first_name.value == ""){mesaj+="Nome non valido \n"; valid=false;}
	if (last_name.value == ""){mesaj+="Cognome non valido \n"; valid=false;}
	if (birth_place.value == ""){mesaj+="Luogo di nascita non valido \n"; valid=false;}
	if (birth_date.value == ""){mesaj+="Data di nascita non valido \n"; valid=false;}
	if (fiscal_code.value == ""){mesaj+="Codice fiscale non valido \n"; valid=false;}
	if (address.value == ""){mesaj+="Indirizzo non valido \n"; valid=false;}
	if (city.value == ""){mesaj+="Citta' non valida \n"; valid=false;}
	if ((cap.value < 10000)||(cap.value > 50000)){mesaj+="CAP non valido \n"; valid=false;}
	if (phone.value == ""){mesaj+="Telefono non valido \n"; valid=false;}
	if (provincia.value == ""){mesaj+="Provincia non valida \n"; valid=false;}
	if(parola1!=parola2){mesaj+="Le passwords non corrispondono \n"; valid=false;}
	if(email.value.indexOf('@', 0) == -1){mesaj+="E-mail non valida \n"; valid=false;}
//	if(privacy_rules.checked==false){mesaj+="You must accept the privacy rules\n";valid=false;}
//	if(self_confirm.checked==false){mesaj+="You must accept the privacy rules\n";valid=false;}
		
	var show = false;
	if(getSelectedText(titolo)=="Ragionieri Commercialisti")
		show = true;
	else
		if(getSelectedText(titolo)=="Consulenti del lavoro")
			show = true;
	if(show)
	{
		if (colegio.value == ""){mesaj+="Sede del collegio non valida \n"; valid=false;}
		if (colegio_nr.value == 0){mesaj+="Numero del collegio non valido\n"; valid=false;}
	}
	
	
	if(!valid)
		alert(mesaj);
	return valid;
}

function checkTitle(cbx,row_id)
{
	var tr = document.getElementById(row_id);
	var show = true;
    var nr = document.getElementById("college_nr");
	
	if( getSelectedText(cbx) != "Dottori Commercialisti ed Esperti Contabili" && getSelectedText(cbx) != "Consulenti del lavoro" && getSelectedText(cbx) != "Avvocati" ){
      	show = false;
      	nr.value="1";
		Show(tr,show);
		return false;
	}
	else
	{
        nr.value="";
		Show(tr,show);
		return true
    }
	
}

function checkTitle2(cbx,row_id)
{
	var tr = document.getElementById(row_id);
	var show = true;
	
	if( getSelectedText(cbx) == "Dottori Commercialisti ed Esperti Contabili"  ){
		Show(tr,show);
		return true
	}
	else
	{
       show = false;
		Show(tr,show);
		return false;
    }
	
}

function Show(obj,show)
{
	if(show==true)
		obj.style.visibility = "visible";
	else
		obj.style.visibility = "hidden";
}

function stripSelectedTextSpaces(combo)
{
	
	for (i=0; i < combo.length; i++)
		if (combo.options[i].selected == true){
				var tmp = new Array()
				tmp = combo.options[i].value.split(' ')
				college_array_name = tmp.join("")
				return college_array_name;
			}
		    
	return null;
}

function changeCollegiList(cb_master, cb_slave_id, arr_values){
	var arr = arr_values[stripSelectedTextSpaces(cb_master)];
	cb_slave = document.getElementById(cb_slave_id);
	cb_slave.length = 0;
	cb_slave.length = arr.length;
	for (i=0; i<arr.length;i++)
		cb_slave.options[i].text = arr[i];
	cb_slave.options[0].selected = true;
}

function appendOptionLast(text)
{
  var elOptNew = document.createElement('option');
  elOptNew.text = text;
  elOptNew.value = text;
  var elSel = document.getElementById('college');

  try {
    elSel.add(elOptNew, null);
  }
  catch(ex) {
    elSel.add(elOptNew); // IE only
  }
}




function getSelectedValue(combo){
	for (var i=0; i < combo.length; i++)
		if (combo.options[i].selected == true)
		    return combo.options[i].value;
	return -1;
}

function getSelectedText(combo){
	for (i=0; i < combo.length; i++)
		if (combo.options[i].selected == true)
		    return combo.options[i].text;
	return null;
}

function play(filepath)
{

  myWin= open("", "","width=320,height=260,status=no,toolbar=no,menubar=no");
  var str = '<param name="movie" value="/'+filepath+'" />';
  str += '<param name="quality" value="high" /><param name="bgcolor" value="#ffffff" />';
  str += '<embed src="/'+filepath+'" quality="high" bgcolor="#ffffff" width="300" height="240" name="drcform" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';

  myWin.document.write('<html><head><title>Presentazione');
  myWin.document.write('</title></head><body><center>');
  myWin.document.write('<object style="position:absolute;right:10px;top:10px" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="300" height="240"  align="middle" VIEWASTEXT>');
  myWin.document.write('<param name="allowScriptAccess" value="sameDomain" />');
  myWin.document.write(str);
  myWin.document.write('</object>');
  myWin.document.write('</center></body></html>');
  myWin.document.close();
  myWin.focus();
}

function play_grande(filepath)
{

  myWin= open("", "","width=360,height=275,status=no,toolbar=no,menubar=no");
  var str = '<param name="movie" value="/'+filepath+'" />';
  str += '<param name="quality" value="high" /><param name="bgcolor" value="#ffffff" />';
  str += '<embed src="/'+filepath+'" quality="high" bgcolor="#ffffff" width="340" height="255" name="drcform" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';

  myWin.document.write('<html><head><title>Presentazione');
  myWin.document.write('</title></head><body><center>');
  myWin.document.write('<object style="position:absolute;right:10px;top:10px" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="340" height="255"  align="middle" VIEWASTEXT>');
  myWin.document.write('<param name="allowScriptAccess" value="sameDomain" />');
  myWin.document.write(str);
  myWin.document.write('</object>');
  myWin.document.write('</center></body></html>');
  myWin.document.close();
  myWin.focus();
}

function playspeciale(filepath)
{

  myWin= open("", "","width=360,height=275,status=no,toolbar=no,menubar=no");
  var str = '<param name="movie" value="/'+filepath+'" />';
  str += '<param name="quality" value="high" /><param name="bgcolor" value="#ffffff" />';
  str += '<embed src="/'+filepath+'" quality="high" bgcolor="#ffffff" width="320" height="256" name="drcform" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';

  myWin.document.write('<html><head><title>Anteprima Speciale');
  myWin.document.write('</title></head><body><center>');
  myWin.document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="340" height="255"  align="middle" VIEWASTEXT>');
  myWin.document.write('<param name="allowScriptAccess" value="sameDomain" />');
  myWin.document.write(str);
  myWin.document.write('</object>');
  myWin.document.write('</center></body></html>');
  myWin.document.close();
  myWin.focus();
}

function play2(filepath)
{
  myWin= open("", "","scrollbars=0,resizable=0,location=0,menubar=0,status=0,toolbar=0,width=300,height=240,left=62,top=20");
  myWin.document.write('<html><head><title>Anteprima Convegno');
  myWin.document.write('</title></head>');
  myWin.document.write('<script language="javascript" type="text/javascript" src="/design/corporate/javascript/utile.js"></script>');
  myWin.document.write('<body>');
  myWin.document.write('<div id="Introduzione" style="position:absolute;top:0px;left:0px"></div>');
  myWin.document.write('<script language="javascript">');
  myWin.document.write('InsertFlashControlDemo("Introduzione","Anteprima","300","240","' +filepath + '","middle");');
  myWin.document.write('</script>');
  myWin.document.write('</body></html>');
  myWin.document.close();
  myWin.focus();
}

function playintro2()
{
  filepath = "filmati/intro3D900675.swf";
  myWin= open("", "","scrollbars=0,resizable=0,location=0,menubar=0,status=0,toolbar=0,width=900,height=675,left=62,top=20");
  myWin.document.write('<html><head><title>La formazione permanente in E-Learning');
  myWin.document.write('</title></head>');
  myWin.document.write('<script language="javascript" type="text/javascript" src="/design/corporate/javascript/utile.js"></script>');
  myWin.document.write('<body>');
  myWin.document.write('<div id="Introduzione" style="position:absolute;top:0px;left:0px"></div>');
  myWin.document.write('<script language="javascript">');
  myWin.document.write('InsertFlashControlDemo("Introduzione","Guida","900","675","' + filepath + '","middle");');
  myWin.document.write('</script>');
  myWin.document.write('</body></html>');
  myWin.document.close();
  myWin.focus();
}

function playintro()
{
  filepath = "filmati/videoDemo.swf";
  myWin= open("", "","scrollbars=0,resizable=0,location=0,menubar=0,status=0,toolbar=0,width=853,height=480,left=80,top=90");
  var str = '<param name="movie" value="/'+filepath+'" />';
  str += '<param name="quality" value="high" /><param name="bgcolor" value="#ffffff" />';
  str += '<embed src="/'+filepath+'" quality="high" bgcolor="#ffffff" width="853" height="480" name="drcform" style="position:absolute;top:0px;left:0px" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';

  myWin.document.write('<html><head><title>Scopri E-Learning Professioni');
  myWin.document.write('</title></head><body>');
  myWin.document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="853" height="480"  style="position:absolute;top:0px;left:0px" VIEWASTEXT>');
  myWin.document.write('<param name="allowScriptAccess" value="sameDomain" />');
  myWin.document.write(str);
  myWin.document.write('</object>');
  /*myWin.document.write('<script language="javascript" type="text/javascript" src="/design/corporate/javascript/fixit.js"></script>');*/
  myWin.document.write('</body></html>');

  myWin.document.close();
  myWin.focus();
}

function playintro_milano()
{
  filepath = "filmati/intro_milano.swf";
  myWin= open("", "","scrollbars=0,resizable=0,location=0,menubar=0,status=0,toolbar=0,width=900,height=675,left=62,top=20");
  var str = '<param name="movie" value="/'+filepath+'" />';
  str += '<param name="quality" value="high" /><param name="bgcolor" value="#ffffff" />';
  str += '<embed src="/'+filepath+'" quality="high" bgcolor="#ffffff" width="900" height="675" name="drcform" style="position:absolute;top:0px;left:0px" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';

  myWin.document.write('<html><head><title>La formazione permanente in E-Learning');
  myWin.document.write('</title></head><body>');
  myWin.document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="900" height="675"  style="position:absolute;top:0px;left:0px" VIEWASTEXT>');
  myWin.document.write('<param name="allowScriptAccess" value="sameDomain" />');
  myWin.document.write(str);
  myWin.document.write('</object>');
  /*myWin.document.write('<script language="javascript" type="text/javascript" src="/design/corporate/javascript/fixit.js"></script>');*/
  myWin.document.write('</body></html>');

  myWin.document.close();
  myWin.focus();
}

function play_corso(filepath)
{

  myWin= open("", "","width=990,height=550,status=no,toolbar=no,menubar=no");
  var str = '<param name="movie" value="/'+filepath+'" />';
  str += '<param name="quality" value="high" /><param name="bgcolor" value="#ffffff" />';
  str += '<embed src="/'+filepath+'" quality="high" bgcolor="#ffffff" width="990" height="550" name="Corso" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';

  myWin.document.write('<html><head><title>Presentazione');
  myWin.document.write('</title></head><body><center>');
  myWin.document.write('<object style="position:absolute;right:0px;top:0px" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="990" height="550"  align="middle" VIEWASTEXT>');
  myWin.document.write('<param name="allowScriptAccess" value="sameDomain" />');
  myWin.document.write(str);
  myWin.document.write('</object>');
  myWin.document.write('</center></body></html>');
  myWin.document.close();
  myWin.focus();
}

function InsertFlashControlDemo(DivEmbedder,ObjectName,Width,Height,URLname,Alignment){
	var embeddiv = document.getElementById(DivEmbedder);
	embeddiv.innerHTML =
	'<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"' + 			'codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width=' +
	Width + ' height=' +
	Height + '  align=' +
    Alignment + ' VIEWASTEXT>'+
	//'<param name=wmode value=transparent>' +
	'<param name="allowScriptAccess" value="sameDomain" />' +
	'<param name="movie" value="/' +
    URLname +'" />' +
	'<param name="quality" value="high" /><param name="menu" value="false" />' +
    '<param name="bgcolor" value="#ffffff" />'+
	'<embed style="position:absolute;top:0px;left:0px" src="/' +
	URLname + '" quality="high" bgcolor="#ffffff" width=' +
	Width + ' height=' +
	Height + ' name=' +
    ObjectName + ' align=' +
    Alignment + ' allowScriptAccess="sameDomain"' +
	//' wmode=transparent' +
	' type="application/x-shockwave-flash"' +
    ' pluginspage="http://www.macromedia.com/go/getflashplayer" />' +
	'</object>';
}

function InsertFlashControl(DivEmbedder,ObjectName,Width,Height,URLname,Alignment,Color){
	var embeddiv = document.getElementById(DivEmbedder);
	if(Color==undefined)
		Color="#ffffff";
	embeddiv.innerHTML =
	'<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"' + 			'codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width=' +
	Width + ' height=' +
	Height + '  align=' +
    Alignment + ' VIEWASTEXT >'+
	'<param name="allowScriptAccess" value="sameDomain" />' +
	'<param name="movie" value="' +
    URLname +'" />' +
	'<param name="quality" value="best" /><param name="menu" value="false" />' +
    '<param name="bgcolor" value=' +
    Color + ' />'+
	'<embed src="' +
	URLname + '" quality="best" bgcolor='+ 
	Color +' width=' +
	Width + ' height=' +
	Height + ' name=' +
    ObjectName + ' align=' +
    Alignment + ' allowScriptAccess="sameDomain"' +
	' type="application/x-shockwave-flash"' +
    ' menu="false" pluginspage="http://www.macromedia.com/go/getflashplayer" />' +
	'</object>';
}

function handleDemoOver(srcPath)
{
    document.imgDemo.src=srcPath;
}

function handleDemoOut(srcPath)
{
    document.imgDemo.src=srcPath;
}

function handleEntraOver(srcPath)
{
    document.imgEntra.src=srcPath;
}

function handleEntraOut(srcPath)
{
    document.imgEntra.src=srcPath;
}

function handleDownloadOver(srcPath)
{
    document.imgDownload.src=srcPath;
}

function handleDownloadOut(srcPath)
{
    document.imgDownload.src=srcPath;
}

var is_busy = false;
var is_form_busy = false;

function hide(td, lnk)
{
	if (is_busy){
		alert("Attendere prego!");
		return false;
	}
	else{
	is_busy = true;	
	var cell = document.getElementById(td);
	cell.style.visibility = "hidden";
	window.location.href=lnk;
	return true;
	}
}

function hideFormButton(td)
{
	if (is_form_busy){
		alert("Attendere prego!");
		return false;
	}
	else{
	is_form_busy = true;	
	var cell = document.getElementById(td);
	cell.style.visibility = "hidden";
	submit();
	return true;
	}
}

var is_enabled = true;

function clicknext(link)
{
    if(is_enabled)
        window.location.href = link;

}

/*
function lesson_callback(){
	var next = document.getElementById('next_lesson');
	var prev = document.getElementById('prev_lesson');
	
	next.style.visibility = "visible";
	prev.style.visibility = "visible";
	
}
*/
TrapClicksForHowManySeconds = 20;



// If the user clicks the submit button and causes a 
//    trap, or clicks when a trip is set, you may spawn 
//    an alert box with a message. If you do want to 
//    spawn the alert box, specify the message between 
//    the quotation marks. Otherwise, leave it blank.
//(Blank is two consecutive quotation mark characters, 
//    with nothing between them.)
// Note: If you use any quotation marks in the message 
//       itself, those must be preceeded with a back-slash 
//       character. Example: "My name is \"tall\", okay?"

AlertBoxMessage = "";



// If the user clicks the submit button and causes a trap, 
//    or clicks when a trip is set, you may spawn a popup 
//    box. If you want to spawn the popup box, specify 
//    the URL of the web page to insert into the popup. 
//    Otherwise, leave it blank. You may also specify 
//    the height of the popup and the width of the popup.

PopUpBoxURL = "http://willmaster.com";
PopUpBoxHeight = 300;
PopUpBoxWidth = 500;



// If you want the submit button to change its text when 
//    it is clicked, specify the name you assigned to the 
//    form, the name you assigned to the submit button 
//    form field, and the new text for the submit button. 
//    Otherwise, leave at least one of these blank.

NameOfForm = "UserRegister";
NameOfSubmitButton = "Register";
NewTextForSubmitButton = "Processing";



// ////////////////////////////////////////// //
// NO CUSTOMIZATION REQUIRED BELOW THIS POINT //
// ////////////////////////////////////////// //


TrapTime = 0;
DoubleClickTrapperCounter = 0;


function DoubleClickTrapperAction() {
DoubleClickTrapperCounter++;
//DoubleClickTrapperButton();
var trapTheClick = false;
if(DoubleClickTrapperCounter > 1 ) { trapTheClick = true; }
if(trapTheClick == true) {
	if(TrapTime == 0) {
		var tDate = new Date;
		TrapTime = tDate.valueOf();
		}
	else {
		var tDate = new Date;
		var localTrapTime = tDate.valueOf();
		if((localTrapTime - TrapTime) > (TrapClicksForHowManySeconds * 1000)) {
			TrapTime = 0;
			trapTheClick = false;
			DoubleClickTrapperCounter = 0;
			}
		}
	}
var valueToReturn = true;
if(trapTheClick == true) {
	valueToReturn = false;
	/*DoubleClickTrapperPopUp();*/
	DoubleClickTrapperAlert();
	}
return valueToReturn;
} // end of function DoubleClickTrapperAction()


function DoubleClickTrapperButton() {
var formname   = StripSpaces(NameOfForm);
var submitname = StripSpaces(NameOfSubmitButton);
var newtext    = StripSpaces(NewTextForSubmitButton);
if(formname.length > 0 && submitname.length > 0 && newtext.length > 0) {
	var s = 'document.' + NameOfForm + '.' + NameOfSubmitButton + ".value = '" + NewTextForSubmitButton + "'";
	eval(s);
	}
} // end of function DoubleClickTrapperButton()


function DoubleClickTrapperPopUp() {
var url = StripSpaces(PopUpBoxURL);
if(url.length > 0) {
	if(PopUpBoxHeight < 1) { PopUpBoxHeight = 200; }
	if(PopUpBoxWidth < 1) { PopUpBoxWidth = 300; }
	window.open(url,'',('height=' + PopUpBoxHeight + ',width=' + PopUpBoxWidth + ',resizable=yes,scrollbars=yes'));
	}
} // end of function DoubleClickTrapperPopUp()


function DoubleClickTrapperAlert() {
var message = StripSpaces(AlertBoxMessage);
if(message.length > 0) { alert(AlertBoxMessage); }
} // end of function DoubleClickTrapperAlert()


function StripSpaces(s) {
while(s.indexOf(' ') == 0) { s = s.substr(1); }
return s;
} // end of function StripSpaces()

function OnChengeDropDown(dropdown, fieldname, form_id)
{
	var form = document.getElementById(form_id);
	var myindex  = dropdown.selectedIndex;
	var SelValue = dropdown.options[myindex].value;
	field = document.getElementById(fieldname);
	field.value = SelValue;
	form.submit();

//	return true;
}

function checkQuestionarioForm(form_id)
{
	
	var form = document.getElementById(form_id);
	
	if ( form.eta.value == "" )
	{
		alert( "E' necessario inserire l'eta'");
		return false;
	}
	
	var nocheck = true;
	for (i = 0; i < form.genere.length; i++) 
		if (form.genere[i].checked) nocheck = false;
    if (nocheck){
		alert("E' necessario indicare il genere!");
		return false;
	}
	
	var isCheck = true;
	var nome = "";
			
	for (i=0; i<form.elements.length; i++){
		if (form.elements[i].type == "radio" && form.elements[i].name != "genere")
		{
			if( nome != form.elements[i].name)
			{
				nome = form.elements[i].name;
				if( isCheck == false)
				{
					alert("E' necessario rispondere a tutte le domande!");
					return false;
				}
				isCheck = form.elements[i].checked;
			}
			else
			{
				if(form.elements[i].checked)
					isCheck = true;
			}
		}
	}
}

