var xmlHttp1
var xmlHttp2


function checkfield()
{
	var firstname = document.getElementById("f1name").value;
	var lastname=document.getElementById("lname").value;
	var imrno=document.getElementById("imr").value;
	var email=document.getElementById("email").value;
	var aemail=document.getElementById("aemail").value;
	var telno=document.getElementById("telno").value;
	var password=document.getElementById("password").value;
	var cpassword=document.getElementById("cpassword").value;
	var yrpassing=document.getElementById("yrpassing").value;
	//alert (yrpassing);
	
	var i;
	i=0;	
	if(firstname=="")
	{
	   document.getElementById("txtFname").innerHTML="First Name Empty"
	   i=0;
	}
	else
	{
	   document.getElementById("txtFname").innerHTML=""
		i=1;
	}

	if(lastname=="")
	{
	   document.getElementById("txtLname").innerHTML="Last Name Empty"
		i=0;
	}
	else
	{
		   document.getElementById("txtLname").innerHTML=""
		i=1;	
	}

	if(imrno=="")
	{
	   document.getElementById("txtimr").innerHTML="IMR Name Empty"
		i=0;
	}
	else
	{
	     document.getElementById("txtimr").innerHTML=""
		i=1;	
	}

	if(email=="")
	{
	   document.getElementById("txtemail").innerHTML="Email Empty"
		i=0;
	}
	else
	{
	     document.getElementById("txtemail").innerHTML=""
		i=1;	
	}

	if(yrpassing=="")
	{
	   document.getElementById("txtyrpassing").innerHTML="Year of Passing Empty"
		i=0;
	}
	else
	{
	     document.getElementById("txtyrpassing").innerHTML=""
		i=1;	
	}

	/*if(uname=="")
	{
	   document.getElementById("txtUname").innerHTML="User Name Empty"
		i=0;	
	}
	else
	{
	     document.getElementById("txtUname").innerHTML=""
		i=1;
	}*/

	if(password=="")
	{
	   document.getElementById("txtpassword").innerHTML="Password Empty"
		i=0;	
	}
	else
	{
	     document.getElementById("txtpassword").innerHTML=""
		i=1;
	}
	
	if(cpassword=="")
	{
	   document.getElementById("txtcpassword").innerHTML="Confirm Password Empty"
		i=0;	
	}
	else
	{
	     document.getElementById("txtcpassword").innerHTML=""
 		i=1;
		if(password!=cpassword)
		{
	  	   document.getElementById("txtcpassword").innerHTML="Confirm Password Does not Match"
		   i=0;
		}
		else
		{
	     	document.getElementById("txtcpassword").innerHTML=""
		 i=1;
		}
	}

	

	if(i==1)
	{
		
        	document.membership.submit();
 	}

}


function checkmail(e,n)
{

//alert(e);
if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(e))
{
   if(n=="1")
   {
      document.getElementById("txtemail").innerHTML=""
      checkUname(e);	
      //document.getElementById("uname").value=e;
   }
   if(n=="2")
   {
      document.getElementById("txtaemail").innerHTML=""
   }
}
else
{
   if(n=="1")
   {
     document.getElementById("txtemail").innerHTML="Email Not Valid"
   }

   if(n=="2")
   {
     document.getElementById("txtaemail").innerHTML="Email Not Valid"
   }

}
}

function checktelno(str)
{
	
	var numericExpression = /^[0-9-.+ ]+$/;
	if((numericExpression).test(str))
	{
		document.getElementById("txttelno").innerHTML=""
	}
	else
	{
		document.getElementById("txttelno").innerHTML="Telephone number not valid"
	}
}

function checkOldPassword(str)
{
	
	if((document.getElementById("password").value)!=str)
 	{
     		document.getElementById("txtopassword").innerHTML="Old Password Does Not Matches"
 	}
 	else
 	{
     		document.getElementById("txtopassword").innerHTML=""
 	}

}






function checkPassword(str)
{ 
 if((window.document.membership.password.value)!=str)
 {
     document.getElementById("txtcpassword").innerHTML="Retype Password Does Not Matches"
 }
 else
 {
     document.getElementById("txtcpassword").innerHTML=""
 } 	
}

function checkNewPassword(str)
{ 
 if((document.getElementById("npassword").value)!=str)
 {
     document.getElementById("txtcnpassword").innerHTML="Retype Password Does Not Matches"
 }
 else
 {
     document.getElementById("txtcnpassword").innerHTML=""
 } 	
}


function checkUname(str)
{ 
xmlHttp2=GetXmlHttpObject2()
if (xmlHttp2==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 }
var url="checkusername.php"
url=url+"?unm="+str

xmlHttp2.onreadystatechange=userCheck
xmlHttp2.open("POST",url,true)
xmlHttp2.send(null)
}


function userCheck() 
{
if (xmlHttp2.readyState==4 || xmlHttp2.readyState=="complete")
 { 
 document.getElementById("txtemail").innerHTML=xmlHttp2.responseText 
 } 
}

function GetXmlHttpObject()
{
var xmlHttp1=null;
try
 {
 // Firefox, Opera 8.0+, Safari
 xmlHttp1=new XMLHttpRequest();
 }
catch (e)
 {
 //Internet Explorer
 try
  {
  xmlHttp1=new ActiveXObject("Msxml2.XMLHTTP");
  }
 catch (e)
  {
  xmlHttp1=new ActiveXObject("Microsoft.XMLHTTP");
  }
 }
return xmlHttp1;
}


function GetXmlHttpObject2()
{
var xmlHttp2=null;
try
 {
 // Firefox, Opera 8.0+, Safari
 xmlHttp2=new XMLHttpRequest();
 }
catch (e)
 {
 //Internet Explorer
 try
  {
  xmlHttp2=new ActiveXObject("Msxml2.XMLHTTP");
  }
 catch (e)
  {
  xmlHttp2=new ActiveXObject("Microsoft.XMLHTTP");
  }
 }
return xmlHttp2;
}