window.debugMode = false; var b, __pop, IE = (!window.opera && document.all ? true : false);
var debug = (window.debugMode == undefined || window.debugMode == null) ? true : window.debugMode;

var Classes = new Object();
window.Classes = Classes;

var Class = function() {
	return function() {
		this.parentClasses = {};
		this.extend = function(classObj) {
			var tmp = _r(arguments,1);
			if(classObj instanceof Object) {
					if(classObj.prototype) {
						for (var property in classObj.prototype)
							if(!this[property]) {
								if(classObj.prototype[property] instanceof Object && !(classObj.prototype[property] instanceof Function))
									this[property] = _clone(classObj.prototype[property]);
								else
									this[property] = classObj.prototype[property];
							}
						if(classObj.prototype['__construct']) classObj.prototype['__construct'].apply(this,tmp);
					}
					else {
						for (var property in classObj)
							if(!this[property])
								this[property] = classObj[property];
						if(classObj['__construct']) classObj['__construct'].apply(this,tmp);
					}
			}
			return this;
		};
		this.copy = function(classObj) {
			if(classObj && classObj instanceof Object)
				if(classObj.prototype) {
					for (var property in classObj.prototype)
						this[property] = classObj.prototype[property];
				}
				else {
					for (var property in classObj)
						this[property] = classObj[property];
				}
			return this;
		};
		this.clone = function() {
			var obj = new Class();
			for (var property in this)
				obj[property] = this[property];
			return obj;
		};
		this.info = function() {
			var str = '';
			for (var property in this)
				if(this[property] instanceof Object)
					str+=property+'=[Object]\r\n';
				else str+=property+'='+this[property]+'\r\n';
			return str;
		};
		this.infoAbout = function(obj) {
			var str = '';
			for (var property in obj)
				if(this[property] instanceof Object)
					str+=property+'=[Object]\r\n';
				else str+=property+'='+this[property]+'\r\n';
			return str;
		};
		this.inherited = function(classObject,method) {
			if(!classObject.prototype) {
				throw "Class::inherited class not found";
			}
			var tmp = _r(arguments,2);
			if(classObject.prototype && classObject.prototype[method])
				return classObject.prototype[method].apply(this, tmp);
		}
		
		if(this.__construct) this.__construct.apply(this, arguments);
	}
};

Classes.Browser = new Class()
Classes.Browser.prototype = {
	isIE: false,
	isIE7: false,
	isIE8: false,
	isOpera: false,
	isFireFox: false,
	isSafari: false,
	__construct: function() {
		reg = new RegExp("(MSIE|FIREFOX|OPERA|SAFARI)[^0-9]*(\\d)+","g");
		matches = reg.exec(navigator.userAgent.toUpperCase());
		if(matches!=null) {
			switch(matches[1]) {
			case 'MSIE':
				this.isIE = true;
				if(matches[2] && parseInt(matches[2]) == 7) this.isIE7 = true;
				if(matches[2] && parseInt(matches[2]) == 8) this.isIE8 = true;
				break;
			case 'FIREFOX':
				this.isFirefox = true;
				break;
			case 'OPERA':
				this.isOpera = true;
				break;
			case 'SAFARI':
				this.isSafari = true;
				break;
			}
			if(this.isIE && window.opera) {
				this.isIE = false;
				this.isOpera = true;
			}
		}
	},
	displayInfo: function() {
			var str = '';
			for (var property in this)
				if(property.substr(0,2) == 'is') str+=property+' = '+this[property]+'\r\n';
			alert(str);
	}
}

var browser = new Classes.Browser();

Classes.ElementList = Class();
Classes.ElementList.prototype = {
	elementArray: null,
	selector:		null,
	tagName:		null,
	tagId:			null,
	className:	null,
	rootElement:  null,
	__construct: function(selector) {
		this.elementArray = new Array();
		if(arguments.length>=2)
			this.rootElement = arguments[1];
		reg = new RegExp("^(\\w*\\s*)?(\\#\\w+\\s*)?(\\s*\\.(?:\\w*\\s*)+){0,1}","g");
		matches = reg.exec(selector);
		if(matches != null && matches.length<=4) {
			this.selector = matches[0];
			this.tagName = matches[1];
			if(this.tagName)
				this.tagName = this.tagName.toUpperCase().replace(' ','');
			this.tagId = matches[2];
			if(this.tagId)
				this.tagId = this.tagId.substr(1);
			this.className = matches[3];
			if(this.className)
				this.className = this.className.substr(1);
			this.harvestElements(this.rootElement);
		}
	},
	checkNodeList: function(nodeList) {
		var classRule = new RegExp("^"+this.className+"\\s*|\\s+"+this.className+"\\s+|\\s*"+this.className+"\\s*$","g");
		for(var i=0;i<nodeList.length;i++) {
			e = nodeList[i];
			if(this.tagName && this.tagName != e.nodeName) continue;
			if(this.tagId && this.tagId != e.id) continue;
			if(this.className && !(e.className && e.className.match(classRule))) continue;
			this.elementArray.push(e);
		}
	},
	harvestElements: function() {
		var tab = arguments.length>=1 ? arguments[0] : null;
		if(this.tagId) {
			tab = new Array;
			tab.push(_e(this.tagId));
			this.checkNodeList(tab);
		}
		else
		if(this.tagName) {
			tab = (!tab ? document.body : tab).getElementsByTagName(this.tagName.toUpperCase());
			this.checkNodeList(tab);
			return;
		}
		else {
			tab = (!tab ? document.body : tab);
			this.checkNodeList(tab.childNodes);
			if(!tab.childNodes) return;
			for(var i=0;i<tab.childNodes.length;i++)
				this.harvestElements(tab.childNodes[i]);
		}
	},
	forEach: function(callback) {
		this.elementArray.forEach(callback,this);
	}
};


function _e(x) { return (typeof x == 'string') ? document.getElementById(x) : x; }


function _n(x) { var y = _e(x); return y ? y.nodeName : null; }


function _v(x) { var y = _e(x); return y ? (y.value ? y.value : y.innerHTML) : (arguments.lenght>=2 ? arguments[1] : null); }


function _root(x) { return root = (x ? (x.documentElement ? x.documentElement : x.firstChild) : null); }


function _xn(x) { return x ? x.nodeName : null; }


function _xv(x) { return x ? (x.nodeValue ? x.nodeValue : (x.firstChild ? x.firstChild.nodeValue : (arguments.lenght>=2 ? arguments[1] : null))) : (arguments.lenght>=2 ? arguments[1] : null); }

function _string(value,defaultValue) {
	var v = !value ? defaultValue : value;
	return v;
}

function _int(value,defaultValue) {
	var v = parseInt(value);
	if(isNaN(v)) v = defaultValue;
	return v;
}


function _offset(e) {
	if(!e) return [0,0];
	var a = _offset(e.offsetParent);
	a[0] += e.offsetLeft;
	a[1] += e.offsetTop;
	return a;
}


function show(e) { e = _e(e);	if(e) e.style.display = ''; }

function hide(e) { e = _e(e); if(e) e.style.display = 'none'; }


function centerElement(element)
{
	element = _e(element);
	var has_element = document.documentElement && document.documentElement.clientWidth;
	var w = IE ? (has_element ? document.documentElement.clientWidth : document.body.clientWidth) : window.innerWidth;
	var h = IE ? (has_element ? document.documentElement.clientHeight : document.body.clientHeight) : window.innerHeight;
	var offsetTop = (IE ? (has_element ? document.documentElement.scrollTop : document.body.scrollTop) : 0);
	var offsetLeft = (IE ? (has_element ? document.documentElement.scrollLeft : document.body.scrollLeft) : 0);

	if(IE)
	{
		element.style.position = 'absolute';
		var e = element.offsetParent;
		while(e)
		{
			offsetTop -= e.offsetTop;
			offsetLeft -= e.offsetLeft;
			e = e.offsetParent;
		}
	}
	else element.style.position = 'fixed';

	element.style.left = (offsetLeft+Math.floor((w-parseInt(element.style.width.replace('px','')))/2))+"px";
	element.style.top = (offsetTop+Math.floor((h-parseInt(element.style.height.replace('px','')))/2))+"px";
}



function _a() {
	var array = new Array();
	if(arguments.length == 1) {
		if(arguments[0] instanceof Array) return arguments[0];
		else if(arguments[0] instanceof Object) {
			if(arguments[0].length)
				for(var i=0;i<arguments[0].length;i++) array.push(arguments[0][i]);
			else
				for(var n in arguments[0]) array.push(arguments[0][n]);
		}
		else array.push(arguments[0]);
	} else
		for(var i=0;i<arguments.length;i++) array.push(arguments[i]);
	return array;
}


function _r(x) {
	var y = _a(x);
	switch(arguments.length) {
	case 1:	break;
	case 2:
		return y.slice(arguments[1],y.length);
		break;
	case 3:
		return y.slice(arguments[1],arguments[2]);
		break;
	}
	return y;
}


Function.prototype.bind = function() {
  var method = this, object = arguments[0];
  return function() {
	var args = _a(arguments);
	return method.apply(object, args);
  }
}

Function.prototype.bindEvent = function() {
  var method = this, object = arguments[0], args = _a(arguments);
  return function(e) {
	args[0] = e;
	return method.apply(object, args);
  }
}


Function.prototype.bindArgs = function() {
  var method = this, object = arguments[0], args = _r(arguments,1);
  return function() {
	return method.apply(object, args);
  }
}

Function.prototype.bindFuncArgs = function() {
  var method = this, args = _a(arguments);
  return function() {
	return method.apply(method, args);
  }
}

if (!Array.prototype.forEach) {
	Array.prototype.forEach = function(fun) {
		var len = this.length;
		if (typeof fun != "function") throw new TypeError();
		var thisp = arguments[1];
		for (var i = 0; i < len; i++) {
			if (i in this) fun.call(thisp, this[i], i, this);
		}
	};
}


function formGetData(formId)
{
	var formNode = _e(formId);
	var formLen = formNode.length;
	var requestData = '';

	if(formNode && formNode.length > 0) {
		for(var j=0;j<formNode.length;j++) {
			var node = formNode.elements[j];
			if(j==0)
				requestData = node.name + '=' + encodeURIComponent(node.value);
			else
				requestData += '&' + node.name + '=' + encodeURIComponent(node.value);
		}
	}
	return requestData;
}

function addEvent(element,event,func) {
	if(browser.isIE) element.attachEvent("on"+event, func);
	else element.addEventListener(event,func,false);
}

function removeEvent(element,event,func) {
	if(browser.isIE) element.detachEvent("on"+event, func);
	else element.removeEventListener(event,func,false);
}

function eventTarget(x) {
	x = x ? x : window.event;
	return Core.ie ? x.srcElement : x.target;
}

function fixEvent(x) {
	return x ? x : window.event;
}

function preventDefault(e) {
	if(!e) return;
	if(e.preventDefault) e.preventDefault();
	e.returnValue = false;
}

function stopPropagation(e) {
	if(!e) return;
	if(e.stopPropagation) e.stopPropagation();
	e.cancelBubble = true;
}

