// ### skrypty java wykorzystane na stronie

// 2leveltab (menu)

var mastertabvar=new Object()
mastertabvar.baseopacity=0
mastertabvar.browserdetect=""

function showsubmenu(masterid, id){
if (typeof highlighting!="undefined")
clearInterval(highlighting)
submenuobject=document.getElementById(id)
mastertabvar.browserdetect=submenuobject.filters? "ie" : typeof submenuobject.style.MozOpacity=="string"? "mozilla" : ""
hidesubmenus(mastertabvar[masterid])
submenuobject.style.display="block"
instantset(mastertabvar.baseopacity)
highlighting=setInterval("gradualfade(submenuobject)",10)
}

function hidesubmenus(submenuarray){
for (var i=0; i<submenuarray.length; i++)
document.getElementById(submenuarray[i]).style.display="none"
}

function instantset(degree){
if (mastertabvar.browserdetect=="mozilla")
submenuobject.style.MozOpacity=degree/100
else if (mastertabvar.browserdetect=="ie")
submenuobject.filters.alpha.opacity=degree
}


function gradualfade(cur2){
if (mastertabvar.browserdetect=="mozilla" && cur2.style.MozOpacity<1)
cur2.style.MozOpacity=Math.min(parseFloat(cur2.style.MozOpacity)+0.1, 0.99)
else if (mastertabvar.browserdetect=="ie" && cur2.filters.alpha.opacity<100)
cur2.filters.alpha.opacity+=10
else if (typeof highlighting!="undefined") //fading animation over
clearInterval(highlighting)
}

function initalizetab(tabid){
mastertabvar[tabid]=new Array()
var menuitems=document.getElementById(tabid).getElementsByTagName("li")
for (var i=0; i<menuitems.length; i++){
if (menuitems[i].getAttribute("rel")){
menuitems[i].setAttribute("rev", tabid) //associate this submenu with main tab
mastertabvar[tabid][mastertabvar[tabid].length]=menuitems[i].getAttribute("rel") //store ids of submenus of tab menu
if (menuitems[i].className=="selected")
showsubmenu(tabid, menuitems[i].getAttribute("rel"))
menuitems[i].getElementsByTagName("a")[0].onclick=function(){
showsubmenu(this.parentNode.getAttribute("rev"), this.parentNode.getAttribute("rel"))
for (var i=0; i<menuitems.length; i++){menuitems[i].className="";}
this.parentNode.className="selected";
}
}
}
}

// Funkcja do zmiany obrazków po najechaniu na link w liscie wywiadów po prawej


function toggleButton(ktory,ile,id_obrazka,f,q) {
for (i=0; i<ile; i++) {
eval("wybor"+i).className="";
}
if (document.getElementById) {
eval(document.getElementById("wybor"+ktory)).className = "active";
document.getElementById(id_obrazka).setAttribute('src',f + q+'.jpg') 
}
else if (document.all) {
eval(document.all["wybor"+ktory]).className = "active";
document.all[id_obrazka].setAttribute('src',f + q+'.jpg')
}
}


// Funkcja do zakładek po prawej stronie

function showmenu(submenu) { 
	if (document.layers) {
		document.layers[submenu].visibility = "show"
	} else if (document.all) {
		document.all[submenu].style.visibility = "visible"
	} else if (document.getElementById) {
		document.getElementById(submenu).style.visibility="visible"
	} else {
		if (document.layers) document.layers[submenu].visibility = "hide"
		else if (document.all) document.all[submenu].style.visibility = "hidden"
	}
}

function hidemenu(submenu) {
	if (document.layers) {
		if (document.layers[submenu].visibility = "show") {
			document.layers[submenu].visibility = "hide"
		}
	} else if (document.all) {
		if (document.all[submenu].style.visibility = "visible") {
			document.all[submenu].style.visibility = "hidden"
		}
	} else if (document.getElementById) {
		document.getElementById(submenu).style.visibility="hidden"
	}
}
function hideLayer(whichLayer) {
		if (document.getElementById) {
			document.getElementById(whichLayer).style.display = "none";
		}
		else if (document.all) {
			document.all[whichlayer].style.display = "none";
		}
		else if (document.layers) {
			document.layers[whichLayer].display = "none";
		}
	}

function showLayer(whichLayer) {
		if (document.getElementById) {
			document.getElementById(whichLayer).style.display = "block";
		}
		else if (document.all) {
			document.all[whichlayer].style.display = "block";
		}
		else if (document.layers) {
			document.layers[whichLayer].display = "block";
		}
	}
