function GetBrowser()
{
	var xmlHTTP =null;
	try 
	{
		//firefox ,sarfari,opera;
		xmlHTTP   = new XMLHttpRequest();
	}
	catch (e)
	{
		//FOR IE
		try
		{
			xmlHTTP = new ActiveXObject("Msxml2.XMLHTTP");	
		}
		catch (E)
		{
			xmlHTTP = new ActiveXObject("Microsoft.XMLHTTP");			
		}
	}
	return xmlHTTP;
}

function showOverRating(imgId){
	var im=1;
	for(im = 1; im<=imgId; im++){
		document.getElementById("img"+im).src='images/yellow_star_17_16.gif';
		document.getElementById("img"+im).alt='Click to rate';
		document.getElementById("img"+im).title='Click to rate';
	}
}
function showOutRating(imgId,ratingId,typerate){
	var im=1;
	//alert(ratingId);
	var cnt = 0;
	for(im = 1; im<=5; im++){
		if(im <= ratingId)
		{
			
			document.getElementById("img"+im).src='images/orange_star_17_16.gif';
			
			
		}
		else
		{
			cnt++;
			if(cnt == 1 && typerate == 'double')
				document.getElementById("img"+im).src='images/star_3.6.gif';
			else
				document.getElementById("img"+im).src='images/grey_star_17_16.gif';
		}
	}
}
function showOverRatingRev(imgId){
	
	var im=1;
	for(im = 1; im<=imgId; im++){
		document.getElementById("imgr"+im).src='images/yellow_star_17_16.gif';
	}
}
function showOutRatingRev(imgId,ratingId){
	var im=1;
	//alert(ratingId);
	for(im = 1; im<=5; im++){
		if(im <= ratingId)
		{
			document.getElementById("imgr"+im).src='images/orange_star_17_16.gif';
		}
		else
		{
			document.getElementById("imgr"+im).src='images/grey_star_17_16.gif';
		}
	}
}
function showOverRatingBar(imgId,type){
	var im=1;
	for(im = 1; im<=imgId; im++){
		document.getElementById("img"+type+im).src='images/yellow_square.gif';
	}
}
function showOutRatingBar(imgId,type){
	var im=1;
	var vote = document.getElementById('rating11').value;
	
	for(im = 1; im<=imgId; im++){
		if(im <= vote)
		{
			document.getElementById("img"+type+im).src='images/orange_square.gif';
		}
		else
		{
			document.getElementById("img"+type+im).src='images/gray_square.gif';
		}
	}
}

function showOverRatingVideo(imgId,vCNT){
	var im=1;
	for(im = 1; im<=imgId; im++){
		document.getElementById("img_video_"+vCNT+"_"+im).src='images/yellow_star_17_16.gif';
		document.getElementById("img_video_"+vCNT+"_"+im).alt='Click to rate';
		document.getElementById("img_video_"+vCNT+"_"+im).title='Click to rate';
	}
}
function showOutRatingVideo(imgId,ratingId,vCNT){
	var im=1;
	
	for(im = 1; im<=5; im++){
		if(im <= ratingId)
			document.getElementById("img_video_"+vCNT+"_"+im).src='images/orange_star_17_16.gif';
		else
			document.getElementById("img_video_"+vCNT+"_"+im).src='images/grey_star_17_16.gif';
	}
}

function doUpdateProductRating(prodId, vote){
	
		url = "product_rating_update.php";
		var param ="prodid="+prodId+"&vote="+vote+"&type=product";
		//alert(param);
		var xmlhttp =  new GetBrowser();
		xmlhttp.open('POST', url, true);                      
		
		/* The callback function */
		//document.getElementById('div_rating').style.display='';
		xmlhttp.onreadystatechange = function() {
			if (xmlhttp.readyState == 4) {
			
			var objDetails = xmlhttp.responseText;
			//alert(objDetails);
			if(objDetails != null){
				splitObjDetails = objDetails.split('|-|');
				 	document.getElementById("rating").innerHTML=splitObjDetails[0];
 					document.getElementById("rated").innerHTML = splitObjDetails[1];
					document.getElementById("revmsg").innerHTML='Thanks for rating, click to write a quick review.';
					//document.getElementById("reviewDiv").innerHTML=splitObjDetails[0];
			}
					
			}
		}                  
		
		/* Send the POST request */
		xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		xmlhttp.send(param);	
}

