//------------------- is a numeric
function IsNumeric(sText)
{
   var ValidChars = "0123456789.,";
   var IsNumber=true;
   var Char;
    for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
   
   }

//------------------- function change language javascript
function change_language(lng){
var stringa="lng#"+lng;
ajax_post('inc_php/language_set','ajax_loader',stringa,0);
}
//------------------------------------------------
 function win_on(iddiv){
  var idombra="ombra_"+iddiv;
  document.getElementById(idombra).style.display='block';
  document.getElementById(iddiv).style.display='block';
 }
 function win_off(iddiv){
  var idombra="ombra_"+iddiv;
 document.getElementById(idombra).style.display='none';
 document.getElementById(iddiv).style.display='none';
 }
 function win_onoff(iddiv){
 win_off('elenco1');
 win_off('elenco2');
 win_off('elenco3');  
 //---------------------------
 var idombra="ombra_"+iddiv; 
 var stato=document.getElementById(idombra).style.display;
 if(stato=='none')
   {
   win_on(iddiv);
   }
   else
   {
   win_off(iddiv);
   }
 } 
 //--------------------- BOX LOGIN
 function goverifypin(iduser,email){
document.location.href="verifyemail.php?iduser="+iduser+"&email="+email;
}
function userlogin(){
var vemail=document.getElementById('logemail').value;
var vpassword=document.getElementById('logpassword').value;
var err=0;
if(vemail.length<=6 || vemail=="your email"){err++;}
if(vpassword.length<=4 ){err++;}
if(err>0)
		{
		alert(unescape('ACCESS ERROR:\nWrong username or password'));
		}
		else
		{
			var stringa='email#'+vemail+'#password#'+vpassword;
			ajax_post('inc_php/aj_userlogin','ajax_loader',stringa,0);
		}
}
function cuserlogin(){
var vemail=document.getElementById('clogemail').value;
var vpassword=document.getElementById('clogpassword').value;
var err=0;
if(vemail.length<=6 || vemail=="your email"){err++;}
if(vpassword.length<=4 ){err++;}
if(err>0)
		{
		alert(unescape('ACCESS ERROR:\nWrong username or password'));
		}
		else
		{
			var stringa='email#'+vemail+'#password#'+vpassword;
			ajax_post('inc_php/aj_userlogin','ajax_loader',stringa,0);
		}
}

