﻿if(navigator.userAgent.indexOf('Mac')==-1&&top!=self)top.location=self.location;

function $$(s) { return document.getElementById(s); }
function $$$(s) { 
	if ( s.substring(0,1) == '#' ){
		var a = document.getElementById(s.substr(1)) 
		if (a)
			return a;
	} else if ( s.substring(0,1) == '.' ) {
		var body = document.getElementsByTagName('body')[0];
		var a = body.getElementsByTagName('*');
		var w = new Array();
		var c = s.substring(1);
		for (var i=0; i<a.length; i++)
			if (hasClass(a[i],c))
				w.push(a[i]);
		return w;
	}else {
		var w = new Array();
		var a = document.getElementsByTagName(s);
		for (var i=0; i<a.length; i++)
			w.push(a[i]);
		return w;
	}
};

function trim(s) { return s.replace(/^\s+|\s+$/g, ""); };
function ExtractNumber(value) { var n = parseInt(value); return n == null || isNaN(n) ? 0 : n; }
function array_switch(arr) {
	if (!arr) return;
	var w=new Array();
	var len=arr.length;
	for (var i=0; i<len; i++) { 
		w[arr[i]]=i;
	}
	return w;
}

addEvent = function (obiekt, typ, funkcja) {
	if ( typeof funkcja != "function" )
		return false;
	if (obiekt.addEventListener)  {
    	obiekt.addEventListener(typ, funkcja, false);
  	}
	else if (obiekt.attachEvent) {
    	obiekt["e"+typ+funkcja] = funkcja;
    	obiekt[typ+funkcja] = function()  {
				obiekt["e"+typ+funkcja](window.event); 
			}
		obiekt.attachEvent("on"+typ, obiekt[typ+funkcja]);
  	}
	return obiekt;
}

function getEventObj(e) {
	var el;
	if (window.event && window.event.srcElement) { el = window.event.srcElement; }
	if (e && e.target) { el = e.target; }
	if (!el) { return; }					
	(e.preventDefault) ? e.preventDefault() : (e.returnValue = false);
	return el;
}
function getMousePosition(e) {
	var posx = 0;
	var posy = 0;
	if (!e) var e = window.event;
	if (e.pageX || e.pageY) {
		posx = e.pageX;
		posy = e.pageY;
	}
	else if (e.clientX || e.clientY) {
		posx = e.clientX + document.body.scrollLeft
			+ document.documentElement.scrollLeft;
		posy = e.clientY + document.body.scrollTop
			+ document.documentElement.scrollTop;
	}
	return ({'x': posx, 'y':posy});
}

function hasClass(obj,c) { 
	return obj.className.match(new RegExp('(\\s|^)'+c+'(\\s|$)')); 
}
function addClass (obj, c) {
	var e=obj;
	if (!this.hasClass(e,c)) { 
		if (!e.className) 
			e.className = c; 
		else { 
			var newClassName = e.className; 
			newClassName += " ";	
			newClassName += c; 
			e.className = newClassName; 
		}
	}
	return e;
}
function removeClass(obj,c) { 
	var e=obj;
	if (e.hasClass(c)) {
		var reg = new RegExp('(\\s|^)'+c+'(\\s|$)'); 
		e.className=e.className.replace(reg,' '); 
	} 
	return e;	
}
function changeClass(obj,a,b) {
	var e=obj;
	if ( e.hasClass(a) ) {
		e.addClass(b);
		e.removeClass(a);
		return e;
	}
	return false;
}
function setCookie(n,v,d) {
	if (d) {
		var date = new Date();
		date.setTime(date.getTime()+(d*24*60*60*1000));
		var e = "; expires="+date.toGMTString();
	}
	else var e = "";
	document.cookie = n+"="+v+e+"; path=/";
}
function getCookie(n) {
	var name = n + "=";
	var cc;
	var c = document.cookie.split(';');
	for(var i=0;i < c.length;i++) {
		cc = c[i];
		while (cc.charAt(0)==' ') cc = cc.substring(1,cc.length);
		if (cc.indexOf(name) == 0) return cc.substring(name.length,cc.length);
	}
	return false;
}
function delCookie(n) {
	setCookie(name,"deleted",-1);
}
function getUParam(par) {
	par=par.toLowerCase();
	qstr=new String(window.top.location.href);
	qstr=qstr.toLowerCase();
	if (qstr.indexOf('?')==-1 || qstr.indexOf(par+'=')==-1) return false;
	pstr=qstr.substring(qstr.indexOf('?')+1).substring(qstr.substring(qstr.indexOf('?')+1).indexOf(par+'=')+(par.length+1));
	return (pstr.indexOf('&')==-1)?pstr:pstr.substring(0,pstr.indexOf('&'));
}

