/*
 * 
 */

function Gra_Ocena_Over(Ocena) 
	{
	if (Ocena != 0) 
		{
		document.getElementById('Ocena_Gwiazdki_Aktywne').style.display = 'none';
		document.getElementById('Gra_Gra_Pole_Ocena_Liczba').style.display = 'none';
		document.getElementById('Gra_Gra_Pole_Ocena_Glosow').style.display = 'none';
		document.getElementById('Gra_Gra_Pole_Ocena').style.backgroundPosition = '0px -44px';
		}
	else
		{
		document.getElementById('Ocena_Gwiazdki_Aktywne').style.display = ''; 
		document.getElementById('Gra_Gra_Pole_Ocena_Liczba').style.display = '';
		document.getElementById('Gra_Gra_Pole_Ocena_Glosow').style.display = '';
		document.getElementById('Gra_Gra_Pole_Ocena').style.backgroundPosition = '0px 0px';
		}
	
	for (var i = 1; i < 7; i++)
		{
		if (i <= Ocena)
			{
			document.getElementById('Ocena_Gwiazdka_Over_' + i).style.backgroundPosition = '0px -24px';
			}
	   else
	   	{
			document.getElementById('Ocena_Gwiazdka_Over_' + i).style.backgroundPosition = '0px 0px';
	   	}
		}
		
   // Ocena słownie
      var OcenaSlownie = new Array();
      OcenaSlownie[0] = '';
      OcenaSlownie[1] = 'padaka';
      OcenaSlownie[2] = 'słaba';
      OcenaSlownie[3] = 'taka sobie';
      OcenaSlownie[4] = 'niezła';
      OcenaSlownie[5] = 'świetna';
      OcenaSlownie[6] = 'miażdzy wszystko :D';
      
   // Pokaż ocenę
      document.getElementById('Ocena_Napis').innerHTML = OcenaSlownie[Ocena];
	};
	
/*
 * Funkcja wysyła żądanie AJAX, które powoduje zarejestrowanie oceny wystawionej przez gracza
 */
function Gra_OcenGre(ID_Gra, Ocena)
   {
   // Utwórz i wyślij nowe żądanie Ajax
      var TMP_ZadanieAjax = null;
      TMP_ZadanieAjax = new Ajax('/AJAXKontroler/Gra', "");
      TMP_ZadanieAjax.AddVariable('Polecenie'   ,'OcenGre');
      TMP_ZadanieAjax.AddVariable('ID_Gra'      ,ID_Gra);
      TMP_ZadanieAjax.AddVariable('Ocena'       ,Ocena);
      TMP_ZadanieAjax.HTTPRequest.onreadystatechange = function()
         {
         if ((TMP_ZadanieAjax.HTTPRequest.readyState == 4) && (TMP_ZadanieAjax.HTTPRequest.status == 200))
            {
	         eval(TMP_ZadanieAjax.HTTPRequest.responseText);
            }
         };
      TMP_ZadanieAjax.Send();
   }

/*
 * Funkcja wysyła żądanie AJAX, które powoduje wyświetlenie komentarzy
 */
function Gra_PobierzKomentarze(ID_Gra)
   {
   // Utwórz i wyślij nowe żądanie Ajax
      var TMP_ZadanieAjax = null;
      TMP_ZadanieAjax = new Ajax('/AJAXKontroler/Gra', "");
      TMP_ZadanieAjax.AddVariable('Polecenie'   ,'PobierzKomentarze');
      TMP_ZadanieAjax.AddVariable('ID_Gra'      ,ID_Gra);
      TMP_ZadanieAjax.HTTPRequest.onreadystatechange = function()
         {
         if ((TMP_ZadanieAjax.HTTPRequest.readyState == 4) && (TMP_ZadanieAjax.HTTPRequest.status == 200))
            {
	         eval(TMP_ZadanieAjax.HTTPRequest.responseText);
            }
         };
      TMP_ZadanieAjax.Send();
   }

/*
 * Funkcja wysyła żądanie AJAX, która dodaje komentarz do danej gry
 */
function Gra_DodajKomentarz(ID_Gra, Autor, Tresc)
   {
   // Utwórz i wyślij nowe żądanie Ajax
      var TMP_ZadanieAjax = null;
      TMP_ZadanieAjax = new Ajax('/AJAXKontroler/Gra', "");
      TMP_ZadanieAjax.AddVariable('Polecenie'   ,'DodajKomentarz');
      TMP_ZadanieAjax.AddVariable('ID_Gra'      ,ID_Gra);
      TMP_ZadanieAjax.AddVariable('Autor'       ,Autor);
      TMP_ZadanieAjax.AddVariable('Tresc'       ,Tresc);
      TMP_ZadanieAjax.HTTPRequest.onreadystatechange = function()
         {
         if ((TMP_ZadanieAjax.HTTPRequest.readyState == 4) && (TMP_ZadanieAjax.HTTPRequest.status == 200))
            {
	         eval(TMP_ZadanieAjax.HTTPRequest.responseText);
            }
         };
      TMP_ZadanieAjax.Send();
   }
   

/*
 * Funkcja pokazuje graczowi podpowiedź opisującą sposób, w jaki można zagłosować na grę
 * Kolejne podpowiedzi generowane są cyklicznie co 5 minut
 */   
var Gra_Ocena_Podpowiedz_Timer = null;
function Gra_Ocena_PokazPodpowiedz()
	{
	// Zaprogramuj wyświetlenie i ukrycie podpowiedzi
		setTimeout("Element_FadeIn ('Gra_Gra_Pole_Ocena_Podpowiedz' , 0, 100, 4, 20, true)",   50); // wyswietl podpowiedz
		setTimeout("Element_FadeOut('Gra_Gra_Pole_Ocena_Podpowiedz', 100, 0, 2, 20, true)" , 7000); // ukryj podpowiedz
		
	// Zaprogramuj kolejne wyświetlenie podpowiedzi (za 5 minut)
		Gra_Ocena_Podpowiedz_Timer = setTimeout("Gra_Ocena_PokazPodpowiedz()", 5 * 60 * 1000);
	};
   /*
 * Funkcja wysyła żądanie AJAX, które powoduje wyświetlenie listy plików powiązanych z grą
 * Wymaga uprawnień Administratora
 */
