function wyswietl(co) {
var ile = 4; for (var i = 1; i <= ile; i++)
if(co != i) 
document.getElementById("w_" + i).style.display = 'none';
else
document.getElementById("w_" + i).style.display = 'block';
}

function showsMe(co) {
var ile = 4; for (var i = 1; i <= ile; i++)
if(co != i) 
document.getElementById("sz_" + i).style.display = 'none';
else
document.getElementById("sz_" + i).style.display = 'block';
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_openBrWindow(theURL,winName,features) { 
             window.open(theURL,winName,features); }


function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function clearSelect(selectName){
	var c = $(selectName);
	for( i=c.options.length-1; i>=0; i--) c.options[i]=null;
	var opt = document.createElement("option");
		    	opt.text = 'Wybierz:';
		        opt.value = '-1';
		        try { c.add(opt, null); } catch(ex) { c.add(opt); }
}

function clearSelect2(selectName){
	var c = $(selectName);
	for( i=c.options.length-1; i>=0; i--) c.options[i]=null;
	var opt = document.createElement("option");
		    	opt.text = 'Wszystkie';
		        opt.value = '';
		        try { c.add(opt, null); } catch(ex) { c.add(opt); }
}

function PopupPic(sPicURL, command) {
     window.open( "openImage.php?id="+sPicURL+"&command="+command, "",  
     "resizable=1,HEIGHT=100,WIDTH=100");
}



function changeSearchSource(lp){
	switch(lp){
		case '1':
			document.forms['ss'].menu.value = 'katalog'
			document.getElementById('s1').style.display = 'block';
			document.getElementById('s2').style.display = 'none';
			document.getElementById('s3').style.display = 'none';
			document.getElementById('s4').style.display = 'none';
			break;
		case '2':
			document.forms['ss'].menu.value = 'maszynykat'
			document.getElementById('s1').style.display = 'none';
			document.getElementById('s2').style.display = 'block';
			document.getElementById('s3').style.display = 'none';
			document.getElementById('s4').style.display = 'none';
			break;
		case '3':
			document.forms['ss'].menu.value = 'ogloszenia'
			document.getElementById('s1').style.display = 'none';
			document.getElementById('s2').style.display = 'none';
			document.getElementById('s3').style.display = 'block';
			document.getElementById('s4').style.display = 'none';
			break;
		case '4':
			document.forms['ss'].menu.value = 'produkty'
			document.getElementById('s1').style.display = 'none';
			document.getElementById('s2').style.display = 'none';
			document.getElementById('s3').style.display = 'none';
			document.getElementById('s4').style.display = 'block';
			break;
	}
}

function changePicture(sr, id, cat, opis){
	var myimg = document.getElementById('bigphoto');
	myimg.src = sr;
	myimg.onclick = function(){PopupPic(id, cat)};
	if(opis == '!!no!!'){
		
	}
	else{
		var popis = document.getElementById('popis');
		popis.innerHTML = "<img src='img/kw_ye.gif' width='5' height='5'>  " + opis;
	}
}

function changeSort(form){
	var locationObj = new String(window.location);
	var z, d, q, loc;
	z = locationObj.indexOf("sort");
	if(z == -1){
		locationObj = locationObj.concat("&sort=" + form.jak.value);
		
	}
	else{
		d = locationObj.indexOf("&",z+1);
		if(d == -1){
			q = locationObj.indexOf("=",z+1);
			locationObj = locationObj.substring(0,q+1)
			locationObj = locationObj.concat(form.jak.value);
		}
		else{
			q = locationObj.indexOf("=",z+1);
			loc = locationObj.substring(0, q+1);
			loc = loc.concat(form.jak.value);
			q = locationObj.indexOf("&",z+1);
			loc = loc.concat(locationObj.substring(q,locationObj.length));
			locationObj = loc;
		}
	}
	window.location = locationObj;
}

function changeSort2(val){
	var locationObj = new String(window.location);
	var z, d, q, loc;
	z = locationObj.indexOf("sort");
	if(z == -1){
		locationObj = locationObj.concat("&sort=" + val);
		
	}
	else{
		d = locationObj.indexOf("&",z+1);
		if(d == -1){
			q = locationObj.indexOf("=",z+1);
			locationObj = locationObj.substring(0,q+1)
			locationObj = locationObj.concat(val);
		}
		else{
			q = locationObj.indexOf("=",z+1);
			loc = locationObj.substring(0, q+1);
			loc = loc.concat(val);
			q = locationObj.indexOf("&",z+1);
			loc = loc.concat(locationObj.substring(q,locationObj.length));
			locationObj = loc;
		}
	}
	window.location = locationObj;
}


