onload=function(d){
	/* jeśli włączono js - nie potrzeba nam przycisków submit */
	for(var i=0;d=document.getElementsByTagName('*')[i++];){
		if(/\bhide\b/gi.test(d.className)){
			d.style.display='none';
		}
	}
	
	document.getElementById('bagazniki').style.display='none';
	document.getElementById('lancuchy').style.display='none';

	
	/* szybkie dodawanie pól w szukarce * /
	var d=document.getElementById('attribute');
	if(d){
		var button=document.createElement('button');
		button.appendChild(document.createTextNode('Dodaj wybór podzespołu'));
		button.onclick=function(){
			var clone=d.cloneNode(true);
			d.parentNode.insertBefore(clone, d);
			return false;
		}
		d.parentNode.insertBefore(button, d.nextSibling);
	}
	/* end */
	
	if(d=document.getElementById('prod_img')){
		d.onclick=function(){
			popupWindow(this.href);
			return false;
		}
	}
}

bagSlide=function(){
	if(document.getElementById('bagazniki').style.display=='none') document.getElementById('bagazniki').style.display='block';
	else document.getElementById('bagazniki').style.display='none';
}

lanSlide=function(){
	if(document.getElementById('lancuchy').style.display=='none') document.getElementById('lancuchy').style.display='block';
	else document.getElementById('lancuchy').style.display='none';
}

/*
	 Skrypt jest darmowy, poki ten komentarz w nim pozostaje.
	 Released under Creative Commons License
	 http://creativecommons.org/licenses/by/2.0/

	 Original author: Kornel Lesinski
	 http://pornel.net/pups/
*/
var pornpups =
{
	init: function(element)
	{
		if (!element || !element.getElementsByTagName) {return false;}

		var as = element.getElementsByTagName('a');
		for(var i=0;i<as.length;i++)
		{
			if ((as[i].href+'').match(/\.(jpe?g|png|gif)/i))
				as[i].onclick = this.click;
		}

		return true;
	},
	writedoc: function(win,href,title,alt,h,w)
	{
		var doc = win.document;
		doc.open('text/html;charset=ISO-8859-2');
		doc.write(
		'<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">' +
		'<html>' +
		'<head><title>' + alt + '</title>' +
		'<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-2">' +
		'<link rel="stylesheet" href="stylesheet.css" type="text/css">'+
		'<meta http-equiv="imagetoolbar" content="false">' +
		'</head><body onclick="window.close();" style="width:'+w+'px;margin:0;padding:0; background:#fff url(\'img/top.gif\') repeat-x;">' +
		(title?'<h1 class="pop">'+title+'</h1>':'') +
		'<p><img src="'+href+'" alt="'+alt+'"></p>' +
		'</body></html>'
		);
		doc.close();
	},
	title2size: function(str)
	{
		if (str)
		{
			var out = str.match(/\(([0-9]+)x([0-9]+)\)/);
			if (out) return new Array(str.replace(/\(([0-9]+)x([0-9]+)\)/g,''),parseInt(out[1]),parseInt(out[2]));
		}
		return new Array(str,550,420);
	},
	click: function()
	{
		try {
			if (this.pp_win && this.pp_win.close && !this.pp_win.closed) {this.pp_win.close(); this.pp_win=false;}
		}
		catch(e){}
		try {
			var imgs = this.getElementsByTagName('img');
			var title = this.getAttribute('title');
			var alt = imgs[0].getAttribute('alt');
			var titleandsize = pornpups.title2size(title);
			
			// check real height
			var h=document.createElement('h1');
			h.appendChild(document.createTextNode(titleandsize[0]));
			h.setAttribute('style', 'width:'+titleandsize[1]+'px');
			document.body.appendChild(h);
			var height=h.offsetHeight;
			h.parentNode.removeChild(h);
			
			var winopts = "dependent=yes,toolbar=no,resizable=yes,width=" + (titleandsize[1]) + ',height=' + (titleandsize[2]+height);
			var win = window.open(this.href,'_blank',winopts);
			if (win && win.opener)
			{
				this.pp_win = win;
				pornpups.writedoc(win,this.href,titleandsize[0],alt,titleandsize[2],titleandsize[1]);
				return false;
			}
		}
		catch(e){}
		return true;
	},
	initNow: function()
	{
		this.init(document.body);
	},
	initLoad: function()
	{
		var oldOnload = window.onload;
		var that = this;
		window.onload = function()
		{
			if (oldOnload) try{oldOnload();}catch(e){}
			that.initNow();
		}
	}
};
pornpups.initLoad();