var IE6, IE7, IE8, IE9, IE, FF, O;


with(window.navigator.userAgent) {
	if(indexOf('MSIE') != -1) {
		IE = true;
		if(indexOf('MSIE 7') != -1) IE7 = true;
		else if(indexOf('MSIE 8') != -1) IE8 = true;
		else if(indexOf('MSIE 9') != -1) IE9 = true;
		else IE6 = true;
	}
	else if(indexOf('Gecko') != -1) FF = true;
	else if(indexOf('Opera') != -1) O = true;
}

function mine(t, a) {
	if(a=='add') {
		var d = new Date();
		d.setYear(d.getYear() < 1900? d.getYear() + 1901: d.getYear() + 1);
		document.cookie='mine[' + t + ']='+ t + ';expires='+d.toGMTString()+';path=/';
//		alert('Oferta została dodana do listy Państwa ofert. W każdym momencie będą mogli Państwo do nich powrócić.');
	}
	if(a=='remove') document.cookie='mine[' + t + ']=0;expires=;path=/';
}

String.prototype.object = function(params, childs) {var noattr={innerHTML:true,colSpan:true,className:true},el=document.createElement(this.toUpperCase());for(var i in params)if(noattr[i])el[i]=params[i];else el.setAttribute(i,params[i]);if(typeof(childs)!='undefined'){if(childs.length)for(var i=0; i<childs.length; i++)el.appendChild(childs[i]);else if(childs)el.appendChild(childs);};return el;}
String.prototype.ucfirst = function(){return this.replace(/\b([a-z])/i,function(c){return c.toUpperCase()});};

function s_fl(o) {
	if(e('s_l') && o.id=="s_fm" && o.checked==true) { e('s_l').checked=false; return true; }
	if(e('s_fm') && o.id=="s_l" && o.checked==true) { e('s_fm').checked=false; return true; }
}

function e(o, c) {
	if(!this.cache) this.cache = new Array();
	if(!this.cache[o] || c) this.cache[o] = document.getElementById(o);
	return this.cache[o];
}

function swf() {
	var url;
	var w;
	var h;
	var id;
	var style;
	this.draw = draw;
	function draw(url, w, h, id, style) {
		this.url = url;
		this.w = w;
		this.h = h;
		this.id = id;
		this.style = style;
		document.write('<'+'script type="text/javascript" src="/js/f.js"><'+'/script>');
	}
}
swf = new swf;

function a() {
	var f_s1 = e('search_adv1');
	var f_s2 = e('search_adv2');
	if(f_s1.style.display == 'inline') {
		f_s1.style.display = f_s2.style.display = 'none';
		e('search').className='';
		var els = new Array('s_f', 's_m', 's_cat', 's_f', 's_o', 's_n');
		for(i in els) e(els[i]).value='';
		e('s_adv_a').innerHTML='wyszukiwanie zaawansowane';
	} else {
		f_s1.style.display = f_s2.style.display = 'inline';
		e('search').className='adv';
		e('s_adv_a').innerHTML='wyszukiwanie standardowe';
	}
}





var mRI = 0;
var mRB;

function mRU(o, b) {
	if(!mRI) {
		o = e(o);
		if(!o) return false;

		o.style.visibility='hidden';
		o.style.display='inline';

		t = o.getElementsByTagName('A');
		for(i in t) t[i].onmouseover = mRU;

		o.onmouseover = mRU;
		o.onmouseout = mRD;
		b.onmouseout = mRD;

		m = new Object();
		m.x1 = getX(b); m.x2 = getX(o); m.w1 = getW(b); m.w2 = getW(o); m.y1 = getY(b); m.y2 = getY(o); m.h1 = getH(b); m.h2 = getH(o);

		m.object = o;
		m.speed = 10;
		m.frames = 10;
		m.count = 0;
		m.shadow = true;
		mRI = m;
		mRDraw(1);
	}
	mRI.count++;
}

