// rollover img


function rollover(tab) {
   if (current != "") {
	 imgOn = eval(current + ".src");
	 document[current].src = imgOn;
	}
	
	if (tab != loc) {
	  imgOn = eval(tab + "Rollover.src");
	  document[tab].src = imgOn;
	  current = tab;
	}
}

var curform=document.forms["loginform"];
// validate  the  email in t he  forfot pwd
function validaEmail(){

curform=document.forms["forgot"];

var msgErr="Please fill these fileds:\n"
	var msgErr2="";
	  //validate  email 
	  isVuoto('forgotEmail')
	  if(fill=='')msgErr2+='E Mail\n'
	


	
	 //creo messaggio di errore 
	 if(msgErr2!=""){
			alert(msgErr+msgErr2)
	 }
	    
    // se  vuoto  faccio il subnmit		 
	  if (msgErr2=="" && prima!=1){
	        prima=1;
		   curform.submit();
		   return true
	 }
	 else {return false}

}


// validate  the  email in t he  forfot pwd
function validaLogin(){

curform=document.forms["loginform"];

var msgErr="Please fill these fileds:\n"
	var msgErr2="";
	  //validate  email 
	  isVuoto('email')
	  if(fill=='')msgErr2+='E Mail\n'
	  
	  isVuoto('password')
	  if(fill=='')msgErr2+='Password\n'


	
	 //creo messaggio di errore 
	 if(msgErr2!=""){
			alert(msgErr+msgErr2)
	 }
	    
    // se  vuoto  faccio il subnmit		 
	  if (msgErr2=="" && prima!=1){
	        prima=1;
		   curform.submit();
		   return true
	 }
	 else {return false}

}



// validate  the  email in t he  forfot pwd
function validaRicerca(){

curform=document.forms["ricerca"];

var msgErr="Please fill one of this fields:\n"
	var msgErr2="";
	 IdTypeVal='';
	 IdArea='';
	
	
     
	 isVuoto('cmscustomer.Zipcode')
     if(fill=='')msgErr2+='Zip Code\n'
	 
	
	 //creo messaggio di errore 
	 if(msgErr2!=""){
			alert(msgErr+msgErr2)
	 }
	    
    // se  vuoto  faccio il subnmit		 
	  if (msgErr2=="" && prima!=1){
	        prima=1;

		   curform.submit();
		   return true
	 }
	 else {return false}

}

// avoid  user   multiple  sub

prima=0




function validaPwd(){
 curform=document.forms["register"];
 var msgErr="Please fill these fileds:\n"
 var msgErr2="";
 isVuoto('cmscustomer.NewPwd')
 newPwd=fill;
 if(fill=='')msgErr2+='Password\n'
 isVuoto('cmscustomer.cNewPwd')
 cPwd=fill
 if(fill=='')msgErr2+='Confirm Password\n'
 if(newPwd!=cPwd)msgErr2+='Confirm Password and  password  must  be  the  same\n'
  //creo messaggio di errore 
	 if(msgErr2!=""){
			alert(msgErr+msgErr2)
	 }
	    
    // se  vuoto  faccio il subnmit		 
	  if (msgErr2=="" && prima!=1){
	        prima=1;
		   curform.submit();
		   return true
	 }
	 else {return false}
}


// validate  the  email in t he  forfot pwd
function validaRegister(){

curform=document.forms["register"];
    var msgErr="Please fill these fileds:\n"
     var msgErr2="";
     fill='.'
	mainTab='cmscustomer'
	if(curform.elements["privacy"].checked==true){
	
		  if(curform.elements["cmscustomer.Email"]){
		  checkEmail('cmscustomer.Email')
		  if(fill=='')msgErr2+=' Please Enter a  valid E-Mail\n'
		  }
		  if(fill=='')msgErr2+=' Please Enter a  valid E-Mail\n'
		  isVuoto('cmscustomer.Username')
		  if(fill=='')msgErr2+='Screen Name\n'
		  isVuoto('cmscustomer.Pwd')
		  if(fill=='')msgErr2+='Password\n'
		  isVuoto('cmscustomer.cPwd')
		  if(fill=='')msgErr2+='Confirm Password\n'
	
		
		  
		  if(curform.elements["cmscustomer.IdCountry"]){
				checkCombo("cmscustomer.IdCountry")
				if(valore=="")msgErr2+="Country \n"
	      }
		  
		  
		    // Nome
      isVuoto(mainTab+'.Firstname')
      if(fill=='')msgErr2+='Firstname\n'
        // Nome
      isVuoto(mainTab+'.Surname')
      if(fill=='')msgErr2+='Surname\n'
    
      isVuoto(mainTab+'.Address')
      if(fill=='')msgErr2+='Addressy\n'
     
	 
	  isVuoto(mainTab+'.Zipcode')
      if(fill=='')msgErr2+='Zip code\n'
	 
	  isVuoto(mainTab+'.City')
      if(fill=='')msgErr2+='City\n'
	  
	  isVuoto(mainTab+'.State')
      if(fill=='')msgErr2+='State\n'
	  
	  
	  isVuoto(mainTab+'.WorkPhone')
      if(fill=='')msgErr2+='Work Phone\n'
	  
	
	  
	    if(curform.elements["cmscustomerinfo.IdEvent"]){
				checkCombo("cmscustomerinfo.IdEvent")
				if(valore=="")msgErr2+="Select Seminar \n"
	      }
		  
      isVuoto('cmscustomerinfo.How')
      if(fill=='')msgErr2+='How did you hear about this seminar \n'
	  
	  	  isVuoto('cmscustomerinfo.Note')
      if(fill=='')msgErr2+='Best Time to Call and Other Comments \n'
     }
	 else { msgErr2+="You have to give your consent to use the data you provided us with\n"}
	 //creo messaggio di errore 
	 if(msgErr2!=""){
			alert(msgErr+msgErr2)
	 }
	    
    // se  vuoto  faccio il subnmit		 
	  if (msgErr2=="" && prima!=1){
	        prima=1;
		   curform.submit();
		   return true
	 }
	 else {return false}

}