function Admin_Plik_Lista(ID_Gra)
   {
   // Pokaż/ukryj odpowiednie warstwy
   	document.getElementById('Admin_Ramka').style.display        	= '';
   	document.getElementById('Admin_Ramka_Edytor').style.display 	= 'none';
   	document.getElementById('Admin_Ramka_Formularz').style.display = 'none';
   	
   // Utwórz i wyślij nowe żądanie Ajax
      var TMP_ZadanieAjax = null;
      TMP_ZadanieAjax = new Ajax('/AJAXKontroler/Administracja/Gry/Pliki/Lista', "");
      TMP_ZadanieAjax.AddVariable('ID_Gra'      ,ID_Gra);
      TMP_ZadanieAjax.HTTPRequest.onreadystatechange = function()
         {
         if ((TMP_ZadanieAjax.HTTPRequest.readyState == 4) && (TMP_ZadanieAjax.HTTPRequest.status == 200))
            {
	         eval(TMP_ZadanieAjax.HTTPRequest.responseText);
            }
         };
      TMP_ZadanieAjax.Send();
   }

function Admin_Plik_Usun(ID_Gra, ID_Plik)
   {
   // Monit
      if (!confirm("Czy na pewno usunąć ten plik?")) return;
      
   // Utwórz i wyślij nowe żądanie Ajax
      var TMP_ZadanieAjax = null;
      TMP_ZadanieAjax = new Ajax('/AJAXKontroler/Administracja/Gry/Pliki/Usun', "");
      TMP_ZadanieAjax.AddVariable('ID_Gra'      ,ID_Gra);
      TMP_ZadanieAjax.AddVariable('ID_Plik'     ,ID_Plik);
      TMP_ZadanieAjax.HTTPRequest.onreadystatechange = function()
         {
         if ((TMP_ZadanieAjax.HTTPRequest.readyState == 4) && (TMP_ZadanieAjax.HTTPRequest.status == 200))
            {
	         eval(TMP_ZadanieAjax.HTTPRequest.responseText);
            }
         };
      TMP_ZadanieAjax.Send();
   }

function Admin_Plik_ZmienNazwe(ID_Gra, ID_Plik, StaraNazwa)
   {
   // Okno dialogowe
      var NowaNazwa = window.prompt('Nowa nazwa pliku', StaraNazwa);
      if (NowaNazwa == null) return;
      
   // Utwórz i wyślij nowe żądanie Ajax
      var TMP_ZadanieAjax = null;
      TMP_ZadanieAjax = new Ajax('/AJAXKontroler/Administracja/Gry/Pliki/ZmienNazwe', "");
      TMP_ZadanieAjax.AddVariable('ID_Gra'      ,ID_Gra);
      TMP_ZadanieAjax.AddVariable('ID_Plik'     ,ID_Plik);
      TMP_ZadanieAjax.AddVariable('NowaNazwa'   ,NowaNazwa);
      TMP_ZadanieAjax.HTTPRequest.onreadystatechange = function()
         {
         if ((TMP_ZadanieAjax.HTTPRequest.readyState == 4) && (TMP_ZadanieAjax.HTTPRequest.status == 200))
            {
	         eval(TMP_ZadanieAjax.HTTPRequest.responseText);
            }
         };
      TMP_ZadanieAjax.Send();
   }

function Admin_Zdjecie_Lista(ID_Gra)
   {
   // Pokaż/ukryj odpowiednie warstwy
   	document.getElementById('Admin_Ramka').style.display        	= '';
   	document.getElementById('Admin_Ramka_Edytor').style.display 	= 'none';
   	document.getElementById('Admin_Ramka_Formularz').style.display = 'none';
   
   // Utwórz i wyślij nowe żądanie Ajax
      var TMP_ZadanieAjax = null;
      TMP_ZadanieAjax = new Ajax('/AJAXKontroler/Administracja/Gry/Zdjecia/Lista', "");
      TMP_ZadanieAjax.AddVariable('ID_Gra'      ,ID_Gra);
      TMP_ZadanieAjax.HTTPRequest.onreadystatechange = function()
         {
         if ((TMP_ZadanieAjax.HTTPRequest.readyState == 4) && (TMP_ZadanieAjax.HTTPRequest.status == 200))
            {
	         eval(TMP_ZadanieAjax.HTTPRequest.responseText);
            }
         };
      TMP_ZadanieAjax.Send();
   }

function Admin_Zdjecie_Usun(ID_Gra, ID_Zdjecie)
   {
   // Monit
      if (!confirm("Czy na pewno usunąć ten plik?")) return;
      
   // Utwórz i wyślij nowe żądanie Ajax
      var TMP_ZadanieAjax = null;
      TMP_ZadanieAjax = new Ajax('/AJAXKontroler/Administracja/Gry/Zdjecia/Usun', "");
      TMP_ZadanieAjax.AddVariable('ID_Gra'      ,ID_Gra);
      TMP_ZadanieAjax.AddVariable('ID_Zdjecie'  ,ID_Zdjecie);
      TMP_ZadanieAjax.HTTPRequest.onreadystatechange = function()
         {
         if ((TMP_ZadanieAjax.HTTPRequest.readyState == 4) && (TMP_ZadanieAjax.HTTPRequest.status == 200))
            {
	         eval(TMP_ZadanieAjax.HTTPRequest.responseText);
            }
         };
      TMP_ZadanieAjax.Send();
   }