function objectInfo(object) {
	if(!object) return '';

	var str = '<table>';
	for(var e in object) {
		str += '<tr><td style="vertical-align: top">'+e+':</td><td>';
		if(object[e]) {
			if(typeof (object[e]) == "object") str += "{<br />"+objectInfo(object[e])+"}";
			else str += object[e];
		}
		str += '</td></tr>';
	}
	str += '</table>';
	return str;
}

function _clone(src) {
	var obj = {};
	for (var property in src)
		obj[property] = src[property] && src[property] instanceof Object ? _clone(src[property]) : src[property];
	return obj;
}

if(!IE)
{
	document.captureEvents(Event.MOUSEMOVE);
	document.onmousemove=mousePos;
	var netX, netY;
}


function init()
{
	if(__pop) return;
	addEvent(window,'load',function() {
		__pop = document.getElementById("pop");
		b = document.body;
	});
}

function mousePos(e) {
	netX=e.pageX;
	netY=e.pageY;
}

function popPrzesun(pX, pY) {
	if(__pop.style.visibility!='visible') return;
	if(IE) {myszX=event.clientX; myszY=event.clientY;}
		else {myszX=netX-b.scrollLeft; myszY=netY-b.scrollTop;}

	tempX=myszX+pX;
	if(tempX<0) tempX=0;
	tmp=b.clientWidth-myszX-pX-__pop.offsetWidth-20;
	if(tmp<0) {tempX+=tmp; if(tempX<0) tempX=0;}
	__pop.style.left=b.scrollLeft+tempX+"px";

	tempY=myszY+pY;
	if(tempY<0) tempY=0;
	tmp=b.clientHeight-myszY-pY-__pop.offsetHeight-15;
	if(tmp<0) {
		tmp=myszY-15-__pop.offsetHeight;
		if(tmp>=0) tempY=tmp;
	}
	__pop.style.top=b.scrollTop+tempY+"px";
}


function popPokaz(pX, pY, src)
{	
	__pop.style.visibility='visible';
	__pop.innerHTML=src;
	popPrzesun(pX,pY);
}


function popZamknij()
{	
	__pop.style.visibility='hidden';
	__pop.innerHTML='';
	__pop.style.left=0;
	__pop.style.top=0;
}

function popKom(tresc) {
	if(IE)
	{
		text='<div class="dymek">'+tresc+'</div>';
	} else {
		text='<div class="dymek">'+tresc+'</div>';
	}
	popPokaz(10,10,text);
}


function popLinkPrzesun() {
	popPrzesun(10,10);
}


function popSrodekPrzesun() {
	popPrzesun(-90,20);
}

init();
function GetCookie(name)
{
	var arg=name+"=";
	var alen = arg.length;
	var clen = document.cookie.length;
	var i  = 0;
	while (i < clen) {
		var j = i + alen;
		if (document.cookie.substring(i,j) == arg)
			return getCookieVal (j);
		i = document.cookie.indexOf(" ", i) + 1;
		if (i == 0) break;
	}
	return null;
}
function getCookieVal (offset) {
	 var endstr = document.cookie.indexOf (";", offset);
		 if (endstr == 1)
			 endstr = document.cookie.length;
		 return unescape(document.cookie.substring(offset, endstr));
}
function SetCookie (name, value, expires) {
	var exp = new Date();
	var expiro = (exp.getTime() + (24 * 60 * 60 * 1000 * expires));
	exp.setTime(expiro);
	var expstr = "; expires=" + exp.toGMTString();
	document.cookie = name + "=" + escape(value) + expstr;
}
function DeleteCookie(name){
	if (GetCookie(name)) {
		document.cookie = name + "=" + "; expires = Thu, 01-Jan-70 00:00:01 GMT";
	}
}
var imagepath = "images/";

blockarray = new Array();
var blockarrayint = -1;
function doblocks(imgpath) {
	if (imgpath != null) imagepath = imgpath;
	for (var q = 0; q < blockarray.length; q++) {
		xyzswitch(blockarray[q]);
	}
}
function xswitch(listID) {
	if(listID.style.display=="none") {
		listID.style.display="";
	} else {
		listID.style.display="none";
	}
}
function icoswitch(bid) {
	icoID = document.getElementById('pic'+bid);
	if(icoID.src.indexOf("minus") != -1) {
		icoID.src = imagepath+"plus.gif";
		SetCookie('block'+bid,'yes',365);
	} else {
		icoID.src = imagepath+"minus.gif";
		DeleteCookie('block'+bid);
	}
}
function xyzswitch(bid) {
		xswitch(document.getElementById('ph'+bid));
		xswitch(document.getElementById('pe'+bid));
		icoswitch(bid);
}

function addblock(bid)
{
	var blockopen=GetCookie('block'+bid);
	if (blockopen != null)
	{
			blockarrayint += 1;
			blockarray[blockarrayint] = bid;
	}
}


var hiddenblocks = new Array();
var blocks = GetCookie('hiddenblocks');
if (blocks != null) {
	var hidden = blocks.split(":");
	for (var loop = 0; loop < hidden.length; loop++)
	{
		var hiddenblock = hidden[loop];
		hiddenblocks[hiddenblock] = hiddenblock;
	}
}


function blockswitch(bid)
{
	var bph  = document.getElementById('ph'+bid);
	var bpe  = document.getElementById('pe'+bid);
	var bico = document.getElementById('pic'+bid);

	if((bph == null) || (bpe == null))
		return;

	if(bph.style.display=="none")
	{
		bph.style.display="";
		bpe.style.display="none";
		bpe.style.visibility="";
		hiddenblocks[bid] = bid;
	}
	else
	{
		bph.style.display="none";
		bpe.style.display="";
		bpe.style.visibility="";
		hiddenblocks[bid] = null;
	}

	var cookie = null;
	for (var q = 1; q < hiddenblocks.length; q++) {
		if (hiddenblocks[q] != null) {
			if (cookie != null) {
				cookie = (cookie+":"+hiddenblocks[q]);
			} else {
				cookie = hiddenblocks[q];
			}
		}
	}
	if (cookie != null) {
		SetCookie('hiddenblocks', cookie, 365);
	} else {
		DeleteCookie('hiddenblocks');
	}
}

function changenewsonstart(bid,bidac)
{
	var bpe  = document.getElementById(bid);
	var bpeac  = document.getElementById(bidac);
	var act  = document.getElementById('news-active-id');
	xnewselemsttime = 0;
	xnewselemst = true;	
	var b  = document.getElementById(bid+'-st');
	b.src = xnewselemspat+'scr_pause_a.gif';
	if((bpe == null) || (bpeac == null))
		return;
	act.value = bidac;
	bpe.style.display="none";
	bpe.style.visibility="";
	bpeac.style.display="";
	bpeac.style.visibility="";
}

function changenewsonstartset()
{
	var ac  = document.getElementById('news-active-id');
	ac.value = '';
}

function changenewsonstartauto()
{
	setInterval("changenewsonstartautoupdate()", 2000);
}

function changenewsonstartst(buid)
{
	if (xnewselemst == true)	{
		xnewselemst = false;
		if (xnewselemspat != null) {
			var b  = document.getElementById(buid);
			b.src = xnewselemspat+'scr_pause_b.gif';
			}
	}
}

function changenewsonstartautoupdate()
{
if (xnewselemsttime != 3) {
	xnewselemsttime = xnewselemsttime+1;
	return;
}

xnewselemsttime = 0;	
if (xnewselemst == true) {
	var ne;
	var act  = document.getElementById('news-active-id').value;
	if (act == '')
		act = 'news-0';

	 for(var i=0;i<xnewselems.length;i++)
		{
		if (act == xnewselems[i]) {
			if (i==xnewselems.length-1)	ne = xnewselems[0];
			else ne = xnewselems[i+1];
			changenewsonstart(xnewselems[i],ne);	
			}
		}
	}

}


var ajax = new AJAX("");

var errorHandleObj = {
	funcName:null
	};
	
function caller()
{
	if(!ajax) return;
	try {
		for(i=0;i<ajax.callerArray.length;i++)
		{
			var callerObj = ajax.callerArray[i];
			if(callerObj.responseReceived())
			{
				ajax.callerArray.splice(i,1);
				callerObj.responseHandler(callerObj.data);
				return;
			}
		}
	}
	catch(e) {
		if(debug) alert('status: '+e.message);
	}
}


function HttpRequest(url,data,requestData,responseHandler,async,method) {
	try {
		this.http = false;
		if (window.XMLHttpRequest) {
			this.http = new XMLHttpRequest();
		}
		else if (window.ActiveXObject) {
			try {
				this.http  = new ActiveXObject("Msxml2.XMLHTTP");
			} catch (e) {
				this.http = new ActiveXObject("Microsoft.XMLHTTP");
			}
		}
	}
	catch(e) {
		throw "Błąd podczas inicjacji obiektu XmlHTTPRequest";
	}
	this.url = url;
	this.method = method;
	this.responseHandler = responseHandler;
	this.data = data;
	this.requestData = requestData.replace(/&amp;/g,'&');
	this.savedContent = '';
	this.error = false;
	this.responseReceived = function() {
		if (this.http.readyState == 4)
		{
			if (this.http.status == 200)
			{
				return true;
			} else
			{
				if(debug) alert("Wystąpił błąd podczas transmisj danych:\n" +
				this.http.statusText);
				this.error = true;
				return true;
			}
		}
		return false;
	};
	this.getResponseText = function() {
		return this.error ? '' : this.http.responseText;
	}	
	this.getResponseXML = function() {		
		root = this.http.responseXML ? (this.http.responseXML.documentElement ? this.http.responseXML.documentElement : this.http.responseXML.firstChild) : null;
		if(debug && !root) {
			if(arguments.length == 1) 
				arguments[0]('Niepoprawny XML');
			else 
				alert('Niepoprawny XML');			
		}
		else {			
			if(root.nodeName.toUpperCase() == 'ERROR' && root.childNodes[0] && root.childNodes[0].firstChild.nodeValue > 0) {
				var errorMessage = root.childNodes[1] && root.childNodes[1].firstChild && root.childNodes[1].firstChild.nodeValue ? root.childNodes[1].firstChild.nodeValue : '';
				var errorCode = root.childNodes[0].firstChild.nodeValue;
				var retErr = root;
				if(arguments.length == 1) 
				{
					var typeOfArg = typeof(arguments[0]);
					if (typeOfArg == 'function')
						arguments[0](errorMessage);					
					else if (typeOfArg == 'object' && typeof(arguments[0].funcName) == 'function')
					{
						arguments[0].errorCode = errorCode;
						arguments[0].errorMessage = errorMessage;
						arguments[0].funcName(arguments[0]);
					}
					else
						arguments[0](errorMessage);
				}
				else 
					alert(errorMessage);
				return null;
			}
		}
		return root;
	}
	this.http.open(this.method, this.url,async);
	this.http.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	this.http.onreadystatechange = caller;
	this.http.send(this.requestData);
	
}

