var g_bIsFirefox = navigator.userAgent.indexOf("Firefox")>0?true:false;
var g_bIsMSIE = navigator.userAgent.indexOf("MSIE")>0&&navigator.userAgent.indexOf("Opera")<0?true:false;
var g_bIsOpera = navigator.userAgent.indexOf("Opera")>0?true:false;
var g_bIsNetscape = navigator.userAgent.indexOf("Netscape")>0?true:false;

function menuSwitch(oCell, bgColor, color) {
	oCell.style.backgroundColor = bgColor;
	oCell.style.color = color;
	oCell.childNodes[0].style.color = color;
}
function clientCont(name) {
var bKO = false;
	if (navigator.userAgent.indexOf("MSIE")==-1) bKO=true;
	if (navigator.userAgent.indexOf("Opera")>0) bKO=true;
	if (navigator.userAgent.indexOf("Netscape")>0) bKO=true;
	if (navigator.userAgent.indexOf("Firefox")>0) bKO=true;
	if (bKO) {
		alert("La funzione selezionata non č disponibile con il browser che stai utilizzando.\nAttiva manualmente il tuo programma di posta elettronica.");	
		return;
	}
	document.anchors.item('aHH').href='mai';
	document.anchors.item('aHH').href+='lt';
	document.anchors.item('aHH').href+='o:'
	document.anchors.item('aHH').href+=name;
	document.anchors.item('aHH').href+='@i';
	document.anchors.item('aHH').href+='naassitaliafoligno';
	document.anchors.item('aHH').href+='.';
	document.anchors.item('aHH').href+='it';
	document.anchors.item('aHH').click();
	document.anchors.item('aHH').href='';
}


function Login() {
	if (document.frmLogin.txtUsr.value=="") {
		alert("ATTENZIONE\nInserire il nome utente");
		return;
	}
	if (document.frmLogin.txtPwd.value=="") {
		alert("ATTENZIONE\nInserire la password");
		return;
	}
	document.frmLogin.submit();
}