function Admin_Zdjecie_UstawDomyslne(ID_Gra, ID_Zdjecie)
   {
   // Utwórz i wyślij nowe żądanie Ajax
      var TMP_ZadanieAjax = null;
      TMP_ZadanieAjax = new Ajax('/AJAXKontroler/Administracja/Gry/Zdjecia/UstawDomyslne', "");
      TMP_ZadanieAjax.AddVariable('ID_Gra'      ,ID_Gra);
      TMP_ZadanieAjax.AddVariable('ID_Zdjecie'  ,ID_Zdjecie);
      TMP_ZadanieAjax.HTTPRequest.onreadystatechange = function()
         {
         if ((TMP_ZadanieAjax.HTTPRequest.readyState == 4) && (TMP_ZadanieAjax.HTTPRequest.status == 200))
            {
	         eval(TMP_ZadanieAjax.HTTPRequest.responseText);
            }
         };
      TMP_ZadanieAjax.Send();
   }
   
function Admin_Recenzja_Pokaz(ID_Gra)
   {
   // Pokaż/ukryj odpowiednie warstwy
   	document.getElementById('Admin_Ramka').style.display        	= 'none';
   	document.getElementById('Admin_Ramka_Edytor').style.display 	= '';
   	document.getElementById('Admin_Ramka_Formularz').style.display = 'none';
   
   // Pokaż/ukryj odpowiednie przyciski
	   document.getElementById('Admin_Ramka_Edytor_Przycisk_Recenzja').style.display   = '';
	   document.getElementById('Admin_Ramka_Edytor_Przycisk_Sterowanie').style.display = 'none';
	   
   // Utwórz i wyślij nowe żądanie Ajax
      var TMP_ZadanieAjax = null;
      TMP_ZadanieAjax = new Ajax('/AJAXKontroler/Administracja/Gry/Recenzja/Pokaz', "");
      TMP_ZadanieAjax.AddVariable('ID_Gra'      ,ID_Gra);
      TMP_ZadanieAjax.HTTPRequest.onreadystatechange = function()
         {
         if ((TMP_ZadanieAjax.HTTPRequest.readyState == 4) && (TMP_ZadanieAjax.HTTPRequest.status == 200))
            {
	         eval(TMP_ZadanieAjax.HTTPRequest.responseText);
            }
         };
      TMP_ZadanieAjax.Send();
   }

function Admin_Recenzja_Aktualizuj(ID_Gra, Tresc)
   {
   // Utwórz i wyślij nowe żądanie Ajax
      var TMP_ZadanieAjax = null;
      TMP_ZadanieAjax = new Ajax('/AJAXKontroler/Administracja/Gry/Recenzja/Aktualizuj', "");
      TMP_ZadanieAjax.AddVariable('ID_Gra'      ,ID_Gra);
      TMP_ZadanieAjax.AddVariable('Tresc'       ,Tresc);
      TMP_ZadanieAjax.HTTPRequest.onreadystatechange = function()
         {
         if ((TMP_ZadanieAjax.HTTPRequest.readyState == 4) && (TMP_ZadanieAjax.HTTPRequest.status == 200))
            {
	         eval(TMP_ZadanieAjax.HTTPRequest.responseText);
            }
         };
      TMP_ZadanieAjax.Send();
   }   
   
function Admin_Sterowanie_Pokaz(ID_Gra)
   {
   // Pokaż/ukryj odpowiednie warstwy
   	document.getElementById('Admin_Ramka').style.display        	= 'none';
   	document.getElementById('Admin_Ramka_Edytor').style.display 	= '';
   	document.getElementById('Admin_Ramka_Formularz').style.display = 'none';
   
   // Pokaż/ukryj odpowiednie przyciski
	   document.getElementById('Admin_Ramka_Edytor_Przycisk_Recenzja').style.display   = 'none';
	   document.getElementById('Admin_Ramka_Edytor_Przycisk_Sterowanie').style.display = '';
	   
   // Utwórz i wyślij nowe żądanie Ajax
      var TMP_ZadanieAjax = null;
      TMP_ZadanieAjax = new Ajax('/AJAXKontroler/Administracja/Gry/Sterowanie/Pokaz', "");
      TMP_ZadanieAjax.AddVariable('ID_Gra'      ,ID_Gra);
      TMP_ZadanieAjax.HTTPRequest.onreadystatechange = function()
         {
         if ((TMP_ZadanieAjax.HTTPRequest.readyState == 4) && (TMP_ZadanieAjax.HTTPRequest.status == 200))
            {
	         eval(TMP_ZadanieAjax.HTTPRequest.responseText);
            }
         };
      TMP_ZadanieAjax.Send();
   }

function Admin_Sterowanie_Aktualizuj(ID_Gra, Tresc)
   {
   // Utwórz i wyślij nowe żądanie Ajax
      var TMP_ZadanieAjax = null;
      TMP_ZadanieAjax = new Ajax('/AJAXKontroler/Administracja/Gry/Sterowanie/Aktualizuj', "");
      TMP_ZadanieAjax.AddVariable('ID_Gra'      ,ID_Gra);
      TMP_ZadanieAjax.AddVariable('Tresc'       ,Tresc);
      TMP_ZadanieAjax.HTTPRequest.onreadystatechange = function()
         {
         if ((TMP_ZadanieAjax.HTTPRequest.readyState == 4) && (TMP_ZadanieAjax.HTTPRequest.status == 200))
            {
	         eval(TMP_ZadanieAjax.HTTPRequest.responseText);
            }
         };
      TMP_ZadanieAjax.Send();
   }      

function Admin_Formularz_Pokaz()
   {
   // Pokaż/ukryj odpowiednie warstwy
   	document.getElementById('Admin_Ramka').style.display           = 'none';
   	document.getElementById('Admin_Ramka_Edytor').style.display    = 'none';
   	document.getElementById('Admin_Ramka_Formularz').style.display = '';
   }
   
