window.onload=function(){
if(!NiftyCheck())
	return;
//la pagina template

Rounded("div#bordocontent","top","#2F5A84","#FFFFFF","smooth");
Rounded("div#bordocontent","bottom","#9CB7D3","#FFFFFF","smooth");
Rounded("div#content","top","#FFFFFF","transparent","smooth");
Rounded("div#content","bottom","#FFFFFF","transparent","smooth");

//per la finestra real time
Rounded("div#bordocontentRealTime","all","#2F5A84","#FFFFFF","smooth");

//spot della pagina home
Rounded("div#spotSx1","all","#F8F5EC","#FFFFFF","smooth");
Rounded("div#spotSx2","all","#F8F5EC","#FFFFFF","smooth");
Rounded("div#spotSx3","all","#F8F5EC","#FFFFFF","smooth");
Rounded("div#spotSx4","all","#F8F5EC","#FFFFFF","smooth");
Rounded("div#spotSx5","all","#F8F5EC","#FFFFFF","smooth");
Rounded("div#spotSx6","all","#F8F5EC","#FFFFFF","smooth");
Rounded("div#spotSx7","all","#F8F5EC","#FFFFFF","smooth");
Rounded("div#spotSx8","all","#F8F5EC","#FFFFFF","smooth");


//spot laterali
Rounded("div#spot1","all","#FCFBF7","#EDE6D3","smooth");
Rounded("div#spot2","all","#FCFBF7","#EDE6D3","smooth");
Rounded("div#spot3","all","#FCFBF7","#EDE6D3","smooth");
Rounded("div#spot4","all","#FCFBF7","#EDE6D3","smooth");



Rounded("div#mc","all","#FCFBF7","#EDE6D3","smooth");//menu contestuale
Rounded("div#boxRic","all","#FCFBF7","#EDE6D3","smooth");//menu contestuale
Rounded("div#mco","all","#FCFBF7","#EDE6D3","smooth");//menu contestuale orizzontale
Rounded("div#mcStrumenti","all","#FCFBF7","#EDE6D3","smooth");//menu strumenti
Rounded("div#boxMessaggi","all","#FCFBF7","#FFCC00","smooth");//box messaggi 
Rounded("div#boxCuriosita","all","#FCFBF7","#EDE6D3","smooth");//box curiositā
Rounded("div#boxAllegati","all","#FCFBF7","#EDE6D3","smooth");//box degli allegati
Rounded("div#boxTestaProfilo","all","#FCFBF7","#A04D0A","smooth");//box marrone di testa del profilo
Rounded("div#boxRossoScadenza","all","#FCFBF7","#FF0000","smooth");//box rosso asta in scadenza


//riepilogo dell'ordine
Rounded("div#layoutTblCatalogo","top","#FCFBF7","#5C83A9","smooth");
Rounded("div#layoutTblCatalogo1","top","#FCFBF7","#5C83A9","smooth");
Rounded("div#layoutTblCatalogo2","top","#FCFBF7","#5C83A9","smooth");
Rounded("div#layoutTblCatalogo3","top","#FCFBF7","#5C83A9","smooth");

//box per i menu asta nella pagina di profilo, al massimo sono 10
Rounded("div#boxMenuAsta1","all","#FCFBF7","#EDE6D3","smooth");
Rounded("div#boxMenuAsta2","all","#FCFBF7","#EDE6D3","smooth");
Rounded("div#boxMenuAsta3","all","#FCFBF7","#EDE6D3","smooth");
Rounded("div#boxMenuAsta4","all","#FCFBF7","#EDE6D3","smooth");
}

function ControllaMail(str)
   {
   EmailAddr = str;
   Filtro = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/;
   if (Filtro.test(EmailAddr))
      return true;
   else
      return false;
    }


function selectedProv()
{
	var cboProv = document.getElementById("x_provincia");
	return cboProv.options[cboProv.selectedIndex].value;
}


