

  function toLocation(frameid){

  	var str=frameid;
    if (str.search(',')>-1){
	  frameid=str.substring(0,str.search(','))
	}
	
	ajax_storelocation(frameid, 1,"");
  }


  function ajax_storelocation(frameid, action, par){ 

    var url = "recordaction.php";
  	
    if (par.length>0){
       var params = "action=" + action + "&frameid=" + frameid + par;	
    }else{
  
   	  var params = "action=" + action + "&frameid=" + frameid;
    }  
    var http = createAjaxObject();    
	http.open("POST", url, true);
    http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    http.setRequestHeader("Content-length", params.length);
    http.setRequestHeader("Connection", "close");				    
    http.onreadystatechange = function() {//Call a function when the state changes.
      if(http.readyState == 4 && http.status == 200) {

      	if (action == 6){ //Only on Pokerchip Game
		   var newamount =parseInt(http.responseText);
		   if (newamount){ 
		     var insertChipLocation=document.getElementById("showchips");
		     var currentamount = document.getElementById('currentamount').value;	
                      var totalamount = document.getElementById('totalamount').value;  
           
		     if((newamount-currentamount)>0){ 
			    document.getElementById("currentshowamount").firstChild.nodeValue= newamount;
			    var chip =newamount; 
	            chip = "chip" + chip; 
	            document.getElementById(chip).src='images/chip.png'; 
			    document.getElementById('currentamount').value=newamount;
			    if (newamount==totalamount){
			           document.getElementById("message").innerHTML="<b> Congratulations!! </b> <br/><span style='color:#ffffff;font-size:.8em'> You are now qualified to win!</span>";
				   document.getElementById("action").value="Qualified";
				   alert("Congratulation! You have now qualified to Win Caesars Cash.\n  Click OK to continue.");
				  //var answer = confirm("Congratulation! You have now qualified to Win Caesars Cash.\n  Click OK to continue.");
				  //if (answer){
 	                          //}else{
					  //document.forms.qualifier.submit();
				  //}
				  
				}
			  
		     }
		  }
		  
		}
      }                  		  
    }
  http.send(params);
  }  

function createAjaxObject(){	
	 var request_o; 	
	 var browser = navigator.appName; 
	 if(browser == "Microsoft Internet Explorer"){	
	    request_o =  new ActiveXObject("Microsoft.XMLHTTP");	
	 }else{			
	 	request_o = new XMLHttpRequest();
	}	
	return request_o;
}

function store_chip(frameid){
  //alert(frameid);
	ajax_storelocation(frameid, 6,"")
}