function defaultResponseHandler(id) {
	var element = document.getElementById(id);
	if(element != null) {
		element.innerHTML = this.getResponseText();
		runScriptsInsideElement(element);
	}
	else alert(this.getResponseText());
}

function AJAX(url) {
	this.url	= url;
	this.callerArray = new Array();
	this.setURL = function(newURL) {
		this.url = newURL;
	}

	
	this.defaultResponseHandler = null;

	this.call = function(url,data,responseHandler) {
		this.url = url;
		try {
			if(this.url.length == 0) throw "Ustaw URL";
			if(!responseHandler) responseHandler = defaultResponseHandler;
			var x = new HttpRequest(this.url,data,'',responseHandler,true,"GET");
			this.callerArray.push(x);
		}
		catch(e) {
			if(debug) alert('call: '+e.message);
		}
	}
	this.callMethod = function(classID,methodName,getData,postData,data,responseHandler) {
		var uri = ''+(document.location ? document.location : 'index.php');
		var pos = uri.indexOf('?');
		var pos2 = uri.indexOf('#');
		if(pos2>0)
			if(!pos || pos==-1||(pos>0 && pos2<pos))
				pos = pos2;
		if(!pos || pos==-1) pos = uri.length;
		this.url = uri.substr(0,pos);
		
		if(this.url.charAt(pos-1) == '/') this.url+='index.php';
		 {
			if(this.url.length == 0) throw "Ustaw URL";
			if(getData && getData.length>0) this.url += '?'+getData;
			if(postData && postData.length>0)
				postData +=  '&classID='+classID+'&method='+methodName;
			else
				postData =	'classID='+classID+'&method='+methodName;
			if(!responseHandler) responseHandler = function() {};
			var x = new HttpRequest(this.url,data,postData,responseHandler,true,"POST");
			this.callerArray.push(x);
		}
		
	}
	this.callMethodSync = function(classID,methodName,getData,postData,data,responseHandler) {
		var uri = ''+(document.location ? document.location : 'index.php');
		var pos = uri.indexOf('?');
		if(!pos || pos==-1) pos = uri.length;
		this.url = uri.substr(0,pos);
		if(this.url.charAt(pos-1) == '/') this.url+='index.php';
			{
			if(this.url.length == 0) throw "Ustaw URL";
			if(getData && getData.length>0) this.url += '?'+getData;
			if(postData && postData.length>0)
				postData +=  '&classID='+classID+'&method='+methodName;
			else
				postData =	'classID='+classID+'&method='+methodName;
			if(!responseHandler) responseHandler = function() {};
			var x = new HttpRequest(this.url,data,postData,responseHandler,false,"POST");
			
			x.responseHandler(x.data);
			return x;
		}
		
	}
	this.post = function(url,data,requestData,responseHandler) {
		this.url = url;
		try {
			if(this.url.length == 0) throw "Ustaw URL";
			if(!responseHandler) responseHandler = defaultResponseHandler;
			x = new HttpRequest(this.url,data,requestData,responseHandler,true,"POST");
			this.callerArray.push(x);
		}
		catch(e) {
			if(debug) alert('call: '+e.message);
		}
	}
	this.callSync = function(url,data) {
		this.url = url;
		try {
			if(this.url.length == 0) throw "Ustaw URL";
			x = new HttpRequest(this.url,data,'',null,false,"GET");
			return x;
		}
		catch(e) {
			if(debug) alert('call: '+e.message);
		}
		return null;
	}
}

function harvestData(element)
{
	var div = _e(element);
	var requestData = '';
	var x = 0;
	
	e = div.getElementsByTagName('input');
	for(var j=0;j<e.length;j++) {
		if(!((e[j].type=="checkbox" && e[j].checked==false) || (e[j].type=="radio" && e[j].checked==false) || e[j].disabled == true)) {
			if(x==0) requestData = e[j].name + '=' + encodeURIComponent(e[j].value);
			else requestData += '&' + e[j].name + '=' + encodeURIComponent(e[j].value);		
			x++;			
		}			
	}
	e = div.getElementsByTagName('select');
	for(var j=0;j<e.length;j++) {
		if(x==0) requestData = e[j].name + '=' + encodeURIComponent(e[j].value);
		else requestData += '&' + e[j].name + '=' + encodeURIComponent(e[j].value);
		x++;
	}
	e = div.getElementsByTagName('textarea');
	for(var j=0;j<e.length;j++) {
		if(x==0) requestData = e[j].name + '=' + encodeURIComponent(e[j].value);
		else requestData += '&' + e[j].name + '=' + encodeURIComponent(e[j].value);
		x++;
	}
	return requestData;
}

Classes.XMLToJSON = {
	convert: function(xmlDocument) {
		var root  = null;
		if(!xmlDocument) throw "Nieprawid-owy XML";
		if(!xmlDocument.childNodes && !xmlDocument.nodeName) {
			root = xmlDocument.documentElement ? xmlDocument.documentElement : xmlDocument.firstChild;
		} else root = xmlDocument;		
		return this.convertNode(root);
	},	
	convertNode: function(node) {
		var retObj = {};
		if(!node) return retObj;		
		for(var i=0;i<node.childNodes.length;i++) {
			if(!node.childNodes[i]) continue;
			
			if(!node.childNodes[i].childNodes.length) 
				retObj[node.childNodes[i].nodeName] = null;
			else {
				if(node.childNodes[i].firstChild.nodeType == 3 || node.childNodes[i].firstChild.nodeType == 4)
					retObj[node.childNodes[i].nodeName] = node.childNodes[i].firstChild.nodeValue;
				else 
					retObj[node.childNodes[i].nodeName] = this.convertNode(node.childNodes[i]);							
			}
		}
		return retObj;
	}
}
Classes.MenuKategorii = Class();
Classes.MenuKategorii.prototype = {
	handle: null,
	menuDynamiczne: null,
	wszystkieKategorie: null,
	hideMenu: false,
	suffix: '',
	__construct: function(params) {
		addEvent(window,'load',this.uaktywnij.bind(this));
		this.handle = setInterval(this.handleInterval.bind(this),700);		
	},
	pokazKategorie: function() {
		this.hideMenu = false;
		
		this.menuDynamiczne.style.position = 'absolute';
		this.menuDynamiczne.style.display = 'block';
		this.menuDynamiczne.style.background = 'white';
		
	},
	ukryjKategorie: function() {
		
		this.hideMenu = true;
	},
	handleInterval: function() {
		if(!this.hideMenu) return;
		this.menuDynamiczne.style.display = 'none';
		this.hideMenu = false;
	},
	uaktywnij: function() {
		var e = _e('wszystkieKategorie');
		this.wszystkieKategorie = e;
		if(e) {
			addEvent(e,'mouseover',this.pokazKategorie.bind(this));
			addEvent(e,'mouseout',this.ukryjKategorie.bind(this));
		}
		this.menuDynamiczne = e = _e('menuDynamiczne');
		if(this.wszystkieKategorie) {
			addEvent(e,'mouseover',this.pokazKategorie.bind(this));
			addEvent(e,'mouseout',this.ukryjKategorie.bind(this));
		}
		
		if(!browser.isIE ) return;
		if(!e) return;
		
		if(this.wszystkieKategorie)
			this.suffix += '_walp';
		
		var li,list = e.getElementsByTagName('li');
		for(var i=0;i<list.length;i++) {
			li = list[i];
			if(li && (li.className+'').lastIndexOf('podKat'+this.suffix)!=-1) {
				var ullist = li.getElementsByTagName('ul');
				var ul = ullist[0];
				var alist = li.getElementsByTagName('a');
				var a = alist[0];
				
				var f1 = this.pokaz.bindEvent(this,ul);
				var f2 = this.zamknij.bindEvent(this,ul);				
				addEvent(li,'mouseover',f1);
				addEvent(li,'mouseout',f2);
				addEvent(li,'click',this.gotoUrl.bindArgs(this,a.href));
			}			
		}		
		list = e.getElementsByTagName('img');
		for(var i=0;i<list.length;i++) {
			li = list[i];
			var s=li.src;
			li.src = 'img/blank.gif';
			li.style.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true,src=\''+s+'\',sizingMethod=\'none\');';
			li.style.visibility='visible';
		}
	},
	applyReq: function(e,f1,f2) {
		if(!e || !e.nodeName || e.nodeName=='#text') return;		
		for(var n=0;n<e.childNodes.length;n++) {		
			this.applyReq(e.childNodes[n],f1,f2);
		}
		addEvent(e,'mouseover',f1);
		addEvent(e,'mouseout',f2);
	},
	pokaz: function(event,e) {		
		e.style.display = 'block';
		e.parentNode.className += ' hover'+this.suffix;		
	},
	zamknij: function(event,e) {
		e.style.display = 'none';
		e.parentNode.className = 'podKat'+this.suffix;		
	},
	gotoUrl: function(url) {		
		window.location = url;
	}
}

var menuKategorii = new Classes.MenuKategorii();

function showBranch(id)
{
	var element, mopen, mclose;

	element = document.getElementById('m_'+id);
	mopen = document.getElementById('menu_open');
	mclose = document.getElementById('menu_close');

	if(element)
	{
		element.style.display = 'inline';
		mopen.style.display = 'none';
		mclose.style.display = 'inline';
	}
}


function vis(action,button)
{
	var property_one, property_two, mopen, mclose, node;

	mopen = document.getElementById('menu_open');
	mclose = document.getElementById('menu_close');

	if(action)
	{
		property_one = 'none';
		property_two = 'inline';
	}
	else
	{
		property_one = 'inline';
		property_two = 'none';
	}

	if(mopen)
		mopen.style.display=property_one;

	if(mclose)
		mclose.style.display=property_two;

	var menu = document.getElementById('menu_kategorie');
	if(menu)
	{
		for( var x = 0; menu.childNodes[x]; x++ )
			if(menu.childNodes[x].nodeName != '#text' && menu.childNodes[x].id.substr(0,2)=='m_')
				menu.childNodes[x].style.display = property_two;
	}
}


function strona(i)
{
	document.getElementById('str').value = i;
	document.getElementById('search_form').submit();
}

function szukaj(v)
{
	if (v!='')
		document.getElementById('mode_szukaj').value = v;
	document.getElementById('search_form').submit();
}

function szukaj_select(select_field,input_field)
{
	var nm_sz = _e(select_field);
	var nm = nm_sz.selectedIndex;	
	if (nm !=null)
	{
		nm = _int(nm_sz.options[nm].value,0);
		var res = _e(input_field); 
		res.value = nm;
	}
	szukaj('');
}

function szukaj_checkbox(input_field,form_field)
{
	var nm_sz = _e(input_field);
	var res = _e(form_field); 

	if (nm_sz.checked)
		res.value = 1;
	else
		res.value = 0;
	szukaj('');
}