/////////////////////////////////////////////////////////////////////////////////////////////////////
// FUNZIONI PER LA COMPILAZIONE ON-LINE DEL CURRICULUM VITAE
//
function ValidateStep1() {
var frm = document.frmData;
var str = new String();
var re = / /g
	// Nome
	str=frm.txtNome.value; str=str.replace(re, "");
	if (str=="") { alert("Attenzione\nIl campo Nome e' obbligatorio."); frm.txtNome.focus(); return false; }
	// Cognome
	str=frm.txtCognome.value; str=str.replace(re, "");
	if (str=="") { alert("Attenzione\nIl campo Cognome e' obbligatorio."); frm.txtCognome.focus(); return false; }
	// Luogo di nascita
	str=frm.txtLuogoNas.value; str=str.replace(re, "");
	if (str=="") { alert("Attenzione\nIl campo Luogo di nascita e' obbligatorio."); frm.txtLuogoNas.focus(); return false; }
	// Data di nascita - Giorno
	if (frm.selDataNasDay.value=="") { alert("Attenzione\nInserire correttamente la Data di nascita."); frm.selDataNasDay.focus(); return false; }
	// Data di nascita - Mese
	if (frm.selDataNasMonth.value=="") { alert("Attenzione\nInserire correttamente la Data di nascita."); frm.selDataNasMonth.focus(); return false; }
	// Data di nascita - Anno
	str=frm.txtDataNasYear.value; str=str.replace(re, "");
	if (str=="") { alert("Attenzione\nInserire correttamente la Data di nascita."); frm.txtDataNasYear.focus(); return false; }
	if (isNaN(str)) { alert("Attenzione\nInserire correttamente la Data di nascita."); frm.txtDataNasYear.focus(); return false; }
	frm.txtDataNasYear.value=str;
	
	return true;
}
function ValidateStep2() {
var frm = document.frmData;
var str = new String();
var re = / /g
	// Indirizzo
	str=frm.txtIndir.value; str=str.replace(re, "");
	if (str=="") { alert("Attenzione\nIl campo Indirizzo e' obbligatorio."); frm.txtIndir.focus(); return false; }
	// CAP
	str=frm.txtCap.value; str=str.replace(re, "");
	if (str=="") { alert("Attenzione\nIl campo C.A.P. e' obbligatorio."); frm.txtCap.focus(); return false; }
	if (isNaN(str)) { alert("Attenzione\nInserire correttamente Il C.A.P."); frm.txtCap.focus(); return false; }
	// Cittā
	str=frm.txtCitta.value; str=str.replace(re, "");
	if (str=="") { alert("Attenzione\nIl campo Citta' e' obbligatorio."); frm.txtCitta.focus(); return false; }
	// Provincia
	str=frm.txtProv.value; str=str.replace(re, "");
	if (str=="") { alert("Attenzione\nIl campo Provincia e' obbligatorio."); frm.txtProv.focus(); return false; }
	// Provincia
	str=frm.txtTel.value; str=str.replace(re, "");
	if (str=="") { alert("Attenzione\nIl campo Telefono e' obbligatorio."); frm.txtTel.focus(); return false; }
	
	return true;
}
function ValidateStep3() {
var frm = document.frmData;
var str = new String();
var re = / /g;
var i=0, bFound=false;
	// Livello di studio
	if (frm.selLivStudio.value=="") { alert("Attenzione\nSelezionare il livello di studio."); frm.selLivStudio.focus(); return false; }
	// Titolo di Studio
	str=frm.txtTitStudio.value; str=str.replace(re, "");
	if (str=="") { alert("Attenzione\nIl campo Titolo di studio e' obbligatorio."); frm.txtTitStudio.focus(); return false; }
	// Votazione
	str=frm.txtVotazione.value; str=str.replace(re, "");
	if (str=="") { alert("Attenzione\nIl campo Votazione e' obbligatorio."); frm.txtVotazione.focus(); return false; }
	// Esperienze di lavoro
	str=frm.txaEspLavoro.value; str=str.replace(re, "");
	for (i=0; i<str.length; i++) {
		if ( !((str.charAt(i)=="\r") || (str.charAt(i)=="\f") || (str.charAt(i)=="\n")) ) //{alert("str.length: " + str.length + " - i=" + i + "\n charAt(..)=" + str.charAt(i) + "\nbfound=" + bFound);} 
			{bFound=true; break;}
	}
	if (!bFound) { alert("Attenzione\nIl campo Esperienze di lavoro e' obbligatorio."); frm.txaEspLavoro.focus(); return false; }
	// Privacy
	if (!frm.chkPrivacy.checked) { alert("Attenzione\nPer inviare il Curriculum Vitae devi manifestare\nil tuo consenso al trattamento dei dati personali."); frm.chkPrivacy.focus(); return false; }
	
	return true;
}
function stepCV(step, dir) {
	switch(step) {
		case 1: {
			if ( (dir>0) && (!ValidateStep1()) ) return;
			document.frmCV.hNome.value = document.frmData.txtNome.value;
			document.frmCV.hCognome.value = document.frmData.txtCognome.value;
			document.frmCV.hLuogoNas.value = document.frmData.txtLuogoNas.value;
			document.frmCV.hDataNasDay.value = document.frmData.selDataNasDay.value;
			document.frmCV.hDataNasMonth.value = document.frmData.selDataNasMonth.value;
			document.frmCV.hDataNasYear.value = document.frmData.txtDataNasYear.value;
			document.frmCV.hGenere.value = document.frmData.radGenere[0].checked ? "Uomo" : "Donna";
			document.frmCV.hStatoCiv.value = document.frmData.selStatoCiv.value;
			break;
		}
		case 2: {
			if ( (dir>0) && (!ValidateStep2()) ) return;
			document.frmCV.hIndir.value = document.frmData.txtIndir.value;
			document.frmCV.hCap.value = document.frmData.txtCap.value;
			document.frmCV.hCitta.value = document.frmData.txtCitta.value;
			document.frmCV.hProv.value = document.frmData.txtProv.value;
			document.frmCV.hTel.value = document.frmData.txtTel.value;
			document.frmCV.hCell.value = document.frmData.txtCell.value;
			document.frmCV.hEmail.value = document.frmData.txtEmail.value;
			break;
		}
		case 3: {
			if ( (dir>0) && (!ValidateStep3()) ) return;
			document.frmCV.hLivStudio.value = document.frmData.selLivStudio.value;
			document.frmCV.hTitStudio.value = document.frmData.txtTitStudio.value;
			document.frmCV.hVotazione.value = document.frmData.txtVotazione.value;
			document.frmCV.hEspLavoro.value = document.frmData.txaEspLavoro.value;
			document.frmCV.hPrivacy.value = document.frmData.chkPrivacy.checked ? 1 : 0;
			break;
		}
		case 4: step=2;
	}
	
	if (dir>0) step++;
	else step--;
	
	document.frmCV.hStep.value=step;
	document.frmCV.submit();
}
function startCV() {
	document.frmCV.hStep.value=1;
	document.frmCV.submit();
}
function doClient() {
var bKO = false;
	if (navigator.userAgent.indexOf("MSIE")==-1) bKO=true;
	if (navigator.userAgent.indexOf("Opera")>0) bKO=true;
	if (navigator.userAgent.indexOf("Netscape")>0) bKO=true;
	if (navigator.userAgent.indexOf("Firefox")>0) bKO=true;
	if (bKO) {
		alert("La funzione selezionata non č disponibile con il browser che stai utilizzando.\nAttiva manualmente il tuo programma di posta elettronica.");	
		return;
	}
	document.anchors.item('aCV').href='mai';
	document.anchors.item('aCV').href+='lt';
	document.anchors.item('aCV').href+='o:'
	document.anchors.item('aCV').href+='recruiting';
	document.anchors.item('aCV').href+='@';
	document.anchors.item('aCV').href+='inaassitaliafoligno';
	document.anchors.item('aCV').href+='.';
	document.anchors.item('aCV').href+='it';
	document.anchors.item('aCV').click();
	document.anchors.item('aCV').href='javascript:doClient()';
}
//
// FUNZIONI PER LA COMPILAZIONE ON-LINE DEL CURRICULUM VITAE
/////////////////////////////////////////////////////////////////////////////////////////////////////



