// JScript File
	
	function getimagebaseid(obj)
	{
		return obj.id.substring(0,obj.id.length-1);
		//return obj.id;
	}
	
	function setrating(obj,setOn){
		
		var imgobj=document.getElementById(obj.id);
		var imgidbase =getimagebaseid(imgobj);
       
        //alert(imgidbase);
		var index=imgobj.getAttribute("i");
		var src=imgobj.getAttribute("src");
		
		var i;
		
		var current, replacewith
		if(setOn==true)
		{
			current='off.gif';
			replacewith='on.gif';
		}
		else
		{
			current='on.gif';
			replacewith='off.gif';
		}
		for(i=0;i<=index;i++)
		{
			setimage(imgidbase+i,src.replace(current,replacewith));			
		} 
		return;
	}
	
	function getrating(){
	
	return;
	}
	
	function  addrating(obj, addratingUrl, rpubliciddiv, ruseriddiv, displayimageid, imagedirectoryurl )
	{
		
		obj=document.getElementById(obj.id); 	 
		var index =parseInt(obj.getAttribute("i"))+1;
		
		var url=addratingUrl + index;		
		makeHttpRequest(url,'alert')
		togglerating(index, rpubliciddiv, ruseriddiv, displayimageid, imagedirectoryurl   );
	}

	function togglerating(rating, rpubliciddiv, ruseriddiv, displayimageid, imagedirectoryurl)
	{
		var img=imagedirectoryurl+rating+'.gif';
		
		//hide div where user can add ratings
		document.getElementById(rpubliciddiv).style.display= "none";

		//display div that contains the read only rating control
		document.getElementById(ruseriddiv).style.display= "block";
		//set the new rating image to the read only rating control
		document.getElementById(displayimageid).setAttribute("src",img);
	}



//Make the actual connection.

function makeHttpRequest(strURL) {

	var xmlHttpReq = false;
    var self = this;
    // Mozilla/Safari
    if (window.XMLHttpRequest) {
        self.xmlHttpReq = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    self.xmlHttpReq.open('POST', strURL, true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function() {
        if (self.xmlHttpReq.readyState == 4) { //ready state 4 means its complete.
            updatepage(self.xmlHttpReq.responseText);
        }
    }
    self.xmlHttpReq.send(strURL);
}
function updatepage(str)
{
	//alert(str);
}
function setimage(id,imgsrc)
{
	var image =document.getElementById(id);
	if (image!=null)
		image.setAttribute("src",imgsrc);
}

 


 