function mRDraw(a) {

	m = mRI;
	o = m.object;

	x1 = m.x1; x2 = m.x2; w1 = m.w1; w2 = m.w2; y1 = m.y1; y2 = m.y2; h1 = m.h1; h2 = m.h2;

	if(typeof(mRB) != 'object') {
		mRB = document.createElement('div');
		with(mRB.style) {
			border = '1px solid #cde4ed';
			background = '#ffffff';
			width = (a? w1: w2) + 'px';
			height = (a? h1: h2) + 'px';
			position = 'absolute';
			zIndex = 50;
			left = (a? x1: x2) + 'px';
			top = (a? y1: y2) + 'px';
		}
		m.i = m.frames;
		if(m.shadow) e(o.id+'Shadow').style.display = 'none';
		o.style.visibility='visible';
		o.style.display = 'none';
		w = (a? w1: w2);
		h = (a? h1: h2);
		document.body.appendChild(mRB);
	}

	if(h > 0 && w > 0 && --m.i) {
	w = w - (a? -1: 1) * w2 / m.frames + (a? -1: 1) * w1 / m.frames;
	h = h - (a? -1: 1) * h2 / m.frames + (a? -1: 1) * h1 / m.frames;

		with(mRB.style) {
			left = Math.floor(x2 - (x1 > x2? -1: 1) * (a? m.i: m.frames - m.i) * Math.abs(x1 - x2) / m.frames) + 'px';
			top = Math.floor(y2 - (y1 > y2? -1: 1) * (a? m.i: m.frames - m.i) * Math.abs(y1 - y2) / m.frames) + 'px';

			width = w + 'px';
			height = h + 'px';
		}
		setTimeout('mRDraw('+a+')', m.speed);
	} else {
		document.body.removeChild(mRB);
		mRB = void(0);
		if(a) {
			o.style.display = 'inline';
			if(m.shadow) e(o.id+'Shadow').style.display = 'block';
		} else {
			if(m.shadow) e(o.id+'Shadow').style.display = 'none';
			mRI = void(0);
		}
	}
}

function mRD() { setTimeout('mRDrawWait('+mRI.count+')', 333); }
function mRDrawWait(p) { if(mRI.count == p) mRDraw(0); }



function l(u) { s = document.createElement('script'); s.type = 'text/javascript'; s.defer = true; s.src = u; document.body.appendChild(s); }
function getInt(n) { return n == 'auto'? 0: parseInt(n.replace('px', '')); }
function getStyle(o, s) { if(o.currentStyle) return o.currentStyle[s]; else if(window.getComputedStyle) return document.defaultView.getComputedStyle(o, null).getPropertyValue(s.replace(/([A-Z]+)/g, '-$1').toLowerCase()); }
function getX(o) { return getXY(o, 1); }
function getY(o) { return getXY(o, 0); }
function getW(o) { return getInt(getStyle(o, 'width')) + getInt(getStyle(o, 'paddingLeft')) + getInt(getStyle(o, 'paddingRight')); }
function getH(o) { return getInt(getStyle(o, 'height')) + getInt(getStyle(o, 'paddingTop')) + getInt(getStyle(o, 'paddingBottom')); }
function getXY(o, xy) { var p = 0; if(o.offsetParent) while(1) { p += (xy? o.offsetLeft: o.offsetTop); if(!o.offsetParent) break; o = o.offsetParent; } else if(o.x || o.y) p += (xy? o.x: o.y); return p; }
function onMouseOut(evt, o) {var i = evt.toElement || evt.relatedTarget; while(i) { if(i == o) return false; else if(i.tagName == 'HTML') return true; i = i.parentNode; }}



var imgBox = {
	img: [],
	text: [],
	cache: [],
	counter: 1,
	next: function() {
		if(++this.counter > this.img.length) this.counter = 1;
		this.draw();
	},
	prev: function() {
		if(--this.counter < 1) this.counter = this.img.length;
		this.draw();
	},
	draw: function() {
		if(this.img.length) {
			e('img_nav').innerHTML = '<span onclick="imgBox.prev();" class="prev" style="cursor: pointer;">'+(this.counter)+'<\/span> z <'+'span onclick="imgBox.next();" class="next" style="cursor: pointer;">'+this.img.length+'<\/span>'+this.text[this.img[this.counter - 1][1]];
			if(!this.cache[this.counter - 1]) {
				this.cache[this.counter - 1] = new Image();
				this.cache[this.counter - 1].src = this.img[this.counter - 1][0];
			}
			e('img').src = this.cache[this.counter - 1].src;
			e('img').title = this.text[this.img[this.counter - 1][1]];
		}
		return true;
	}
}

