var popUpPlayer = 0;

function openPlayer()
{
	var URLStr = 'mp3player.php';
	var width = 550;
	var height = 200;
	var left = (screen.width/2) - width/2;
  	var top = (screen.height/2) - height/2;

	popUpPlayerWindow(URLStr, left, top, width, height);
}

function popUpPlayerWindow(URLStr, left, top, width, height)
{
  if(width>screen.width)
  {
  	width = screen.width;
  }

	
  var playerCookie = czytaj_ciacho("openPlayer");
	
  if(popUpPlayer.closed || playerCookie == 0)
  {
	  popUpPlayer = open(URLStr, 'popUpPlayer', 'toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
	  document.cookie = "openPlayer=1";
  }
  else
  {
//  	popUpPlayer.window.focus();
  }
}



// funkcja pobrana z http://js.webhelp.pl/index.php?id=86&roz=js&ac=read
function czytaj_ciacho(nazwa)
 {
  nazwa+="="; //uzupełnia nazwę
  startCookie=document.cookie.indexOf(nazwa); //sprawdza czy istnieje cookie o podanej nazwie
  if (startCookie==-1) {return ""} //jeżeli nie istnieje
  startCookie+=nazwa.length; //początek treści cookie
  if (document.cookie.indexOf(";",startCookie)==-1) //jeżeli jest więcej cookie
   {
    koniecCookie=document.cookie.length; //jeżeli nie ma podstawia jako koniec cookie, koniec całego tekstu
   }
  else
   {
    koniecCookie=document.cookie.indexOf(";",startCookie); // podstawia pod koniec miejsce występowania ";" (czyli początek następnego cookie)
   }
  textCookie=document.cookie.substring(startCookie,koniecCookie); //kopiuje treść cookie
  textCookie=unescape(textCookie); //rozkodowuje treść
  return textCookie; //zwraca wartość
}

