<!--
// 2010.02.17
//-------------------------- globalne -----------------------------
function addBookmark(url, title)
{
	if (window.sidebar)
		window.sidebar.addPanel(title, url,"");
	else if( document.all)
		window.external.AddFavorite(url,title);

	return false;
}

function ffcopy(text)
{
	try
	{
		netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
		var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);
		if (!clip) return false;

		var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);
		if (!trans) return false;

		trans.addDataFlavor('text/unicode');

		var str = new Object();
		var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);

		var copytext=text;
		str.data=copytext;

		trans.setTransferData("text/unicode",str,copytext.length*2);

		var clipid=Components.interfaces.nsIClipboard;
		if (!clip) return false;
		clip.setData(trans,null,clipid.kGlobalClipboard);

		return true;
	}
	catch (exception)
	{
		return false;
	}
	return true;
}

function _htmlentities(text, amp, quot, apostrophe, less_than, greater_than)
{
	if (!text.length) return text;
	if (amp) text=text.replace(/&/g,'&amp;');
	if (quot) text=text.replace(new RegExp('"','g'),'&quot;');
	if (apostrophe) text=text.replace(/\'/g,'&#39;');
	if (less_than) text=text.replace(/</g,'&lt;');
	if (greater_than) text=text.replace(/>/g,'&gt;');
	return text;
}

function _addshlashes(text)
{
	text=text.replace(/&#39;/g,'\&#39;');
	return text;
}

function Object2Text(option)
{
	var text=null;
	var out=Array();
	var i=0;

	for (field in option)
	{
		if(typeof(option[field])=="number")
			out[i]="&#39;"+field+"&#39;:"+option[field];
		else
		{
			if (option[field].length) text=_htmlentities(option[field], 1, 0, 0, 0, 0);
			out[i]="&#39;"+field+"&#39;:&#39;"+text+"&#39;";
		}
		i++;
	}

	out.join(', ');
	out='{'+out+'}';
	return out;
}

function check(fields, regs, mess)
{
	for (i=0; i<fields.length; i++)
		if (!fields[i].value.match(regs[i]))
		{
			Message(mess[i]);
			fields[i].focus();
			return false;
		}
	return true;
}

var mouse=0
function mouseDown(e) 
{
	var ctrl=0;
	var alt=0;
	var shift=0;
 
	if (parseInt(navigator.appVersion)>3) 
	{
		if (navigator.appName=="Netscape") 
		{
			shift=(e.shiftKey)?4:0;
			alt=(e.altKey)?2:0;
			ctrl=(e.ctrlKey)?1:0;
		}
		else
		{
			shift=event.shiftKey;
			alt =event.altKey;
			ctrl=event.ctrlKey;
		}
		mouse=shift+alt+ctrl;
	}

	return true;
}

if (parseInt(navigator.appVersion)>3) 
	document.onmousedown = mouseDown;

var win = new Array();
function WinOpen(nr,path,title,sx,sy, sc)
{
	if (win[nr]!=null && !win[nr].closed) 
		win[nr].close();

	if (!sc)
	{
		if (sx>(screen.width-100)) sx=screen.width-100;
		if (sy>(screen.height-100)) sy=screen.height-100;
	}

	if (sx && sx<250) sx=250;	//popup < 250 ff ¼le wywietlany

	if (sx!=0 && sy!=0)
	{
		sl = (screen.width-sx)/2;
		st = (screen.height-sy)/2;
		win[nr] = window.open(path,title,'left='+sl+',top='+st+',width='+sx+',height='+sy+',scrollbars=yes,resizable=yes,status=no');
		if (win[nr]) win[nr].focus();
	}
	
	return false;
}

var upload_win = null;

function UploadWinOpen()
{
	if (upload_win!=null && !upload_win.closed) upload_win.close();

	upload_win = window.open('./upload.php','Upload','left=100,top=100,scrolling=no,width=350,height=250,scrollbars=no,resizable=no,status=no');
	upload_win.focus();
}

function UploadWinClose()
{
	if (upload_win!=null && !upload_win.closed) upload_win.close();
}

function WinResizeTo(sx, sy)
{
	if (sx>(screen.width-100)) sx=screen.width-100;
	if (sy>(screen.height-100)) sy=screen.height-100;
	if (sx && sx<200) sx=200;	//popup < 200 ff ¼le wywietlany

	window.resizeTo(sx,sy);
}

function ToolTipShow(elem, text)
{
	if (!(newElem=document.getElementById('tooltip1')))
	{
		var newElem = document.createElement("div");
		newElem.setAttribute("id", "tooltip1");
		newElem.setAttribute("style", "visibility: visible; ");
		document.body.appendChild(newElem);
	}

	var x=elem.offsetLeft;
	var y=elem.offsetTop+elem.offsetHeight;

	var parent = elem;
	while (parent.offsetParent) {
		parent = parent.offsetParent;
		x += parent.offsetLeft;
		y += parent.offsetTop ;
	}

	newElem.style.visibility = "visible" ;
	newElem.style.backgroundColor= "#CCCC00" ;
	newElem.style.position = "absolute";
	newElem.style.left = x+"px";
	newElem.style.top = y+"px";
	newElem.innerHTML="<table ><tr><td>"+text+"</td></tr></table>";

	return false;
}

function ToolTipHide()
{
	var elem;
	if (elem=document.getElementById('tooltip1'))
		elem.style.visibility = "hidden" ;

	return false;
}

function setCookie(c_name, value, expiredays)
{
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	document.cookie=c_name+ "=" +escape(value)+((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}

function getCookie(c_name)
{
	if (document.cookie.length>0)
	{
		c_start=document.cookie.indexOf(c_name + "=");
		if (c_start!=-1)
		{ 
			c_start=c_start + c_name.length+1; 
			c_end=document.cookie.indexOf(";",c_start);
			if (c_end==-1) c_end=document.cookie.length;
			return unescape(document.cookie.substring(c_start,c_end));
		} 
	}
	return "";
}

function getStyle(el, styleProp)
{
	var x;

	if (typeof(el) == 'string')
		x = document.getElementById(el);
	else
		x = el;


	if (x.currentStyle)
	{
		switch (styleProp)
		{
			case 'font-size':
				styleProp='fontSize';
				break;
			case 'margin-top':
				styleProp='marginTop';
				break;
			case 'margin-bottom':
				styleProp='marginBottom';
				break;
		}
		return x.currentStyle[styleProp];
	}
	else if (window.getComputedStyle)
	{
		switch (styleProp)
		{
			case 'fontSize':
				styleProp='font-size';
				break;
			case 'marginTop':
				styleProp='margin-top';
				break;
			case 'marginBottom':
				styleProp='margin-bottom';
				break;
		}
		if (x.nodeName!="#text")
			return document.defaultView.getComputedStyle(x, null).getPropertyValue(styleProp);
	}
	return 0;
}

var startAAA = Array();
var defaultAAA = Array();

function AAA(trgt, inc, start)
{
	if (!document.getElementById) return;
	var d, fontSize, index;

	for (var i=0; i<trgt.length; i++)
	{
		d = document.getElementById(trgt[i])

		if (!defaultAAA[trgt[i]])
		{
			fontSize = getStyle(trgt[i],'fontSize');

			if (fontSize.indexOf('px')!=-1)
			{
				index = fontSize.indexOf('px')
				fontSize = fontSize.substr(0, index);
			}
			else if (fontSize.indexOf('pt')!=-1)
			{
				index = fontSize.indexOf('pt')
				fontSize = fontSize.substr(0, index);
				fontSize = Number(fontSize);
				fontSize*=1.33333;
			}

			defaultAAA[trgt[i]]= Number(fontSize);
			startAAA[trgt[i]]= Number(fontSize);
		}

		if (start)
			startAAA[trgt[i]]=Number(getCookie('fontSize_'+trgt[i]));
		else if (!inc)
			startAAA[trgt[i]]=defaultAAA[trgt[i]];
		else
			startAAA[trgt[i]] += inc;

		if (startAAA[trgt[i]] < 0) startAAA[trgt[i]] = 0;
		d.style.fontSize = startAAA[trgt[i]]+'px';
		setCookie('fontSize_'+trgt[i], startAAA[trgt[i]], 365);
	}

	return false;
}

function substr_count(haystack, needle, offset, length)
{
		// Count the number of substring occurrences
		// 
		// +		discuss at: http://kevin.vanzonneveld.net/techblog/article/javascript_equivalent_for_phps_substr_count/
		// +			 version: 810.819
		// +	 original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
		// +	 bugfixed by: Onno Marsman

	var pos = 0, cnt = 0;

	haystack += '';
	needle += '';
	if(isNaN(offset)) offset = 0;
	if(isNaN(length)) length = 0;
	offset--;

	while((offset = haystack.indexOf(needle, offset+1)) != -1 )
		if(length > 0 && (offset+needle.length) > length)
			return false;
		else
				cnt++;

	return cnt;
}

document.viewport = {
	viewportWidth: function() 
	{
		return self.innerWidth || (document.documentElement.clientWidth || document.body.clientWidth);
		// self.innerWidth - the more standards compliant browsers (mozilla/netscape/opera/IE7)self.innerWidth
		// document.documentElement.clientWidth - IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)
		// document.body.clientWidth - older versions of IE (np. IE 4)
	},

	viewportHeight: function() 
	{
		return self.innerHeight || (document.documentElement.clientHeight || document.body.clientHeight);
		// self.innerHeight - the more standards compliant browsers (mozilla/netscape/opera/IE7)self.innerWidth
		// document.documentElement.clientHeight - IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)
		// document.body.clientHeight - older versions of IE (np. IE 4)
	},

	viewportSize: function() 
	{
		return { width: this.viewportWidth(), height: this.viewportHeight() };
	}
}

function getPageYScroll()
{
	var yScroll;

	if (self.pageYOffset) 
		yScroll = self.pageYOffset;
	else if (document.documentElement && document.documentElement.scrollTop)	// Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
	else if (document.body)	// all other Explorers
		yScroll = document.body.scrollTop;

	return yScroll;
}

function CenterOnViewport(objectId)
{
	object = document.getElementById(objectId);
	dialogWidth = object.offsetWidth;
	dialogHeight = object.offsetHeight;

	//calculate position
	dialogTop = (document.viewport.viewportHeight() - dialogHeight)/2;
	dialogLeft = (document.viewport.viewportWidth() - dialogWidth)/2;

	//Position the Dialog
	object.style.top = dialogTop+"px";
	object.style.left = dialogLeft+"px";
}

function ShowDialog(objectId1, objectId2)
{
	var object = document.getElementById(objectId1);
	if (!object) return;

	var height = 0, height_temp;
	var width = 0;

	var elems = document.body.childNodes;
	for(i=0;i<elems.length;i++)
	{
		if (!elems[i].id || (elems[i].id && elems[i].id != objectId1))
		{
			if (elems[i].offsetHeight)
				height += parseInt(elems[i].offsetHeight);

			if (elems[i].offsetWidth > width)
				width = parseInt(elems[i].offsetWidth);

			height_temp = parseInt(getStyle(elems[i], 'marginTop')) + parseInt(getStyle(elems[i], 'marginBottom'));
			if(!isNaN(height_temp)) height += height_temp;
		}
	}

	object.style.height = height+"px";
	object.style.width = width+"px";
	CenterOnViewport(objectId2);
	document.getElementById(objectId2).style.visibility = 'visible';
}

function RefreshWindow(win)
{
	var index, href;

	href = win.location.href;
	index = href.indexOf('#');
	if (index > -1) 
		href = href.substr(0, index);
	win.location.href = href;
}

function getElement(elem, nodeName, pos)
{
	var counter = 0;

	for (i=0; i<elem.childNodes.length; i++)
		if (elem.childNodes[i].nodeName.toUpperCase() == nodeName.toUpperCase())
		{
			if (counter==pos) return elem.childNodes[i];
			counter++;
		}

	return null;
}
-->