function StarsHighlight(star,selected){
	/*Gwiazdki
	star0=gwiazdka pusta
	star1=wypelniowna
	star2=wypelniona ale wieksza niz zaznaczona
	*/
	for(i=1;i<=5;i++){
		if (selected){
			if(i<=star){
				if (i<=selected){
					if(stars[i].src!=star1.src){ stars[i].src=star1.src; }
				}else{
					if(stars[i].src!=star2.src){ stars[i].src=star2.src; }
				}
			}else{
				if(stars[i].src!=star0.src){ stars[i].src=star0.src; }
			}
		}else{
			if(i<=star){
				if(stars[i].src!=star1.src){ stars[i].src=star1.src; }
			}else{
				if(stars[i].src!=star0.src){ stars[i].src=star0.src; }
			}
		}
	}
}

function ClearStars(sel){

	if (sel){
		for(i=5;i>=1;i--){
			if (i<=sel){
				if (stars[i].src!=star1.src){ stars[i].src=star1.src; }
			}else{
				if (stars[i].src!=star0.src) { stars[i].src=star0.src; }
			}
		}
	}else{
		for(i=5;i>=1;i--){
			if (stars[i].src!=star0.src) { stars[i].src=star0.src; }
		}
	}
	
}

function ShowButton(sel){
	if(sel){ document.getElementById('btn_vote').style.display='block'; }
}

function HideStars(){
	document.getElementById('GlosowanieTable').style.display="none";
}

function VoteWindow(Mark,Item){
	window.open("http://www.flashgamesbank.com/flash_games/vote/"+Item+"/"+Mark+"","glosuj","menubar=no,toolbar=no,location=no,directories=no,status=no,scrollbars=no,resizable=no,width=300,height=200");
} 
function Vote(mark,id)
{
	var url = "http://www.flashgamesbank.com/flash_game/vote/"+id+"/"+mark+"";

	 // kontynuuje, je?i obiekt xmlHttp nie jest pusty
	  if (xmlHttp)
	  {
	    // prcuje po-?zy?si? serwerem
	    try
	    {
	      // pocz?kuje odczyt pliku z serwera
	      xmlHttp.open("GET", url, true);
	      xmlHttp.onreadystatechange = handleRequestStateChangeVote;
	      xmlHttp.send(null);
	    }
	    // w razie niepowodzenia wy?ietla komunikat o b-?ie
	    catch (e)
	    {
	      alert("I can't connect to Server:\n" + e.toString());
	    }
	  }

}
// funkcja wywoływana przy zmianie statusu żądania HTTP
function handleRequestStateChangeVote() 
{

  // kiedy readyState ma wartość 4, jesteśmy gotowi do odebrania odpowiedzi z serwera
  if (xmlHttp.readyState == 4) 
  {
    // kontynuuje tylko, gdy status HTTP ma wartość "OK"
    if (xmlHttp.status == 200) 
    {
      try
      {
        // przetwarza wiadomość z serwera
		readResponseVote();
		
      }
      catch(e)
      {
        // komunikat o błędzie
        alert("Error reading the response: " + e.toString());
      }
    } 
    else
    {
      // wyświetla wiadomość o statusie
      alert("Problem przy pobieraniu danych:\n" + xmlHttp.statusText);
    }
  }
}
function readResponseVote()
{
	var xmlRoot = xmlHttp.responseXML;
	exit = xmlRoot.getElementsByTagName('exit')[0].firstChild.nodeValue;
	votes= xmlRoot.getElementsByTagName('vote')[0].firstChild.data;
	document.getElementById('vote').innerHTML = votes; 
	
	alert(exit);
}
function readCookie(name){
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(i=0;i < ca.length;i++){
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}