
var openedRow = null;
var timerID = null;
var timerRunning = false;
var id,pause=0,position=0;
var hours, minutes, lastseconds;
var now, client, roznica;
var seconds;
var ile_start;
var godziny_start, minuty_start, sekundy_start;
var now;
var zmiana=false;


var ref_start = new Date("June 7, 2004, 06:00:00");
var ref_stop = new Date("June 8, 2004, 20:00:00");


var stan=0; //  0 - przed ref; 1 - w trakcie ref; 2 - po ref
var tekst; // tekst, który wyświetla się przed godzinami

var photos1=new Array()
var photos2=new Array()
var photos3=new Array()
var photos11=new Array()

var signer1 = new Array()
var signer2 = new Array()
var signer3 = new Array()
var signer4 = new Array()
var signer11 = new Array()

var which=1
var ktory=1

// tutaj zaczynają się funkcje, które otwierają topleyera

function hideOpole(){
				var obj = document.layers ? document.layers["opole_top"] :
				document.getElementById ?  document.getElementById("opole_top").style : document.all["opole_top"].style;
				obj.visibility = document.layers ? "hide" : "hidden";
				location.reload();
			}
		function SetCookie(cookieName,cookieValue,nDays) {
			var today = new Date();
			var expire = new Date();
			if (nDays==null || nDays==0) nDays=1;
			expire.setTime(today.getTime() + 3600000*24*nDays);
			document.cookie = cookieName+"="+escape(cookieValue)
		                 + ";expires="+expire.toGMTString();
			}


		function ReadCookie(cookieName) {
			var theCookie=""+document.cookie;
			var ind=theCookie.indexOf(cookieName);
			if (ind==-1 || cookieName=="") return ""; 
			var ind1=theCookie.indexOf(';',ind);
			if (ind1==-1) ind1=theCookie.length; 
			return unescape(theCookie.substring(ind+cookieName.length+1,ind1));
		}

		function test_cookie() {
			if(ReadCookie("Baner") == "") { 
				//alert("Wyswietlam baner");
				SetCookie("Baner",1,1);
				wyswietl_flash();
			}else{
				//alert("Baner byl wyswietlony" + ReadCookie("Baner"));
			}
			return false;
		}

		function wyswietl_flash() { 
	document.writeln('<div id="opole_top" style="position:absolute; z-index:5; width:400; height:300; left:220px; top:170px;">');
	document.writeln('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"');
	document.writeln('codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="400" height="300" id="toplayer_4_dzwiek" align="middle">');
	document.writeln('<param name="allowScriptAccess" value="sameDomain">');
	document.writeln('<param name="movie" value="swf/toplayer_400_300_08.swf">');
	document.writeln('<param name="quality" value="high">');
	document.writeln('<param name="scale" value="noscale">');
	document.writeln('<param name="wmode" value="opaque">');
	document.writeln('<param name="bgcolor" value="#060045">');
	document.writeln('<param name="FlashVars" value="adzamknij=javascript:hideOpole()">');
	document.writeln('<embed src="swf/toplayer_400_300_08.swf" FlashVars="adzamknij=javascript:hideOpole()" quality="high" bgcolor="#060045" scale="noscale"	wmode="opaque"');
	document.writeln(' width="400" height="300" name="toplayer_4_dzwiek" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"> </embed>');
	document.writeln(' </object>');
	document.writeln('</div>');


		}
// a tutaj kończą się funkcje, które otwierają topleyera		



function stopclock (){
        if(timerRunning)
                clearTimeout(timerID);
        timerRunning = false;
}