function getPageSize() {
	/*
	var de = document.documentElement;
	return { 'width' : window.innerWidth || (de && de.clientWidth ) || document.body.clientWidth,
		'height' : window.innerHeight || (de && de.clientHeight ) || document.body.clientHeight };
	*/
	// rozmiary okna
	if( window.innerHeight  )  {
		pageWidth = window.innerWidth + window.scrollMaxX;
		pageHeight = window.innerHeight + window.scrollMaxY;
	}
	// all but Explorer Mac 
	else if( document.body.scrollHeight > document.body.offsetHeight ) {
		pageWidth = document.body.scrollWidth;
		pageHeight = document.body.scrollHeight;
	}
	// works in Explorer 6 Strict, Mozilla (not FF) and Safari
	else { 
		xScroll = document.getElementsByTagName("html").item(0).offsetWidth;
		yScroll = document.getElementsByTagName("html").item(0).offsetHeight;	
		pageWidth = (xScroll < document.body.offsetWidth) ? document.body.offsetWidth : xScroll; 
		pageHeight = (yScroll < document.body.offsetHeight) ? document.body.offsetHeight : yScroll; 
		//pageHeight = (document.getElementsByTagName("html").item(0).clientHeight == 0) ? document.body.clientHeight : document.getElementsByTagName("html").item(0).clientHeight;
	}
	return { 'width': pageWidth, 'height': pageHeight };
}

function setOpacity(obj, value) {
	obj.style.opacity = value/10;
	obj.style.filter = 'alpha(opacity=' + value*10 + ')';
}

function hide_objects() {
	var objs=document.getElementsByTagName('object');
	for (var i=0; i<objs.length; i++) {
		objs[i].style.visibility='hidden';
		objs[i].fBox_show='1';
	}
}
function show_objects() {
	var objs=document.getElementsByTagName('object');
	for (var i=0; i<objs.length; i++) {
		if ( objs[i].fBox_show=='1' ) {
			objs[i].style.visibility='';
		}
	}
}

function sh(obj) { 
	if ( !obj.style || obj.style.display=="block" ) 
		obj.style.display="none"; 
	else if ( obj.style.display=="none" ) 
		obj.style.display="block"; 
};

var z = "";
z = z+" !\"#$%&'()*+,-./0123456789:;<=>?@";
z = z+"AaĄąBbCcĆćDdEeĘęFfGgHhIiJjKkLlŁłMmNnŃńOoÓó";
z = z+"PpQqRrSsŚśTtUuVvWwXxYyZzŹźŻż[\\]^_`{|}~";
z=z.split('');
z=array_switch(z);

function porownajPL(a,b) {
	a=new String(a);
	b=new String(b);
	var a_tab = a.split('');
	var b_tab = b.split('');
	for (var i=0, a_ile=a_tab.length; i<a_ile; i++) {
		if (z[a_tab[i]] > z[b_tab[i]])
			return 1;
		else if (z[a_tab[i]] < z[b_tab[i]])
			return -1;
	}
	return 0;
}

function echo(s) { document.write(s); }
function echoN(s) { document.write(s +'<br />'); }
function echoA(tab) {
	for (var i=0; i<tab.length; i++) 
		echo (i+' -> '+tab[i]+'<br/>');
}

function wups(wloc,wdth,hght) { 
	if(wdth==0)wdth=620;
	if(hght==0)hght=630;
	var paramki='menubar=no, toolbar=no, location=yes, width='+wdth+', height='+hght+', left=30, top=30, scrollbars=yes, status=yes, resizable=yes';
	var namik=wloc.substring(wloc.lastIndexOf('=')+1);
	if(namik.length>10)namik='openedW';
	nwin=window.open(wloc,namik,paramki);
	nwin.focus();
}