function scrollDiv(o, d) { t = e(o).getElementsByTagName('div'); j = 0; u = new Array(); scrollCache = new Array(); for(i in t) if(t[i].id) { u[j] = t[i]; scrollCache[j] = t[i].innerHTML; j++; } for(i = 0; i < j; i++) u[i].innerHTML = scrollCache[d == 'rew'? (i? i - 1: j - 1): (i == j - 1? 0: i + 1)]; }

var ad = {
	iframe: function(param){
		var odp = '';
		try {
			odp = '<iframe frameborder="0" allowtransparency="yes" scrolling="no"';
			odp += ' src="/ad/' + param.site + '/' + param.ad + '.html?' + (document.referrer && !document.referrer.match('/' + document.domain + '/')? 'referer=' + escape(document.referrer) + '&': '') + 'url=' + escape(document.URL);
			if(param.site == 'main' || param.site.indexOf('_main') > 0) odp += 'strona-glowna.html';
			odp += '" style="border:0 none;height:0;' + param.style + ' "';
			odp += ' id="' + param.id + '"';
			if(typeof(param.cssClass) != 'undefined') {
				odp+= ' class='+param.cssClass;
			}
			odp += '></iframe>';
			document.write(odp);
		} catch(err) {}
}}

var googleAnalytics = function(kod, domema) {
	this.pageTracker = _gat._getTracker(kod);
	with(this.pageTracker) { _setDomainName(domema); _initData(); }
	this.setStep = this.pageTracker._trackPageview;
	this.pageTracker._trackPageLoadTime();
}

var debug = function() {
	document.body.appendChild('script'.object({src: 'http://jquery.com/src/jquery-latest.js'}));
	this.outline = function() {jQuery('body *').css('outline', '1px solid red');}
}

var infolinia = {
	list: [],
	step: 0,
	steps: 5,
	view: 3000,
	timeout: 50,
	init: function(obj) {
		this.list = obj.getElementsByTagName('DL');
		changeOpac(0, this.list[1]);
		this.list[1].style.display='';
		setTimeout(function(){infolinia.animate();}, this.view);
	},
	animate: function() {
		this.step++;
		var opacity = Math.abs(this.step % (this.steps * 2) - this.steps) * (100 / this.steps);
		changeOpac(opacity, this.list[0]);
		changeOpac(100 - opacity, this.list[1]);
		setTimeout(function(){infolinia.animate();}, (opacity == 0 || opacity == 100) ? this.view : this.timeout);
	}
};

function changeOpac(opacity, obj) { obj.zIndex++;
	if(opacity == 100) {obj.style.opacity = '';obj.style.MozOpacity = ''; obj.style.KhtmlOpacity = ''; obj.style.filter = '';return false;}
	obj.style.opacity = (opacity / 100);obj.style.MozOpacity = (opacity / 100);obj.style.KhtmlOpacity = (opacity / 100);obj.style.filter = "alpha(opacity=" + opacity + ")";
	var children = obj.getElementsByTagName('a');
	for(var i=0; i < children.length; i++) children[i].style.visibility = 'visible';
};

function addEvent(elm, evType, fn, useCapture) { if (elm.addEventListener) { elm.addEventListener(evType, fn, useCapture); return true;	} else if (elm.attachEvent) { var r = elm.attachEvent('on' + evType, fn); return r;	} else { elm['on' + evType] = fn; } };


function closeCalendar(e) {
	try {
		var keycode;
	    if (window.event) keycode = window.event.keyCode;
	    else if (e) keycode = e.which;
		if (keycode == 27) f_tcalHideAll();
	} catch(err){}
};

function closeCalendarClick(e) {
	try {
		if (e == null) e = window.event;
		var target;
		if(e.target != null) target = e.target;
		else target = e.srcElement;
		var obj = e.srcElement || e.target;
		if (obj.target == 'body') {return false;}
		for (var i=0; i<50; i++) { //sprawdzam, czy rodzicem jest kontener kalendarza - jesli nie, zamykamy
			if (obj == null || obj.nodeName == 'BODY') { f_tcalHideAll(); return false; }
			else if (obj.id == 'tcal') return false;
			obj = obj.parentNode;
	}} catch(err){}
};

addEvent(document, 'keydown', function(e){closeCalendar(e);}, true);
addEvent(document, 'mousedown', function(e){closeCalendarClick(e);}, true);