function TworzTID(Nazwa)
    {
    var Wynik = new String(Nazwa);

    IN = / /; OUT = "" ; for (i = 0; i < 10; i++) Wynik = Wynik.replace(IN,OUT);
    IN = /ą/; OUT = "a"; for (i = 0; i < 10; i++) Wynik = Wynik.replace(IN,OUT);
    IN = /ć/; OUT = "c"; for (i = 0; i < 10; i++) Wynik = Wynik.replace(IN,OUT);
    IN = /ę/; OUT = "e"; for (i = 0; i < 10; i++) Wynik = Wynik.replace(IN,OUT);
    IN = /ł/; OUT = "l"; for (i = 0; i < 10; i++) Wynik = Wynik.replace(IN,OUT);
    IN = /ń/; OUT = "n"; for (i = 0; i < 10; i++) Wynik = Wynik.replace(IN,OUT);
    IN = /ó/; OUT = "o"; for (i = 0; i < 10; i++) Wynik = Wynik.replace(IN,OUT);
    IN = /ś/; OUT = "s"; for (i = 0; i < 10; i++) Wynik = Wynik.replace(IN,OUT);
    IN = /ź/; OUT = "z"; for (i = 0; i < 10; i++) Wynik = Wynik.replace(IN,OUT);
    IN = /ż/; OUT = "z"; for (i = 0; i < 10; i++) Wynik = Wynik.replace(IN,OUT);
    IN = /Ą/; OUT = "A"; for (i = 0; i < 10; i++) Wynik = Wynik.replace(IN,OUT);
    IN = /Ć/; OUT = "C"; for (i = 0; i < 10; i++) Wynik = Wynik.replace(IN,OUT);
    IN = /Ę/; OUT = "E"; for (i = 0; i < 10; i++) Wynik = Wynik.replace(IN,OUT);
    IN = /Ł/; OUT = "L"; for (i = 0; i < 10; i++) Wynik = Wynik.replace(IN,OUT);
    IN = /Ń/; OUT = "N"; for (i = 0; i < 10; i++) Wynik = Wynik.replace(IN,OUT);
    IN = /Ó/; OUT = "O"; for (i = 0; i < 10; i++) Wynik = Wynik.replace(IN,OUT);
    IN = /Ś/; OUT = "S"; for (i = 0; i < 10; i++) Wynik = Wynik.replace(IN,OUT);
    IN = /Ź/; OUT = "Z"; for (i = 0; i < 10; i++) Wynik = Wynik.replace(IN,OUT);
    IN = /Ż/; OUT = "Z"; for (i = 0; i < 10; i++) Wynik = Wynik.replace(IN,OUT);

    return Wynik;
    };
   /* Nifty Corners Cube - rounded corners with CSS and Javascript
Copyright 2006 Alessandro Fulciniti (a.fulciniti@html.it)

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA

Drobne poprawki: Promet
*/

var niftyOk=(document.getElementById && document.createElement && Array.prototype.push);
var niftyCss=false;

String.prototype.find=function(what){
return(this.indexOf(what)>=0 ? true : false);
}

var oldonload=window.onload;
if(typeof(NiftyLoad)!='function') NiftyLoad=function(){};
if(typeof(oldonload)=='function')
    window.onload=function(){oldonload();AddCss();NiftyLoad()};
else window.onload=function(){AddCss();NiftyLoad()};

function AddCss(){
niftyCss=true;
/*
var l=CreateEl("link");
l.setAttribute("type","text/css");
l.setAttribute("rel","stylesheet");
l.setAttribute("href","niftyCorners.css");
l.setAttribute("media","screen");
document.getElementsByTagName("head")[0].appendChild(l);
*/
}

function Nifty(selector,options){
if(niftyOk==false) return;
if(niftyCss==false) AddCss();
var i,v=selector.split(","),h=0;

if (getElementsBySelector(v[0]) == '') return;				// promet


if(options==null) options="";
if(options.find("fixed-height"))
    h=getElementsBySelector(v[0])[0].offsetHeight;
for(i=0;i<v.length;i++)
    Rounded(v[i],options);
if(options.find("height")) SameHeight(selector,h);
}

function Rounded(selector,options){
var i,top="",bottom="",v=new Array();
if(options!=""){
    options=options.replace("left","tl bl");
    options=options.replace("right","tr br");
    options=options.replace("top","tr tl");
    options=options.replace("bottom","br bl");
    options=options.replace("transparent","alias");
    if(options.find("tl")){
        top="both";
        if(!options.find("tr")) top="left";
        }
    else if(options.find("tr")) top="right";
    if(options.find("bl")){
        bottom="both";
        if(!options.find("br")) bottom="left";
        }
    else if(options.find("br")) bottom="right";
    }
if(top=="" && bottom=="" && !options.find("none")){top="both";bottom="both";}
v=getElementsBySelector(selector);
for(i=0;i<v.length;i++){
    FixIE(v[i]);
    if(top!="") AddTop(v[i],top,options);
    if(bottom!="") AddBottom(v[i],bottom,options);
    }
}

function AddTop(el,side,options){
var d=CreateEl("b"),lim=4,border="",p,i,btype="r",bk,color;
d.style.marginLeft="-"+getPadding(el,"Left")+"px";
d.style.marginRight="-"+getPadding(el,"Right")+"px";
if(options.find("alias") || (color=getBk(el))=="transparent"){
    color="transparent";bk="transparent"; border=getParentBk(el);btype="t";
    }
else{
    bk=getParentBk(el); border=Mix(color,bk);
    }
d.style.background=bk;
d.className="niftycorners";
p=getPadding(el,"Top");
if(options.find("small")){
    d.style.marginBottom=(p-2)+"px";
    btype+="s"; lim=2;
    }
else if(options.find("big")){
    d.style.marginBottom=(p-10)+"px";
    btype+="b"; lim=8;
    }
else d.style.marginBottom=(p-5)+"px";
for(i=1;i<=lim;i++)
    d.appendChild(CreateStrip(i,side,color,border,btype));
el.style.paddingTop="0";
el.insertBefore(d,el.firstChild);
}