function controllaCampi(pagina,lingua){
	if( Trim(document.reguser.x_nome.value) == ""){
		if(lingua == "en"){alert("Please enter your name!");}else{alert("Compilare il campo Nome!");				
		}
	}else if( Trim(document.reguser.x_cognome.value) == ""){
		if(lingua == "en"){alert("Please enter your last name!");}else{alert("Compilare il campo Cognome!");}
	}else if( Trim(document.reguser.x_indirizzo.value) == ""){
		if(lingua == "en"){alert("Please enter address field!");}else{alert("Compilare il campo Indirizzo!");}
	}else if( Trim(document.reguser.x_citta.value) == ""){
		if(lingua == "en"){alert("Please enter city field!");}else{alert("Compilare il campo Cittā!");}
	}else if(selectedProv() == 0 && document.getElementById("x_provincia").value == ""){
		if(lingua == "en"){alert("Please enter province field!");}else{alert("Compilare il campo Provincia!");}
	}else if( Trim(document.reguser.x_cap.value) == ""){
		if(lingua == "en"){alert("Please enter cap field!");}else{alert("Compilare il campo CAP!");}
	}else if(document.reguser.x_email.value == ""){
		if(lingua == "en"){alert("Please enter your e-mail address!");}else{alert("Compilare il campo Email!");}
	}else if (! ControllaMail(document.reguser.x_email.value)){
	  if(lingua == "en"){alert("E-mail format ("+document.reguser.x_email.value+") is not correct!");}
	  else{alert("L'indirizzo e-mail ("+document.reguser.x_email.value+") non č corretto!");}
	}else if(document.reguser.x_username.value == ""){
		if(lingua == "en"){alert("Please enter your Username!");}else{alert("Compilare il campo Username!");}
	}else if (document.reguser.x_username.value.length <3) {
		if(lingua == "en"){alert("Username not be lower than 3 character!");}else{alert("Username non inferiore a 3 caratteri!");}
	}else if(document.reguser.x_password.value == ""){		
		if(lingua == "en"){alert("Please enter your Password!");}else{alert("Compilare il campo Password!");}
	}else if (document.reguser.x_password.value.length <3) {
		if(lingua == "en"){alert("Password not be lower than 3 character!");}else{alert("Password non inferiore a 3 caratteri!");}
	}else if(document.reguser.x_password2.value == ""){		
		if(lingua == "en"){alert("Please confirm you Password!");}else{alert("Confermare la Password!");}
	}else if(document.reguser.x_password.value != document.reguser.x_password2.value){				
		if(lingua == "en"){alert("Password fields must match!");}else{alert("I campi password devono essere uguali!");}
	}else if(pagina!=true){
		if (document.reguser.privacy.checked == false){
			if(lingua == "en"){
				alert("I hereby authorize Filsam to have my personal data processed!");	
			}else{
				alert("Acconsentire al trattamento dei dati personali!");	
			}
		}else{
			document.reguser.submit();
		}
	}else{		
		document.reguser.submit();
	}
}

function Trim(str)
{  
	while(str.charAt(0) == (" ") )
  {  
		str = str.substring(1);
  }
  while(str.charAt(str.length-1) == " " )
  {  
		str = str.substring(0,str.length-1);
  }
  return str;
}
function controllaContatto(lingua){
	if(document.formContatto.nome.value == ""){
		if(lingua == "en"){
			alert("Please enter your name!");}else{alert("Compilare il campo Nome!");}
	}else if(document.formContatto.cognome.value == ""){
		if(lingua == "en"){alert("Please enter your last name!");}else{alert("Compilare il campo Cognome!");}
	}else if(document.formContatto.email.value == ""){
		if(lingua == "en"){alert("Please enter your e-mail address!");}else{alert("Compilare il campo Email!");}
	}else if(document.formContatto.body.value == ""){
		if(lingua == "en"){alert("Please enter your Message!");}else{alert("Compilare il campo Messaggio!");}
	}else{
		document.formContatto.submit()
	}
}