function pokazFormularz()
{
	var combo = document.getElementById('sz_gdzieID');
	if (!combo)
		return;
	var selected = combo.options[combo.selectedIndex].value;
	var sup = new Array(0,1,2,3,4,293,361);
	if (selected == 'all') selected = 0;
	if (selected > 4 && selected !=293 && selected !=361) selected = 0;
	if (selected == 293)
	{
		document.getElementById('f24_293').style.display = '';
		document.getElementById('f24_0').style.display = 'none';
	}
	else
	{
		document.getElementById('f24_293').style.display = 'none';
		document.getElementById('f24_0').style.display = '';
	}
	for (k in sup)
	{
		var t = document.getElementById(('f'+sup[k]));
		if(t)
		{
			t.style.display = (sup[k]==selected ? '' : 'none');
			if (sup[k]==selected)
			{
				var nosniki = _e('id_n'+selected);
				var n_main = _e('sz_id_n');
				if (nosniki && n_main)
				{
					var selected_n = n_main.selectedIndex>0?n_main.options[n_main.selectedIndex].value:null;
					
					for (var i =  n_main.options.length; i >= 0; i--) 
						n_main.remove(i);
					
					for (var i = 0; i < nosniki.options.length; i++) 
						n_main.options[i] = new Option(nosniki.options[i].text, nosniki.options[i].value, false, nosniki.options[i].value == selected_n?true:false )
					
					alert ('No¶niki ' + selected);
					_e('id_n_name').innerHTML = 'No¶niki ' + selected;
					
				}
			}
		}	
			
	}
}



function pokazPolaFormularza()
{

	var combo = document.getElementById('sz_gdzieID');
	if (!combo)
		return;
			
	var ArrayFields = {
		
		"id_n" : 			{0:false,1:false,2:true,3:true,4:true,361:false,293:false},
		"prodcategory" : {"all":true,0:true}, 
		"name" : 			{"all":true,0:true},
		"author" : 		{0:true,1:true,2:true,3:true,4:false,361:false,293:false},
		"publisher" : {0:false,1:true,2:true,3:true,4:true,361:true,293:true},
		"series" : 		{0:false,1:true,2:false,3:false,4:false,361:false,293:false},
		"isbn" : 			{0:false,1:true,2:false,3:false,4:false,361:false,293:true},
		"catalogid" : {0:false,1:false,2:true,3:true,4:false,361:false,293:false},
		"prod" : 			{0:false,1:false,2:true,3:false,4:false,361:false,293:true},
		"capacity" : 	{0:false,1:false,2:false,3:false,4:false,361:true,293:false},
		"description" : {"all":true,0:true}
		
};

		var FieldsNames = {
		"prodcategory" : "Kategoria", 
		"name" : "Tytuł",
		"name361" : "Nazwa",
		"id_n" : "No¶nik",
		"author" : "Autor",
		"author2" : "Wykonawca",
		"author3" : "Reżyser/Aktor",
		"publisher" : "Wydawca",
		"publisher3" :"Dystrybutor",
		"publisher361" :"Producent",
		"series" : "Seria wydawnicza",
		"isbn" : "ISBN",
		"isbn293" : "ISSN",
		"catalogid" : "Nr katalogowy",
		"prod" : "Spis tre¶ci",
		"prod2" : "Lista Utworów",
		"capacity" : "Pojemno¶ć",
		"description" : "Opis"
	};
	
	var selected = combo.options[combo.selectedIndex].value;
	var sup = {0:true,1:true,2:true,3:true,4:true,293:true,361:true};
	if (!sup[selected])
		selected = 0;	

	var formularz = _e('szu_form');
	if (!formularz)
		return;
	var form_id;
	var form_name;
	var field_name;
	
	var test = new Array();
	
	
	for (var i =0; i < formularz.childNodes.length; i++)
	{
		form_id = _e(formularz.childNodes[i]).id;
		if (form_id)
		{
			field_name = form_id.replace('szu_','');
			test = new Array(null,null,null,null,null);	
			if (ArrayFields[field_name]) test[1] = ArrayFields[field_name];
			if (ArrayFields[field_name][selected]) test[2] = ArrayFields[field_name][selected];
			if (ArrayFields[field_name][0]) test[3] = ArrayFields[field_name][0];
			if (ArrayFields[field_name]["all"])			test[4] = ArrayFields[field_name]["all"];
			
			if (ArrayFields[field_name] && 
			((ArrayFields[field_name][selected]?ArrayFields[field_name][selected]==true:ArrayFields[field_name][0]==true&&ArrayFields[field_name][0]!==true) ||
			ArrayFields[field_name]["all"]==true)
			)
			{
				form_name = FieldsNames[field_name + selected]?FieldsNames[field_name + selected]:FieldsNames[field_name];
				if (form_name)
				{
					if (_e('name_' + field_name))
						 _e('name_' + field_name).innerHTML = form_name + ':';
					
					if (field_name == 'id_n')
					{
						var nosniki = _e(field_name + selected);
						var n_main = _e('sz_' + field_name);
						
						var err;
						
						if (nosniki && n_main)
						{
							var selected_n = n_main.selectedIndex>0?n_main.options[n_main.selectedIndex].value:null;
							if (selected_n == null && nosniki.selectedIndex>0)
								{
									selected_n = nosniki.options[nosniki.selectedIndex];
									selected_n = nosniki.options[nosniki.selectedIndex].value;
								}
							else
								selected_n = nosniki.options[nosniki.selectedIndex].value;
							
							
							
							
							for (var k =  n_main.options.length; k >= 0; k--)
								n_main.remove(k);
							
							for (var k = 0; k < nosniki.options.length; k++) 
							{
								
									n_main.options[n_main.options.length] = new Option(nosniki.options[k].text, nosniki.options[k].value, false, nosniki.options[k].value == selected_n?true:false )
									
									
								
									
							}
						}
					}
				}
				_e(form_id).style.display = '';	
			}
			else
			{
				_e(form_id).style.display = 'none';
				if (_e('sz_' + field_name))
				{
					if (_e('sz_' + field_name).selectedIndex > 0)
						_e('sz_' + field_name).selectedIndex = -1;
					else if (_e('sz_' + field_name).value)
						_e('sz_' + field_name).value = '';
					
						
				}
			}
		}
	
	
	}
}




var showHideStatus = 0;
var koszykPopupStatus = -1;
var koszykPopupTimer = 0;
var koszykPopupIETop = 0;


addEvent(window,'load',function(){addLinkerEvents();});


var dodany = 0;

function google_transakcja_sprawdz(id)
{
	if(!window.XMLHttpRequest && !window.ActiveXObject)
		return 1;
	var req = ajax.callMethodSync('AjaxZamowienie','googleTransakcjaSprawdz','orders_id='+id,null,null,null);
	return _int(req.getResponseText(),0);
}

function showButton()
{
	blockswitch(916);
}

function showMessage(title,message,autoHide)
{
	var did = IE ? 'dymek_id_IE' : 'dymek_id';
	var dymekId = _e(did);
	if(!dymekId) {
		alert(title+":\r\n"+message);
		return;
	}

	centerElement(dymekId);

	span = dymekId.getElementsByTagName('span');
	if(title)
	{
		span[0].style.display = '';
		span[0].innerHTML = title;
	}
	else span[0].style.display = 'none';

	div = dymekId.getElementsByTagName('div');
	div = div[0].getElementsByTagName('div');
	div[0].innerHTML = message;

	span = dymekId.getElementsByTagName('span');

	setTimeout("show('"+did+"');", 10);
	if(autoHide) setTimeout("hide('"+did+"');", 2000);
}

function showWaitingMessage(message)
{
	var did = IE ? 'waiting_dymek_IE' : 'waiting_dymek';
	var dymekId = _e(did);
	if(!dymekId) {
		return;
	}

	centerElement(dymekId);

	span = dymekId.getElementsByTagName('span');
	span[0].style.display = '';
	span[0].innerHTML = 'Komunikat';

	div = dymekId.getElementsByTagName('div');
	div = div[0].getElementsByTagName('div');
	div[0].innerHTML = message;

	span = dymekId.getElementsByTagName('span');
	setTimeout("show('"+did+"');", 20);
}

function hideWaitingMessage()
{
	var did = IE ? 'waiting_dymek_IE' : 'waiting_dymek';
	var dymekId = _e(did);
	if(dymekId) {
		hide(did);
	}	
}



function showErrorMessage(message) {
	showMessage('Komunikat',message,false);
}

function handleError(obj){
	if (obj.errorCode == 2)
	 

		window.location.reload(true);
	else
		showMessage('Komunikat',obj.errorMessage+'!!',false);
}

function ajax_do_koszyka(pid,mode)
{
	ajax.callMethod('AjaxKoszyk','addProduct', 'raction=1&pi='+pid, null, {'mode':mode}, function(data) {
		
		var root = this.getResponseXML(showErrorMessage);
		if(root)
		{
			if (_e(('koszyk_tresc')) && root.childNodes[0].firstChild)
			{
				var ilosc = root.childNodes[0].firstChild.nodeValue;
				str = '<span class="f_size_11">';
				str += (ilosc == '1')? '1 rzecz za ' : ilosc+' rzeczy za ';
				str += '</span><span class="f_size_11">';
				str += root.childNodes[1].firstChild.nodeValue+' PLN </span>'
				document.getElementById('koszyk_tresc').innerHTML = str;
			}
			switch(parseInt(data.mode))
			{
				case 1:
					showButton();
				break;
				case 2:
				break;
				default:
					if (root.childNodes[0].firstChild)
					{
						_e('koszyk_warstwa_A').innerHTML =  root.childNodes[4].firstChild.nodeValue;
						koszykPopUpShowHide(1);
						if (koszykPopupTimer)
							clearTimeout(koszykPopupTimer);
						koszykPopupTimer = setTimeout("koszykPopUpShowHide(-1);", 3000);
					}
				
				

			}
		}
	});
}

function showHideKoszykPopup(op)
{
	if (op == 1)
	{
		_e('koszyk_region').style.display='';
		
	}
	else
	{
		_e('koszyk_region').style.display='none';
		
	}

}