function AddBottom(el,side,options){
var d=CreateEl("b"),lim=4,border="",p,i,btype="r",bk,color;
d.style.marginLeft="-"+getPadding(el,"Left")+"px";
d.style.marginRight="-"+getPadding(el,"Right")+"px";
if(options.find("alias") || (color=getBk(el))=="transparent"){
    color="transparent";bk="transparent"; border=getParentBk(el);btype="t";
    }
else{
    bk=getParentBk(el); border=Mix(color,bk);
    }
d.style.background=bk;
d.className="niftycorners";
p=getPadding(el,"Bottom");
if(options.find("small")){
    d.style.marginTop=(p-2)+"px";
    btype+="s"; lim=2;
    }
else if(options.find("big")){
    d.style.marginTop=(p-10)+"px";
    btype+="b"; lim=8;
    }
else d.style.marginTop=(p-5)+"px";
for(i=lim;i>0;i--)
    d.appendChild(CreateStrip(i,side,color,border,btype));
el.style.paddingBottom=0;
el.appendChild(d);
}

function CreateStrip(index,side,color,border,btype){
var x=CreateEl("b");
x.className=btype+index;
x.style.backgroundColor=color;
x.style.borderColor=border;
if(side=="left"){
    x.style.borderRightWidth="0";
    x.style.marginRight="0";
    }
else if(side=="right"){
    x.style.borderLeftWidth="0";
    x.style.marginLeft="0";
    }
return(x);
}

function CreateEl(x){
return(document.createElement(x));
}

function FixIE(el){
if(el.currentStyle!=null && el.currentStyle.hasLayout!=null && el.currentStyle.hasLayout==false)
    el.style.display="inline-block";
}

function SameHeight(selector,maxh){
var i,v=selector.split(","),t,j,els=[],gap;
for(i=0;i<v.length;i++){
    t=getElementsBySelector(v[i]);
    els=els.concat(t);
    }
for(i=0;i<els.length;i++){
    if(els[i].offsetHeight>maxh) maxh=els[i].offsetHeight;
    els[i].style.height="auto";
    }
for(i=0;i<els.length;i++){
    gap=maxh-els[i].offsetHeight;
    if(gap>0){
        t=CreateEl("b");t.className="niftyfill";t.style.height=gap+"px";
        nc=els[i].lastChild;
        if(nc.className=="niftycorners")
            els[i].insertBefore(t,nc);
        else els[i].appendChild(t);
        }
    }
}

function getElementsBySelector(selector){
var i,j,selid="",selclass="",tag=selector,tag2="",v2,k,f,a,s=[],objlist=[],c;
if(selector.find("#")){ //id selector like "tag#id"
    if(selector.find(" ")){  //descendant selector like "tag#id tag"
        s=selector.split(" ");
        var fs=s[0].split("#");
        if(fs.length==1) return(objlist);
        f=document.getElementById(fs[1]);
        if(f){
            v=f.getElementsByTagName(s[1]);
            for(i=0;i<v.length;i++) objlist.push(v[i]);
            }
        return(objlist);
        }
    else{
        s=selector.split("#");
        tag=s[0];
        selid=s[1];
        if(selid!=""){
            f=document.getElementById(selid);
            if(f) objlist.push(f);
            return(objlist);
            }
        }
    }
if(selector.find(".")){      //class selector like "tag.class"
    s=selector.split(".");
    tag=s[0];
    selclass=s[1];
    if(selclass.find(" ")){   //descendant selector like tag1.classname tag2
        s=selclass.split(" ");
        selclass=s[0];
        tag2=s[1];
        }
    }
var v=document.getElementsByTagName(tag);  // tag selector like "tag"
if(selclass==""){
    for(i=0;i<v.length;i++) objlist.push(v[i]);
    return(objlist);
    }
for(i=0;i<v.length;i++){
    c=v[i].className.split(" ");
    for(j=0;j<c.length;j++){
        if(c[j]==selclass){
            if(tag2=="") objlist.push(v[i]);
            else{
                v2=v[i].getElementsByTagName(tag2);
                for(k=0;k<v2.length;k++) objlist.push(v2[k]);
                }
            }
        }
    }
return(objlist);
}

function getParentBk(x){
var el=x.parentNode,c;
while(el.tagName.toUpperCase()!="HTML" && (c=getBk(el))=="transparent")
    el=el.parentNode;
if(c=="transparent") c="#FFFFFF";
return(c);
}

function getBk(x){
var c=getStyleProp(x,"backgroundColor");
if(c==null || c=="transparent" || c.find("rgba(0, 0, 0, 0)"))
    return("transparent");
if(c.find("rgb")) c=rgb2hex(c);
return(c);
}

function getPadding(x,side){
var p=getStyleProp(x,"padding"+side);
if(p==null || !p.find("px")) return(0);
return(parseInt(p));
}

function getStyleProp(x,prop){
if(x.currentStyle)
    return(x.currentStyle[prop]);
if(document.defaultView.getComputedStyle)
    return(document.defaultView.getComputedStyle(x,'')[prop]);
return(null);
}

function rgb2hex(value){
var hex="",v,h,i;
var regexp=/([0-9]+)[, ]+([0-9]+)[, ]+([0-9]+)/;
var h=regexp.exec(value);
for(i=1;i<4;i++){
    v=parseInt(h[i]).toString(16);
    if(v.length==1) hex+="0"+v;
    else hex+=v;
    }
return("#"+hex);
}

function Mix(c1,c2){
var i,step1,step2,x,y,r=new Array(3);
if(c1.length==4)step1=1;
else step1=2;
if(c2.length==4) step2=1;
else step2=2;
for(i=0;i<3;i++){
    x=parseInt(c1.substr(1+step1*i,step1),16);
    if(step1==1) x=16*x+x;
    y=parseInt(c2.substr(1+step2*i,step2),16);
    if(step2==1) y=16*y+y;
    r[i]=Math.floor((x*50+y*50)/100);
    r[i]=r[i].toString(16);
    if(r[i].length==1) r[i]="0"+r[i];
    }
return("#"+r[0]+r[1]+r[2]);
}

