
var cntStatControl; 
var cntStarControl;

var AjaxObject = {      
     handleSuccess:function(o){            
         this.processResult(o);            
     },   
   
     handleFailure:function(o){            
         document.getElementById("vote_result").innerHTML= o.status + " " + o.statusText;   
     },   
   
     processResult:function(o){      		
         var root = o.responseXML.documentElement;                   
         if (root.getElementsByTagName('error')[0].firstChild!=null){         
			document.getElementById("vote_result").innerHTMLroot.getElementsByTagName('error')[0].firstChild.nodeValue;
         }else{        			
			var oRating = root.getElementsByTagName('rating')[0].firstChild.nodeValue;   
			var oVotes = root.getElementsByTagName('votes')[0].firstChild.nodeValue;   
			var oTotalVotes = root.getElementsByTagName('totalvotes')[0].firstChild.nodeValue;   			
			document.getElementById(cntStarControl).style.width=((oTotalVotes)*25) + 'px';						
			document.getElementById(cntStatControl).innerHTML=oTotalVotes  +  " out of 5.0";  	
			document.getElementById("vote_result").innerHTML="Thank you for voting!";								
			var myAnim = new YAHOO.util.ColorAnim('divBusinessHeader', {borderColor: { to: '#AACC00' } });           
			myAnim.animate();			
			var voteAnim = new YAHOO.util.ColorAnim('vote_result', {backgroundColor: { to: '#AACC00' } });           
			voteAnim.animate();
         }
         			   
     }   
     ,   
   
     startRequest:function(){    
        // var transaction = YAHOO.util.Connect.asyncRequest('GET', 'http://www.couponrepublic.com/util_rate.aspx', callback);
     }
           
 };   
   
 var callback =   
 {   
     success:AjaxObject.handleSuccess,   
     failure:AjaxObject.handleFailure,   
     scope: AjaxObject   
 };   
   
 //AjaxObject.startRequest();  
 
 function rate_business(BusinessID, Rating, StarControl, StatControl){

	if (document.getElementById("vote_result").innerHTML==''){
	
	cntStarControl=StarControl;
	cntStatControl=StatControl;
	
	var transaction = YAHOO.util.Connect.asyncRequest('GET', 'util_rate.aspx?bid=' + BusinessID + '&vote=' + Rating , callback); 
	//var transaction = YAHOO.util.Connect.asyncRequest('GET', 'http://localhost/couponrepublic/util_rate.aspx?bid=' + BusinessID + '&vote=' + Rating , callback); 
	
	}
	
 
 }
 
 
 
 
 