function ajax_show_hide(op)
{
		var uri_q = ''+(document.location ? document.location : 'index.php');

		var pos_h = uri_q.indexOf('#');
		var pos_q = uri_q.indexOf('?');
		var getSzukaj = '';
		if(pos_q && pos_q!=-1)
		{
			if (!pos_h || pos_q==-1)
				pos_h =  uri_q.length;
			else
				pos_h = pos_h - pos_q -1;
			getSzukaj = uri_q.substr(pos_q+1,pos_h);
		}

		if (getSzukaj == '' && window.KategoriaSuper)
		{
			getSzukaj = 'sz_gdzie='+window.KategoriaSuper;
		}
		
	var formularz = _e('wyszukiwarka_formularz');
		
	if (formularz)
	{
		pokazPolaFormularza();
		
		if(formularz.style.display == '') 
		{
			showHideStatus = 1;
			formularz.style.display = 'none';
		}
		else
		{
			showHideStatus = -1;
			formularz.style.display = ''; 
		}
		
		
		
	}
	else
	ajax.callMethod('Szukaj', 'ajaxFormularzSzukaj', getSzukaj, null, {'op': op}, function(data) {
		
		
		
		
		
		
		var ie = _e('wyszukiwarka_warstwa_A');
		var region = _e('wyszukiwarka_region');
		
		

		
		var navi = _e('navigator');
		
		
			_e('wyszukiwarka_warstwa_A').innerHTML = this.getResponseText();
			
			var wyszukiwarka_form = 'wyszukiwarka_region';
		
		



		
		noff = _offset(navi);

		
		region.style.left = (noff[0])+'px';
		
		ioff = _offset(region);
		
		
		
		region.style.top = (noff[1] + 15)+'px';
		
		len = ie.offsetWidth;
		iePosStart = (noff[0])-ioff[0]-len;
		
		scrollFx.moveSteps = 10;

		showHideStatus = ((data.op == -1)? ((showHideStatus == -1)? 1 : -1) : 1);
		pokazPolaFormularza();
		
		switch(showHideStatus)
		{
			case 1:
				
			
				scrollFx.assignOnFinish('wyszukiwarka_warstwa', function() {
					hide('wyszukiwarka_formularz');
				});
				scrollFx.setOffset('wyszukiwarka_warstwa', iePosStart+len);
				scrollFx.left('wyszukiwarka_warstwa', len);


					
				
			break;
			case -1:
				
				
				scrollFx.setOffset('wyszukiwarka_warstwa', iePosStart);
				scrollFx.right('wyszukiwarka_warstwa', len);
				scrollFx.assignOnFinish('wyszukiwarka_warstwa', function() {
					show('wyszukiwarka_formularz');
				});


				
			break;
		
		
		
		
		
		
		
		
		
		
		
			
			
		}
	});
}


function szukaj_formularz_status()
{
	showHideStatus = -1;
}


function do_koszyka(pi,mode)
{
	var docLocation = 'Start';
	var pos_q = document.URL.lastIndexOf('/');
	if(pos_q && pos_q!=-1 && pos_q+1 < document.URL.length)
		docLocation = document.URL.substr(pos_q+1);

	trackEvent('product','addtobasket',docLocation +' '+ pi); 
	if(window.brak_przekierowania_do_koszyka && mode!=2)
	{
		ajax_do_koszyka(pi,mode);
		return false;
	}
	if (dodany>0) return true;
	dodany = pi;
	document.location = 'koszyk.php?todo=add&pi='+pi;
	return false;
}

function ajax_przechowalnia(id,przekierowanie) {
	ajax.callMethod('Przechowalnia','addProduct', 'id='+id, null, null, function(data) {
		var root = this.getResponseXML();
		if(root && root.childNodes.length == 3) {
			ok = _int(_xv(root.childNodes[0]),0);
			stan = _xv(root.childNodes[1]);
			stan = stan == '0' ? 'brak' : stan;
			e = _e('przechowalnia_stan');
			if(e) e.innerHTML = '&nbsp;Ilo¶ć pozycji: '+stan;
			msg = _xv(root.childNodes[2]);
			if(ok && przekierowanie != null) document.location = przekierowanie;
			else showMessage('Komunikat',msg,true);
		}
	});
	return false;
}

function ajax_przechowalnia_usun(id,przeniesDoKoszyka) {
	ajax.callMethod('Przechowalnia','removeProduct', 'id='+id, null, null, function(data) {
		var root = this.getResponseXML();
		if(root && root.childNodes.length == 4) {
			ok = _int(_xv(root.childNodes[0]),0);
			stan = _xv(root.childNodes[1]);
			stan = stan == '0' ? 'brak' : stan;
			e = _e('przechowalnia_stan');
			if(e) e.innerHTML = '&nbsp;Ilo¶ć pozycji: '+stan;
			msg = _xv(root.childNodes[2]);
			if(ok) {
				e = _e('przechowalnia_lista');
				if(e) e.innerHTML = _xv(root.childNodes[3]);
				if(przeniesDoKoszyka) do_koszyka(id,2);
			}
			else showMessage('Komunikat',msg,true);
		}
	});
	return false;
}


function ajax_dostawa()
{
	pml = document.getElementById('payment_method_id');
	sml = document.getElementById('shipping_method_id');
	if (pml.firstChild && pml.firstChild.selectedIndex > -1)
		pid = pml.firstChild.options[pml.firstChild.selectedIndex].value;
	else
		pid = 0;
	if (sml.firstChild && sml.firstChild.selectedIndex > -1)
		sid = sml.firstChild.options[sml.firstChild.selectedIndex].value;
	else
		sid = 0;

	ajax.callMethod('AjaxDostawa','getShipping', 'pid='+pid+'&sid='+sid, null, null, function(data) {
		smnol = document.getElementById('shipping_method_name_on_list');
		smpol = document.getElementById('shipping_method_price_on_list');
		smtol = document.getElementById('shipping_method_total_on_list');
		pml = document.getElementById('payment_method_id');
		sml = document.getElementById('shipping_method_id');
		var root = this.getResponseXML();
		if(root && smnol) {
			smnol.innerHTML = root.childNodes[0].firstChild.nodeValue;
			smpol.innerHTML = root.childNodes[1].firstChild.nodeValue;
			smtol.innerHTML = root.childNodes[2].firstChild.nodeValue;
			pml.innerHTML = root.childNodes[3].firstChild.nodeValue;
			sml.innerHTML = root.childNodes[4].firstChild.nodeValue;
		}
	});

}

function pop(u,w,h)
{
	x = window.open(u, null, "height="+h+", width="+w+", left=0, top=0");
}


function ajax_polec_znajomemu(typ,id)
{
	if(typ == 1)
		ajax.call('info.php?pi='+id+'&okno=pz', null, function() {
			centerElement('pe915');
			blockswitch('915');
			var root = this.getResponseXML();
			if(root)	{
				var kod = root.childNodes[0].firstChild.nodeValue;
				document.getElementById('obrazek_gen').src = 'info.php?gen='+kod;
			}
		});
	if(typ == 2)
		ajax.post('info.php?pi='+id+'&okno=pz', null, formGetData('form_polec_znajomemu'), function(data) {
			var root = this.getResponseXML();
			if(!root) return;
			var msg = Array();
					msg.kod_obrazka_blad = 'Uzupełnij kod obrazka!';
					msg.niepoprawny_kod_obrazka_blad = 'Niepoprawny kod obrazka!';
					msg.nadawca_email_blad = 'Uzupełnij email nadawcy!';
					msg.niepoprawny_nadawca_email_blad = 'Niepoprawny email nadawcy!';
					msg.adresat_email_blad = 'Uzupełnij email adresata!';
					msg.niepoprawny_adresat_email_blad = 'Niepoprawny email adresata!';
					msg.email_status = 'E-mail został wysłany.';

			var message = '';
			var title = 'Bł±d!';

			for(var x = 0; root.childNodes[x]; x++)
			{
				var node = root.childNodes[x];
				switch(node.nodeName)
				{
					case 'kod':
						document.getElementById('obrazek_gen').src = 'info.php?gen='+node.firstChild.nodeValue;
					break;
					case 'email_status':
						title = 'Komunikat';
						blockswitch(915);
					default:
						if(!node.firstChild || (node.firstChild && node.firstChild.nodeValue == 1))
							message += '<div style="width:250px;" class="f_size_12 c_red bold">'+(msg[node.nodeName] ? msg[node.nodeName] : '')+'</div>';
					break;
				}
			}
			showMessage(title,message,false);
		});
}





function HideKoszykOnClick()
{
	if (koszykPopupStatus == 1)
	{
		
		if (mouse.targetElement.className == 'button_kosz' || mouse.targetElement.href)
			return;
		else
			koszykPopUpShowHide(-1);
	}
}


function koszykPopUpShowHide(op)
{
	if (koszykPopupStatus == op && !(IE && op==1))
	{
		if (op == 1)
			showHideKoszykPopup(1);
		return;
	}

		var ie = _e('koszyk_warstwa_A');
		var region = _e('koszyk_region');
		var koszyk = _e('koszyk_popup');
		var e = pop;
		var left_margin = 15;
		var right_margin = 20;

		if (IE)
		{
			region.style.position = 'absolute';

			if (op==-1 && koszykPopupIETop)
				region.style.top = koszykPopupIETop + 'px';
			else
			{
				var has_element = document.documentElement && document.documentElement.clientWidth;
				var w = has_element ? document.documentElement.clientWidth : document.body.clientWidth;
				var h = has_element ? document.documentElement.clientHeight : document.body.clientHeight;
				var offsetTop = has_element ? document.documentElement.scrollTop : document.body.scrollTop;

				var e = region.offsetParent;
				while(e)
				{
					offsetTop -= e.offsetTop;
					e = e.offsetParent;
				}
				offsetTop += 20;

				koszykPopupIETop = offsetTop + 20;
				region.style.top = koszykPopupIETop + 'px';
			}
		}


		var kosz_len = parseInt(region.style.width.replace('px','')) - right_margin;

		


		scrollFx.moveSteps = 10;

		switch(op) 
		{
			case -1:
				
				scrollFx.setOffset('koszyk_warstwa',0);
				scrollFx.right('koszyk_warstwa', kosz_len + right_margin);
				scrollFx.assignOnFinish('koszyk_warstwa', function() {
					showHideKoszykPopup(-1);
				});
			break;
			case 1:
				
				showHideKoszykPopup(1);
				scrollFx.setOffset('koszyk_warstwa', kosz_len);
				scrollFx.left('koszyk_warstwa', kosz_len);
				scrollFx.assignOnFinish('koszyk_warstwa', function() {
					showHideKoszykPopup(1);
				});

			break;
		}
		koszykPopupStatus = op;
}

function koszykDymekIeFix() {
	if(window.event.offsetX > 220 && window.event.offsetY < 30) hide('dymek_id_IE');
}

var preLoaders = {};
function preLoadGroupLabel(name,groupLabelArray) {
	var mainSite = false;
	var offset = [0,0];
	if(arguments[2]) {
		if(typeof(arguments[2])=="object")
			offset = arguments[2];
		else
		if(typeof(arguments[2])=="boolean") mainSite = true;
	}

	var groupImagesArray = new Array;
	var groupIdArray = new Array;
	var groupName = name;
	for(var groupId in groupLabelArray) {
		groupImagesArray.push(groupLabelArray[groupId]);
		groupIdArray.push(groupId);
	}
	if(groupIdArray.length == 0) return;
	preLoaders[name] = new Classes.ImagePreloader({
		imagesArray: groupImagesArray,
		data: groupIdArray,
		onError: function(img,index) {
		},
		onImageLoad: function(img,index) {
			var groupLabel = this.imagesArray[index];
			var groupId = this.data[index];
			var r = new Classes.ElementList("div .promo_label_"+groupId);
			r.elementArray.forEach(function(e) {
				if(!e) return true;
				switch(groupName) {
				case 'pageinfo':
					e.style.marginTop = (-img.height)+'px';
					e.style.marginLeft = (browser.isIE ? 55 : 55)+'px';
					break;
				case 'pinfo':
					e.style.marginTop = (-img.height)+'px';
					break;
				case 'pinfo_v1':

					break;
				default:
					if(mainSite) {
						e.style.marginTop = (-img.height)+'px';
						e.style.marginLeft = (browser.isIE ? -80 : -10)+'px';
					}
					else {
						e.style.marginTop = (-img.height+offset[1])+'px';
						e.style.marginLeft = (offset[0])+'px';
					}
					break;
				}
				if(browser.isIE && !browser.isIE7) {
					e.innerHTML = '';
					e.style.background = 'transparent';
					e.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src="+groupLabel+", sizingMethod='noscale')";
				}
				else
					e.style.background = "url("+groupLabel+") no-repeat 0px 0px";

				e.style.visible = 'visible';
				e.style.width = img.width+'px';
				e.style.height = img.height+'px';
			});
		}
	});
	preLoaders[name].preload();
}

