var siteurl="http://www.sikhzone.net/";

function runGETajax(objID, serverPage)
{
	var xmlhttp=false;
	try{ xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");}
	catch(e){try{xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");}catch(ex){xmlhttp=false;}}
	if(!xmlhttp & typeof XMLHttpRequest!='undefined'){xmlhttp=new XMLHttpRequest();}
	var obj=document.getElementById(objID);xmlhttp.open("GET", serverPage);
	xmlhttp.onreadystatechange=function(){
		if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
			obj.innerHTML = xmlhttp.responseText;}}
	xmlhttp.send(null);
}

function runPOSTajax(objID, serverPage, params)
{
	var xmlhttp=false;
	try{xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");}
	catch(e){try{xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");}catch(ex){xmlhttp=false;}}
	if(!xmlhttp & typeof XMLHttpRequest!='undefined'){xmlhttp=new XMLHttpRequest();}
	var obj=document.getElementById(objID);xmlhttp.open("POST", serverPage, true);
	//Send the proper header information along with the request
	xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlhttp.setRequestHeader("Content-length", params.length);xmlhttp.setRequestHeader("Connection", "close");
	xmlhttp.onreadystatechange = function() {//Call a function when the state changes.
		if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
			obj.innerHTML = xmlhttp.responseText;}}
	xmlhttp.send(params);
}

function makestars()
{
	objID=document.getElementById("rating");
	
	rating=parseInt(objID.innerHTML, 10);
		
	objID.innerHTML="";
	
	for(i=0;i<5;i++)
	{
		if(rating>0)
		{
			objID.innerHTML+="<img src=\""+siteurl+"images/static/onstar.gif\" />";
			rating--;
			continue;
		}
		objID.innerHTML+="<img src=\""+siteurl+"images/static/offstar.gif\" />";
	}
}

function showstars(rating)
{
	for(i=1;i<=5;i++)
	{
		tagid="rstar"+i;
		
		document.getElementById(tagid).src=siteurl+"images/static/offstar.gif";
	}
	for(i=1;i<=rating;i++)
	{
		tagid="rstar"+i;
		
		document.getElementById(tagid).src=siteurl+"images/static/onstar.gif";
	}
	document.getElementById('message').innerHTML=rating+" Stars";
}

function resetstars()
{
	for(i=1;i<=5;i++)
	{
		tagid="rstar"+i;
		
		document.getElementById(tagid).src=siteurl+"images/static/offstar.gif";
	}
	document.getElementById('message').innerHTML="";
}

function ratephoto(rating, pID)
{
	var url=siteurl+"ratePhoto.php?pID="+pID+"&rating="+rating;
	runGETajax("ratingstars", url);
	document.getElementById('message').innerHTML="";
}