/* End of Nifty Corners Cube Code */
/*
 * Określa bezwzględne położenie obiektu (współrzędna X)
 * by Peter-Paul Koch & Alex Tingle
 */
function findPosX(obj)
   {
   var curleft = 0;
   if (obj.offsetParent)
      while(1) 
        {
        curleft += obj.offsetLeft;
        if (!obj.offsetParent) break;
        obj = obj.offsetParent;
        }
   else if(obj.x) curleft += obj.x;
   return curleft - document.getElementById('Kontener').offsetLeft;	// uwaga: dostowano do układu nasz-uam.pl
   }

/*
 * Określa bezwzględne położenie obiektu (współrzędna Y)
 * by Peter-Paul Koch & Alex Tingle
 */
function findPosY(obj)
   {
   var curtop = 0;
   if (obj.offsetParent)
      while(1)
         {
         curtop += obj.offsetTop;
         if(!obj.offsetParent) break;
         obj = obj.offsetParent;
         }
   else if(obj.y) curtop += obj.y;
   return curtop - document.getElementById('Tresc').offsetTop;	// uwaga: dostowano do układu nasz-uam.pl
   }

/*
 * Wyświetla okienko (DIV) z podpowiedzią dla danego pola w obszarze podpowiedzi
 * Parametry: Edytowane pole, ID wiersza, w którym znajduje się pole
 */
function Form_ShowHint(Field, TrID)
   {
   var TD        = document.getElementById("ColH_" + TrID);
   var TR        = document.getElementById(TrID);
   var Form_Hint = document.getElementById('Form_Hint');
   
   Form_Hint.innerHTML    = "<div style='padding-left: 20px; padding-top: 2px'>" + Field.getAttribute('alt') + "</span>";
   Form_Hint.style.left   = findPosX(TD)    + 'px';
   Form_Hint.style.top    = findPosY(TD)    + 'px';
   Form_Hint.style.width  = TD.clientWidth  -26 + 'px';
   Form_Hint.style.minHeight = TD.offsetHeight - 6 + 'px';	// Minimalna wysokość ramki podpowiedzi - taka jak wysokość wiersza*/
   Form_Hint.style.visibility = "visible";
   }
   
/*
 * Ukrywa okienko (DIV) z podpowiedzią
 */   
function Form_HideHint()
   {
   var Form_Hint = document.getElementById('Form_Hint');
   Form_Hint.style.visibility = "hidden";
   }

// -------------------------------------------------------------------------------------------------------------
// OBSŁUGA WALIDACJI ONLINE
// -------------------------------------------------------------------------------------------------------------

var Form_ChangeQueue = Array();											// kolejka zmian
var Form_AjaxRequest = null;												// żądanie Ajax obsługujące sprawdzanie poprawności formularza
var TimerID          = setTimeout("Form_PageValidate()", 50);	// utwórz timer

/*
 * Inicjuje sprawdzanie poprawności dla danego pola
 * Parametry: Zmienione pole (onChange), ID wiersza, w którym znajduje sie pole
 */   
function Form_FieldChange(Field, TrID)
   {
   // Pobierz obiekty
      var TD          = document.getElementById("ColH_" + TrID);
   
   // Zaznacz, że pole jest sprawdzane (ikonka wToku w polu podpowiedzi)
      TD.className    = TD.className.replace(" Form_InfoKolPoprawne","");
      TD.className   += " Form_InfoKolSprawdzanie";  
      TD.innerHTML    = "";

   // Odłóż zmianę pola do kolejki
      var Record      = Array();
      Record["name"]  = Field.name;
      Record["value"] = Field.value;
      
      if (Field.type == 'checkbox')
      	{
      	if (Field.checked) Record["value"] = "true"; else Record["value"] = "";
      	}
      	
      Form_ChangeQueue.unshift(Record);
      
   // Przeprogramuj wywołanie funkcji sprawdzającej poprawność formularza
      clearTimeout(TimerID);
      TimerID = setTimeout("Form_PageValidate()", 750);      
   }   
   
/*
 * Inicjuje sprawdzanie poprawności strony poprzez mechanizm AJAX
 * Funkcja automatycznie wywoływana co 750ms poprzez Timer
 */
function Form_PageValidate()
   {
   // Sprawdź czy są zadania w kolejce
      if (Form_ChangeQueue.length == 0) return;

   // Odwróć kolejkę. Jeżeli nadpisano wartość tego samego pola kilka razy to ostatnia wartość jest najważniejsza (musi być najwcześniej w tablicy)
      Form_ChangeQueue.reverse();
         
   // Przygotuj żądanie AJAX
      Form_AjaxRequest = new Ajax('/Walidator', "Form_ReadXML");
      for (i = 0; i < Form_ChangeQueue.length; i++)
         {
         Form_AjaxRequest.AddVariable(Form_ChangeQueue[i]["name"],Form_ChangeQueue[i]["value"]);
         };
      
   // Ustaw funkcję zwrotną, wyślij żądanie AJAX
      Form_AjaxRequest.HTTPRequest.onreadystatechange = Form_ReadXML;
      Form_AjaxRequest.Send();
   
   // Wyczyść kolejkę
      Form_ChangeQueue.length = 0;
   }
   
function Form_FieldFadeOut(TdID, ImgID)
   {
   // Pobierz obiekty
      var TD          = document.getElementById(TdID);
      var IMG         = document.getElementById(ImgID);
   
   // Jeżeli obiekt IMG nie istnieje (może się tak zdarzyć gdy przed zakończeniem wyświetlania ikonki wprowadzono zmianę) to nic nie rób
      if (IMG == null) return;
   
   // Pobierz aktualny poziom przeźroczystości
      var Opacity     = IMG.style.opacity - 0.05;
      
   // Sprawdź czy ikonka powinna być jeszcze widoczna
      if (Opacity > 0)
         {
         // Ustaw nowy poziom przeźroczystości
            IMG.style.opacity = Opacity;
            IMG.style.filter  = "alpha(opacity=" + (Opacity * 100) + ")";

         // Zaprogramuj ponowne wywołanie funkcji
            setTimeout("Form_FieldFadeOut('" + TdID + "','" + ImgID + "')", 75);  
         }
      else
         {
         // Usuń element
            TD.innerHTML = "";
         }    
   }
      
