function ajaxFunction(url,value,divid)
{
	var xmlHttp;
	try
	  {
		  // Firefox, Opera 8.0+, Safari
		  xmlHttp=new XMLHttpRequest();
	  }
	catch (e)
	  {
	  // Internet Explorer
	  try
		{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
	  catch (e)
		{
		try
		  {
		  	xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		  }
		catch (e)
		  {
		  alert("Your browser does not support AJAX!");
		  return false;
		  }
		}
	  }
	  xmlHttp.onreadystatechange=function()
		{
		if(xmlHttp.readyState==4)
		  {
		  document.getElementById(divid).innerHTML=xmlHttp.responseText;
		 
		  //alert(xmlHttp.responseText);
		  }
		}
	  xmlHttp.open("GET",url+"&avail="+value+"&targetid="+divid,Math.random());
	  xmlHttp.send(null);
} // and ajax function



function isEmailAddr(email)
{
	//email = value of email field;  	
	/*if(email == "")
	{
		alert("Please Enter Email Address");
		result = false;
	}
	else 
	{	*/
			var theStr = new String(email);
			var index = theStr.indexOf("@");
			if (index > 0)
				{
					var pindex = theStr.indexOf(".",index);
					if ((pindex > index+1) && (theStr.length > pindex+1))
						{
								result = true;
						}
					else
						{
								result = false;
							
						}	
				}
			else
				{
								result = false;
				}
  //	}

  return result;
}



function validate_cust(theForm) {

	phone1 	= document.all.phone1.value;
	phone2	= document.all.phone2.value;
	phone3	= document.all.phone3.value;

	fax1 	= document.all.fax1.value;
	fax2	= document.all.fax2.value;
	fax3	= document.all.fax3.value;


	if(!validRequired(theForm.f_name, "First Name"))
		return false;
	if(!validRequired(theForm.l_name, "Last Name"))
		return false;
	if(!validEmail(theForm.email, "Email"))
		return false;
	if(!validRequired(theForm.payment_address, "Billing Address"))
		return false;
	if(!validRequired(theForm.payment_city, "Billing City"))
		return false;
	if(!validRequired(theForm.payment_state, "Billing State"))
		return false;

/********Login validations ***********/

	if(!chkchar(theForm.user_name.value,"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789"))
		{
			alert("Please enter a valid Login name\nValid characters are ( a-z , A-Z , 0-9 , _ )");
			theForm.user_name.focus()
			return false;
		}
	
	if(!chkchar(theForm.password.value,"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789"))
		{
			alert("Please enter a valid Password\nValid characters are ( a-z , A-Z , 0-9 , _ )");
			theForm.password.focus();
			return false;
		}
	
	if(theForm.password.value != theForm.con_pass.value){
		alert("Password and Confirm Passwords are not matching!");
		return false;
	}


	document.all.home_phone.value = phone1 + phone2 + phone3;
	document.all.fax.value = fax1 + fax2 + fax3;

return true;
}


function validate_editcust(theForm) {

	phone1 	= document.all.phone1.value;
	phone2	= document.all.phone2.value;
	phone3	= document.all.phone3.value;

	fax1 	= document.all.fax1.value;
	fax2	= document.all.fax2.value;
	fax3	= document.all.fax3.value;


	if(!validRequired(theForm.f_name, "First Name"))
		return false;
	if(!validRequired(theForm.l_name, "Last Name"))
		return false;
	if(!validRequired(theForm.billing_address, "Billing Address"))
		return false;
	if(!validRequired(theForm.billing_city, "Billing City"))
		return false;
	if(!validRequired(theForm.billing_state, "Billing State"))
		return false;


	document.all.home_phone.value = phone1 + phone2 + phone3;
	document.all.fax.value = fax1 + fax2 + fax3;


return true;
}

function validate_editadmin(theForm) {

	phone1 	= document.all.phone1.value;
	phone2	= document.all.phone2.value;
	phone3	= document.all.phone3.value;

	fax1 	= document.all.fax1.value;
	fax2	= document.all.fax2.value;
	fax3	= document.all.fax3.value;


	if(!chkchar(theForm.password.value,"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789"))
		{
			alert("Please enter a valid Password\nValid characters are ( a-z , A-Z , 0-9 , _ )");
			theForm.password.focus();
			return false;
		}
	if(theForm.password.value != theForm.con_pas.value){
		alert("Password and Confirm Passwords are not matching!");
		return false;
	}
	if(!validRequired(theForm.f_name, "First Name"))
		return false;
	if(!validRequired(theForm.l_name, "Last Name"))
		return false;
	if(!validRequired(theForm.payment_address, "Billing Address"))
		return false;
	if(!validRequired(theForm.payment_state, "Billing City"))
		return false;
	if(!validRequired(theForm.payment_zip_code, "Billing State"))
		return false;


	document.all.contact_phone.value = phone1 + phone2 + phone3;
	document.all.fax.value = fax1 + fax2 + fax3;


return true;
}




