String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g, ''); }
String.prototype.ltrim = function() { return this.replace(/^\s+/g, ''); }
String.prototype.rtrim = function() { return this.replace(/\s+$/g, ''); }

$(document).ready( function(){




		 $("#obrazki").cycle({delay: 0, timeout: 4000, fx: 'fade'});
		



		
});


    // convert all characters to lowercase to simplify testing
    var agt=navigator.userAgent.toLowerCase();

    // *** BROWSER VERSION ***
    // Note: On IE5, these return 4, so use is_ie5up to detect IE5.
    var is_major = parseInt(navigator.appVersion);
    var is_minor = parseFloat(navigator.appVersion);

    var is_ie     = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
    var is_ie3    = (is_ie && (is_major < 4));
    var is_ie4    = (is_ie && (is_major == 4) && (agt.indexOf("msie 4")!=-1) );
    var is_ie4up  = (is_ie && (is_major >= 4));
    var is_ie5    = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.0")!=-1) );
    var is_ie5_5  = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.5") !=-1));
    var is_ie5up  = (is_ie && !is_ie3 && !is_ie4);
    var is_ie5_5up =(is_ie && !is_ie3 && !is_ie4 && !is_ie5);
    var is_ie6    = (is_ie && (is_major == 4) && (agt.indexOf("msie 6.")!=-1) );
    var is_ie6up  = (is_ie && !is_ie3 && !is_ie4 && !is_ie5 && !is_ie5_5);
    var is_opera = (window.opera)?true:false;
    var is_opera7 = (window.opera)?true:false;
    var is_gecko = (agt.indexOf('gecko') != -1);


if(document.all && !document.getElementById)
    document.getElementById = function(id) { return document.all[id]; }

if(document.all && !document.getElementsByTagName)
    document.getElementsByTagName = function(tag) { return document.all.tags(tag); }


var lo = 1;
function sof (a) {
	if (document.getElementById('foto' + lo)) document.getElementById('foto' + lo).style.display = 'none';
	document.getElementById('oferta' + lo).style.display = 'none';
	document.getElementById('lin' + lo).className = '';
	lo = a;
	if (document.getElementById('foto' + lo)) document.getElementById('foto' + lo).style.display = '';
	document.getElementById('oferta' + lo).style.display = '';
	document.getElementById('lin' + lo).className = 'selected';

}

function footReset() {
	f = document.getElementById('footer').style.position="relative";
	f = document.getElementById('footer').style.position="absolute";
	//alert('test');
	if (txtalert != '') {
		alert(txtalert);
		txtalert = '';
	}
}


function flash(name,src,x,y,ver,opcja) {
	

	if (opcja == 'w3c') {
		document.write ('<object id="'+name+'" type="application/x-shockwave-flash" data="'+src+'" width="'+x+'" height="'+y+'" >');
		document.write ('<param name="movie" value="'+src+'" >');
		document.write ('<param name="swliveconnect" value="true">');
		document.write ('</object>');
	}
	else {

		document.write ('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"');
		document.write ('codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version='+ver+',0,0,0"');
		document.write ('width='+x+' height='+y+' id="'+name+'">');
		document.write ('<param name=movie value="'+src+'">');
		document.write ('<param name=quality value=high>');

		if (opcja == 'transparent') document.write ('<param name="wmode" value="transparent">');

		document.write ('<param name="swliveconnect" value="true">');
		document.write ('<embed src="'+src+'" quality="high" width="'+x+'" height="'+y+'"');
		document.write (' type="application/x-shockwave-flash"');
		document.write (' pluginspage="http://www.macromedia.com/downloads/"');
		document.write (' name="'+name+'" swliveconnect="true">');
		document.write ('</embed>');
		document.write ('</object>');
	}
}


