﻿//Insert the Data in tblrate Table


        var canvote='';
	function PopWindowNoScroll(URL,height,width)
	{
		hWindow = window.open(URL,height+width,"width="+width+",height="+height+",resize=no,resizable=no,scrollbars=no,menubar=no,status=no");
		hWindow.focus();
	}


	function rateposition(show_imgno)
	{
	canvote=document.getElementById('canvote').value;
	  if (canvote=='Yes')
	  {
          	  for (ui=1;ui<=5;ui++)
          	  {
          	   mobj=document.getElementById("rate_img" + ui);
          	   if (ui<=show_imgno) mobj.src="images/ratelightorange.gif"
          	   else mobj.src="images/ratewhite.gif"
          	  }
	  }
	}

	function RateStatus(NewRatings,Rems)
	{
	 Myint=parseInt(NewRatings);
	 //alert(Rems);
	 for (ui=1;ui<=5;ui++)
	 {
	  mobj=document.getElementById("rate_img" + ui);
	   if (ui<=NewRatings) mobj.src="images/rateorange.gif"
	   else mobj.src="images/ratewhite.gif"
	  }
	 //document.getElementById("RateCaption").innerHTML="<font size=1 face=verdana color=navy>"+Rems+"</font>"
        //  canvote="No";
	}


	function rateoff(show_imgno)
	{
	canvote=document.getElementById('canvote').value;
                if (canvote=='Yes')
                {
        	  for (ui=1;ui<=5;ui++)
        	  {
        	   mobj=document.getElementById("rate_img" + ui);
        	   if (ui<=show_imgno) mobj.src="images/ratelightorange.gif"
        	   else mobj.src="images/ratewhite.gif"
        	  }
                }
	}
	



function rateclicked(show_imgno){

canvote=document.getElementById('canvote').value;
if (canvote=='Yes')
{
	var ajaxRequest;  // The variable that makes Ajax possible!
	
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
	// Create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function()
	{
		if(ajaxRequest.readyState == 4)
		{
		  
	 
			alert("Rating successful");
			/*var lblrate=document.getElementById('lblrating');
			if(lblrate.innerHTML=="0")
			    lblrate.innerHTML=parseFloat(show_imgno);
			 else
			    lblrate.innerHTML=(parseFloat(lblrate.innerHTML)+parseFloat(show_imgno))/2;*/
			document.getElementById('canvote').value='No';
			for (ui=1;ui<=5;ui++)
	             {
	            
	              mobj=document.getElementById("rate_img" + ui);
	               if (ui<=show_imgno) mobj.src="images/ratelightorange.gif"
	               else mobj.src="images/ratewhite.gif"
	              }
			
			
		 }
	}
	     var Id = document.getElementById('ipadd').value;
	     var txtNewsId = document.getElementById('albumId').value;
	     
   
	var queryString = "?add=" + Id;
	queryString=queryString+"&albumId=" + txtNewsId;
	queryString=queryString+"&Rate=" + show_imgno;
	document.getElementById('rate').value=show_imgno;
	
	ajaxRequest.open("GET", "ajaxfile.aspx" + queryString, true);
	ajaxRequest.send(null); 
	 canvote='No';
	
	}
	else 
	alert("You have already rated this album!!!");
}