function ustaw_czas(){
	lastseconds=59;
	if (stan==0) {tekst="Wybory za:"; var start=ref_start;};
    if (stan==1) {
		tekst="DO KOŃCA:"; var start=ref_stop; 
		if (zmiana) {
			now = ref_start;
			zmiana=false; 
			roznica= client.getSeconds();
		}
	};
	if (stan==2) {tekst="WYBORY ZAKONCZONE"; var start=ref_stop;};
	
	ile_start = start.getTime() - now.getTime();

	godziny_start = Math.floor((ile_start) / (1000 * 60 * 60));
	var minuty_pom = Math.floor(ile_start / (1000 * 60));
	minuty_start = minuty_pom - godziny_start*60;
	var sekundy_pom = Math.floor(ile_start  / 1000);
	sekundy_start = sekundy_pom - minuty_start*60 - godziny_start*60*60;

	seconds = sekundy_start;
	hours = godziny_start;
        minutes = minuty_start;
	lastseconds = seconds;
}

function showtime () {

     	 client= new Date();
         var timeValue = "" + ((hours < 10) ? "0" : "") + hours + " h ";
         timeValue += ((minutes < 10) ? ":0" : ":") + minutes + " ";
         timeValue += ((seconds < 10) ? ":0" : ":") + seconds;
		 
		 
		 seconds = ((stan==0) ? 59 - client.getSeconds() - roznica : 59 - client.getSeconds() + roznica);
		 seconds = ((seconds < 0) ? 60 + seconds : seconds);
		 seconds = ((seconds > 59) ? seconds - 60: seconds);
		 
		 minutes -= ((seconds > lastseconds) ? 1 : 0);
		 lastseconds = seconds;
         
         hours -= ((minutes < 0) ? 1 : 0);		 
         minutes = ((minutes < 0) ? 59 : minutes); 		 
         hours = ((hours < 0) ? 0 : hours);

		 if (hours==0 && minutes==0 && seconds==0){
		 	stan +=1;
			zmiana=true;
			ustaw_czas();
		 	document.clock.txt.value = tekst;
			
			}
		 if (stan<2) {
			if((seconds % 10 )>5 ) { napis = "FREKWENCJA WYNIOSŁA " }
			else { napis = tekst + " " +timeValue; }
		 	  document.clock.txt.value = napis; 
              timerID = setTimeout("showtime()",500);
              timerRunning = true;	
			}
		 else {
			  document.clock.txt.value = tekst;
		 }	

}
function startclock (data) {
        var t;
		hours = 0;
		minutes = 0;
		lastseconds = 0;
        stopclock();
		now=new Date(data);
		client=new Date();
		ile_start = ref_start.getTime() - now.getTime();
		
		if (ile_start>0) {stan=0; roznica = now.getSeconds() - client.getSeconds();}
		if (ile_start<=0 && ile_start>-136800000) {stan=1; roznica = client.getSeconds() - now.getSeconds();}
		if (ile_start<=-136800000) {stan=2; roznica = client.getSeconds() - now.getSeconds();}
		ustaw_czas();
        	showtime();

}

function popup (img,sx,sy,num) {

                 var winl = (screen.width-sx)/2;

                 var wint = (screen.height-sy)/2;

    image = "<a href='javascript:self.close()'><img src='http://ww2.tvp.pl/tvppl/"+img+"' border='0' alt='Kliknij by zamknąć'></a>";

    popupwin=window.open("","num","location=no,directories=no,status=no,menubar=no,scrollbars,top="+wint+",left="+winl+",width="+sx+",height="+sy+"");

    popupwin.document.write("<HTML><HEAD><TITLE>" + num + "</TITLE></HEAD><BODY BGCOLOR=#FFFFFF><CENTER>" + image );
    popupwin.document.write("</CENTER></BODY></HTML>");

    popupwin.document.close();

}


function popup_gemius (img,sx,sy,num) {

                 var winl = (screen.width-sx)/2;

                 var wint = (screen.height-sy)/2;

    image = "<a href='javascript:self.close()'><img src='http://ww2.tvp.pl/tvppl/"+img+"' border='0' alt='Kliknij by zamknąć'></a>";

    popupwin=window.open("","num","location=no,directories=no,status=no,menubar=no,scrollbars,top="+wint+",left="+winl+",width="+sx+",height="+sy+"");

    popupwin.document.write("<HTML><HEAD><TITLE>" + num + "</TITLE></HEAD><BODY BGCOLOR=#FFFFFF><CENTER>" + image + "</CENTER></BODY></HTML>");

    popupwin.document.close();

}