function setSize() {

	ww = (window.innerWidth)?window.innerWidth:document.body.clientWidth
	if (ww>800) {
		document.getElementById('container').style.marginLeft = '-490px';
		document.getElementById('container').style.width = '980px';
	}
	else {
		document.getElementById('container').style.marginLeft = '-389px';
		document.getElementById('container').style.width = '954px';
	}
}


function oW (path,Xsiz,Ysiz,popUnder) {
	var przed = '';
	if (!(Xsiz > 0)) { Xsiz = 450; }
	if (!(Ysiz > 0)) { Ysiz = 300; }
	w = window.open(przed+path, 'fotozoom', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,fullscreen=no,channelmode=no,width='+Xsiz+',height='+Ysiz+',top=30,left=30');
	if (popUnder) {
		w.blur();
		window.focus();
	}
	else {
		w.focus();
	}
	void(0);
}



function pobierz(nazwa) {
    if (document.cookie.length > 0) {
        startc = document.cookie.indexOf(nazwa + "=");
        if (startc != -1) {
            startc += nazwa.length + 1;
            endc = document.cookie.indexOf(";", startc);
            if (endc == -1) {
                endc = document.cookie.length;
            }
            return unescape(document.cookie.substring(startc,endc));
        }
	return false;
    }
    return false;
}

function rejestruj(nazwa, wartosc,dni) {
    var dzisiaj=new Date();
    var wygasnie=new Date();
    !dni ?dni=7 :"";
    // dni - data po której ciastko traci ważnosc 
    // jesli dni==0 to ważne w ciągu danej "sesji"
    wygasnie.setTime(dzisiaj.getTime()+1000*60*60*24*dni);
	document.cookie=nazwa+"="+escape(wartosc)+";expires="+wygasnie.toGMTString();
}

function sClear(obj,itxt) {
	if (obj.value == itxt) obj.value = '';
}
function sReturn(obj,itxt) {
	if (obj.value == '') obj.value = itxt;
}

function init() {
	
	if (txtalert != '') {
		alert(txtalert);
		txtalert = '';
	}
spSize();
}

window.onload = init;


function cq (kod,zm) {

		var tmpIl = eval( "document.grupa[\"il["+kod+"]\"].value;");

		++tmpIl;

		--tmpIl;

		reszta = tmpIl%zm;

		if ((zm > 0) && (tmpIl < 999999) ) {

			eval( "document.grupa[\"il["+kod+"]\"].value = tmpIl + zm - reszta;");

		}

		else if ((zm < 0) && (tmpIl > 0)){

			if ( reszta > 0 ) { eval( "document.grupa[\"il["+kod+"]\"].value = tmpIl - reszta;"); }

			else {	eval( "document.grupa[\"il["+kod+"]\"].value = tmpIl + zm;"); }

		}

	if (document.getElementById('zzm')) {

			

			document.getElementById('zzm').className  = "bma";

		}

}



function rq (kod,zm) {

		var tmpIl = eval( "document.grupa[\"il["+kod+"]\"].value;");

		++tmpIl;

		--tmpIl;

		reszta = tmpIl%zm;

		if (!(tmpIl >= 0)) {

			alert ("Wprowadzono nie poprawna wartosc!");

			eval( "document.grupa[\"il["+kod+"]\"].value = 0;");

		}

		else if (reszta > 0) {

			alert ("Ilosc musi być wielokrotnoscia liczby "+zm);

			eval( "document.grupa[\"il["+kod+"]\"].value = tmpIl - reszta;");

		}

		if (document.getElementById('zzm')) {

			

			document.getElementById('zzm').className  = "bma";

		}



}

function spSize() {
if (document.getElementById('menu')) {
	m = document.getElementById('menu');
	c = document.getElementById('content');
	if (m.clientHeight > c.clientHeight) c.style.minHeight = m.clientHeight + 'px';
}
}



function clearOpts(os) {
	for(a = 1; a <= 5; ++a) {
		if (a != os && document.getElementById('cecha'+a)) {
			s = document.getElementById('cecha'+a);
			s.options.length = 1;
		}
	}
}

function disableOpts(os) {
	for(a = 1; a <= 5; ++a) {
		if (a != os && document.getElementById('cecha'+a)) {
			s = document.getElementById('cecha'+a);
			
			for (var i=1, option; option = s.options[i]; i++) {
				option.disabled = true;
			}
		}
	}
}

function enableOpt(n,v) {

	if (document.getElementById('cecha'+n) && document.getElementById('cecha'+n).options) {
		s = document.getElementById('cecha'+n);
		for (var i=1, option; option = s.options[i]; i++) {
			if (option.value == v) option.disabled = false;
		}
	}
}
var selOpt = [];


function array_search(ar,v) {
	for(a in ar) {
		if (ar[a] == v) return true;
	}
	return false;
}	

function saveOpt() {
	for(a = 1; a <= 5; ++a) {
		if (document.getElementById('cecha'+a)) {	
			selOpt[a] = document.getElementById('cecha'+a).value;
		}
	}
}

function add2cart() {
	var selOpt = [];
	for(a = 1; a <= 5; ++a) {
		if (document.getElementById('cecha'+a)) {	
			if (document.getElementById('cecha'+a).selectedIndex == 0 && document.getElementById('cecha'+a).options.length > 1) {
				alert ('Proszę wybrać '+ntypy[a]);
				document.getElementById('cecha'+a).focus();
				return false;
			}
			selOpt[a] = document.getElementById('cecha'+a).options[document.getElementById('cecha'+a).selectedIndex].innerHTML;
			//op = document.getElementById('cecha'+a).options[document.getElementById('cecha'+a).selectedIndex];
			//for (x in op) alert (x + '=>' +op[x]);
			//alert (document.getElementById('cecha'+a).selectedIndex + '::' + document.getElementById('cecha'+a).options[document.getElementById('cecha'+a).selectedIndex].innerHTML);
			
		}	
	}
	for (kod in ptypy) {
		kodOK = 1;
		for (n in ptypy[kod]) {
			if (ptypy[kod][n] && selOpt[n] != ptypy[kod][n]) kodOK = 0;
		}
		if (kodOK) {
			
			document.location.href = '/page.php?cat=76&add['+kod+']=1';
			return true;
		}
	}
}

function populate(sc,nrc)
{
	saveOpt();
	clearOpts(nrc);
	//nrcK = nrc - 1;
	optVals = [];
	for (kod in ptypy) {
		if (ptypy[kod][nrc] == sc.value || sc.value == '') {
			for (n in ptypy[kod]) {
				
				if (n != nrc && ptypy[kod][n]) {
					if (!optVals[n]) optVals[n] = {};
					if (!array_search(optVals[n],ptypy[kod][n])) {
						ind = document.getElementById('cecha'+n).options.length;
						document.getElementById('cecha'+n).options[ind] = new Option(ptypy[kod][n],ptypy[kod][n]);
						optVals[n][kod] = ptypy[kod][n];
						if (selOpt[n] == ptypy[kod][n]) document.getElementById('cecha'+n).selectedIndex = ind;
					}
				}	
			}
		}
	}
	

}

function populateX(sc,nrc)
{
	saveOpt();
	disableOpts(nrc);
	//nrcK = nrc - 1;
	optVals = [];
	for (kod in ptypy) {
		if (ptypy[kod][nrc] == sc.value || sc.value == '') {
			for (n in ptypy[kod]) {
				
				if (n != nrc && ptypy[kod][n] != '') {
					enableOpt(n,ptypy[kod][n]);
				}	
			}
		}
	}
	

}

function cecha(kid) {
ret = ''
par = kid.value.substring(2)
l = ',';
while (par.indexOf(':') >= 0) {
    n = par.indexOf(':');
    x = par.lastIndexOf(':');
    if ( x == n) {l = '';}
    str = par.substring(0,n);
    m = str.indexOf(";");
    ret = ret+str.substring(0,m)+'-'+kid.id+','+str.substring(m+1)+l;
    par = par.substring(n+1);
} 

return ret;
}


function filterek(thiskat,addurl) {
	params = '';
	fs = document.getElementById('filter');
	kids = fs.childNodes;
	l = '';
	var a;
	for (a = 1; a < 8; ++a) {
		if (document.getElementById('cechaw'+a)) {
			kid = document.getElementById('cechaw'+a);
			if (kid.nodeType == 1 && kid.tagName == 'SELECT' && kid.value) {
			    if (kid.value.substring(0,2) == '##') {
				params = params+l+cecha(kid);
			    }
			    else {
				params = params+l+'eq-'+kid.id+','+kid.value.isourlencode();
			    }
			    l = ',';
			}
		}
	}

	h = '';
	if (params.trim() != '')  h = '.html';

	document.location.href= thiskat+params+((addurl && params)?',':'')+addurl+h;
}




$(document).ready( function(){
	
	$('.sp-kill').hide();
	$('.display-none').hide();
	$('.sp-kill input').val('nospam');

	$('img.actItemYoutube').each(function(){
		if (this.alt != '') {
			$(this).after('<object type="application/x-shockwave-flash" style="width: ' + this.width + 'px; height:' + this.height + 'px;" data="' + this.alt + '"><param name="movie" value="' + this.alt + '" /><param name="wmode" value="transparent" /></object>');
		}

		
	});

	$('a.login-required').click(function() {
		this.innerHTML = $(this).attr('nicetitle');
		return false;
	});

	$('img.actItemYoutube').remove();

});

/* Made by Mathias Bynens <http://mathiasbynens.be/> */
function number_format(a, b, c, d) {
 if (b == null) b = 2;
 if (c == null) c = ',';
 if (d == null) d = ' ';
 a = Math.round(a * Math.pow(10, b)) / Math.pow(10, b);
 e = a + '';
 f = e.split('.');
 if (!f[0]) {
  f[0] = '0';
 }
 if (!f[1]) {
  f[1] = '';
 }
 if (f[1].length < b) {
  g = f[1];
  for (i=f[1].length + 1; i <= b; i++) {
   g += '0';
  }
  f[1] = g;
 }
 if(d != '' && f[0].length > 3) {
  h = f[0];
  f[0] = '';
  for(j = 3; j < h.length; j+=3) {
   i = h.slice(h.length - j, h.length - j + 3);
   f[0] = d + i +  f[0] + '';
  }
  j = h.substr(0, (h.length % 3 == 0) ? 3 : (h.length % 3));
  f[0] = j + f[0];
 }
 c = (b <= 0) ? '' : c;
 return f[0] + c + f[1];
}


$(function() {
   $('a[@rel*=lightbox]').lightBox({
	overlayBgColor: '#000',
	overlayOpacity: 0.7,
	imageLoading: '/img/lb/lightbox-ico-loading.gif',
	imageBtnClose: '/img/lb/closelabel.gif',
	imageBtnPrev: '/img/lb/prev.gif',
	imageBtnNext: '/img/lb/next.gif',
	containerResizeSpeed: 350,
	txtImage: 'Ilustracja',
	txtOf: 'z'
   });
});

function createCookie(name,value,days)
{
if (days)
{
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toGMTString();
}

else var expires = "";
document.cookie = name+"="+value+expires+"; path=/";
}

function unhide(divID,l) {
  var item = document.getElementById(divID);
  if (item) {
    item.className=(item.className=='hidden')?'unhidden':'hidden';
    l.innerHTML=(item.className=='hidden')?'<showhide>pokaż opis tabeli &raquo;</showhide>':'<showhide>&laquo; ukryj opis tabeli</showhide>';
    cook=(item.className=='hidden')?1:0;
  }
  createCookie('mopis',cook,30);
  l.blur();
  return false;
}

