var rated = 0;

	function rate (e, act,id) {
		if (act == -9) {			
			for (i = 1; i <= 5; i++) {
				document.getElementById(id + i).src="images/white-star.png";
			}
			document.getElementById('rating'+id).value = 0;
			rated = 0;
		} else if (act == 0) {
			if (rated == 0) rate (0, -9,id);
		} else if (act == -1 ) {
			last = e.src;
			e.src = "images/red-star.png";
		} else if (rated == 0) {
			if (act > 0) {
				document.getElementById('rating'+id).value = act;
				rated = 1;
			} else {
				act = -act;
			}
			for (i = 1; i <= act; i++) {
				document.getElementById(id + i).src="images/red-star.png";
			}
			for (; i <= 5; i++) {
				document.getElementById(id + i).src="images/white-star.png";
			}
		}
	}


	var lastID=0;

	function show_city (cityID, func, e) {

		if (func == 1) {
			posi = e.coords.split(/\,/);
			document.getElementById('city_sold').style.top = posi[1] - 120 + "px";
			document.getElementById('city_sold').style.left = posi[0] - 155 + "px";
			document.getElementById('city_sold').style.display = "block";
			
			if (cities[cityID][0]==0){ document.getElementById('NoShop').innerHTML = "لا يوجد";}
			else if (cities[cityID][0]>0){ document.getElementById('NoShop').innerHTML = "عدد المكتبات : "+cities[cityID][0];}
			
			
			document.getElementById('NoSold').innerHTML = cities[cityID][1];
			lastID=cityID;
		} else if (func == 0) {
			document.getElementById('city_sold').style.display = "none";
		} else if (func == 2) {
			if (cities[lastID][0] > 0) {
				text="";
				for (i = 2; cities[lastID][i] != "0000"; i++)
					text += '<p>' + cities[lastID][i] + '</p>';
				document.getElementById('city_shop').style.display = "block";
				document.getElementById('shops').innerHTML = text;
			}
		}

	}

	var Confirm = 0;
	function confirm (id) {
		if (Confirm == 0 && document.getElementById('rating'+id).value == 0) {
			Confirm = 1;
			alert ("You did not rate the book! Please re-submit again.");
			return false;
		}
		return true;
	}
	
	function confirmtopic (id) {
		if (Confirm == 0 && document.getElementById('rating'+id).value == 0) {
			Confirm = 1;
			alert ("You did not rate the pic! Please re-submit again.");
			return false;
		}
		return true;
	}

cities = new Array();

for (i = 0; i < 100; i++)
	cities[ i]=['', ''];
