//TEXT SELECT DISABLING
function redisable(e) { //NS
  return false;
}

function reenable() { //NS
  return true;
}

if (window.sidebar) { //NS
  document.onmousedown=disableselect;
  document.onclick=reenable;
}

document.onselectstart=new Function ("return false"); //IE

function enableselect() {
  document.onselectstart=new Function ("return true"); //IE
  document.onmousedown=reenable; //NS
}

function disableselect() {
  document.onselectstart=new Function ("return false"); //IE
  document.onmousedown=redisable; //NS
}

//RUNNING SCROLLER
function checkBrowser(){
	this.ver=navigator.appVersion
	this.dom=document.getElementById?1:0
	this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom)?1:0;
    this.ie4=(document.all && !this.dom)?1:0;
    this.ns5=(this.dom && parseInt(this.ver) >= 5) ?1:0;
    this.ns4=(document.layers && !this.dom)?1:0;
    this.bw=(this.ie5 || this.ie4 || this.ns4 || this.ns5)
    return this
}
bw=new checkBrowser()
//The pixel value of where you want the layer to start (from the top)
lstart=50;
//Set this to false if you just want it to go one time
loop=true 
//Set the speed, lower value gives more speed
speed=40
//Set this to how many pixels you want it to go for each step, this also changes the speed.    
pr_step=1
//Object constructor
function makeObj(obj,nest){
   nest=(!nest) ? '':'document.'+nest+'.'
    this.el=bw.dom?document.getElementById(obj):bw.ie4?document.all[obj]:bw.ns4?eval(nest+'document.'+obj):0;
      this.css=bw.dom?document.getElementById(obj).style:bw.ie4?document.all[obj].style:bw.ns4?eval(nest+'document.'+obj):0;
    this.scrollHeight=bw.ns4?this.css.document.height:this.el.offsetHeight
    this.newsScroll=newsScroll;
    this.moveIt=b_moveIt; this.x; this.y;
   this.obj = obj + "Object"
   eval(this.obj + "=this")
   return this
}
function b_moveIt(x,y){
    this.x=x;this.y=y
    this.css.left=this.x
    this.css.top=this.y
}
//Makes the object scroll up
function newsScroll(speed){
    if(this.y>-this.scrollHeight){
         this.moveIt(0,this.y-pr_step)
         setTimeout(this.obj+".newsScroll("+speed+")",speed)
    }else if(loop) {
         this.moveIt(0,lstart)
         eval(this.obj+".newsScroll("+speed+")")
      }
}
//Makes the object
function newsScrollInit(){
    oNewsCont=new makeObj('divNewsCont')
    oNewsScroll=new makeObj('divNewsText','divNewsCont')
    oNewsScroll.moveIt(0,lstart)
    oNewsCont.css.visibility='visible'
    oNewsScroll.newsScroll(speed)
}