function newsletter_zapisz()
{
	ajax.callMethod('PromocjaDnia','zapisz', null, harvestData('newsletter_form'), null, function(data) {
		var root = this.getResponseXML(showErrorMessage);
		if(!root) return;
		root = Classes.XMLToJSON.convert(root);
		var e =_e('newsletter_zapisz');
		e.innerHTML = root.code;
	});
}


function galeriaOtworz(gid)
{
	window.open('popup_galeria.php?gid='+gid, 'Galeria','height=500, width=600, left=200, top=50, resizable, scrollbars');
}


/****************************************************
     Author: Brian J Clifton
     Url: http:
     This script is free to use as long as this info is left in
     
     Combined script for tracking external links, file downloads and mailto links
     
     All scripts presented have been tested and validated by the author and are believed to be correct
     as of the date of publication or posting. The Google Analytics software on which they depend is 
     subject to change, however; and therefore no warranty is expressed or implied that they will
     work as described in the future. Always check the most current Google Analytics documentation.
 
****************************************************/
 
 


 
 
function addLinkerEvents() {
        var t1 = false;
   			var t2 = false;
   
				if(typeof window.pageTracker1 !== 'undefined')
			 		t1 = true;
   			if(typeof window.pageTracker2 !== 'undefined')
			 		t2 = true;
   
   			if (!t1 && !t2)
				 	return;   			
   
   			var as = document.getElementsByTagName("a");
   			var extTrack = [document.location.hostname,"javascript"];
	      
        
        
        var extDoc = [".doc",".xls",".exe",".zip",".pdf",".js"];
        
        
        
        
        
        for(var i=0; i<as.length; i++) {

							 
							 var flag = 0;
               var tmp = as[i].getAttribute("onclick");
 
               
               if (tmp != null) {
                 tmp = String(tmp);
                 if (tmp.indexOf('urchinTracker') > -1 || tmp.indexOf('_trackEvent') > -1 || tmp.indexOf('trackBanner') > -1) continue;
               }
 
               
               for (var j=0; j<extTrack.length; j++) {                                     
                       if (as[i].href.indexOf(extTrack[j]) == -1 && as[i].href.indexOf('google-analytics.com') == -1 ) {
                               flag++;
                       }
               }
               
               
               
               if (flag == extTrack.length){
                       if (as[i].href)
											 {
												 var splitResult = as[i].href.split("\/\/");
												 if (splitResult[1])
												 {
												 	 splitResult[1] = splitResult[1].replace(/\/$/g,'');

		                       as[i].setAttribute("onclick", 
													 (t1?"pageTracker1._trackEvent('outgoing', 'goto', '" +splitResult[1]+ "');":"") +
													 (t2?"pageTracker2._trackEvent('outgoing', 'goto', '" +splitResult[1]+ "');":"") +
													 ((tmp != null) ? tmp+";" : ""));
													 

												 }
	                     }
               }
							 
               
               
               for (var j=0; j<extDoc.length; j++) {
                       if (as[i].href.indexOf(extTrack[0]) != -1 && as[i].href.indexOf(extDoc[j]) != -1) {
                               var splitResult = as[i].href.split(extTrack[0]);
                               as[i].setAttribute("onclick",
															 	((tmp != null) ? tmp+";" : "") +
																 (t1?"pageTracker1._trackEvent('downloads', 'get', '" +splitResult[1]+ "');":"") +
																 (t2?"pageTracker2._trackEvent('downloads', 'get', '" +splitResult[1]+ "');":"")
																 );



                               break;
                       }
                       
               }
 
 
               
               if (as[i].href.indexOf("mailto:") != -1  && as[i].href.indexOf("gashbug@google.com") == -1 ) {
                       var splitResult = as[i].href.split(":");
                       as[i].setAttribute("onclick",
											 	((tmp != null) ? tmp+";" : "") + 
												 (t1?"pageTracker1._trackEvent('mailto', 'send', '" +splitResult[1]+ "');":"") +
												 (t2?"pageTracker2._trackEvent('mailto', 'send', '" +splitResult[1]+ "');":"")
												 
												 );

               
               }
        }
        
}

function trackEvent(category,act,label) {
	if(typeof window.pageTracker1 !== 'undefined')
 		pageTracker1._trackEvent(category,act,label);
	if(typeof window.pageTracker2 !== 'undefined')
		pageTracker2._trackEvent(category,act,label); 
}

function trackBanner(label) {
	trackEvent('banner','click',label);	 
}

function bannerRedirect(url) {
	var splitResult = url.split("\/\/");
	if (splitResult[1])
		trackEvent('banner','click',splitResult[1]);
	else
		trackEvent('banner','click',url);
	




		window.location = url; 
}




function AC_AddExtension(src, ext)
{
  if (src.indexOf('?') != -1)
    return src.replace(/\?/, ext+'?'); 
  else
    return src + ext;
}

function AC_Generateobj(objAttrs, params, embedAttrs) 
{ 
  var str = '<object ';
  for (var i in objAttrs)
    str += i + '="' + objAttrs[i] + '" ';
  str += '>';
  for (var i in params)
    str += '<param name="' + i + '" value="' + params[i] + '" /> ';
  str += '<embed ';
  for (var i in embedAttrs)
    str += i + '="' + embedAttrs[i] + '" ';
  str += ' ></embed></object>';

  document.write(str);
}

function AC_FL_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
     , "application/x-shockwave-flash"
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_SW_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".dcr", "src", "clsid:166B1BCA-3F9C-11CF-8075-444553540000"
     , null
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
  var ret = new Object();
  ret.embedAttrs = new Object();
  ret.params = new Object();
  ret.objAttrs = new Object();
  for (var i=0; i < args.length; i=i+2){
    var currArg = args[i].toLowerCase();    

    switch (currArg){	
      case "classid":
        break;
      case "pluginspage":
        ret.embedAttrs[args[i]] = args[i+1];
        break;
      case "src":
      case "movie":	
        args[i+1] = AC_AddExtension(args[i+1], ext);
        ret.embedAttrs["src"] = args[i+1];
        ret.params[srcParamName] = args[i+1];
        break;
      case "onafterupdate":
      case "onbeforeupdate":
      case "onblur":
      case "oncellchange":
      case "onclick":
      case "ondblClick":
      case "ondrag":
      case "ondragend":
      case "ondragenter":
      case "ondragleave":
      case "ondragover":
      case "ondrop":
      case "onfinish":
      case "onfocus":
      case "onhelp":
      case "onmousedown":
      case "onmouseup":
      case "onmouseover":
      case "onmousemove":
      case "onmouseout":
      case "onkeypress":
      case "onkeydown":
      case "onkeyup":
      case "onload":
      case "onlosecapture":
      case "onpropertychange":
      case "onreadystatechange":
      case "onrowsdelete":
      case "onrowenter":
      case "onrowexit":
      case "onrowsinserted":
      case "onstart":
      case "onscroll":
      case "onbeforeeditfocus":
      case "onactivate":
      case "onbeforedeactivate":
      case "ondeactivate":
      case "type":
      case "codebase":
        ret.objAttrs[args[i]] = args[i+1];
        break;
      case "width":
      case "height":
      case "align":
      case "vspace": 
      case "hspace":
      case "class":
      case "title":
      case "accesskey":
      case "name":
      case "id":
      case "tabindex":
        ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
        break;
      default:
        ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
    }
  }
  ret.objAttrs["classid"] = classid;
  if (mimeType) ret.embedAttrs["type"] = mimeType;
  return ret;
}

Classes.Mouse = Class();
Classes.Mouse.prototype = {
	dx:		0,
	dy:		0,
	x:			0,
	y:			0,
	
	targetElement:		null, 
	button:					false,
	mouseEvents:	{
		onMouseMove:		new Array(),
		onMouseDown:		new Array(),
		onMouseUp:		new Array()
	},
	
	__construct: function() {
		
		document.onmousedown = this.mouseButtonPressed.bind(this);
		document.onmouseup     = this.mouseButtonReleased.bind(this);
	},
	findCoords: function(e) {
		if( !e ) { e = window.event; } 
			if( !e || ( typeof( e.pageX ) != 'number' && typeof( e.clientX ) != 'number' ) ) { 
				this.x = 0;
				this.y = 0;
				return; 
			}
		if( typeof( e.pageX ) == 'number' ) { 
			var posX = e.pageX; var posY = e.pageY; 
		} else {
			var posX = e.clientX; var posY = e.clientY;
			if( !( ( window.navigator.userAgent.indexOf( 'Opera' ) + 1 ) || ( window.ScriptEngine && ScriptEngine().indexOf( 'InScript' ) + 1 ) || window.navigator.vendor == 'KDE' ) ) {
			if( document.documentElement && ( document.documentElement.scrollTop || document.documentElement.scrollLeft ) ) {
				posX += document.documentElement.scrollLeft; posY += document.documentElement.scrollTop;
			} else if( document.body && ( document.body.scrollTop || document.body.scrollLeft ) ) {
				posX += document.body.scrollLeft; posY += document.body.scrollTop;
				}
			}
		}
		this.dx = posX - this.x;
		this.dy = posY - this.y;
		this.x = posX;
		this.y = posY;		
		if(this.mouseEvents && this.mouseEvents.onMouseMove) {
			var e = this.mouseEvents.onMouseMove;
			for(var i = 0;i<e.length;i++) e[i](this);
		}
	},
	mouseButtonPressed:  function(e) {
		var targ;
		this.button = true;		
		if (!e) var e = window.event;
		if (e.target) targ = e.target;
		else if (e.srcElement) targ = e.srcElement;
		if (targ.nodeType == 3) 
			targ = targ.parentNode;		
		this.targetElement = targ;		
		if(this.mouseEvents && this.mouseEvents.onMouseDown) {
			var e = this.mouseEvents.onMouseDown;
			for(var i = 0;i<e.length;i++) e[i](this);	
		}		
	},
	mouseButtonReleased: function(e) {
		this.button = false;
		if(this.mouseEvents && this.mouseEvents.onMouseUp) {
			var e = this.mouseEvents.onMouseUp;
			for(var i = 0;i<e.length;i++) e[i](this);			
		}
	},
	addEvent: function(event,func) {
		if(!this.mouseEvents) return;
		var ea = this.mouseEvents[event];
		ea.push(func);
	},
	removeEvent: function(event,func) {
		if(!this.mouseEvents) return;
		var ea = this.mouseEvents[event];
		for(var i = 0;i < ea.length;i++)
			if(ea[i].toString() == func.toString()) {
				ea.splice(i,1);
				return;
			}
	}
}