//  validazione  resche
function validaRe(){

curform=document.forms["register"];
    var msgErr="Please fill these fileds:\n"
     var msgErr2="";

	mainTab='cmsuser'
    if(curform.elements["cmscustomerinfo.IdEvent"]){
				checkCombo("cmscustomerinfo.IdEvent")
				if(valore=="")msgErr2+="Select Seminar \n"
   }

    isVuoto('cmscustomerinfo.How')
    if(fill=='')msgErr2+='How did you hear about this seminar \n'
	  
	isVuoto('cmscustomerinfo.Note')
    if(fill=='')msgErr2+='Best Time to Call and Other Comments \n'
    
	 //creo messaggio di errore 
	 if(msgErr2!=""){
			alert(msgErr+msgErr2)
	 }
	    
    // se  vuoto  faccio il subnmit		 
	  if (msgErr2=="" && prima!=1){
	        prima=1;
		   curform.submit();
		   return true
	 }
	 else {return false}

}




//  checco se  una  cambo  è stata settata
function checkCombo(obj){
      valore=""; 
	  
	   if(curform.elements[obj].selectedIndex!=-1){
      index=curform.elements[obj].selectedIndex
	  valore=curform.elements[obj].options[index].value
	  }
	
	  return valore

}
//   checco un  radio button
function checkRadio(obj){
  radio_choice = false;
  butVal=''
  for (counter = 0; counter < curform.elements[obj].length; counter++){
        if (curform.elements[obj][counter].checked){
		     radio_choice = true; 
			 butVal=counter
			
	    }
  }
  return radio_choice;butVal;
} 
 
 
 //se e un numero
 
 function isNumero(obj){
 Numero='';
 if(curform.elements[obj]){
  
  // verifico  se  è un numero  con le  reg
  var x=curform.elements[obj].value
  var anum=/(^\d+$)|(^\d+\.\d+$)/
  if (anum.test(x)) Numero=true
  }
  
  else Numero=true
  return Numero;
}
// se la data  è  valida
function ceckDate(obj){
dateExists=true
 var monthLength = new Array(31,28,31,30,31,30,31,31,30,31,30,31);
 curData=curform.elements[obj].value
 arrData=curData.split('-');
 day=arrData[0];
 month=arrData[1];
 year=arrData[2]
 maxYear=2100;
 minYear=1900;
 
    if(arrData.length!=3)
	    dateExists = false;
    if (year/4 == parseInt(year/4))
		monthLength[1] = 29;
	if (day > monthLength[month-1])
		dateExists = false;
	if (month >12 || month<1)
		dateExists = false;
	if (year >maxYear || year<minYear)
	   dateExists = false;
	return dateExists;


}

//verifico  se l'oggetto esiste e  se  è vuoto
function isVuoto(obj){

 fill=''
    // se l'oggetto  esiste
	if(curform.elements[obj]){
	   // se è vuto
	   if(curform.elements[obj].value!='')fill=curform.elements[obj].value
	   
	}
	else fill=true

  return fill

}


//verifico  se il valore dell'oggetto e un numero
function isNumber(obj){
 
 fill=''
    // se l'oggetto  esiste
	if(curform.elements[obj]){
	// se è vuto
		fill=curform.elements[obj].value;
		
		if(isNaN(fill)&& fill!=''){fill=''}
		else fill=true
		
	}
  else fill=true
  return fill

}


function getValue(obj){

return curform.elements[obj].value;

}


function setDefault(obj) {

  curform.elements[obj].selectedIndex=0
}

function setIndex(obj,Indice) {
   curform.elements[obj].selectedIndex=Indice
}

function ricarica(modo,id){
 if(modo=="del"){
    var conf=confirm("Are you sure you want to delete this record???")
	if (conf!=true) return
  }
  curform.mode.value=modo
  curform.curId.value=id
  loca=location.href.split('?')
  curform.action=loca[0]
  curform.submit()
}


function validaData(obj){
 ceckDate(obj)
 if(dateExists==false){
  alert("Data Sbagliata")
 }
}


function openDati(w,h,path) {
  var win_opts = "location=0,scrollbars=0,status=0,resizable=0,directories=0,menubar=0,top="+0+",left="+0+",screenY="+0+",screenX="+0; 
  var all_opts = win_opts + ',width=' + w + ',height=' + h ;
  var win = open(path,"immaWin",all_opts) ;
 }

 
 function openUrl(w,h,path) {
  var win_opts = "location=1,scrollbars=1,status=0,resizable=1,directories=0,menubar=0,top="+0+",left="+0+",screenY="+0+",screenX="+0; 
  var all_opts = win_opts + ',width=' + w + ',height=' + h ;
  var win = open(path,"immaWin",all_opts) ;
 } 
   
 function checkEmail(obj) {
 fill=''
    if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(curform.elements[obj].value)){
      return fill=true

 
    }
return fill
}