function doUpdateProductRating_multiple(prodId, vote){
	
		url = "product_rating_update.php";
		var param ="prodid="+prodId+"&vote="+vote+"&type=product";
		//alert(param);
		var xmlhttp =  new GetBrowser();
		xmlhttp.open('POST', url, true);                      
		
		/* The callback function */
		//document.getElementById('div_rating').style.display='';
		xmlhttp.onreadystatechange = function() {
			if (xmlhttp.readyState == 4) {
			
			var objDetails = xmlhttp.responseText;
			//alert(objDetails);
			if(objDetails != null){
				//alert(objDetails);
				splitObjDetails = objDetails.split('|-|');
				
				//alert(splitObjDetails);
				 	document.getElementById(prodId+"rating").innerHTML=splitObjDetails[0];
					if(splitObjDetails[1].replace('customers rated this','') > 1)
					{
 						document.getElementById(prodId+"_cust_cnt").innerHTML =  trimAll(splitObjDetails[1].replace('customers rated this',''))+' Ratings';
					}
					else
					{
 						document.getElementById(prodId+"_cust_cnt").innerHTML =  trimAll(splitObjDetails[1].replace('customers rated this',''))+' Rating';
					}
				}
					
			}
		}                  
		
		/* Send the POST request */
		xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		xmlhttp.send(param);	
	
}
function doUpdateVideoRating(videoId, vote,vCNT){
		url = "product_rating_update.php";
		var param ="videoid="+videoId+"&vote="+vote+"&type=video";
		//alert(param);
		var xmlhttp =  new GetBrowser();
		xmlhttp.open('POST', url, true);                      
		
		/* The callback function */
		//document.getElementById('div_rating').style.display='';
		xmlhttp.onreadystatechange = function() {
			if (xmlhttp.readyState == 4) {
			
			var objDetails = xmlhttp.responseText;
			//alert(objDetails);
			if(objDetails != null){
					document.getElementById("rateVideo"+vCNT).innerHTML=objDetails;
					document.getElementById("revvideomsg"+vCNT).style.display='';
					document.getElementById("revvideomsg"+vCNT).innerHTML='<span class="floatl text13">Thanks for rating</span>';
			}
					
			}
		}                  
		
		/* Send the POST request */
		xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		xmlhttp.send(param);	
	
}
function doLoadProductRating(prodid,type){

	if(type == 0)
	{
		var divname = 'reviewdiv';
		var rating = '';
		document.getElementById(divname).style.height = '';
		document.getElementById(divname).style.overflow = 'hidden';
	}
	else if(type == 1)
	{
		var divname = 'ratingDiv';
		var rating = document.getElementById('rating11').value;
	}

	if(document.getElementById('no_review') != null || document.getElementById('no_review') != undefined)
		var no_review='yes';
	else
		var no_review='no';
		
		var url = "write_a_review.php";
		var param ="prodid="+prodid+"&type="+type+"&rate="+rating+"&no_review="+no_review;
		//alert(url);
		var xmlhttp =  new GetBrowser();
		xmlhttp.open('POST', url, true);   
		/* The callback function */
		//document.getElementById('div_rating').style.display='';
		xmlhttp.onreadystatechange = function() {
			if (xmlhttp.readyState == 4) {
			var objDetails = xmlhttp.responseText;
			
			/*alert(objDetails);
			return false;*/
			if(objDetails != null){
				if(document.getElementById('no_review') != null || document.getElementById('no_review') != undefined)
				{
					document.getElementById('no_review').style.display='';
				}
				if(document.getElementById('rating_revcnt') != null || document.getElementById('rating_revcnt') != undefined)
				{
					document.getElementById('rating_revcnt').innerHTML = rating+' / 5';
				}
				document.getElementById(divname).innerHTML = objDetails;
				document.getElementById('fname').focus();
				
			}
					
			}
			//alert(xmlhttp.readyState);
		}                  
		
		/* Send the POST request */
		xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		xmlhttp.send(param);	
}