var mouse = new Classes.Mouse();
Classes.ScrollFx = Class();
Classes.ScrollFx.prototype = {
	array:			{},
	moveSpeed:	20,
	moveSteps:	100,
	itemWidth:	171,
	
	__construct: function(params) {
		if(params) this.copy(params);
	},

	getObject: function(id) {
		if(!this.array[id]) {
			this.array[id] = {
				buffer:		0,
				content:	_e(id+'_A'),
				move:		0,
				data:			'',
				offset: 0,
				total: 0,
				handle: null,
				onfinish: null
			};
		}		
	},
	switchBufferDisplay: function(id) {
		this.getObject(id);
		if(this.array[id]) {
			oldBuffer = _e(id+(this.array[id].buffer == 1 ? '_A' : '_B'));
			this.array[id]['content'].style.display = '';
			oldBuffer.style.display = 'none';
		}
	},
	switchBufferContent: function(id) {
		this.getObject(id);
		if(this.array[id]) {
			oldBuffer = _e(id+(this.array[id].buffer == 0 ? '_A' : '_B'));
			this.array[id]['content'] = newBuffer = _e(id+(this.array[id].buffer == 1 ? '_A' : '_B'));
			this.array[id].buffer = this.array[id].buffer ? 0 : 1;
		}
	},
	assignBuffer: function(id,value) {
		this.getObject(id);
		if(this.array[id]) this.array[id]['content'].innerHTML = value;
	},
	isFinished: function(id) {
		this.getObject(id);
		return (this.array[id]['handle']==null);
	},
	moveContent: function(id,p) {
		var content = this.array[id]['content'];		
		this.array[id].move += Math.abs(p);
		if(this.array[id].move > this.array[id]['total']) this.array[id]['move'] = this.array[id]['total'];

		if(this.array[id]['handle'] && this.array[id]['move'] == this.array[id]['total']) {
			window.clearInterval(this.array[id]['handle']);
			this.array[id]['handle'] = null;
			
			if(this.array[id]['onfinish'])	this.array[id]['onfinish']();
		}
		if(!content) return;
		content.style.marginLeft = (this.array[id]['offset']+(p<0 ? -this.array[id]['move'] : this.array[id]['move']))+'px';
		if(content.childNodes.length>0 && content.childNodes[0].nodeName!='#text') content.childNodes[0].style.visibility = 'visible';
		
	},
	setOffset: function(id,p) {
		this.getObject(id);
		this.array[id]['offset'] = p;
		this.array[id]['total'] = 0;
		this.array[id]['move'] = 0;
		var content = this.array[id]['content'];
		if(!content) return;
		if(this.array[id]['handle']) {
			window.clearInterval(this.array[id]['handle']);
			this.array[id]['handle'] = null;
		}
		content.style.marginLeft = p+'px';
		
	},
	assignData: function(id,data) {
		this.getObject(id);
		this.array[id]['data'] = data;
	},
	assignOnFinish: function(id,event) {
		this.getObject(id);
		this.array[id]['onfinish'] = event;
	},
	getData: function(id) {
		this.getObject(id);
		return !this.array[id]['data'] ? '' : this.array[id]['data'];
	},
	left: function(id,length) {
		this.getObject(id);
		this.array[id]['move'] = 0;
		this.array[id]['total'] = length;
		var x = -Math.abs(length/this.moveSteps);
		if(this.array[id]['handle']) {
			window.clearInterval(this.array[id]['handle']);
			this.array[id]['handle'] = null;
		}
		this.array[id]['handle'] = window.setInterval('scrollFx.moveContent(\''+id+'\','+x+')',this.moveSpeed);
	},
	right: function(id,length) {
		this.getObject(id);
		this.array[id]['move'] = 0;
		this.array[id]['total'] = length;
		var x = Math.abs(length/this.moveSteps);
		if(this.array[id]['handle']) {
			window.clearInterval(this.array[id]['handle']);
			this.array[id]['handle'] = null;
		}
		this.array[id]['handle'] = window.setInterval('scrollFx.moveContent(\''+id+'\','+x+')',this.moveSpeed);
	}
}

var scrollFx = new Classes.ScrollFx();

Classes.ImagePreloader = Class();
Classes.ImagePreloader.prototype = {
	leftToLoad: null,
	errorCnt: null,
	abort:  null,
	imagesArray: null,
	objectsArray: null,
	data:	  null,

	onImageLoad: null,
	onImageError: null,
	onImageAbort: null,
	
	onLoad: null,
	onError: null,
	onAbort: null,


	__construct: function(params) {
		if(!params) throw "__construct ImagePreloader: null params";
		this.copy(params);
	},

	preload: function() {
		this.errorCnt = 0;
		this.abort = 0;
		this.leftToLoad = this.imagesArray ? this.imagesArray.length : 0;
		this.objectsArray = new Array();		

		for(i=0;i<this.imagesArray.length;i++) {
			var img = new Image();
			this.objectsArray.push(img);
			img.onload = this.onImgLoad.bindEvent(this,img,i);
			img.onerror = this.onImgError.bindEvent(this,img,i);
			img.onabort = this.onImgAbort.bindEvent(this,img,i);
			img.src = this.imagesArray[i];
		}
	},
	checkIfCompleted: function() {
		if(this.leftToLoad <= 0) {
			if(this.errorCnt <= 0 && this.abort <= 0 && this.onLoad) this.onLoad();
			else
				if(this.abort > 0 && this.onAbort) this.onAbort();
				else
					if(this.errorCnt > 0 && this.onError) this.onError();
		}
	},
	onImgLoad: function(e,img,index) {
		this.leftToLoad--;
		if(this.onImageLoad) this.onImageLoad(img,index);
		this.checkIfCompleted();
	},
	assignData: function(data) {
		this.data = data;
	},
	onImgError: function(e,img,index) {
		this.errorCnt++;
		this.leftToLoad--;
		if(this.onImageError) this.onImageError(img,index);
		this.checkIfCompleted();
	},
	onImgAbort: function(e,img,index) {
		this.abort++;
		this.leftToLoad--;
		if(this.onImageAbort) this.onImageAbort(img,index);
		this.checkIfCompleted();
	}
}
var Style = {
	assign: function(element,style) {		
		element = _e(element);
		if(!element) return;
		if(typeof (style) == 'string') {
			if( typeof( element.style.cssText ) != 'undefined' ) element.style.cssText = style;
			else element.setAttribute('style',style);
		}
		else {
			styleStr = '';
			for(x in style) 
				switch(x) {
				case 'zIndex':
					styleStr += 'z-index: '+style[x]+'; ';
					break;
				case 'marginTop':
					styleStr += 'margin-top: '+style[x]+'; ';
					break;
				case 'marginLeft':
					styleStr += 'margin-left: '+style[x]+'; ';
					break;
				default:
					styleStr += x+': '+style[x]+'; ';
					break;
				}			
			if( typeof( element.style.cssText ) != 'undefined' ) element.style.cssText = styleStr;
			else element.setAttribute('style',styleStr);
		}
		return element;
	}	
};

function centerElementEx(element,style)
{
	element = _e(element);
	var has_element = document.documentElement && document.documentElement.clientWidth;
	var w = IE ? (has_element ? document.documentElement.clientWidth : document.body.clientWidth) : window.innerWidth;
	var h = IE ? (has_element ? document.documentElement.clientHeight : document.body.clientHeight) : window.innerHeight;		
	
	var offsetTop = _int(arguments[3] ? arguments[3].x : (IE || browser.isOpera ? (has_element ? document.documentElement.scrollTop : document.body.scrollTop) : window.scrollY),0);
	var offsetLeft = _int(arguments[3] ? arguments[3].y : (IE || browser.isOpera ? (has_element ? document.documentElement.scrollLeft : document.body.scrollLeft) : 0),0);
	
	style.position = 'absolute';
	
	var e = element.offsetParent;
	offsetTop -= _int(e.offsetTop,0);
	offsetLeft -= _int(e.offsetLeft,0);
	

	style.left = (offsetLeft+Math.floor((w-parseInt(style.width.replace('px','')))/2))+"px";
	style.top = (offsetTop+Math.floor((h-parseInt(style.height.replace('px','')))/2))+"px";
}

