
//Gets the browser specific XmlHttpRequest Object
// *** ajax DOM test *** //
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 submitForm()
{ 
	document.getElementById("submit_comments").innerHTML="";
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null){
	 alert ("Browser does not support HTTP Request")
	 return false;
	}
	
	var comment = document.commentForm.comment.value;
	var comment_name = document.commentForm.comment_name.value;
	var comment_email = document.commentForm.comment_email.value;
	var dvd_chat_id = document.commentForm.dvd_chat_id.value;
	
	var url ="/our-animals/daily-video-diaries/submit_comment.inc.php";
	var data = "comment="+comment+"&comment_name="+comment_name+"&comment_email="+comment_email+"&dvd_chat_id="+dvd_chat_id;
	data = data + "&ajaxid="+Math.random()
	xmlHttp.onreadystatechange=stateChangedsubmit
	
	xmlHttp.open('POST', url, true);
	xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	xmlHttp.send(data);
	return false;
}

function stateChangedsubmit() 
{ 
	
	
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		document.getElementById("submit_comments").innerHTML=xmlHttp.responseText 
	} else {
		document.getElementById("submit_comments").innerHTML="<div style='border:1px dashed red;color:red;padding:8px;margin:5px 0;float:left;width:420px'>Sending request ...</div>";

	}
}

function getXmlHttpRequestObject() {
	if (window.XMLHttpRequest) {
		return new XMLHttpRequest();
	} else if(window.ActiveXObject) {
		return new ActiveXObject("Microsoft.XMLHTTP");
	} else {
		alert("Your browser doesn't support ajax");
	}
}

function listAnimals(selected)
{
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null){
	 alert ("Browser does not support HTTP Request")
	 return
	}
	var strIndex = document.form1.subspecies.selectedIndex;
	var str = document.form1.subspecies[strIndex].value;
	var url="/our-animals/daily-video-diaries/ajax.php";
	url=url+"?subspecies="+str;
	if(selected != ""){
		url=url+"&selected="+selected
	}	
	url=url+"&sid="+Math.random()

	xmlHttp.onreadystatechange=stateChangedanimals 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function stateChangedanimals() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		document.getElementById("animals").innerHTML=xmlHttp.responseText 
	} 
}