//ENLARGING PHOTOS & DOCUMENTS
function enlarge(f,w,h,s) {
	if (typeof(wdw) != 'undefined') wdw.close();
	if (w>h) {
		w+=30; h+=100;
		wdw=window.open('',"wenlarge","titlebar=no,toolbar=no,status=no,location=no,menubar=yes,resizable=no,scrollbars="+s+",width="+w+",height="+h);
		wdw.document.write('<HTML><HEAD><META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=windows-1250"><LINK REL="stylesheet" HREF="../sheet.css" TYPE="text/css"></HEAD><BODY MARGINHEIGHT="0" MARGINWIDTH="0" BOTTOMMARGIN="0" LEFTMARGIN="0" RIGHTMARGIN="0" TOPMARGIN="0" CLASS="main"><TABLE CELLSPACING="0" CELLPADDING="0" WIDTH="100%" HEIGHT="100%"><TR CLASS="header2"><TD HEIGHT="50"><IMG SRC="./layout/header_1_0st.jpg" HSPACE="20"></TD><TD ALIGN="right"><IMG SRC="./layout/header_2_0st.jpg" HSPACE="30"></TD></TR><TR><TD COLSPAN="2" HEIGHT="2" CLASS="border"></TD></TR><TR><TD COLSPAN="2" ALIGN="center"><IMG BORDER="1" SRC="'+f+'"></TD></TR><TR><TD HEIGHT="25" COLSPAN="2" ALIGN="right"><A CLASS="afooter" HREF="javascript:self.close();">ZAMKNIJ OKNO</A>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD></TR></TABLE></BODY></HTML>');
	} else {
		w+=100; h+=30;
		wdw=window.open('',"wenlarge","titlebar=no,toolbar=no,status=no,location=no,menubar=yes,resizable=no,scrollbars="+s+",width="+w+",height="+h);
		wdw.document.write('<HTML><HEAD><META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=iso-8859-2"><LINK REL="stylesheet" HREF="../sheet.css" TYPE="text/css"></HEAD><BODY MARGINHEIGHT="0" MARGINWIDTH="0" BOTTOMMARGIN="0" LEFTMARGIN="0" RIGHTMARGIN="0" TOPMARGIN="0" CLASS="main"><TABLE CELLSPACING="0" CELLPADDING="0" WIDTH="100%" HEIGHT="100%"><TR><TD WIDTH="50" VALIGN="middle" ALIGN="center" CLASS="header2"><IMG SRC="./layout/header_2_90st.jpg"></TD><TD ROWSPAN="3" WIDTH="2" CLASS="border"></TD><TD ROWSPAN="3" ALIGN="center"><IMG BORDER="1" SRC="'+f+'"></TD></TR><TR><TD VALIGN="top" CLASS="header2"><IMG SRC="./layout/header_1_90st.jpg" VSPACE="20"></TD></TR><TR><TD VALIGN="bottom" ALIGN="center" CLASS="header2"><A CLASS="afooter" HREF="javascript:self.close();">ZAMKNIJ<BR>OKNO</A></TD></TR></TABLE></BODY></HTML>');
	} 
	wdw.focus();
}

//HIGHLATING MENU ITEMS
var lastItem=0;
var lastItem2=0;
var lastInnerHTML;
var lastInnerHTML2;

function showDiv(t,n) {
var elem,num,color,empty,elem2;

	//disallow fading links & clear already starded fade
	fadeAllowed = false;
	var i = 1; 
	while (i<fadeId.length) {
		clearTimeout(fadeId[i]);
		i++;
	}
		
	switch (t) {
		case 'menu':
			num=labelOfMenuItem.length-1;
			color='#B0D1D8';
			if (lastItem>0) {
				elem=t+lastItem+'a';
				document.getElementById(elem).innerHTML=lastInnerHTML;
				elem=t+lastItem+'td';
				document.getElementById(elem).style.color=color;
			}
			break;
		case 'sub':
			num=8;
			color='#B0D1D8';
			if (lastItem>0) {
				elem=t+lastItem+'a';
				document.getElementById(elem).innerHTML=lastInnerHTML;
				elem=t+lastItem+'td';
				document.getElementById(elem).style.color=color;
			}
			break;
		case 'subsec':
			num=8;
			color='#B0D1D8';
			if (lastItem2>0) {
				elem=t+lastItem2+'a';
				document.getElementById(elem).innerHTML=lastInnerHTML2;
				elem=t+lastItem2+'td';
				document.getElementById(elem).style.color=color;
			}
			break;
	}
	for (i=1;i<=num;i++) {
		if (i==1) empty=true;
		elem=t+i;
		if (i==n) {
			elem2=elem;
			elem=elem+'a';
			if (document.getElementById(elem).innerHTML.indexOf('<!-- wolne -->')==-1) empty=false;
			if (!empty) {
				document.getElementById(elem2).style.visibility='visible';
				switch (t) {
					case 'menu':
						document.getElementById(elem).style.background='#2C4889';
						lastItem=i;
						lastInnerHTML=document.getElementById(elem).innerHTML;
						break;
					case 'sub':
						document.getElementById(elem).style.backgroundImage='url(./layout/sub_4.jpg)';
						document.getElementById(elem).style.backgroundRepeat='repeat-y';
						lastItem=i;
						lastInnerHTML=document.getElementById(elem).innerHTML;
						break;
					case 'subsec':
						document.getElementById(elem).style.backgroundImage='url(./layout/sub_4.jpg)';
						document.getElementById(elem).style.backgroundRepeat='repeat-y';
						lastItem2=i;
						lastInnerHTML2=document.getElementById(elem).innerHTML;
						break;
				}
						document.getElementById(elem).innerHTML=document.getElementById(elem).innerHTML.substring(document.getElementById(elem).innerHTML.indexOf('>')+1,document.getElementById(elem).innerHTML.lastIndexOf('<'));
				elem=elem+'r';
				document.getElementById(elem).style.background='#2C4889';
			} else {
				document.getElementById(elem2).style.visibility='hidden';
						document.getElementById(elem).innerHTML=document.getElementById(elem).innerHTML.substring(document.getElementById(elem).innerHTML.indexOf('>')+1,document.getElementById(elem).innerHTML.lastIndexOf('<'));
				elem=elem+'r';
				document.getElementById(elem).style.background='#5A7BB0';
			}

		}	else {
			document.getElementById(elem).style.visibility='hidden';
			elem=elem+'a';
			if (document.getElementById(elem).innerHTML.indexOf('<!-- wolne -->')==-1) empty=false;
			if (!empty) {
				switch (t) {
					case 'menu':
						document.getElementById(elem).style.background='#4A68A4';						
						break;
					case 'sub':
						document.getElementById(elem).style.backgroundImage='url(./layout/sub_5.jpg)';
						document.getElementById(elem).style.backgroundRepeat='repeat-y';
						break;
					case 'subsec':
						document.getElementById(elem).style.backgroundImage='url(./layout/sub_5.jpg)';
						document.getElementById(elem).style.backgroundRepeat='repeat-y';
						break;
				}
				elem=elem+'r';
				document.getElementById(elem).style.background='#4A68A4';
			}
		} 
	}
	
	//allow fading links
	fadeAllowed = true;
}

