var frm_aj=null;
function create_ajax()
{
	var ajobj_opac=null;
	if (window.XMLHttpRequest) // Mozilla, Safari,...
	{ajobj_opac = new XMLHttpRequest();} 
	
	else if (window.ActiveXObject) // IE
	{ 
            try {ajobj_opac = new ActiveXObject("Msxml2.XMLHTTP");} catch (e) 
			{
                try {ajobj_opac = new ActiveXObject("Microsoft.XMLHTTP");} catch (e) {}
            }
     }
	else 
	{
		if (ajobj_opac==null)
		{alert("Your browser doesn't support AJAX.");}
		return false;
	}
	return  ajobj_opac;
}

function aj_postreq(url,parameters,functionname,post_user_obj)
{
	if(functionname!=null && functionname!="")
	{post_user_obj.onreadystatechange = eval(functionname);}
	post_user_obj.open('POST', url, true);
	post_user_obj.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	post_user_obj.setRequestHeader("Content-length", parameters.length);
	post_user_obj.setRequestHeader("Connection", "close");
	post_user_obj.send(parameters);
}

function postform()
{
	if(document.phcommentform.uname.value=="")
	{alert("Please enter your name");document.phcommentform.uname.focus();return false;}

	if(document.phcommentform.email.value=="")
	{alert("Please enter your email");document.phcommentform.email.focus();return false;}

	if(document.phcommentform.phcomment.value=="")
	{alert("Please enter your name");document.phcommentform.phcomment.focus();return false;}

	return true;
}


function callpost()
{
	if(postform()==true)
	{
		frm_aj=create_ajax();
		var parameters="uname="+document.phcommentform.uname.value+"&email="+document.phcommentform.email.value+"&phcomment="+document.phcommentform.phcomment.value+"&phname="+document.phcommentform.phname.value;
		aj_postreq('/phcomment.php',parameters,'print_cont',frm_aj)
	}
}

function print_cont()
{
	if (frm_aj.readyState == 4) 
	{	
	if (frm_aj.status == 200) 
	{
		if(frm_aj.responseText=="success")
	   {
			document.getElementById('thank').innerHTML="<font class='textsmall'>Thanking you for posting your comments. Your comments will be displayed soon.</font>";
			document.phcommentform.uname.value="";
			document.phcommentform.email.value="";
			document.phcommentform.phcomment.value="";
		}
	}
	}
}
