function createRequestObject()
{
/* Initialising the variable xmlhttp */
	var xmlhttp=false;
	
/* Try and catch block for creating xmlhttp object according to the browser */
	try
	{
	/* The xmlhttp object is built into the Microsoft XML Parser. */
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch (e)
	{
		try 
		{
		/* The xmlhttp object is built into the Microsoft IE. */
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		} 
		catch (E) 
		{
			xmlhttp = false;
		}
	}
/* The xmlhttp object is built into the browsers other than Microsoft IE. */
	if (!xmlhttp && typeof XMLHttpRequest!='undefined')
	{
		xmlhttp = new XMLHttpRequest();
	}
	return xmlhttp;
}
var request = createRequestObject();
//---------------------------------
function checkname()
{
	var chname=document.form2.Name.value;	
	if(chname.length > 0)
	{
	request.open('GET','val.php?name=' + chname,true);	
	//alert('changed name');	 
	request.onreadystatechange = function()
	{
		if(request.readyState == 4)
		{
			if(request.status == 200)
			{
					var response = request.responseText;
				
					if ((response.toLowerCase()) == (chname.toLowerCase()))
					{
						document.getElementById('vname').value= response;
						document.getElementById('err_name').innerHTML = "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">         <tr>       <td width=\"10\">&nbsp;</td>  <td width=\"16\" valign=\"middle\"><img src=\"images/ok_icon.jpg\" alt=\"ok\"></td>   <td width=\"10\">&nbsp;</td>  <td></td>     </tr>       </table>";
					document.getElementById("err_row_name").style.background = '#FFFFFF';
					}	
					
					else 
					{
					
					document.getElementById('err_name').innerHTML = response;
					//document.getElementById('err_name').style.background = '#fce9e9';
					document.getElementById("err_row_name").style.background = '#fce9e9';					
					}
				
				
				}
			
			}
	}
	
	}
	else
	// alert('name cannot be left blank');
	document.getElementById('err_name').innerHTML = "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr><td width=\"10\">		&nbsp;</td>  <td width=\"16\" valign=\"middle\"><img src=\"images/error1.gif\" alt=\"Error\"></td> <td width=\"10\">&nbsp;</td>  <td><span class=\"style3\" >Name is Blank</span> </td>     </tr>       </table>";
	document.getElementById("err_row_name").style.background = '#fce9e9';
	request.send(null);
}

function check_org()
{
	var org=document.form2.Organization.value;
	if(org.length > 0)
	{
	request.open('GET','val.php?chorg=' + org,true);	
	// alert('changed organization');
	
	request.onreadystatechange = function()
		{
			if(request.readyState == 4)
			{
				if(request.status == 200)
				{
					
					var response = request.responseText;
				
				if (response.toLowerCase() == org.toLowerCase())
				{
					document.getElementById('vorg').value= response;
					document.getElementById('err_org').innerHTML = "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">         <tr>       <td width=\"10\">&nbsp;</td>  <td width=\"16\" valign=\"middle\"><img src=\"images/ok_icon.jpg\" alt=\"ok\"></td>   <td width=\"10\">&nbsp;</td>  <td></td>     </tr>       </table>";
					document.getElementById("err_row_org").style.background = '#FFFFFF';
					}	
				else
				{			
					document.getElementById('err_org').innerHTML = response;
					document.getElementById("err_row_org").style.background = '#fce9e9';
				
				}
		}
	}
	}
	}
	else
	// alert('organization name cannot be left blank');
	document.getElementById('err_org').innerHTML= "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr><td width=\"10\">&nbsp;</td>  <td width=\"16\" valign=\"middle\"><img src=\"images/error1.gif\" alt=\"Error\"></td> <td width=\"10\">&nbsp;</td>  <td><span class=\"style3\" >Organization Name is Blank</span> </td>     </tr>       </table>";
	document.getElementById("err_row_org").style.background = '#fce9e9';
	request.send(null);
}

function check_email()
{
	var mail = document.form2.email.value;
	if(mail.length > 0)
	{
	request.open('GET','val.php?email=' + mail,true);	
	//alert('changed mail');
	request.onreadystatechange = function()
	{
		if(request.readyState == 4)
		{
			if(request.status == 200)
			{
				if(request.responseText != "")
				{
					
					var response= request.responseText;
					document.getElementById('mail').innerHTML = response;
					document.getElementById("err_row_email").style.background = '#fce9e9';
				}
				else
			document.getElementById("mail").innerHTML = "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">         												             <tr><td width=\"10\">&nbsp;</td>  <td width=\"16\" valign=\"middle\"><img src=\"images/ok_icon.jpg\" alt=\"ok\"></td>   			 <td width=\"10\">&nbsp;</td>  <td><span class=\"style3\" style = \"color: #3e3f42;\">Email Address Accepted</span> </td></tr></table>";
			document.getElementById("err_row_email").style.background = '#FFFFFF';
				
				}
		}
	}
	}
	else
	// alert('email cannot be left blank');
	document.getElementById('mail').innerHTML= "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr><td width=\"10\">&nbsp;</td>  <td width=\"16\" valign=\"middle\"><img src=\"images/error1.gif\" alt=\"Error\"></td> <td width=\"10\">&nbsp;</td>  <td><span class=\"style3\" >email is is Blank</span> </td>     </tr>       </table>";
	document.getElementById("err_row_email").style.background = '#fce9e9';
			
	request.send(null);
}

function check_address()
{
	var chaddress =document.form2.Street_Address.value;
	if (chaddress.length > 0)
	{
	request.open('GET','val.php?street_address=' + chaddress,true);	
	//alert('changed street address');
	request.onreadystatechange = function()
	{
		if(request.readyState == 4)
		{
			if(request.status == 200)
			{
				var response= request.responseText;
				if((response.toLowerCase()) == (chaddress.toLowerCase()))
				
					{ 
					document.getElementById('addr').value= response;
					document.getElementById('Address').innerHTML = "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">         <tr>       <td width=\"10\">&nbsp;</td>  <td width=\"16\" valign=\"middle\"><img src=\"images/ok_icon.jpg\" alt=\"ok\"></td>   <td width=\"10\">&nbsp;</td>  <td></td>     </tr>       </table>";
					document.getElementById("err_row_addr").style.background = '#FFFFFF';
					}else
						{					
						document.getElementById('Address').innerHTML = response;
						document.getElementById("err_row_addr").style.background = '#fce9e9';
						}
			}
			}
		}
	
	}
	else
	// alert('street address cannot be left blank');
	document.getElementById('Address').innerHTML= "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr><td width=\"10\">&nbsp;</td>  <td width=\"16\" valign=\"middle\"><img src=\"images/error1.gif\" alt=\"Error\"></td> <td width=\"10\">&nbsp;</td>  <td><span class=\"style3\" >Address is Blank</span> </td>     </tr>       </table>";
	document.getElementById("err_row_addr").style.background = '#fce9e9';
	request.send(null);
}

function check_city()
{
	var chcity =document.form2.City.value;
	if (chcity.length > 0)
	{
	request.open('GET','val.php?city_name=' + chcity,true);	
	// alert('changed city');
	request.onreadystatechange = function()
	{
		if(request.readyState == 4)
		{
			if(request.status == 200)
			{
				var response= request.responseText;
				
				if((response.toLowerCase()) == (chcity.toLowerCase()))
				
					{ 
					document.getElementById('vcity').value= response;
					document.getElementById('err_city').innerHTML = "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">         <tr>       <td width=\"10\">&nbsp;</td>  <td width=\"16\" valign=\"middle\"><img src=\"images/ok_icon.jpg\" alt=\"ok\"></td>   <td width=\"10\">&nbsp;</td>  <td></td>     </tr>       </table>";
					document.getElementById("err_row_city").style.background = '#FFFFFF';
					}else
						{					
						document.getElementById('err_city').innerHTML = response;
						document.getElementById("err_row_city").style.background = '#fce9e9';
						}
			}
			}
		}
	
	}
	else
	// alert('city cannot be left blank');
	document.getElementById('err_city').innerHTML= "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr><td width=\"10\">&nbsp;</td>  <td width=\"16\" valign=\"middle\"><img src=\"images/error1.gif\" alt=\"Error\"></td> <td width=\"10\">&nbsp;</td>  <td><span class=\"style3\" >City name is blank</span> </td>     </tr>       </table>";
	document.getElementById("err_row_city").style.background = '#fce9e9';
	request.send(null);
}

function check_pin()
{
	// alert('changed pincode');
	var chpincode =document.form2.Pin_Code.value;
	if (chpincode.length > 0)
	{
	request.open('GET','val.php?pin_code=' + chpincode,true);	
	
	request.onreadystatechange = function()
	{
		if(request.readyState == 4)
		{
			if(request.status == 200)
			{
				var response= request.responseText;
				if(response == "")
					{ 
					document.getElementById('pincode').innerHTML = "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">         <tr>       <td width=\"10\">&nbsp;</td>  <td width=\"16\" valign=\"middle\"><img src=\"images/ok_icon.jpg\" alt=\"ok\"></td>   <td width=\"10\">&nbsp;</td>  <td></td>     </tr>       </table>";
					document.getElementById("err_row_pincode").style.background = '#FFFFFF';
					}else
						{					
						document.getElementById('pincode').innerHTML = response;
						document.getElementById("err_row_pincode").style.background = '#fce9e9';
						}
			}
			}
		}
	
	}
	else
	// alert('pin code cannot be left blank');
	document.getElementById('pincode').innerHTML= "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr><td width=\"10\">&nbsp;</td>  <td width=\"16\" valign=\"middle\"><img src=\"images/error1.gif\" alt=\"Error\"></td> <td width=\"10\">&nbsp;</td>  <td><span class=\"style3\" >Pin code is blank</span> </td>     </tr>       </table>";
	document.getElementById("err_row_pincode").style.background = '#fce9e9';
	document.getElementById("err_row_pincode").style.background = '#fce9e9';
	request.send(null);
}


function check_country()
{
	var chcountry =document.form2.Country.value;
	if (chcountry.length > 0)
	{
	request.open('GET','val.php?country=' + chcountry,true);	
	// alert('changed country');
	request.onreadystatechange = function()
	{
		if(request.readyState == 4)
		{
			if(request.status == 200)
			{
				var response= request.responseText;
				if((response.toLowerCase()) == (chcountry.toLowerCase()))
				
					{ 
					document.getElementById('vcountry').value= response;
					document.getElementById('err_country').innerHTML = "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">         <tr>       <td width=\"10\">&nbsp;</td>  <td width=\"16\" valign=\"middle\"><img src=\"images/ok_icon.jpg\" alt=\"ok\"></td>   <td width=\"10\">&nbsp;</td>  <td></td>     </tr>       </table>";
					document.getElementById("err_row_country").style.background = '#FFFFFF';
					}else
						{					
						document.getElementById('err_country').innerHTML = response;
						document.getElementById("err_row_country").style.background = '#fce9e9';
						}
			}
			}
		}
	
	}
	else
	// alert('country cannot be left blank');
	document.getElementById('err_country').innerHTML= "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr><td width=\"10\">&nbsp;</td>  <td width=\"16\" valign=\"middle\"><img src=\"images/error1.gif\" alt=\"Error\"></td> <td width=\"10\">&nbsp;</td>  <td><span class=\"style3\" >Country name is blank</span> </td>     </tr>       </table>";
	document.getElementById("err_row_country").style.background = '#fce9e9';
	request.send(null);
}



function check_tel()
{

	var tel_country = document.form2.Tel_Country_Code.value;
	var tel_area = document.form2.Tel_Area_Code.value;
	var tel_number = document.form2.Tel_Number.value;
	
	if((tel_country.length > 0) && (tel_area.length > 0) &&	 (tel_number.length > 0))
	{
	request.open('GET','val.php?' + 'tel_countrycode=' + tel_country + '&tel_areacode=' + tel_area + '&tel_number=' + tel_number,true);	
	//alert('changed telephone');
	request.onreadystatechange = function()
	{
		if(request.readyState == 4)
		{
			if(request.status == 200)
			{
				var response= request.responseText;
				if(response == "")
				{
				document.getElementById("tel").innerHTML = "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">         <tr>       <td width=\"10\">&nbsp;</td>  <td width=\"16\" valign=\"middle\"><img src=\"images/ok_icon.jpg\" alt=\"ok\"></td>   <td width=\"10\">&nbsp;</td>  <td></td>     </tr>       </table>";				
			document.getElementById("err_row_tel").style.background = '#FFFFFF';
				}
				else
				{
					
					document.getElementById('tel').innerHTML = response;
					document.getElementById("err_row_tel").style.background = '#fce9e9';
				}
				
				
				}
		}
	}
	}
	else
	// alert('tel no cannot be left blank');
	document.getElementById('tel').innerHTML= "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr><td width=\"10\">&nbsp;</td>  <td width=\"16\" valign=\"middle\"><img src=\"images/error1.gif\" alt=\"Error\"></td> <td width=\"10\">&nbsp;</td>  <td><span class=\"style3\" >Please enter the complete phone no.</span> </td>     </tr>       </table>";
	document.getElementById("err_row_tel").style.background = '#fce9e9';
	request.send(null);
}




/*
function checkorg()
{
	alert('accesed org');		 
	var chorg=document.form2.Organization.value;
	var request = createRequestObject();
	request.open('GET','val.php?org=' + chorg,true);	
	request.onreadystatechange = function()
	{
		if(request.readyState == 4)
		{
			if(request.status == 200)
			{
				var response1 = request.responseText;
				document.getElementById('org').innerHTML = response1;
			}
		}
	}
	request.send(null);
}

function check_field()
{
	alert('form submitted');		 
	var chk_name=document.form2.Name.value;
	if(chk_name.length<0)
	{
		alert('please enter the name');
	}
}
		
	
	/*var chk_streetaddr=document.form2.Street_Address.value;
	var chk_city=document.form2.City.value;
	var chk_pin=document.form2.Pin_Code.value;
	var chk_country=document.form2.Country.value; */
	
	
	
	
	
	
	
	
	
	
	
	/*var request = createRequestObject();
	request.open('GET','val.php?org=' + chorg,true);	
	request.onreadystatechange = function()
	{
		if(request.readyState == 4)
		{
			if(request.status == 200)
			{
				var response1 = request.responseText;
				document.getElementById('org').innerHTML = response1;
			}
		}
	}
	request.send(null);
}
*/


// var state = document.form1.state.value;
		//alert('you entered name');
	//var chname=document.abcd.name.value;
	
	//var request = createRequestObject();
	/*request.open('GET', 'cityn.php?', true);
	request.onreadystatechange = function()
	{
		if(request.readyState == 4)
		{
			if(request.status == 200)
			{
				var response = request.responseText;
				document.getElementById('msg').innerHTML = response;
			}
		}
	}
	request.send(null);
}
*/