//-------------------------- REGISTER JS
function checkresp(){
var verifiedemail=document.getElementById('verifiedemail').innerHTML;
return verifiedemail;
}
//--------------
function specifyonoff(){
var   sectorused=document.getElementById('sectorused').value;
var   trspecify=document.getElementById('trspecify');
//----
if(sectorused!="ALL OTHER USES")
   {
      trspecify.innerHTML="<td >&nbsp;</td><td >&nbsp;</td>";
   }
   else
   {
    trspecify.innerHTML="<td align=\"right\"><font color=\"#CC0000\">*</font>"+
    "Please  give some details or specifications</td><td><input id=\"specify\" type=\"text\" value=\"\" maxlength=\"120\"  class=\"input_box\" style=\"width:350px\" /></td>";
   }
}
//------------------
function formcheck3(){
var company=document.getElementById('company');
var country=document.getElementById('country');
var person=document.getElementById('person');
var email=document.getElementById('email');
//var email2=document.getElementById('email2');
var password=document.getElementById('password');
//var password2=document.getElementById('password2');
var looking=document.getElementById('looking');
var mainuse=document.getElementById('mainuse');
var sectorused=document.getElementById('sectorused');
var quantity=document.getElementById('quantity');
var particular=document.getElementById('particular');
//--------------------------------------------------------
var vcompany=company.value;
var vcountry=country.value;
var vperson=person.value;
var vemail=email.value;
//var vemail2=email2.value;
//var vpassword=password.value;
//var vpassword2=password2.value;
var vlooking=looking.value;
var vmainuse=mainuse.value;
var vsectorused=sectorused.value;
var vquantity=quantity.value;
var vparticular=particular.value;
//--------------------------------------------------------
var err=0;
var msg="ERROR FORM FIELDS:";
//----- set normal border border
company.style.border='1px solid #6699FF';
country.style.border='1px solid #6699FF';
person.style.border='1px solid #6699FF';
email.style.border='1px solid #6699FF';
//email2.style.border='1px solid #6699FF';
//password.style.border='1px solid #6699FF';
//password2.style.border='1px solid #6699FF';
looking.style.border='1px solid #6699FF';
mainuse.style.border='1px solid #6699FF';
sectorused.style.border='1px solid #6699FF';
quantity.style.border='1px solid #6699FF';
particular.style.border='1px solid #6699FF';
//---- control
if(vcompany.length<=3){err++;msg=msg+"\nWrong Company name field";company.style.border='2px solid #FF0000';}
if(vcountry<=0){err++;msg=msg+"\nWrong country field";country.style.border='2px solid #FF0000';}
if(vperson.length<=3){err++;msg=msg+"\nWrong person name field";person.style.border='2px solid #FF0000';}
if(vemail.length<=6){err++;msg=msg+"\nWrong email field";email.style.border='2px solid #FF0000';}
//if(vemail2!=vemail){err++;msg=msg+"\nWrong email rewrite field";email2.style.border='2px solid #FF0000';}
//if(vpassword.length<=3){err++;msg=msg+"\nWrong password field";password.style.border='2px solid #FF0000';}
//if(vpassword2!=vpassword){err++;msg=msg+"\nWrong password rewrite field";password2.style.border='2px solid #FF0000';}
if(vlooking.length<=4){err++;msg=msg+"\nYou need to specify what you're looking for?";looking.style.border='2px solid #FF0000';}
if(vmainuse.length<=4){err++;msg=msg+"\nYou need to specify what you're main use of the Plastic Pallet";mainuse.style.border='2px solid #FF0000';}
if(vsectorused.length<=4){err++;msg=msg+"\nYou need to specify what you're the sector in which the requested the Plastic Pallet";sectorused.style.border='2px solid #FF0000';}
if(vquantity.length<=0){err++;msg=msg+"\nYou need to specify quantity";quantity.style.border='2px solid #FF0000';}
if(vsectorused!="ALL OTHER USES"){
  
}
else
{
   var specify=document.getElementById('specify');
   var vspecify=specify.value;
   specify.style.border='1px solid #6699FF';
   if(vspecify.length<=3){err++;msg=msg+"\nYou need to specify details of request";specify.style.border='2px solid #FF0000';}
}
//--------------------------------------------------------
//+vpassword+' PWD2:'+vpassword2+'email:'+vemail+' email2:'+vemail2)
if(err==0)
	{ //-------- check email by AJAX
	var stringa='email#'+email.value;
	ajax_post('inc_php/aj_emailverify3','ajax_loader',stringa,0);
	//------
	}
	else
	{
	alert(msg);
	}
	//------
}        
//--------------------------------------------------------
//------------------
function formcheck2(){
var company=document.getElementById('company');
var country=document.getElementById('country');
var person=document.getElementById('person');
var email=document.getElementById('email');
//var email2=document.getElementById('email2');
var password=document.getElementById('password');
//var password2=document.getElementById('password2');
var looking=document.getElementById('looking');
var mainuse=document.getElementById('mainuse');
var sectorused=document.getElementById('sectorused');
var quantity=document.getElementById('quantity');
var particular=document.getElementById('particular');
//--------------------------------------------------------
var vcompany=company.value;
var vcountry=country.value;
var vperson=person.value;
var vemail=email.value;
//var vemail2=email2.value;
var vpassword=password.value;
//var vpassword2=password2.value;
var vlooking=looking.value;
var vmainuse=mainuse.value;
var vsectorused=sectorused.value;
var vquantity=quantity.value;
var vparticular=particular.value;
//--------------------------------------------------------
var err=0;
var msg="ERROR FORM FIELDS:";
//----- set normal border border
company.style.border='1px solid #6699FF';
country.style.border='1px solid #6699FF';
person.style.border='1px solid #6699FF';
email.style.border='1px solid #6699FF';
//email2.style.border='1px solid #6699FF';
password.style.border='1px solid #6699FF';
//password2.style.border='1px solid #6699FF';
looking.style.border='1px solid #6699FF';
mainuse.style.border='1px solid #6699FF';
sectorused.style.border='1px solid #6699FF';
quantity.style.border='1px solid #6699FF';
particular.style.border='1px solid #6699FF';
//---- control
if(vcompany.length<=3){err++;msg=msg+"\nWrong Company name field";company.style.border='2px solid #FF0000';}
if(vcountry<=0){err++;msg=msg+"\nWrong country field";country.style.border='2px solid #FF0000';}
if(vperson.length<=3){err++;msg=msg+"\nWrong person name field";person.style.border='2px solid #FF0000';}
if(vemail.length<=6){err++;msg=msg+"\nWrong email field";email.style.border='2px solid #FF0000';}
//if(vemail2!=vemail){err++;msg=msg+"\nWrong email rewrite field";email2.style.border='2px solid #FF0000';}
if(vpassword.length<=3){err++;msg=msg+"\nWrong password field";password.style.border='2px solid #FF0000';}
//if(vpassword2!=vpassword){err++;msg=msg+"\nWrong password rewrite field";password2.style.border='2px solid #FF0000';}
if(vlooking.length<=4){err++;msg=msg+"\nYou need to specify what you're looking for?";looking.style.border='2px solid #FF0000';}
if(vmainuse.length<=4){err++;msg=msg+"\nYou need to specify what you're main use of the Plastic Pallet";mainuse.style.border='2px solid #FF0000';}
if(vsectorused.length<=4){err++;msg=msg+"\nYou need to specify what you're the sector in which the requested the Plastic Pallet";sectorused.style.border='2px solid #FF0000';}
if(vquantity.length<=0){err++;msg=msg+"\nYou need to specify quantity";quantity.style.border='2px solid #FF0000';}
if(vsectorused!="ALL OTHER USES"){
  
}
else
{
   var specify=document.getElementById('specify');
   var vspecify=specify.value;
   specify.style.border='1px solid #6699FF';
   if(vspecify.length<=3){err++;msg=msg+"\nYou need to specify details of request";specify.style.border='2px solid #FF0000';}
}
//--------------------------------------------------------
//+vpassword+' PWD2:'+vpassword2+'email:'+vemail+' email2:'+vemail2)
if(err==0)
	{ //-------- check email by AJAX
	var stringa='email#'+email.value;
	ajax_post('inc_php/aj_emailverify2','ajax_loader',stringa,0);
	//------
	}
	else
	{
	alert(msg);
	}
	//------
}        
//--------------------------------------------------------
function formcheck(){
var company=document.getElementById('company');
var country=document.getElementById('country');
var person=document.getElementById('person');
var email=document.getElementById('email');
//var email2=document.getElementById('email2');
var password=document.getElementById('password');
//var password2=document.getElementById('password2');
var looking=document.getElementById('looking');
//--------------------------------------------------------
var vcompany=company.value;
var vcountry=country.value;
var vperson=person.value;
var vemail=email.value;
//var vemail2=email2.value;
var vpassword=password.value;
//var vpassword2=password2.value;
var vlooking=looking.value;
//--------------------------------------------------------
var err=0;
var msg="ERROR FORM FIELDS:";
//----- set normal border border
company.style.border='1px solid #6699FF';
country.style.border='1px solid #6699FF';
person.style.border='1px solid #6699FF';
email.style.border='1px solid #6699FF';
//email2.style.border='1px solid #6699FF';
password.style.border='1px solid #6699FF';
//password2.style.border='1px solid #6699FF';
looking.style.border='1px solid #6699FF';
//---- control
if(vcompany.length<=3){err++;msg=msg+"\nWrong Company name field";company.style.border='2px solid #FF0000';}
if(vcountry<=0){err++;msg=msg+"\nWrong country field";country.style.border='2px solid #FF0000';}
if(vperson.length<=3){err++;msg=msg+"\nWrong person name field";person.style.border='2px solid #FF0000';}
if(vemail.length<=6){err++;msg=msg+"\nWrong email field";email.style.border='2px solid #FF0000';}
//if(vemail2!=vemail){err++;msg=msg+"\nWrong email rewrite field";email2.style.border='2px solid #FF0000';}
if(vpassword.length<=3){err++;msg=msg+"\nWrong password field";password.style.border='2px solid #FF0000';}
//if(vpassword2!=vpassword){err++;msg=msg+"\nWrong password rewrite field";password2.style.border='2px solid #FF0000';}
if(vlooking.length<=4){err++;msg=msg+"\nYou need to specify what you're looking for?";looking.style.border='2px solid #FF0000';}
//--------------------------------------------------------
//alert('???????????????PWD:'+vpassword+' PWD2:'+vpassword2+'email:'+vemail+' email2:'+vemail2)
if(err==0)
	{ //-------- check email by AJAX
	var stringa='email#'+email.value;
	ajax_post('inc_php/aj_emailverify','ajax_loader',stringa,0);
	//------
	}
	else
	{
	alert(msg);
	}
	//------

}
//--------------------------------------------------------
function mailcheck(codepa){
var email=document.getElementById('email');
var err=0;
var msg="ERROR FORM FIELDS:";
	if(codepa==1){err++;msg=msg+"\nThis email already used, try another";email.style.border='2px solid #FF0000';}
	if(codepa==2){err++;msg=msg+"\nWrong email field, try another";email.style.border='2px solid #FF0000';}
	if(codepa==3){err++;msg=msg+"\nEmail check not runned";email.style.border='2px solid #FF0000';}
        if(codepa==4){err++;msg=msg+"\nE-mail address  Rejected  !! \nPlease try  again  with  your  official  e-mail  company !\nWe accept only  users sign in  with a specific  company e-mail  address !\nGeneric email like @yahoo or like @gmail is not accepted!  ";email.style.border='2px solid #FF0000';}
if(err==0)
	{ //-------- check email by AJAX
	createnewuser();
	//------
	}
	else
	{
	alert(msg);
	}
}
//----------------------
//--------------------------------------------------------
function mailcheck2(codepa){
var email=document.getElementById('email');
var err=0;
var msg="ERROR FORM FIELDS:";
	if(codepa==1){err++;msg=msg+"\nThis email already used, try another";email.style.border='2px solid #FF0000';}
	if(codepa==2){err++;msg=msg+"\nWrong email field, try another";email.style.border='2px solid #FF0000';}
	if(codepa==3){err++;msg=msg+"\nEmail check not runned";email.style.border='2px solid #FF0000';}
        if(codepa==4){err++;msg=msg+"\nE-mail address  Rejected  !! \nPlease try  again  with  your  official  e-mail  company !\nWe accept only  users sign in  with a specific  company e-mail  address !\nGeneric email like @yahoo or like @gmail is not accepted!  ";email.style.border='2px solid #FF0000';}

if(err==0)
	{ //-------- check email by AJAX
	createnewuser2();
	//------
	}
	else
	{
	alert(msg);
	}
}
//--------------------------------------------------------
function mailcheck3(codepa){
var email=document.getElementById('email');
var err=0;
var msg="ERROR FORM FIELDS:";
	if(codepa==1){err++;msg=msg+"\nThis email already used, try another";email.style.border='2px solid #FF0000';}
	if(codepa==2){err++;msg=msg+"\nWrong email field, try another";email.style.border='2px solid #FF0000';}
	if(codepa==3){err++;msg=msg+"\nEmail check not runned";email.style.border='2px solid #FF0000';}
if(err==0)
	{ //-------- checked email by AJAX
         contactus();
	//------
	}
	else
	{
	alert(msg);
	}
}
//----------------------
function contactus()
{
var company=document.getElementById('company').value;
var country=document.getElementById('country').value;
var person=document.getElementById('person').value;
var email=document.getElementById('email').value;
var looking=document.getElementById('looking').value;
var mainuse=document.getElementById('mainuse').value;
var sectorused=document.getElementById('sectorused').value;
var quantity=document.getElementById('quantity').value;
var particular=document.getElementById('particular').value;
if(sectorused!="ALL OTHER USES"){
  var specify="";
}
else
{
   var specify=document.getElementById('specify').value;
}
//----------
var stringa="company#"+company
			+"#country#"+country
			+"#person#"+person
			+"#email#"+email
			+"#looking#"+looking
                        +"#mainuse#"+mainuse
                        +"#sectorused#"+sectorused
                        +"#quantity#"+quantity
                        +"#particular#"+particular
                        +"#specify#"+specify
		ajax_post('inc_php/aj_contactus','ajax_loader',stringa,0);									
}
//----------------------
//----------------------
//----------------------
function createnewuser2()
{
var company=document.getElementById('company').value;
var country=document.getElementById('country').value;
var person=document.getElementById('person').value;
var email=document.getElementById('email').value;
var password=document.getElementById('password').value;
var looking=document.getElementById('looking').value;
var mainuse=document.getElementById('mainuse').value;
var sectorused=document.getElementById('sectorused').value;
var quantity=document.getElementById('quantity').value;
var particular=document.getElementById('particular').value;
if(sectorused!="ALL OTHER USES"){
  var specify="";
}
else
{
   var specify=document.getElementById('specify').value;
}
//----------
var stringa="company#"+company
			+"#country#"+country
			+"#person#"+person
			+"#email#"+email
			+"#password#"+password
			+"#looking#"+looking
                        +"#mainuse#"+mainuse
                        +"#sectorused#"+sectorused
                        +"#quantity#"+quantity
                        +"#particular#"+particular
                        +"#specify#"+specify
		ajax_post('inc_php/aj_createnewuser2','ajax_loader',stringa,0);									
}
//----------------------
function createnewuser()
{
var company=document.getElementById('company').value;
var country=document.getElementById('country').value;
var person=document.getElementById('person').value;
var email=document.getElementById('email').value;
var password=document.getElementById('password').value;
var looking=document.getElementById('looking').value;
var stringa="company#"+company
			+"#country#"+country
			+"#person#"+person
			+"#email#"+email
			+"#password#"+password
			+"#looking#"+looking			
		ajax_post('inc_php/aj_createnewuser','ajax_loader',stringa,0);									
}
function createuserok(){
var vemail=document.getElementById('email').value;
var vpassword=document.getElementById('password').value;
			var stringa='email#'+vemail+'#password#'+vpassword;
			ajax_post('inc_php/aj_userlogin','ajax_loader',stringa,0);
//document.location.href="createnewuserok.php";
}
function createuserok2(){
   alert("Welcome !\nThank for your interest.\nYour request is mailed with success !\n"+
         "You will get answer as soon as possible.\nOpen your e-mail program and confirm !\nBest Regards,\nSirtoli Dario\nwww.pallet.com");
var vemail=document.getElementById('email').value;
var vpassword=document.getElementById('password').value;
			var stringa='email#'+vemail+'#password#'+vpassword;
			ajax_post('inc_php/aj_userlogin','ajax_loader',stringa,0);
//document.location.href="createnewuserok.php";
}
//---------
function contactsendok(){
   alert("Welcome !\nThank for your interest.\nYour request is mailed with success !\n"+
         "You will get answer as soon as possible.\nBest Regards,\nSirtoli Dario\nwww.pallet.com");
//document.location.href="index.php";

}
