var is_ie = (navigator.userAgent.indexOf('MSIE') >= 0) ? 1 : 0;
var is_ie5 = (navigator.appVersion.indexOf("MSIE 5.5")!=-1) ? 1 : 0;
var is_opera = ((navigator.userAgent.indexOf("Opera 6")!=-1)||(navigator.userAgent.indexOf("Opera/6")!=-1)) ? 1 : 0;
var is_netscape = (navigator.userAgent.indexOf('Netscape') >= 0) ? 1 : 0;

function InitXMLHttp(fxhandle)
{
	var objXmlHttp = null;
	if(is_ie)
	{
		var objName = (is_ie5) ? 'Microsoft.XMLHTTP' : 'Msxml2.XMLHTTP'; 
		try{
		objXmlHttp = new ActiveXObject(objName);
		objXmlHttp.onreadystatechange = fxhandle;
		}catch(e){
		return;
		}
	}else if (is_opera)
	{
		return; 
	}else{ 
		objXmlHttp = new XMLHttpRequest();
		objXmlHttp.onload = fxhandle;
		objXmlHttp.onerror = fxhandle;

	} 
	return objXmlHttp; 
}

var mX;
var rX;
var enable=1;


function res()
{
document.getElementById("rating2").style.width = "0px";
}

function ref(e,obj,d)
{
if(!enable)return;
if(!e){e=window.event;}
if(!e.offsetX)
{
	checkS(e);
	showP(obj);
}
else
{
	rX = e.offsetX;
}
if(d)
{
	xmlHttp=InitXMLHttp(done);
	if(xmlHttp==null)return;
	xmlHttp.open('POST','subrat.php',true);
	xmlHttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	xmlHttp.send('rating='+rX);
}
else
document.getElementById("rating2").style.width = rX + "px";
}
function done()
{
	if(xmlHttp.readyState == 4 && xmlHttp.status==200)
	{
		var arr=xmlHttp.responseText.split("(&)");
		document.getElementById("rate").innerHTML = 'Average Site Rating : ';
		document.getElementById("rating1").style.width='190px';
		document.getElementById("rating2").style.width=arr[0]+'px';
		document.getElementById("ratno").innerHTML=arr[1] + " / 10";
		document.cookie
		enable=0;
	}
	
}

function checkS(e){// captures the mouse position
mX = 0;
if (!e) {var e = window.event};//IE
if (e.pageX){//Moz
mX = e.pageX; 
}
else if (e.clientX){//IE
mX = e.clientX-2;//IE correction
}
}
function showP(obj){
var oX = obj.offsetLeft;
while(obj.parentNode){// finds the absolute position of the object
oX=oX+obj.parentNode.offsetLeft;
if(obj==document.getElementsByTagName('body')[0]){break}
else{obj=obj.parentNode;}
}
rX=mX-oX;//relative X
}
function res()
{
document.getElementById("rating2").style.width = "0px";
}

function Init()
{
document.getElementById("rating_bkd").innerHTML = "<span id=\"rate\">Click below to rate this site:</span><br/><div id=\"rating0\" style=\"background: url('images/star0.gif') repeat-x;height:25px;width:190px;border:1px solid #9AA4B2;cursor:pointer;\" onmousemove=\"ref(event,this,0)\" onclick=\"ref(event,this,1)\"><div id=\"rating1\" style=\"background: url('images/star1.gif') repeat-x;height:25px;width:120px;\"><div id=\"rating2\" style=\"background: url('images/star2.gif') repeat-x;height:25px;width:0px;\">&nbsp;</div></div></div><span id=\"ratno\"></span>";
}