Classes.Preview = Class();
Classes.Preview.prototype = {
	element: null,
	elementStyle: null,
	imageElement:	null,
	imageStyle: null,
	promoLabelElement:	null,
	promoLabelStyle: null,
	closeButton: null,
	closeButtonStyle: null,
	
	width: null,
	height: null,
	imgWidth: null,
	imgHeight: null,
	opacity: 0,
	speed:  1,
	handle: null,
		
	__construct: function() {
		this.element = document.createElement('div');
		this.elementStyle = {
			position: 'absolute',
			overflow: "hidden",
			visibility: "hidden",
			background: "url('img/bg.png') repeat",
			width: '300px',
			height: '300px',
			left: '0px',
			top: '0px',
			zIndex: '1300'
		};
		Style.assign(this.element,this.elementStyle);		
		
		
		this.element.onclick = this.close.bind(this);		
		document.body.appendChild(this.element);
		
		this.imageElement = document.createElement('img');
		this.imageStyle = {
			visibility: "hidden",
			border: "#FFFFFF solid 20px",
			overflow: "hidden",
			position: 'absolute'
		};
		Style.assign(this.imageElement,this.imageStyle);
		this.element.appendChild(this.imageElement);
		
		this.closeButton = document.createElement('img');
		this.closeButton.src = 'img/bbg_x.png';
		this.closeButtonStyle = {
			visibility: "hidden",				
			position: 'absolute'
		};
		this.closeButton.onclick = this.close.bind(this);
		Style.assign(this.closeButton,this.closeButtonStyle);
		this.element.appendChild(this.closeButton);
		
		this.nextButton = document.createElement('img');
		this.nextButton.src = 'img/bbg_right.png';
		this.nextButtonStyle = {
			display: "none",
			position: 'absolute',
			left: '5px',
			top: '5px'
		};
		this.nextButton.onclick = this.onNextClick.bind(this);
		Style.assign(this.nextButton,this.nextButtonStyle);
		this.element.appendChild(this.nextButton);
		
		this.prevButton = document.createElement('img');
		this.prevButton.src = 'img/bbg_left.png';
		this.prevButtonStyle = {
			display: "none",
			position: 'absolute',
			left: '5px',
			top: '5px'
		};
		this.prevButton.onclick = this.onPrevClick.bind(this);
		Style.assign(this.prevButton,this.prevButtonStyle);
		this.element.appendChild(this.prevButton);
	},
	fitToWindow: function(scale) {		
		var has_element = document.documentElement && document.documentElement.clientWidth;
		var w = IE ? (has_element ? document.documentElement.clientWidth : document.body.clientWidth) : window.innerWidth;
		var h = IE ? (has_element ? document.documentElement.clientHeight : document.body.clientHeight) : window.innerHeight;		
				
		aw = (Math.round(scale*w));
		ah = (Math.round(scale*h));
		
		if(this.imgWidth-40 > aw-100) {					
			this.imgHeight = Math.round(((aw-100)/(this.imgWidth-40))*(this.imgHeight-40));
			this.imgWidth = (aw-100);
		}
		if(this.imgHeight-40 > ah-100) {			
			this.imgWidth = Math.round(((ah-100)/(this.imgHeight-40))*(this.imgWidth-40));
			this.imgHeight = (ah-100);
		}		
		
		this.elementStyle.width = w+'px'; 				
		this.elementStyle.height = h+'px';		
		this.imageStyle.width = this.imgWidth +'px'; 				
		this.imageStyle.height = this.imgHeight +'px';		
		
		
		centerElementEx(this.element,this.elementStyle);
		Style.assign(this.element,this.elementStyle);
		centerElementEx(this.imageElement,this.imageStyle,{x:0,y:0});		
		
		this.closeButtonStyle.left = (w-_int(this.closeButton.width+20))+'px';
		this.closeButtonStyle.top = 5+'px';
	},
	show: function(img) {			
		this.hideButtons();
		this.imageElement.src = img.src;		
		this.imgWidth = img.width;
		this.imgHeight = img.height;		
		
		this.fitToWindow(0.98);
		
		this.elementStyle.visibility = 'visible';		
		this.imageStyle.visibility = 'visible';
		this.closeButtonStyle.visibility = 'visible';
		if(browser.isIE && !browser.isIE7) {
				this.elementStyle.background = "transparent";
				this.elementStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='img/bg.png', sizingMethod='scale')";
		}
		else this.elementStyle.background = "url('img/bg.png') repeat";
		
		Style.assign(this.element,this.elementStyle);		
		Style.assign(this.imageElement,this.imageStyle);
		Style.assign(this.closeButton,this.closeButtonStyle);		
	},	
	close: function() {		
		if(!this.element || !this.imageElement) return;
		
		this.imageStyle.visibility = "hidden";
		this.elementStyle.visibility = "hidden";
		this.closeButtonStyle.visibility = 'hidden';
		
		Style.assign(this.element,this.elementStyle);
		Style.assign(this.imageElement,this.imageStyle);
		Style.assign(this.closeButton,this.closeButtonStyle);
		
		if(this.promoLabelElement) {
			this.promoLabelStyle.visibility = 'hidden';
			Style.assign(this.promoLabelElement,this.promoLabelStyle);
		}
	},
	showLabel: function(link) {
		if(!this.promoLabelElement) {		
			this.promoLabelElement = document.createElement('div');		
			this.element.appendChild(this.promoLabelElement);
			this.promoLabelElement.onclick = this.close.bind(this);
		}
		this.promoLabelStyle = {
			visibility: "hidden",			
			width: "200px",
			height: "200px",
			position: 'absolute'			
		};		
		Style.assign(this.promoLabelElement,this.promoLabelStyle);
		img = new Image();
		img.src = link;		
		this.promoLabelStyle.left = (_int(this.imageStyle.left,0)-10)+'px';
		this.promoLabelStyle.top = (_int(this.imageStyle.top,0)+this.imgHeight-img.height+40)+'px';
		this.promoLabelStyle.visibility = "visible";
		if(browser.isIE && !browser.isIE7) {
			this.promoLabelStyle.background = 'transparent';
			this.promoLabelStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+link+"', sizingMethod='noscale')";
		}
		else
			this.promoLabelStyle.background = 'url('+link+') no-repeat 0px 0px';
				
		Style.assign(this.promoLabelElement,this.promoLabelStyle);	
	},
	showButtons: function() {
		this.prevButtonStyle.left = (_int(this.imageStyle.left,0)-this.prevButton.width)+'px';
		this.prevButtonStyle.top = (_int(this.imageStyle.top,0)+(this.imageElement.offsetHeight-this.prevButton.height)/2)+'px';
		this.nextButtonStyle.left = (_int(this.imageStyle.left,0)+this.imageElement.offsetWidth)+'px';
		this.nextButtonStyle.top = (_int(this.imageStyle.top,0)+(this.imageElement.offsetHeight-this.nextButton.height)/2)+'px';
		this.prevButtonStyle.display = this.imageIdx<=0 ? 'none' : '';
		this.nextButtonStyle.display = this.imageIdx>=this.imageSet.length-1 ? 'none' : '';
		Style.assign(this.nextButton,this.nextButtonStyle);
		Style.assign(this.prevButton,this.prevButtonStyle);		
	},
	hideButtons: function() {
		this.nextButtonStyle.display = 'none';
		this.prevButtonStyle.display = 'none';
		Style.assign(this.nextButton,this.nextButtonStyle);
		Style.assign(this.prevButton,this.prevButtonStyle);		
	},
	showGallery: function(imageSet,idx) {				
		this.imageSet = imageSet;
		this.showImageByIdx(idx);
	},
	showImageByIdx: function(idx) {
		this.hideButtons();
		this.imageIdx = idx;
		if(idx+1<this.imageSet.length) {
			var preloadImg = new Image();
			preloadImg.src = this.imageSet[idx+1];
		}
		var img = new Image();
		img.src = this.imageSet[idx];		
		this.show(img);
		this.showButtons();
	},
	onNextClick: function(e) {
		e = fixEvent(e);
		this.showImageByIdx(this.imageIdx+1);		
		stopPropagation(e);
		return false;
	},
	onPrevClick: function(e) {
		e = fixEvent(e);
		this.showImageByIdx(this.imageIdx-1);		
		stopPropagation(e);
		return false;
	}
};

var imagePreloader = null;
var preview = null;

function openPreview(duzy,maly,promoLabel) {		
	var image = duzy && duzy.length > 0 ? duzy : maly;		
	imagePreloader = new Classes.ImagePreloader({
		imagesArray: [image,'img/bg.png','img/bbg_x.png'],
		data: null,
		onImageError: function(img,index) {			
			alert('Błąd oidczas ładowania obrazka: '+img.src);
		},
		onLoad: function() {
			if(!preview) 
				preview = new Classes.Preview({
					type: 'perview'
				});			
			preview.image = new Image;
			preview.image.src = image;
			preview.show(preview.image);			
			
		}
	});
	imagePreloader.preload();
}

function openGallery(imageSet,idx) {	
	imagePreloader = new Classes.ImagePreloader({
		imagesArray: [imageSet[idx],'img/bg.png','img/bbg_x.png','img/bbg_right.png','img/bbg_left.png'],
		data: null,
		onImageError: function(img,index) {			
			alert('Błąd oidczas ładowania obrazka: '+img.src);
		},
		onLoad: function() {
			if(!preview) 
				preview = new Classes.Preview({
					type: 'gallery'
				});
			preview.showGallery(imageSet,idx);
		}
	});
	imagePreloader.preload();	
}
Classes.ScrollFx = Class();
Classes.ScrollFx.prototype = {
	array:			{},
	moveSpeed:	20,
	moveSteps:	100,
	itemWidth:	171,
	
	__construct: function(params) {
		if(params) this.copy(params);
	},

	getObject: function(id) {
		if(!this.array[id]) {
			this.array[id] = {
				buffer:		0,
				content:	_e(id+'_A'),
				move:		0,
				data:			'',
				offset: 0,
				total: 0,
				handle: null,
				onfinish: null
			};
		}		
	},
	switchBufferDisplay: function(id) {
		this.getObject(id);
		if(this.array[id]) {
			oldBuffer = _e(id+(this.array[id].buffer == 1 ? '_A' : '_B'));
			this.array[id]['content'].style.display = '';
			oldBuffer.style.display = 'none';
		}
	},
	switchBufferContent: function(id) {
		this.getObject(id);
		if(this.array[id]) {
			oldBuffer = _e(id+(this.array[id].buffer == 0 ? '_A' : '_B'));
			this.array[id]['content'] = newBuffer = _e(id+(this.array[id].buffer == 1 ? '_A' : '_B'));
			this.array[id].buffer = this.array[id].buffer ? 0 : 1;
		}
	},
	assignBuffer: function(id,value) {
		this.getObject(id);
		if(this.array[id]) this.array[id]['content'].innerHTML = value;
	},
	isFinished: function(id) {
		this.getObject(id);
		return (this.array[id]['handle']==null);
	},
	moveContent: function(id,p) {
		var content = this.array[id]['content'];		
		this.array[id].move += Math.abs(p);
		if(this.array[id].move > this.array[id]['total']) this.array[id]['move'] = this.array[id]['total'];

		if(this.array[id]['handle'] && this.array[id]['move'] == this.array[id]['total']) {
			window.clearInterval(this.array[id]['handle']);
			this.array[id]['handle'] = null;
			
			if(this.array[id]['onfinish'])	this.array[id]['onfinish']();
		}
		if(!content) return;
		content.style.marginLeft = (this.array[id]['offset']+(p<0 ? -this.array[id]['move'] : this.array[id]['move']))+'px';
		if(content.childNodes.length>0 && content.childNodes[0].nodeName!='#text') content.childNodes[0].style.visibility = 'visible';
		
	},
	setOffset: function(id,p) {
		this.getObject(id);
		this.array[id]['offset'] = p;
		this.array[id]['total'] = 0;
		this.array[id]['move'] = 0;
		var content = this.array[id]['content'];
		if(!content) return;
		if(this.array[id]['handle']) {
			window.clearInterval(this.array[id]['handle']);
			this.array[id]['handle'] = null;
		}
		content.style.marginLeft = p+'px';
		
	},
	assignData: function(id,data) {
		this.getObject(id);
		this.array[id]['data'] = data;
	},
	assignOnFinish: function(id,event) {
		this.getObject(id);
		this.array[id]['onfinish'] = event;
	},
	getData: function(id) {
		this.getObject(id);
		return !this.array[id]['data'] ? '' : this.array[id]['data'];
	},
	left: function(id,length) {
		this.getObject(id);
		this.array[id]['move'] = 0;
		this.array[id]['total'] = length;
		var x = -Math.abs(length/this.moveSteps);
		if(this.array[id]['handle']) {
			window.clearInterval(this.array[id]['handle']);
			this.array[id]['handle'] = null;
		}
		this.array[id]['handle'] = window.setInterval('scrollFx.moveContent(\''+id+'\','+x+')',this.moveSpeed);
	},
	right: function(id,length) {
		this.getObject(id);
		this.array[id]['move'] = 0;
		this.array[id]['total'] = length;
		var x = Math.abs(length/this.moveSteps);
		if(this.array[id]['handle']) {
			window.clearInterval(this.array[id]['handle']);
			this.array[id]['handle'] = null;
		}
		this.array[id]['handle'] = window.setInterval('scrollFx.moveContent(\''+id+'\','+x+')',this.moveSpeed);
	}
}

var scrollFx = new Classes.ScrollFx();

