function unlock(myID){
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null){
		alert ("Your browser does not support AJAX!");
		return;
	}
	var url="unlock.php";
	myRand=parseInt(Math.random()*99999999);  // cache buster
	url=url+"?rand=" + myRand + "&storyID=" + myID;
	//xmlHttp.onreadystatechange=function() { if (xmlHttp.readyState!=4) return false; }
	xmlHttp.open("GET",url,false);
	xmlHttp.send(null);
}

function GetXmlHttpObject()
	{
	var xmlHttp=null;
	try
	  {
	  // Firefox, Opera 8.0+, Safari
	  xmlHttp=new XMLHttpRequest();
	  }
	catch (e)
	  {
	  // Internet Explorer
	  try
	    {
	    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
	    }
	  catch (e)
	    {
	    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
	    }
	  }
	return xmlHttp;
}

function rate(storyID, rating){
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null){
		alert ("Your browser does not support AJAX!");
		return;
	}
	var url="http://www.smashedclock.com/exquisite_corpse/rate.php";
	url=url+"?storyID=" + storyID + "&rating=" + rating;
	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function stateChanged(){
	if (xmlHttp.readyState==4){
		newRating = xmlHttp.responseText;
		document.getElementById("rating").innerHTML = 
		"<p>Current Rating:" +  newRating + " stars out of 5</p> <p><font size='-2'>Your rating has been counted</font></p>";
	}
}


function over_star(star){
	for(i=1; i <= star; i++){
		document.getElementById(i).innerHTML = "<img src='../images/star1.png'/>";
	}
	
	for(i=(star+1); i <= 5; i++){

		document.getElementById(i).innerHTML = "<img src='../images/star2.png' />";
	}
	
}

function out_stars(original){
	for(i=1; i <= original; i++){
		document.getElementById(i).innerHTML = "<img src='../images/star1.png'/>";
	}
	
	for(i=(original+1); i <= 5; i++){
		document.getElementById(i).innerHTML = "<img src='../images/star2.png' />";
	}
}

function test_ajax(){
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null){
		return false;
	}
	return true;
}

