
function resetStars() {
	for (var i=1; i <= 5; i++) {
		doStar(i, 'http://i.thisislondon.co.uk/i/std/siteimages/stars/starOff.gif');
	}
}
function resetAll() {
	resetStars();
}

function lightStars(rating) {
	resetStars();
	for (var i=1; i<= rating; i++) {
		doStar(i, 'http://i.thisislondon.co.uk/i/std/siteimages/stars/starOn.gif');
		document.forms.addRating.rating.value='' + i;
	}
}

function doStar(elId, image) {
	elId = 's' + elId; 
	document.getElementById(elId).src='' + image;
}

function submitRatingForm() {
	document.forms.addRating.submit();
}

function setItemRating(itemType,itemId) {
	var cookie = getCookie(itemType+"UScores");
	userRating = 0;
	if (cookie!=null) {
		var split = cookie.split("~");
		for (var i=1;i<split.length;i++){
			var text = split[i];
			var id = text.substring(0,text.indexOf("/"));
			var rating = text.substring(text.indexOf("/")+1);
			if (id==itemId) {
				userRating=rating;
				break;
			}
		}
	}
	document.getElementById('itemRating').value = userRating ;
}

function showDiv(boxid){ 
   document.getElementById(boxid).style.display="block"; 
} 

function hideDiv(boxid){ 
   document.getElementById(boxid).style.display="none"; 
}
function toggleDiv(show, hide) {
	showBox = document.getElementById(show);
	hideBox = document.getElementById(hide);
	
	if (hideBox.style.display == "block") {
		showDiv(show);
		hideDiv(hide);
	}
	else {
		showDiv(hide);
		hideDiv(show);
	}
}

function show() {
	document.getElementById('hide').style.display='none';
    document.getElementById('show').style.display='inline';
}
function hide() {
	document.getElementById('hide').style.display='inline';
    document.getElementById('show').style.display='none';
}

function functionFalse() {
	
}

function setCookie(name,value,expires,path,domain,secure){
	var curCookie=name+"="+escape(value)+
		((expires)?"; expires="+expires.toGMTString():"")+
		((path)?"; path="+path:"")+
		((domain)?"; domain="+domain:"")+
		((secure)?"; secure":"");
	document.cookie=curCookie;
}

function getCookie(name){
	var dc=document.cookie;
	var prefix=name+"=";
	var begin=dc.indexOf("; "+prefix);
	if(begin==-1){
		begin=dc.indexOf(prefix);
		if(begin!=0)return null;
	}
	else
		begin+=2;
	var end=document.cookie.indexOf(";",begin);
	if(end==-1)
		end=dc.length;
	return unescape(dc.substring(begin+prefix.length,end));
}

function deleteCookie(name,path,domain){
	if(getCookie(name)){
		document.cookie=name+"="+
		((path)?"; path="+path:"")+
		((domain)?"; domain="+domain:"")+
		"; expires=Thu, 01-Jan-70 00:00:01 GMT";
	}
}

function addCookieEnabledTest(name,value,path,domain){
	if(!getCookie(name)) {
		var curCookie=name+"="+escape(value)+
			((path)?"; path="+path:"")+
			((domain)?"; domain="+domain:"");
		document.cookie=curCookie;
	}
}