function toggleButy(ktory) {
	popy101.className="";
	popy102.className="";
	popy103.className="";
		if (document.getElementById) {
			document.getElementById(ktory).className = "active";
		}
		else if (document.all) {
			document.all[ktory].className = "active";
		}
}
function toggleBut(ktory) {
	popx101.className="";
	popx102.className="";
	popx103.className="";
	popx104.className="";
		if (document.getElementById) {
			document.getElementById(ktory).className = "active";
		}
		else if (document.all) {
			document.all[ktory].className = "active";
		}
}


// Funkcja do otwierania okienek

 function pop_window(url) {
 //remove a attribute if you don't want it to show up
  var popit = window.open(url,'console','menubar,toolbar,location,directories,status=no,scrollbars,resizable,width=1000,height=880');
 }



// Funkcja do warstw (używam na podstronach)

function doSection (secNum){
//display the section if it's not displayed; hide it if it is displayed
if (secNum.style.display=="none"){secNum.style.display=""}
else{secNum.style.display="none"}
}
function noSection (secNum){
//remove the section when user clicks in the opened DIV
if (secNum.style.display==""){secNum.style.display="none"}
}

 function pop_album(url) {
   var popit = window.open('/konkursy/album/index.html','live','menubar=no,toolbar=no,location=no,directories=no,status=no,scrollbars,resizable,width=505,height=450');
 }



 function pop_czat(url) {
   var popit = window.open('/czat.html','Czat','menubar=no,toolbar=no,location=no,directories,status,scrollbars=no,resizable,width=760,height=710');
 }



 function pop_live(url) {
   var popit = window.open('http://www.skijumping.pl/live','live','menubar=no,toolbar=no,location=no,directories=no,status=no,scrollbars,resizable,width=1050,height=760');
 }


 function pop_live_coc(url) {
   var popit = window.open('http://berkutschi.com/pl/front/live_ticker/index2/3026','coc','menubar=no,toolbar=no,location=no,directories=no,status=no,scrollbars,resizable,width=805,height=600');
 }
 
 function pop_live_lcoc(url) {
   var popit = window.open('http://berkutschi.com/de/front/live_ticker/index/3174','coc','menubar=no,toolbar=no,location=no,directories=no,status=no,scrollbars,resizable,width=805,height=600');
 }



 function pop_video(url) {
   var popit = window.open('/video_pop.php?id_pliku=' + url,'Multimedia','resizable,width=520,height=390');
 }



 function pop_wyniki(url) {
   var popit = window.open(url,'wyniki','menubar=no,toolbar=no,location=no,directories=no,status=no,scrollbars,resizable,width=625,height=750');
 }




 function pop_wyniki_plik(url) {
   var popit = window.open(url,'wyniki','menubar=no,toolbar=no,location=no,directories=no,status=no,scrollbars,resizable,width=800,height=550');
 }


// Funkcja do potwierdzenia zgloszenia do moderacji
function zglos(ktory) {
var czyRobot=document.getElementById("zglospassword").value
submitOK=true
if (czyRobot.length>0) { submitOK=false }

if (confirm("Czy napewno chcesz zgłosic komentarz do moderacji?") && submitOK)
	{
	document.getElementById("zglos").elements["zglosid"].value=ktory
	document.getElementById("zglos").submit()
	}
}


var confirmMsg=true;
function confirmLink(theLink, theSqlQuery)
{
    // Confirmation is not required in the configuration file
    var confirmMsg="Czy napewno chcesz";

    var is_confirmed = confirm(confirmMsg + ' :\n' + theSqlQuery);
    if (is_confirmed) {
        theLink.href += '&is_js_confirmed=1';
    }

    return is_confirmed;
} // end of the 'confirmLink()' function

var before=""

var montharray=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")

function countdown(yr,m,d){
var today=new Date()
var todayy=today.getFullYear()
var todaym=today.getMonth()
var todayd=today.getDate()
var todaystring=montharray[todaym]+" "+todayd+", "+todayy
var futurestring=montharray[m-1]+" "+d+", "+yr
var difference=(Math.round((Date.parse(futurestring)-Date.parse(todaystring))/(24*60*60*1000))*1)
if (difference==0)
document.write(current)
else if (difference>0)
document.write(""+difference+
" dni"+before)
}
