

/* BLINK Functions Cross Browser */
function doBlink() {
  // Blink, Blink, Blink...
  var blink = document.all.tags("blink")
  for (var i=0; i < blink.length; i++)
    blink[i].style.visibility = blink[i].style.visibility == "" ? "hidden" : "" 
}

function startBlink() {
  // Make sure it is IE4
  if (document.all)
    setInterval("doBlink()",1000)
}
//window.onload = startBlink;
/* END BLINK Function Cross Browser */


function CheckFrmPassword()
{
	if (!CheckMandatoryField(document.getElementById("pass_area").value))
	{
		alert(ERRMSG[7]);
		return false;
	}
}

function CheckFormInfo()
{	  	
	if (!CheckMandatoryField(document.getElementById("play_nome").value))
	{
		alert(ERRMSG[2]);
		return false;
	}

	if (!CheckMandatoryField(document.getElementById("play_cnome").value))
	{
		alert(ERRMSG[2]);
		return false;
	}
	
	if (!CheckMandatoryField(document.getElementById("play_infoarea").value))
	{
		alert(ERRMSG[2]);
		return false;
	}

	if (!_regexEmail(document.getElementById("play_email").value))
	{
		alert(ERRMSG[5]);
		return false;
	}
	
	//se tutto OK disabilitare il tasto invia e settare campo nascosto = si
	document.getElementById("richiesta_info").value = "si";
	//document.getElementById("btn_invia").disabled = true;
	return true;
}

function CheckFormAvviso()
{	  	
	if (!CheckMandatoryField(document.getElementById("titolo_avviso").value))
	{
		alert(ERRMSG[2]);
		return false;
	}

	if (!CheckMandatoryField(document.getElementById("testo_avviso").value))
	{
		alert(ERRMSG[2]);
		return false;
	}
	/*
	if (!CheckMandatoryField(document.getElementById("password_avviso").value))
	{
		alert(ERRMSG[2]);
		return false;
	}
	*/
	return true;
}

function CheckFormCV()
{
	if (!CheckMandatoryField(document.getElementById("data_cv").value))
	{
		alert(ERRMSG[2]);
		return false;
	}

	if (!CheckMandatoryField(document.getElementById("luogo_cv").value))
	{
		alert(ERRMSG[2]);
		return false;
	}
	
	if (!CheckMandatoryField(document.getElementById("attivita_cv").value))
	{
		alert(ERRMSG[2]);
		return false;
	}

	if (!_regexEuroDate(document.getElementById("data_cv").value))
	{
		alert(ERRMSG[1]);
		return false;
	}

}




function CheckMandatoryField(szTxt)
{
	if (szTxt.length == 0)
		return false;
	else
		return true;
}

function _regexEmail(szEmail)
{

	var regex = /^([0-9a-zA-Z]+[-._+&])*[0-9a-zA-Z]+@([-0-9a-zA-Z]+[.])+[a-zA-Z]{2,6}$/
	if (regex.test(szEmail))
		return true
	else
		return false

}

function _regexEuroDate(szDate)
{
	 var regex = /^(?:(?:0?[1-9]|1\d|2[0-8])(\/|-)(?:0?[1-9]|1[0-2]))(\/|-)(?:[1-9]\d\d\d|\d[1-9]\d\d|\d\d[1-9]\d|\d\d\d[1-9])$|^(?:(?:31(\/|-)(?:0?[13578]|1[02]))|(?:(?:29|30)(\/|-)(?:0?[1,3-9]|1[0-2])))(\/|-)(?:[1-9]\d\d\d|\d[1-9]\d\d|\d\d[1-9]\d|\d\d\d[1-9])$|^(29(\/|-)0?2)(\/|-)(?:(?:0[48]00|[13579][26]00|[2468][048]00)|(?:\d\d)?(?:0[48]|[2468][048]|[13579][26]))$/  			
	 //alert(regex.test(data_avviso));

	 if (regex.test(szDate))	 
		 return true;
	 else
		 return false;
}


/* ELENCO MESSAGGI D'ERRORE */

var ERRMSG = new Array();

ERRMSG[0] = "Attenzione, inserire LOGIN e PASSWORD per accedere all'area riservata.";
ERRMSG[1] = "Attenzione, inserire la data nel formato corretto.";
ERRMSG[2] = "Attenzione, compilare tutti i campi prima di proseguire.";
ERRMSG[3] = "Attenzione, il messaggio di avviso non può superare i 350 caratteri.";
ERRMSG[4] = "Attenzione, ci sono alcuni caratteri non ammessi nel campo di testo.";
ERRMSG[5] = "Attenzione, l'indirizzo email non è valido.";
ERRMSG[6] = "Attenzione, si è verificato un errore nell'invio del messaggio. Riprova più tardi, grazie.";
ERRMSG[7] = "Attenzione, inserire la password per procedere.";



/******************************************/
/* Controlla il tasto premuto dall'utente */
/******************************************/
function CheckDigit(e,tipo)
{

	//alert(obj.value);
	var cod = null;
	// browser sniffer
	if(window.event) {  // for IE, e.keyCode or window.event.keyCode can be used
		cod = e.keyCode;
	}
	else if(e.which) { // netscape or Firefox
		cod = e.which;
	}
		
	//alert(cod);
	
	if (tipo == "pass")
		return true
	
	if (cod == 13)	// NO return
		return false;

	if (cod == 8 || cod == null)  //OK se tab o delete
		return true;


	if (tipo == "data")
	{	
		if (cod >= 47 && cod <= 57)
			return true;
		else
			return false;
	}
	

}

function EsciAreaRiservata() {
	location.replace('default.asp?hid_exit=si');
}

function gB() {
	history.back();
}


function showf1(bVal)
{
	//alert(document.getElementById("rad1").value);
	//alert(document.getElementById("rad2").value);
	document.getElementById("firsttd").innerHTML = "Titolo Avviso";
	document.getElementById("secondtd").innerHTML = "Testo dell' Avviso";
	if(bVal)
		document.getElementById("rad1").checked = true;
}

function showf2(bVal)
{
	document.getElementById("firsttd").innerHTML = "Titolo Programma";
	document.getElementById("secondtd").innerHTML = "Testo del Programma";
	if(bVal)
		document.getElementById("rad2").checked = true;
}

function showf3(bVal)
{
	document.getElementById("firsttd").innerHTML = "Titolo Progetto";
	document.getElementById("secondtd").innerHTML = "Testo Progetto";
	if(bVal)
		document.getElementById("rad3").checked = true;
}

