// JavaScript Document
var xmlHttp;
function fnGetSubCat(cat)
{
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	{
	 alert ("Browser does not support HTTP Request");
	 return
	}
	var url="http://petsfact.com/callAjax.php?vet="+cat;
		xmlHttp.onreadystatechange=stateChangedvet;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
	//alert(url);
}
function stateChangedvet() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
 	//alert(xmlHttp.responseText);
	document.getElementById("showSubCat").innerHTML=xmlHttp.responseText;
	
 } 
}function fnGetSubsitter(cat)
{
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	{
	 alert ("Browser does not support HTTP Request");
	 return
	}
	var url="callAjax.php?sitter="+cat;
	xmlHttp.onreadystatechange=stateChangedsit ;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}
function stateChangedsit() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
 	//alert(xmlHttp.responseText);
	document.getElementById("showSubsitter").innerHTML=xmlHttp.responseText;
	
 } 
}
function fnGetSubgroomer(cat)
{
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	{
	 alert ("Browser does not support HTTP Request");
	 return
	}
	var url="callAjax.php?groomer="+cat;
	xmlHttp.onreadystatechange=stateChangedgroom ;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}
function stateChangedgroom() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
 	//alert(xmlHttp.responseText);
	document.getElementById("showSubgroomer").innerHTML=xmlHttp.responseText;
	
 } 
}
function fnGetSubCat1(cat)
{
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	{
	 	alert ("Browser does not support HTTP Request");
	 return
	}
	var url="callAjax.php?cat12="+cat;
	xmlHttp.onreadystatechange=stateChanged ;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}
function GetXmlHttpObject()
{
var xmlHttp=null;
try
 {
 // Firefox, Opera 8.0+, Safari
 xmlHttp=new XMLHttpRequest();
 }
catch (e)
 {
 //Internet Explorer
 try
  {
  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  }
 catch (e)
  {
  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
 }
return xmlHttp;
}

function fnGetProducts(subCat)
{
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	{
	 	alert ("Browser does not support HTTP Request");
	 return
	}
	var selected = document.getElementById("frmSpecs").ddCat.options[document.getElementById("frmSpecs").ddCat.options.selectedIndex].value;
	var url="callAjax.php?subCat="+subCat+"&category="+selected;
	xmlHttp.onreadystatechange=stateChanged1 ;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}
function stateChanged1() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
 	//alert(xmlHttp.responseText);
	document.getElementById("showPro").innerHTML=xmlHttp.responseText;
	
 } 
}
function fnShowSpecs(pro)
{
		if(pro==0)
		{
		alert("Please Selec Product");
		document.getElementById("showSpecs").style.visibility = "hidden";
		return false;
		}
		else 
		{
			document.getElementById("showSpecs").style.visibility = "visible";
			var selected = document.getElementById("frmSpecs").ddCat.options[document.getElementById("frmSpecs").ddCat.options.selectedIndex].value;
			var selected1 = document.getElementById("frmSpecs").ddSubCat.options[document.getElementById("frmSpecs").ddSubCat.options.selectedIndex].value;
			var url="callAjax.php?product="+pro+"&subCategory="+selected1+"&category="+selected;
			xmlHttp.onreadystatechange=stateChanged2;
			xmlHttp.open("GET",url,true);
			xmlHttp.send(null);
		}
}
function checklogin()
{
	
	var objRegExp = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	var name=document.mail.name;
	var email=document.getElementById("email");
	var password=document.getElementById("password1");
	var password2=document.getElementById("password2");
	
	var vOwner=document.getElementById("vOwner");
	var newOwner=document.getElementById("newOwner");
	
	var vetName = document.getElementById("txtName");
	var Street = document.getElementById("txtStreet");
	var City = document.getElementById("txtCity");
	var County = document.getElementById("txtCounty");
	var phone = document.getElementById("txtPhone");
	var zip = document.getElementById("txtZip");
	var Desc = document.getElementById("txtDesc");
	var Video = document.getElementById("txtVideo");
	var stateselect = document.getElementById("stateselect");
	var ddSubCat = document.getElementById("ddSubCat");
	
	var txtName = document.getElementById("txtName");
	var txtStreet = document.getElementById("txtStreet");
	var txtCity = document.getElementById("txtCity");
	var txtselect = document.getElementById("txtselect");
	var txtZip = document.getElementById("txtZip");
	var txtPhone = document.getElementById("txtPhone");
	
	if (name.value == "")
	{
		name.style.background = '#FFFF9B';
		alert ("please Type You'r NAME");
		name.focus();
		return false;
	}
			else
			{
				name.style.background = '#FFFFFF';
			}
			
	
	if (!objRegExp.test(email.value))
	{
		email.style.background = '#FFFF9B';
		alert ("please Type You'r E_MAIL");
		email.focus();
		return false;	
	}
			else
			{
				email.style.background = '#ffffff';
			}
	if(password1.value =="")
	{
		password1.style.background = '#FFFF9B';
		alert ("Plz provied Password ");
		password1.focus();
		return false;
	}
			else
			{
				password.style.background = '#ffffff';
			}
	if(password1.value.length<6)
	{
		alert ("Password Should be alteast 6 letters ");
		password1.focus();
		return false;
	}		
	if(password2.value!=password1.value)
	{
		password2.style.background = '#FFFF9B';
		alert ("Password Mismatch");
		password2.focus();
		return false;
	}
			else
			{
				password2.style.background = '#ffffff';
			}
	if(mail.selected.value=="")
	{
		alert("please select the type");
		return false;
	}		
	if(document.getElementById("newOwner").checked==true && document.getElementById("vOwner").checked==true)
	{
		alert ("Select only one option");
		return false;
	}
	if(!document.getElementById("newOwner").checked==true && !document.getElementById("vOwner").checked==true)
	{
		alert ("Select atleast one option");
		document.getElementById("newOwner").focus();
		return false;
	}
	
	if(document.getElementById("vOwner").checked==true)
	{
		if (stateselect.value==0)
		{
		 alert ("Select Your State");
		 stateselect.focus();
			return false;
		}
		else if (ddSubCat.value==0)
		{
		 alert ("Select Your Veterinarian");
		 ddSubCat.focus();
			return false;
		}
	}
	
	if(document.getElementById("newOwner").checked==true)
	{
		if (txtName.value=="")
		{
		 alert ("Type Your Clinic Name");
		 txtName.focus();
			return false;
		}
		else if (txtStreet.value=="")
		{
		 alert ("Type Street Address");
		 txtStreet.focus();
			return false;
		}
		else if (txtCity.value=="")
		{
		 alert ("City Name ?");
		 txtCity.focus();
			return false;
		}
		else if (txtselect.value==0)
		{
		 alert ("Select State");
		 txtselect.focus();
			return false;
		}
		else if (txtZip.value=="")
		{
		 alert ("Zip code ?");
		 txtZip.focus();
			return false;
		}
		else if (txtPhone.value=="")
		{
		 alert ("Phone Number ?");
		 txtPhone.focus();
			return false;
		}
		
	}
}
function fnSetDir(selected)
{ 
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	{
	 	alert ("Browser does not support HTTP Request");
		
	 return
	}
	 var url="http://petsfact.com/CallDir.php?selected="+selected;

	xmlHttp.onreadystatechange=stateChangeddir ;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
	
}
function stateChangeddir() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
 	//alert(xmlHttp.responseText);
	document.getElementById("showDir").innerHTML=xmlHttp.responseText;
	
 } 
}
