// JavaScript Document////////////////
function trim(str) 
{ 
    return str.replace(/^\s+|\s+$/g,''); 
}
var req;
function getReqXMLHTTPObj()
{
	var a = null;
	try{a = new ActiveXObject("Msxml2.XMLHTTP")}
	catch(b)
	{
		try{a = new ActiveXObject("Microsoft.XMLHTTP")}
		catch(c){a=null;}
	}
	if(!a && typeof XMLHttpRequest!="undefined")
	{
		a = new XMLHttpRequest();
	} 
	return a;
}

function AjaxCall(url, onCallback) 
{
	req = getReqXMLHTTPObj();
    req.onreadystatechange = onCallback;
    var rnd = Math.floor(Math.random()*100000)
    url = url + "&rnd=" + rnd;
    req.open("GET", url, true);
    req.send(null);
}
function AjaxCallload(url, onCallback) 
{
	reqL = getReqXMLHTTPObj();
    reqL.onreadystatechange = onCallback;
    var rnd = Math.floor(Math.random()*100000)
    url = url + "&rnd=" + rnd;
    reqL.open("GET", url, true);
    reqL.send(null);
}
function AjaxCallNoCallBack(url) 
{
	req = getReqXMLHTTPObj();
    req.open("GET", url, false);
    req.send(null);
}
function AjaxPostCall(url, qs, onCallback) 
{   
	 req_post = getReqXMLHTTPObj();
    if (onCallback)
	 {
        req_post.onreadystatechange = onCallback;
	 }
    var rnd = Math.floor(Math.random()*1000000)
    qs = qs + "&rnd=" + rnd + "&method=post";
    req_post.open("POST", url, true);
	 req_post.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    req_post.setRequestHeader("Accept","text/xml");
    req_post.send(qs);
}

function AjaxPostCallComment(url, qs, onCallback) 
{   
	 req_postC = getReqXMLHTTPObj();
    if (onCallback)
	 {
        req_postC.onreadystatechange = onCallback;
	 }
    var rnd = Math.floor(Math.random()*1000000)
    qs = qs + "&rnd=" + rnd + "&method=post";
    req_postC.open("POST", url, true);
	 req_postC.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    req_postC.setRequestHeader("Accept","text/xml");
    req_postC.send(qs);
}

function AjaxCallComment(url, onCallback) 
{
	reqC = getReqXMLHTTPObj();
    reqC.onreadystatechange = onCallback;
    var rnd = Math.floor(Math.random()*100000)
    url = url + "&rnd=" + rnd;
    reqC.open("GET", url, true);
    reqC.send(null);
}


function hit_vote(id,mode,votefor,votpage)
{
  if(votpage=="videodetails")
  {
	  document.getElementById('_'+id+'showvote').innerHTML='<img src="images/loading2.gif" alt="" />';
  }
  
  qs="id="+id+"&mode="+mode+"&type="+votefor+"&votpage="+votpage;
  AjaxPostCall('vote.php', qs, vote_on_video);
}
function vote_on_video()
{
	if (req_post.readyState == 4) 
	{
		text=req_post.responseText;
		//alert(text);
		text_arr=text.split(",");
		str="document.getElementById('"+trim(text_arr[1])+"')";
		obj=eval(str);
	    obj.innerHTML=text_arr[0];
	}
}