function popup2 (img,sx,sy,num) {

                 var winl = (screen.width-sx)/2;

                 var wint = (screen.height-sy)/2;
				 
				 h='"http://www.mojemmsy.tvp.pl"';

    image = "<a href='javascript:opener.location.href=" +  h + ";self.close()'><img src='http://ww2.tvp.pl/tvppl/"+img+"' border='0' alt='Moje MMSy'></a>";

    popupwin=window.open("","num","toolbar=no,location=no,directories=no,status=no,menubar=no,top="+wint+",left="+winl+",width="+sx+",height="+sy+"");

    popupwin.document.write("<HTML><HEAD><TITLE>"+num+"</TITLE></HEAD><BODY LEFTMARGIN=0 RIGHTMARGIN=0 TOPMARGIN=0 BOTTOMMARGIN=0 MARGINWIDTH=0 MARGINHEIGHT=0 BGCOLOR=#FFFFFF><CENTER>" + image + "</CENTER></BODY></HTML>");

    popupwin.document.close();

}


function popup3 (img,sx,sy,num) {

                 var winl = (screen.width-sx)/2;

                 var wint = (screen.height-sy)/2;

    image = "<a href='javascript:self.close()'><img src='http://ww2.tvp.pl/tvppl/"+img+"' border='0' alt='Kliknij by zamknąć'></a>";

    popupwin=window.open("","num","location=no,directories=no,status=no,menubar=no,scrollbars=no,top="+wint+",left="+winl+",width="+sx+",height="+sy+"");

    popupwin.document.write("<HTML><HEAD><TITLE>"+num+"</TITLE></HEAD><BODY  LEFTMARGIN=0 RIGHTMARGIN=0 TOPMARGIN=0 BOTTOMMARGIN=0 MARGINWIDTH=0 MARGINHEIGHT=0 BGCOLOR=#FFFFFF><CENTER>" + image + "</CENTER></BODY></HTML>");

    popupwin.document.close();

}



    var puzzle = null; 
    function popup_puzle(url) { 
		if(puzzle && puzzle.open && !puzzle.closed){
			puzzle.focus();
		}else{
			var w = Math.min(screen.width-30, 1000);
			var h = Math.min(screen.height-70, 1000);
			puzzle = window.open(url,'puzz','width='+w+',height='+h+',resizable=1'); void(0); 
			var px = (screen.width-w)/2;
			puzzle.moveTo(px,5);
		}
	}


function window_open_center (url,title,sx,sy) {

                 var winl = (screen.width-sx)/2;

                 var wint = (screen.height-sy)/2;


    window.open(url,title,"toolbar=no,location=no,resizeable=yes,directories=no,status=no,scrollbars=yes,menubar=no,top="+wint+",left="+winl+",width="+sx+",innerWidth="+sx+",innerHeight="+sy+",height="+sy+"");

}


function window_open_center_v2 (url,title,sx,sy) {

                 var winl = (screen.width-sx)/2;

                 var wint = (screen.height-sy)/2;


    window.open(url,title,"toolbar=no,location=no,resizeable=no,directories=no,status=no,scrollbars=yes,menubar=no,top="+wint+",left="+winl+",width="+sx+",height="+sy+"");

}


function na_open_window (title,url,zm1,zm2,sx,sy,zm3,zm4,zm5,zm6,zm7) {

                 var winl = (screen.width-sx)/2;

                 var wint = (screen.height-sy)/2;


    window.open(url,title,"toolbar=no,location=no,resizeable=no,directories=no,status=no,scrollbars=no,menubar=no,top="+wint+",left="+winl+",width="+sx+",height="+sy+"");

}


function okno(url,id,w,h)
{
popup=window.open(url,id,'scrollbars=Yes,width='+w+',height='+h);



}

function okno2(url,id,w,h)
{
window.open(url,id,'scrollbars=No,width='+w+',height='+h);
}