function Form_ReadXML()
   {
   if ((Form_AjaxRequest.HTTPRequest.readyState == 4) && (Form_AjaxRequest.HTTPRequest.status == 200))
      {
      var xmldoc = Form_AjaxRequest.HTTPRequest.responseXML;
      var root_node = xmldoc.getElementsByTagName('element');

      for (var iNode = 0; iNode < root_node.length; iNode++) 
        {
        var element_node = root_node.item(iNode);
   
        // Odczytaj atrybuty z XML
           var t_id    = element_node.getElementsByTagName('id'   ); if (t_id.length)    t_id    = t_id.item(0).firstChild.data;    else t_id    = "";
           var t_class = element_node.getElementsByTagName('class'); if (t_class.length) t_class = t_class.item(0).firstChild.data; else t_class = "";
           var t_style = element_node.getElementsByTagName('style'); if (t_style.length) t_style = t_style.item(0).firstChild.data; else t_style = "";
           var t_html  = element_node.getElementsByTagName('html' ); if (t_html.length)  t_html  = t_html.item(0).firstChild.data;  else t_html  = null;
   
        // Pobierz docelowy element strony
           var E        = document.getElementById(t_id);
           var oldClass = E.className;
       
        // Obsługa *ikonki OK* (w kolumnie info) jeżeli sprawdzany wiersz uznany został za prawidłowy
           if (((oldClass.indexOf("Form_InfoKolSprawdzanie") != -1) && (t_class.indexOf("Form_InfoKolBlad") == -1))
           ||  ((oldClass.indexOf("Form_InfoKolBlad")        != -1) && (t_class.indexOf("Form_InfoKolBlad") == -1)))
              {
              if (t_html == null) t_html = "";
              t_html = "<img id='" + t_id + "Icon" + "' src='/Grafika/Framework/Form_IkonaOK.gif' style='opacity:1.0; filter:alpha(opacity=100)'>" + t_html;
              setTimeout("Form_FieldFadeOut('" + t_id + "','" + t_id + "Icon')",1250);
              }
              
        // Nadpisz atrybuty elementu strony
		     E.className = t_class;
           if (t_html != null) E.innerHTML = t_html;
		  }
      };
   }/*
 * Podstawowa obsługa mechanizmu AJAX
 * na podstawie strony: http://developer.mozilla.org/en/docs/AJAX:Getting_Started
 * uzupełnione o komunikację poprzez sloty IFRAME
 */

var Ajax_CurrentSlot = 1;
var Ajax_MaxSlots    = 4;

function Ajax(url, callback)
   {
   // Atrybuty publiczne
      this.Method           = "POST";			// Aktualnie: tylko POST
      this.IsAsynchronous   = true;				// 
      this.URL              = url;				//	
      
   // Atrybuty prywatne
      this.AjaxSlot         = null;				// slot (obiekt Ajax), który będzie wykorzystany do wysłania żądania)
      this.HTTPRequest      = null;				// obiekt żądania
   
   /*
    * Dodanie zmiennych do żądania
    */
   this.AddVariable = function(Name, Value)
      {
      this.AjaxSlot.AddVariable(Name, Value);
      }
   
   /*
    * Wysłanie żądania do serwera
    */ 
   this.Send = function()
      {
      this.AjaxSlot.Method         = this.Method;
      this.AjaxSlot.IsAsynchronous = this.IsAsynchronous;
      this.AjaxSlot.URL            = this.URL;
      
      this.AjaxSlot.Send();
      }
    
   /*
    * Kod konstruktora
    */
   if ((frames['AJAXSlot' + Ajax_CurrentSlot] == undefined) || (frames['AJAXSlot' + Ajax_CurrentSlot].Ajax == undefined))
      {
      // Jeżeli brak slotów lub sloty nie są jeszcze gotowe to utwórz połączenie bez użycia slotów
         this.AjaxSlot = new Ajax2(url, callback);   
         this.HTTPRequest = this.AjaxSlot.HTTPRequest;
      }
   else
      {
      // Wykorzystaj kolejny slot (cyklicznie)
         this.AjaxSlot = new frames['AJAXSlot' + Ajax_CurrentSlot].Ajax(url, callback);   
         this.HTTPRequest = this.AjaxSlot.HTTPRequest;
         Ajax_CurrentSlot++; if (Ajax_CurrentSlot > Ajax_MaxSlots) Ajax_CurrentSlot = 1;
      }
   }

function Ajax2(url, callback)
   {
   // Atrybuty publiczne
      this.Method           = "POST";			// Aktualnie: tylko POST
      this.IsAsynchronous   = true;				// 
      this.URL              = url;				//	
      
   // Atrybuty prywatne
      this.HTTPRequest      = null;				// obiekt żądania
      this.PostData         = "";            // łańcuch zmiennych w postaci POST (z1=w1&z2=w2...)
   
   /*
    * Dodanie zmiennych do żądania
    */
   this.AddVariable = function(Name, Value)
      {
      if (this.PostData.length > 0) this.PostData += '&';
      this.PostData += Name + "=" + encodeURIComponent(Value);
      }
      
   /*
    * Wysłanie żądania do serwera
    */ 
   this.Send = function()
      {
      this.HTTPRequest.open(this.Method, this.URL, this.IsAsynchronous);
      this.HTTPRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      this.HTTPRequest.setRequestHeader("Pragma", "no-cache");
		this.HTTPRequest.setRequestHeader("Cache-Control", "no-store, no-cache, must-revalidate, post-check=0, pre-check=0");
      this.HTTPRequest.send(this.PostData);
      }
    
   /*
    * Kod konstruktora
    */
   
      // Tworzenie obiektu this.HTTPRequest
         if (window.XMLHttpRequest) {this.HTTPRequest = new XMLHttpRequest(); if (this.HTTPRequest.overrideMimeType) this.HTTPRequest.overrideMimeType('text/xml'); } 
         else if (window.ActiveXObject) {try {this.HTTPRequest = new ActiveXObject("Msxml2.XMLHTTP");} catch (e) {try {this.HTTPRequest = new ActiveXObject("Microsoft.XMLHTTP");} catch (e) {} } }
   }
   
   /*
 *
 */
 
