// JavaScript Document



function funConfirmDelete()	// This is called when Delete buton is clicked
{
	return confirm("Are you sure you want to Delete?");	
}


 


// Ajex comon function

function GetXmlHttpObject(handler) 
{ 
	var objXmlHttp=null 

	if (navigator.userAgent.indexOf("Opera")>=0) 
	{ 
	    alert("This example doesn't work in Opera") 
	    return  
	} 
	
   	if (navigator.userAgent.indexOf("MSIE")>=0) 
   	{ 
	   var strName="Msxml2.XMLHTTP" 
	   if (navigator.appVersion.indexOf("MSIE 5.5")>=0) 
       	   { 
     	 	strName="Microsoft.XMLHTTP" 
       	   } 
      	  try 
      	  { 
		  objXmlHttp=new ActiveXObject(strName) 
		  objXmlHttp.onreadystatechange=handler 
		  return objXmlHttp 
          } 
          catch(e) 
          { 
		  alert("Error. Scripting for ActiveX might be disabled") 
		  return 
      	 } 
     } 
	
    if (navigator.userAgent.indexOf("Mozilla")>=0) 
    { 
	   objXmlHttp=new XMLHttpRequest() 
	   objXmlHttp.onload=handler 
	   objXmlHttp.onerror=handler 
	   return objXmlHttp 
   } 
} 



// Function for rating
var divVal = '';
function rateBlog(str,val,bid,uid) 
{ 
   	divVal = str 
   	if (divVal > 0) 
   	{            
		document.getElementById("load"+divVal).style.display='block'
		var randomnumber=Math.floor(Math.random()*110);
		var url="http://blog.monsterindia.com/rateblog.html?bid="+str+"&randno="+randomnumber+"&val="+val+"&id="+bid+"&uid="+uid;
		//alert(url);
		xmlHttp=GetXmlHttpObject(stateChangedUpdateCategory) 
		xmlHttp.open("GET", url , true) 
		xmlHttp.send(null) 
		document.getElementById("load"+divVal).innerHTML='Loading....'   
	} 
   	else 
   	{ 
   		document.getElementById(divVal).innerHTML="" 
   	} 
}

function deleteRate(bid,uid,flag)
{
	var randomnumber=Math.floor(Math.random()*110);
	var url="http://blog.monsterindia.com/rateblog.html?flag="+flag+"&randno="+randomnumber+"&uid="+uid+"&id="+bid+"&";
//	alert(url);
	xmlHttp=GetXmlHttpObject(stateChangedUpdateCategory)
	xmlHttp.open("GET", url , true)
	xmlHttp.send(null)
//	document.getElementById("load"+divVal).innerHTML='Loading....'
} 

function stateChangedUpdateCategory() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") 
   	{ 
   	//	document.getElementById("load"+divVal).style.display='none'
		document.getElementById("load18").innerHTML=xmlHttp.responseText 
   	} 
   	else
   	{
		document.getElementById("load18").style.display='block'
		document.getElementById("load18").innerHTML='Loading....'   
	}
} 


function showimage(a,id)
{
		var name = "image_"+id+"_";
		for(var i=1; i<=a; i++)
		{
			document.getElementById(name+i).src="http://media.monsterindia.com/blog/icon_star.gif";
		}	
		for(var k=a+1; k<=5; k++)
		{
			document.getElementById(name+k).src="http://media.monsterindia.com/blog/icon_stargray.gif";
		}
}

// Here we need not of cat
	
function removeimage(a,cat,id)
{
	var name = "image_"+id+"_";
	for(var i=1; i<=a; i++)
	{
		document.getElementById(name+i).src="http://media.monsterindia.com/blog/icon_stargray.gif";
	}
	default_rate(a,cat,id)
}	



function default_rate(a,cat,id)
{

// here i need query for the particular id to extract the previous rate
	
	var name = "image_"+id+"_";
	for(var i=cat; i>=1; i--)
	{
		document.getElementById(name+i).src="http://media.monsterindia.com/blog/icon_star.gif";
	}
}	
