// JavaScript Document

var xmlHttp

function updateMatchingBreeds(species, question, answer, timestamp)
{ 
	xmlHttp=GetXmlHttpObject()
	
	if (xmlHttp==null)
	{
		 document.getElementById("breedCount").innerHTML="Your Browser does not support this feature"
		 return
	}
	
	var url="http://www.findmeapet.com.au/common/breed_selector_ajax.php"
	
	url=url+"?q="+question
	
	url=url+"&a="+answer
	
	url=url+"&t="+timestamp

	url=url+"&s="+species

	url=url+"&sid="+Math.random()
	
	xmlHttp.onreadystatechange=stateChanged 
	
	xmlHttp.open("GET",url,true)
	
	xmlHttp.send(null)
	
}
	
function stateChanged() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
		phpResponse = xmlHttp.responseText
		
	 	document.getElementById("breedCount").innerHTML=phpResponse
		
		// alert(phpResponse.length)
		
		if (phpResponse.length > 60)
		{
			document.STWForm.submit.disabled = true;
		}
		else
		{
			document.STWForm.submit.disabled = false;
		}
	} 
}

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;
}