function pasek(txt)
{
   window.status = txt;
   setTimeout("erase()",2000);
}
function erase() {
   window.status="";
}

function linka(href){
		if (href!='none') { top.location.href=href; }
}

function laduj_wot()
{
url='http://www.tvp.com.pl/wot/go.htm'; id='WOT';
window.open(url, id, 'scrollbars=No,resizable=1,width=547,height=480');
}
function forum_wiadomosc(form,parent) {
title = form.title.value;
nick = form.nick.value;
email = form.email.value;
note = form.note.value;

skrypt='forum/forum?parent=' + parent + '&title=' + title + '&nick=' + nick + '&email=' + email + '&note=' + note;

tytul='Forum';
window.open(skrypt, tytul, 'scrollbars=No,resizable=1,width=220,height=150');
}

function glosuj(id,idCat,Pkt) {
los=Math.random();
skrypt='poll/poll?id=' + id + '&idCat=' + idCat + '&Pkt=' + Pkt + '&los=' + los;
tytul='Głosowanie';
window.open(skrypt, tytul, 'scrollbars=No,resizable=1,width=220,height=150'); 
}


function zadaj_pytanie() {
pytanie = document.forms[2].pytanie.value;
podpis = document.forms[2].podpis.value;
email = document.forms[2].email.value;
document.forms[2].pytanie.value="";
document.forms[2].podpis.value="";
document.forms[2].email.value="";
skrypt='pytanie/pytanie?pytanie=' + pytanie + '&podpis=' + podpis + '&email=' + email;
tytul='Pytanie';
window.open(skrypt, tytul, 'scrollbars=No,resizable=1,width=220,height=150');
}

function otworz_w_okienku() {
  WinId = window.open('','NewWindow','scrollbars=No,resizable=1,width=220,height=150');
}


function ImageSrc(source,sign){
        this.source = source
        this.sign = sign
}

function newWindow(file,Okno,szerokosc,wysokosc) {
     msgWindow=open(file,Okno,'scrollbars=yes,resizable=yes,width='+szerokosc+',height='+wysokosc);
     if (msgWindow.opener == null) msgWindow.opener = self;

 }
function backward(position,obj,form){
	window.status=''
    	if (ktory>1){
		    ktory--
		    var photo = eval("photos"+position+"[ktory].source")
		    var sign = eval("photos"+position+"[ktory].sign")
		    obj.src=photo
		    form.sign.value=sign
		    }
	}

function forward(position,obj,form){
        photosLength=eval("photos"+position+".length")
	if (ktory<photosLength-1){
		ktory++
		var photo = eval("photos"+position+"[ktory].source")
		var sign = eval("photos"+position+"[ktory].sign")
		obj.src=photo
		form.sign.value=sign
	        }
}

function GoTo(form){
	var lista = form.category
	location=form.category.options[form.category.selectedIndex].value
}

function forum_wiadomosc1(form,parent) {
title = form.title.value;
nick = form.nick.value;
email = form.email.value;
note = form.note.value;

skrypt='forum/forum?parent=' + parent + '&title=' + title + '&nick=' + nick + '&email=' + email + '&note=' + note;

tytul='Forum';
window.open(skrypt, tytul, 'scrollbars=No,resizable=1,width=220,height=150');
}

function forum_wiadomosc_test() {
  WinId = window.open('','NewWindow','width=300,height=220,resizable=1,scrollbars=Yes');
}

// pop-up z obrazkiem w oknie pozbawionym marginesow
var jpg_okno;
function jpg_popup(url,tytul,opcje){
  if (jpg_okno){
    jpg_okno.close();
  }
  jpg_okno = window.open('',tytul,opcje);
  jpg_okno.document.open();
  jpg_okno.document.write("<HEAD><title>"+tytul+"</title></head><BODY style='margin-left:0; margin-top:0;'><IMG src="+url+"></body>");
  jpg_okno.document.close();
  jpg_okno.focus();
} 