//CALCULATING PAGES WIDTH
function properWidth(mn) {
var size1=800;
var size2=1024;
var safe=40;
	if (screen.width>size1) return size2-mn-safe; else return size1-mn-safe;
	/*if (window.innerWidth) { //NS
		if (window.innerWidth>size1) return size2-mn-safe; else return size1-mn-safe;
	} else { //IE
		if (document.body.offsetWidth>size1) return size2-mn-safe; else return size1-mn-safe;
	}*/
} 

//MAP
function MM_showHideLayers() {
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) {
		obj=document.getElementById(args[i]);
		v=args[i+2];
   	if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v;
	}
}

function P7_autoLayers() {
	var g,b,k,f,args=P7_autoLayers.arguments;
	var a = parseInt(args[0]);if(isNaN(a))a=0;
	if(!document.p7setc) {
 		p7c=new Array();
		document.p7setc=true;
  	for (var u=0;u<10;u++) p7c[u] = new Array();
	}
 	for(k=0; k<p7c[a].length; k++) {
  	g=document.getElementById(p7c[a][k]);
   	b=(document.layers)?g:g.style;b.visibility="hidden";
	}
 	for(k=1; k<args.length; k++) {
		if (args[k]!='') {
  		g=document.getElementById(args[k]);
   		b=(document.layers)?g:g.style;b.visibility="visible";f=false;
   		for(j=0;j<p7c[a].length;j++) {
    		if(args[k]==p7c[a][j]) {f=true;}
			}
  		if(!f) {p7c[a][p7c[a].length++]=args[k];}
		}
	}
}

//FORCE FRAMES
function forceFrames() {
	if (window.self==parent.window) {
		var str=location.href.substring(location.href.lastIndexOf('/')+1,location.href.length);
		location.replace('./index.html'+'#'+str);
	}
}
function findIndexes(str) {
var str2;
	while (str.indexOf('%20')>-1) str = str.replace('%20',' ');
	for (i=1;i<submenuItem.length;i++) {
		for (j=1;j<submenuItem[i].length;j++) {
			str2 = submenuItem[i][j]['link'];
			if (str2.substring(str2.lastIndexOf('/')+1,str2.length)==str) {
				m=i;
				s=j;
				found=true;
			}
		}
	}
	for (i=1;i<submenuItem2.length;i++) {
		for (j=1;j<submenuItem2[i].length;j++) {
			if (typeof(submenuItem2[i][j]) != 'undefined') {//nie wszystkie majš podmenu2
				for (k=1;k<submenuItem2[i][j].length;k++) {
					str2 = submenuItem2[i][j][k]['link'];
					if (str2.substring(str2.lastIndexOf('/')+1,str2.length)==str) {
						m=i;
						s=j;
						l=k;
						found=true;
					}
				}
			}
		}
	}
}