/////////////////////////////////////////////////////////////////////////////////////////////////////
// FUNZIONI PER L'INVIO DI MESSAGGI DALLE PAGINE CONTATTI
//
function ValidateFldContatti(fld) {
var frm = document.frmContatti;
var str = new String();
var re = / /g;
var i=0, bFound=false;
	str=frm.elements[fld].value; str=str.replace(re, "");
	for (i=0; i<str.length; i++) {
		if ( !((str.charAt(i)=="\r") || (str.charAt(i)=="\f") || (str.charAt(i)=="\n")) )
			{bFound=true; break;}
	}
	if (!bFound) {
		alert("Attenzione\nI campi contrassegnati da * rosso sono obbligatori.");
		frm.elements[fld].focus();
		return false;
	}
	return true;
}
function SendMsg(flds, rFlds) {
var aFlds, aRFlds
var i;
	
	aFlds = flds.split(",");
	aRFlds = rFlds.split(",");
	for (i=0; i<aFlds.length; i++)
		if ( aRFlds[i]==1 && !ValidateFldContatti(aFlds[i]) ) return;
	
	if ( !ValidateFldContatti("txaMsg") ) return;
	if (!frmContatti.chkPrivacy.checked) { 
		alert("Attenzione\nPer inviare il tuo messaggio devi manifestare\nil consenso al trattamento dei dati personali."); 
		frmContatti.chkPrivacy.focus(); 
		return;
	}

	document.frmContatti.hOper.value=1;
	document.frmContatti.submit();
}
//
// FUNZIONI PER L'INVIO DI MESSAGGI DALLE PAGINE CONTATTI
/////////////////////////////////////////////////////////////////////////////////////////////////////