/*
 * Otwiera podany dokument w oknie
 */ 
var okno;
function Window(Dokument, Szerokosc, Wysokosc, NazwaOkna)
    {
    okno = window.open('',NazwaOkna,'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars,width='+(Szerokosc+20)+',height='+Wysokosc);
    okno.resizeTo(Szerokosc+20,Wysokosc);
    okno.location = Dokument;
    okno.focus();
    }
    
/*
 * Powoduje zanikanie obiektu (jego widoczności) od start[0-1] do stop[0-1] co krok step[0-1] wywoływane co interval[ms]
 * gdy HideAfter == true to ukrywa (display:none) element po zakończeniu procesu ściemniania
 */    
function Element_FadeOut(ID, Start, Stop, Step, Interval, HideAfter)
   {
   // Pobierz obiekty
      var Element     = document.getElementById(ID);
   
   // Pobierz aktualny poziom przeźroczystości
      var Opacity     = Math.round(Element.style.opacity * 100);
      if (Opacity == Start) Opacity = Opacity - Step;
      else                  Opacity = Start;
      
   // Sprawdź czy element powinna być jeszcze widoczna
      if (Opacity > Stop)
         {
         // Ustaw nowy poziom przeźroczystości
            Element.style.opacity = Opacity / 100.0;
            Element.style.filter  = "alpha(opacity=" + (Opacity) + ")";

         // Zaprogramuj ponowne wywołanie funkcji
            setTimeout("Element_FadeOut('" + ID + "'," + Opacity + "," + Stop + "," + Step + "," + Interval + "," + HideAfter + ")", Interval);  
         }
      else
         {
         // Ukryj element
            if (HideAfter) Element.style.display = "none";
         }    
   }
    
/*
 * Powoduje pojawianie się obiektu (jego widoczności) od start[0-1] do stop[0-1] co krok step[0-1] wywoływane co interval[ms]
 * Flaga ShowInHidden powoduje wymuszenie wyświetlenia obiektu (display:'')
 */    
function Element_FadeIn(ID, Start, Stop, Step, Interval, ShowIfHidden)
   {
   // Pobierz obiekty
      var Element     = document.getElementById(ID);
   
   // Pobierz aktualny poziom przeźroczystości
      var Opacity     = Math.round(Element.style.opacity * 100);
      if (Opacity == Start) Opacity = Opacity + Step;
      else                  Opacity = Start;
      
   // Sprawdź czy element powinna być jeszcze widoczna
      if (Opacity < Stop)
         {
         // Ustaw nowy poziom przeźroczystości
            Element.style.opacity = Opacity / 100.0;
            Element.style.filter  = "alpha(opacity=" + (Opacity) + ")";

         // Zaprogramuj ponowne wywołanie funkcji
            setTimeout("Element_FadeIn('" + ID + "'," + Opacity + "," + Stop + "," + Step + "," + Interval + ")", Interval);  
         }
         
   // Wyświetlenie obiektu - flaga ShowIfHidden
      if (ShowIfHidden) Element.style.display = '';         
   }
        /*
 * Szablon
 * Zapewnienie 100% wysokości strony
 */

function DostosujStrone() 
	{
   var Kontener 				= document.getElementById("Kontener");
   var Tresc    				= document.getElementById("Tresc");
   var Body                = document.getElementById("Body");

	// Zaokrąglij boki
	   Nifty("div.Gra_Kategorie_Ramka"     ,"normal transparent fixed-height right");
	   Nifty("div.Gra_Nominacje_Ramka"     ,"normal transparent fixed-height left");
	   Nifty("div.Gra_Rekomendacja_Ramka"  ,"normal transparent fixed-height left");
	   Nifty("div.Gra_OstatnioDodane_Ramka","normal transparent fixed-height left");
	   Nifty("div.Gra_LosoweGry_Ramka"		,"normal transparent fixed-height left");
	   Nifty("div.Gra_Gra_Ramka"				,"normal transparent fixed-height left");
	   Nifty("div#Wyroznienie_Info"        ,"normal transparent fixed-height right");

	   Nifty("a.Gra_SpisGier_Nawigacja_Strona"						,"normal transparent fixed-height bottom");
	   Nifty("a.Gra_SpisGier_Nawigacja_Strona_Wybrana"				,"normal transparent fixed-height bottom");
	   Nifty("a.Gra_SpisGier_Nawigacja_Strona_Niedostepna"		,"normal transparent fixed-height bottom");

	   Nifty("a.Gra_SpisGier_Nawigacja_Dzial"							,"normal transparent fixed-height top");
	   Nifty("a.Gra_SpisGier_Nawigacja_Dzial_Wybrany"				,"normal transparent fixed-height top");
	   Nifty("a.Gra_SpisGier_Nawigacja_Dzial_Niedostepny"			,"normal transparent fixed-height top");
	
   // Nie wykonuj dostosowania gdy elementy nie istnieją (np. strony wyświetlane w postaci okna)
	   if (Tresc == null) return;

   // Dostosuj wysokość obszaru treści   
      Body.style.display = '';
      var Wysokosc = (Kontener.clientHeight - 120 - 38 - 40);
      if (Wysokosc > 470) 
      	{
         Tresc.style.minHeight = Wysokosc + "px";
         }
      else
      	{
      	Tresc.style.minHeight = "470px";
      	};
	}

window.onload 	 = DostosujStrone;
window.onresize = DostosujStrone;


