//-- Start

//-------------------
//--FUNZIONI GLOBALI
//-------------------
function PageScroll(){
	window.scroll(0,0);
}

function PopupZoom(ID_img,Proj_name) {
  myWin=window.open('/includes/popup_zoom.asp?ID='+ID_img+'&Proj_name='+Proj_name,'Zoom','width=,height=,resizable=yes,scrollbars=no');
  myWin.focus();
}

function PopupNews(ID_news) {
  myWin=window.open('/includes/popup_news.asp?ID=' + ID_news,'News','width=400,height=300,resizable=yes,scrollbars=auto');
  myWin.focus();
}

function PrintableVersion(PageName) {
  myWin=window.open('/'+PageName,'PrintableVersion','width=600,height=700,resizable=yes,scrollbars=yes');
  myWin.focus();
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}


function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
var timerID = "";
function Temporize(){
	MM_swapImgRestore();
	MM_showHideLayers('menushowcase','','hide','menuabout','','hide','menuservices','','hide','menulogin','','hide');
}
MM_reloadPage(true);

function Temporize2(){
	window.close();
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
//-----------------------
//--FINE FUNZIONI GLOBALI
//-----------------------

function MM_swapImage() { //v3.0 Modificata per Alchimedia website-aggiunta chiamata a funzione MM_swapImageRestore()
  MM_swapImgRestore();
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function formController(which){
//Definisco l'array dei messaggi di errore
	var rif_year = 1920;
	var sel_year = 0;
	var bis_year = false;
	var error_txt = new Array;
	error_txt["nome"] = "Nome";
	error_txt["cognome"] = "Cognome";
	//error_txt["sesso"] = "Sesso";
	error_txt["day"] = "Giorno di nascita";
	error_txt["month"] = "Mese di nascita";
	error_txt["year"] = "Anno di nascita";
	error_txt["data_validate"] = "Data di nascita: la data selezionata non e\' una data valida";
	error_txt["comune_nascita"] = "Comune di nascita";
	error_txt["prov_nascita"] = "Provincia di nascita";
	error_txt["cittadinanza"] = "Cittadinanza";
	error_txt["stato_civile"] = "Stato civile";
	error_txt["indirizzo_res"] = "Indirizzo";
	error_txt["citta_res"] = "Cittā";
	error_txt["prov_res"] = "Provincia";
	error_txt["cap_res"] = "Cap";
	error_txt["email"] = "E-mail";
	error_txt["indirizzo_dom"] = "Indirizzo di domicilio";
	error_txt["cap_dom"] = "Cap di domicilio";
	error_txt["citta_dom"] = "Cittā di domicilio";
	error_txt["prov_dom"] = "Provincia di domicilio";
	error_txt["servizio_mil"] = "Obblighi di leva";
	error_txt["conoscenze_informatiche"] = "Conoscenze informatiche";
	error_txt["int_grado_interesse"] = "Livello di interesse";
	var reqString ="Attenzione!!\nControllare i seguenti campi:\n ";
	var reqPass = true ;
	var check = 0;
	var cntEmpty = 0;
	/*Controllo validitā campo "email"*/
	if(which.name == "email") {
		var finder = which.value;
		if (finder !="") {		
			var foundAt = 0;
			var foundPoint = 0;
			for(n = 0 ; n < finder.length ;n++) {
				if ((finder.charAt(n))==("@")) {
					++foundAt ;
				}
				if ((finder.charAt(n))==(".")) {
					++foundPoint ;
				}
			}
			if ((foundAt != 1)||(foundPoint == 0)) {
				alert("ATTENZIONE!!\n L'indirizzo di posta elettronica : "+finder+"\n non č un'indirizzo valido.");
				return false
			}	
		}	
	}
	for (i=0;i<which.length;i++) {
		var temp_elem = which.elements[i] ;
		/*Controllo campo "obbligatorio"*/
		
		if(temp_elem.name=="nome"){
			if (temp_elem.value=="") {
				reqString += ("\n-" + error_txt["nome"]);
				reqPass = false ;
			}
		}
		if(temp_elem.name=="cognome"){
			if (temp_elem.value=="") {
				reqString += ("\n-" + error_txt["cognome"]);
				reqPass = false ;
			}
		}
		/*if(temp_elem.name=="sesso"){
			if (temp_elem.checked==false) {
				cntEmpty++;
				if(cntEmpty>1){
					reqString += ("\n-" + error_txt["sesso"]);
					reqPass = false ;
				}
			}
		}*/
		if(temp_elem.name=="day") {
			if (temp_elem.value=="") {
				reqString += ("\n-" + error_txt["day"]);
				reqPass = false;
			}else{
				var giorno = temp_elem.value;
			}
		}
		if(temp_elem.name=="month") {
			if (temp_elem.value=="") {
				reqString += ("\n-" + error_txt["month"]);
				reqPass = false;
			}else{
				var mese = temp_elem.value;
			}
				
		}
		if(temp_elem.name=="year") {
			if (temp_elem.value=="") {
				reqString += ("\n-" + error_txt["year"]);
				reqPass = false;
			}else{
				var anno = temp_elem.value;
			}
		}
		if(temp_elem.name=="comune_nascita") {
			if (temp_elem.value=="") {
				reqString += ("\n-" + error_txt["comune_nascita"]);
				reqPass = false;
			}	
		}
		if(temp_elem.name=="prov_nascita") {
			if (temp_elem.value=="") {
				reqString += ("\n-" + error_txt["prov_nascita"]);
				reqPass = false;
			}	
		}
		if(temp_elem.name=="cittadinanza") {
			if (temp_elem.value=="") {
				reqString += ("\n-" + error_txt["cittadinanza"]);
				reqPass = false;
			}	
		}
		if(temp_elem.name=="stato_civile") {
			if (temp_elem.value=="") {
				reqString += ("\n-" + error_txt["stato_civile"]);
				reqPass = false;
			}	
		}
		if(temp_elem.name=="indirizzo_res") {
			if (temp_elem.value=="") {
				reqString += ("\n-" + error_txt["indirizzo_res"]);
				reqPass = false;
			}	
		}
		if(temp_elem.name=="citta_res") {
			if (temp_elem.value=="") {
				reqString += ("\n-" + error_txt["citta_res"]);
				reqPass = false;
			}	
		}
		if(temp_elem.name=="prov_res") {
			if (temp_elem.value=="") {
				reqString += ("\n-" + error_txt["prov_res"]);
				reqPass = false;
			}	
		}
		if(temp_elem.name=="cap_res") {
			if (temp_elem.value=="") {
				reqString += ("\n-" + error_txt["cap_res"]);
				reqPass = false;
			}	
		}
		if(temp_elem.name=="email") {
			if (temp_elem.value=="") {
				reqString += ("\n-" + error_txt["email"]);
				reqPass = false;
			}	
		}
		if(temp_elem.name=="indirizzo_dom") {
			if (temp_elem.value=="") {
				reqString += ("\n-" + error_txt["indirizzo_dom"]);
				reqPass = false;
			}	
		}
		if(temp_elem.name=="cap_dom") {
			if (temp_elem.value=="") {
				reqString += ("\n-" + error_txt["cap_dom"]);
				reqPass = false;
			}	
		}
		if(temp_elem.name=="citta_dom") {
			if (temp_elem.value=="") {
				reqString += ("\n-" + error_txt["citta_dom"]);
				reqPass = false;
			}	
		}
		if(temp_elem.name=="prov_dom") {
			if (temp_elem.value=="") {
				reqString += ("\n-" + error_txt["prov_dom"]);
				reqPass = false;
			}	
		}
		if(temp_elem.name=="servizio_mil") {
			if (temp_elem.value=="") {
				reqString += ("\n-" + error_txt["servizio_mil"]);
				reqPass = false;
			}	
		}
		if(temp_elem.name=="conoscenze_informatiche") {
			if (temp_elem.value=="") {
				reqString += ("\n-" + error_txt["conoscenze_informatiche"]);
				reqPass = false;
			}	
		}
		if(temp_elem.name=="int_grado_interesse") {
			if (temp_elem.value=="") {
				reqString += ("\n-" + error_txt["int_grado_interesse"]);
				reqPass = false;
			}	
		}
	}
	if((mese !="") && (giorno !="")&& (anno !="")){
		giorno = parseInt(giorno);
		if((mese == "04")||(mese == "06")||(mese == "09")||(mese == "11")){
			if(giorno > 30){
				reqString += ("\n-" + error_txt["data_validate"]);
				reqPass = false;
			}
		}
	}
	sel_year = parseInt(anno);
	if(((sel_year-rif_year)%4) == 0){
		bis_year = true;
	}
	if((mese == "02")&&(bis_year == true)){
		if(giorno > 29){
			reqString += ("\n-" + error_txt["data_validate"]);
			reqPass = false;
		}
	}
	if((mese == "02")&&(bis_year == false)){
		if(giorno > 28){
			reqString += ("\n-" + error_txt["data_validate"]);
			reqPass = false;
		}
	}
	if (!reqPass) {
		alert(reqString);
		return false ;
	}
}

function controlUpload(which){
	for (i=0;i<which.length;i++){
		if((which.elements[i].name=="f1") && (which.elements[i].value=="")){
			alert("Attenzione!!\nNon č stato selezionato alcun curriculum da allegare.");
			return false;
		}
	}
}
function BodyProperties(){
	document.body.bgProperties="fixed";
}

function SetTableBackground(obj,values){
	document.getElementById(obj).background = values;
}
// End -->