function loadpages(page)
{
	homeurl="http://www.ecologital.com/";
		if(page=="home"){
			window.location.href=homeurl;
		}else{
			window.location.href=homeurl+page;
		}
		
} 



function loadother(val){
		if(val=="Other."){
			document.frmMain.other.style.visibility="visible"
		}else{
			document.frmMain.other.style.visibility="hidden"
		}
}
function login(){
var ecologital=document.frmMain
if(ecologital.username.value=="")
	{
		alert("Please Enter Your User Name")
		ecologital.username.focus();
		return
	}	
if(ecologital.password.value=="")
	{
		alert("Please Enter Your Password")
		ecologital.password.focus();
		return
	}
	document.getElementById("message").style.visibility='visible';
	ecologital.username.value="";
	ecologital.password.value="";
}
function onsub()
{
var ecologital=document.frmMain
if(ecologital.title.value=="Other." && ecologital.other.value=="")
{
alert("Please Enter Your Title")
ecologital.other.focus();
return
}
if(ecologital.fname.value=="")
{
alert("Please Enter Your First Name")
ecologital.fname.focus();
return
}
if (document.frmMain.fname.value.length > 40)
  {
    alert("Please enter at most 40 characters in the \"First Name\" field.");
    document.frmMain.fname.focus();
    return ;
  }

  var checkOK = " ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzƒŠŒŽšœžŸÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþ";
  var checkStr = document.frmMain.fname.value;
  var allValid = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("Please enter only letter characters in the \"First Name\" field.");
    document.frmMain.fname.focus();
    return ;
  }
else if(ecologital.lname.value=="")
{
alert("Please Enter Your Last Name")
ecologital.lname.focus();
return
}
if (document.frmMain.lname.value.length > 40)
  {
    alert("Please enter at most 40 characters in the \"Last Name\" field.");
    document.frmMain.lname.focus();
    return ;
  }

  var checkOK = " ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzƒŠŒŽšœžŸÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþ";
  var checkStr = document.frmMain.lname.value;
  var allValid = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("Please enter only letter characters in the \"Last Name\" field.");
    document.frmMain.lname.focus();
    return ;
  }
else if(document.frmMain.company.value==""){
	alert("Please Enter Your Company Name")
	ecologital.company.focus();
	return
}
else if(ecologital.interest.value=="")
{
alert("Please Enter Your Area of Interest")
ecologital.interest.focus();
return
}
else if(document.frmMain.country.selectedIndex==0){
	alert("Please Select Your Country Name")
	ecologital.country.focus();
	return
}

else if(ecologital.mail.value=="")
{
alert("Please Enter Your Email Address")
ecologital.mail.focus();
return
}
else if (ecologital.mail.value!= "")
  {
   
  var mail1=ecologital.mail.value;
  var i1 = mail1.indexOf('@');
  var i2 = mail1.lastIndexOf('@');
  var i3 = mail1.indexOf('.');
  var i4 =(i1-i3);

  if (mail1.length<=5)
  {
  alert("Your E-mail address is too small");
  ecologital.mail.focus();
  return ;
 } 
  
    if(i1==-1)
 {
  alert(" E-mail address must have a '@' ");
  ecologital.mail.focus();
 return ;
  }
  if(i1<2)
 {
  alert(" E-mail address invalid ");
  ecologital.mail.focus();
 return;
   }
 
    if(i3==-1)
  {
  alert(" E-mail address must have a '.' ");
  ecologital.mail.focus();
 return 
  }
 ch = mail1.charAt(mail1.length-1); 
 if (ch==".")
  {
    alert(" E-mail address cannot contain '.' in end");
    ecologital.mail.focus();
    return 
 }
if(i1!=i2)
{
 alert(" E-mail address cannot contain two '@' signs");
 ecologital.mail.focus();
 return
  }
 arr=mail1.split("@"); 
 var i5=arr[1].indexOf('.'); 
 if(i5==-1)
 {
 alert(" E-mail address must have a '.' after @ sign ");
 ecologital.mail.focus();
 return 
 }
 
  var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzƒŠŒŽšœžŸÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþ0123456789-_.@";
  var checkStr = ecologital.mail.value;
  var allValid = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("Please enter only letter, digit and \"@\" characters in the \"E-mail\" field.");
    ecologital.mail.focus();
    return 
  }
  
} 

//loadpages('add_contact')
ecologital.action="add_contact.php";
ecologital.submit()
}

