function showStarHighLight(sid,id)
  {
		for(var i=0;i<5;i++)
		{
			//if(sid!=0)
			//{
				if(sid==i)
				{
					for(var j=0;j<sid+1;j++)
					{
						
						var starsrc = document.getElementById("star"+j+id);
						starsrc.src = "images/newredstar.png";
					}
				}
			//}	
		}
  } // end of function showStarHighLight
  
function hideStarHightLight(sid,id)
{
		for(var i=0;i<=sid;i++)
		{
			var starsrc = document.getElementById("star"+i+id);
			
			starsrc.src="images/newgreystar.png";
		}
} // end of function hideStarHightLight
	
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;
} //end of GetXmlHttpObject
	
	
function stateChanged() 
{ 
		
		if (xmlHttp.readyState==4)
		{ 
			
			
			 var result	= xmlHttp.responseText;
			 //alert(result);
			 resultArr		= result.split("(!)");
			 var arr1 		= resultArr[0];
			 var arr2 		= resultArr[1];
			 var arr3 		= resultArr[2];
			 var arr4		= trim(resultArr[4]);
			 var divId		= parseInt(resultArr[3]); 
			 var ratingType	= trim(resultArr[5]);
                        // document.getElementById("rateBar"+divId).style.display = "none";
			 var myRate		= document.getElementById("rateStatus"+divId);
			 var ratingDiv	= document.getElementById("rateStar"+divId);
			 var myRateVal	= document.getElementById("ratingVal"+divId);
			 var myRateBar	= document.getElementById("ratebar"+divId);
			 
			// ratingDiv.style.display 	= "none";
			 document.getElementById("rateStatus"+divId).display		= "";
			 myRate.innerHTML			= arr3;
                         //THIS CODE IS COMMENTED FOR NEW DESIGN STYLE
                         //this code didplays total no of votes for that ratting
			 //myRateVal.innerHTML		= arr1;
			 myRateBar.innerHTML		= arr2;
					
			if(ratingType == "User")
			{
				// if(arr4 == "insert")
					 alert("Now you can click was book received.");
					 
				 document.getElementById("btnsubmit"+divId).disabled = false;
			}//if(ratingType == "User")
		}
} // end of stateChanged

function rate(contentId,rateval,conType,ratedto,divId)
{
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	{
		alert ("Your browser does not support AJAX!");
		return;
	}
	
	var url="rating.php";
	url=url+"?contentId="+contentId;
	url=url+"&ratevalue="+rateval;
	url=url+"&contentType="+conType;
	url=url+"&ratedTo="+ratedto;
	url=url+"&divId="+divId;	
	//alert(url+"rating url");
	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
					
} // end of function ratePhoto

function rateBook(contentId,rateval,conType,ratedto,divId)
{
	//alert(contentId+"=="+rateval+"=="+conType+"=="+ratedto+"=="+divId);
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	{
		alert ("Your browser does not support AJAX!");
		return;
	}
	
	var url="http://www.bookchums.com/ratingbook.php";
	//url added for localhost
	//var url="http://localhost/bookchums/ratingbook.php";
	//url added for test site by sayali on 7:00 PM 3/11/2011
	//var url="http://www.engagebooks.com/ratingbook.php";
	url=url+"?contentId="+contentId;
	url=url+"&ratevalue="+rateval;
	url=url+"&contentType="+conType;
	url=url+"&ratedTo="+ratedto;
	url=url+"&divId="+divId;	
	//alert(url+"rating url");
	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
					
} // end of function ratePhoto

function trim(stringToTrim) {
    //alert(stringToTrim);
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}
	
