//-------------------------For Survey and poll------------------------------------

function callAHAHpoll(url, type, parameters, fname){ 
	try {
		req = new XMLHttpRequest(); /* e.g. Firefox */
	} catch(e) {
		try {
			req = new ActiveXObject("Msxml2.XMLHTTP"); /* some versions IE */
		} catch (e) {
			try {
				req = new ActiveXObject("Microsoft.XMLHTTP"); /* some versions IE */ }
			catch (E) {
				req = false;
			}
		}
	}
	req.onreadystatechange = function() {
		//alert(fname);
		responseAHAHpoll(fname);
	};
	req.open(type,url,true);
    req.setRequestHeader("Content-length", parameters.length);
	req.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
	req.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
	if(parameters == '') parameters = null;
	req.send(parameters);
}
function responseAHAHpoll(fname) { 
	if(req.readyState == 1 ) { //loading
		if(document.getElementById('busyimg') != null){ 
			document.getElementById('busyimg').style.display = "block"; //alert("block");
		}
	}
	else if(req.readyState == 4) {
		if(document.getElementById('busyimg') != null)
				document.getElementById('busyimg').style.display = "none"; //alert("stage4");
		if(req.status == 200) {
			 fname(req);		
			//alert(output);
		} else {
			//alert("Report this error to noreply@buzz18.com");
		}
	}
}
//-------------------------------------------------------------------------------










function writit(text,id){
for(i=1;i<=5;i++){
	tagid="rImage"+i;
	if(i % 2 == 1){
		document.getElementById(tagid).src="images/V_rate_off.gif";
	}
	else{
		document.getElementById(tagid).src="images/V_rate_off.gif";
	}
}
cnt=text;
for(i=1;i<=cnt;i++){
	tagid="rImage"+i;
	modi = i%2;
	if(modi == 0){
		document.getElementById(tagid).src="images/V_rate_on.gif";
	}
	else{
		document.getElementById(tagid).src="images/V_rate_on.gif";
	}
}
	disptext = text + " Star";
	if (document.getElementById)
	{
		x = document.getElementById(id);
		x.innerHTML = '';
		x.innerHTML = disptext;
	}
	else if (document.all)
	{
		x = document.all[id];
		x.innerHTML = disptext;
	}
	else if (document.layers)
	{
		x = document.layers[id];
		text2 = '<P CLASS="ntdBL">' + disptext + '</P>';
		x.document.open();
		x.document.write(text2);
		x.document.close();
	}
}

function clearrating(){
	for(i=1;i<=5;i++){
		tagid="rImage"+i;
		if(i % 2 == 1){
			document.getElementById(tagid).src="images/V_rate_off.gif";
		}
		else{
			document.getElementById(tagid).src="images/V_rate_off.gif";
		}
	}
	disptext = "";
	id="test"
	if (document.getElementById)
	{
		x = document.getElementById(id);
		x.innerHTML = '';
		x.innerHTML = disptext;
	}
	else if (document.all)
	{
		x = document.all[id];
		x.innerHTML = disptext;
	}
	else if (document.layers)
	{
		
		x = document.layers[id];
		text2 = '<P CLASS="ntdBL">' + disptext + '</P>';
		x.document.open();
		x.document.write(text2);
		x.document.close();
	}
}

function drawrating(x,y){
	prnt = "<ul>";
	for(i=1;i<=x;i++){
		prnt += "<li style=\"margin-left:5px;\"><img src=\"/images/V_rate_on.jpg\" width=28 height=24 hspace=0 vspace=0 border=0></li>";
	}
	if(y > 0){
		prnt += "<li style=\"margin-left:5px;\"><img src=\"/images/video_halfstar.jpg\" width=28 height=24 hspace=0 vspace=0 border=0></li>";
	}
	else{
		y = 0;
	}
	prnt +=	"<li style=\"margin-left:25px;margin-top:5px;\" class=ntdBL>" + x + "." + y +" Stars</li>";
	document.getElementById("DynUsrRating").innerHTML = prnt;
	prnt += "</ul>";
}

function test(a,b,c,d,e,f)
{

xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
var url="insertcomment.php";
url=url+"?co="+a;
url=url+"&na="+b;
url=url+"&em="+c;
url=url+"&cn="+d;
url=url+"&id="+e;
url=url+"&flag="+f;
url=url+"&sid="+Math.random();
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("POST",url,true);
xmlHttp.send(null);
}
function stateChanged(){ 
 
	if (xmlHttp.readyState==4){
	 
	document.getElementById("commentdiv").innerHTML=xmlHttp.responseText;
	document.registration.reset();
		}
}

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;
}	



