    // 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); }


function chS(obj, new_style) {
    obj.className = new_style;
}

var lastWin;
function setImg (imgSrc,reSize) {
	if (lastWin.jestem) {
		
		if (reSize == 1) {
			lastWin.document.body.innerHTML = '<img src="'+imgSrc+'" id="obrazek" onload="window.resizeTo(this.width + 10,this.height + 30);window.moveTo(20,20);" >'; 
			lastWin.focus();
		}
		else {
			lastWin.document.body.innerHTML = '<img src="'+imgSrc+'" id="obrazek" >'; 
		}
			
	}	
	else {
		setTimeout("setImg('"+imgSrc+"', '"+reSize+"')",100);
	}
}


function setSizeImg () {
	if (lastWin.document.getElementById('obrazek')) {

	//	lastWin.resizeTo(lastWin.document.getElementById('obrazek').width + 10,lastWin.document.getElementById('obrazek').height + 30);
	//	lastWin.moveTo(20,20); 
		alert(lastWin.document.getElementById('obrazek').src);
		lastWin.close(); 
		zoomImg(lastWin.document.getElementById('obrazek').src,lastWin.document.getElementById('obrazek').width,lastWin.document.getElementById('obrazek').height);
	}	
	else {
		setTimeout("setSizeImg()",100);
	}
}

// onload="window.resizeTo(this.width + 10,this.height + 30);window.moveTo(20,20);

function zoomImg(imgSrc,xSize,ySize) {
	reSize = 1;
	if (xSize && ySize) reSize = 0;
	if (!xSize) xSize=300;
	if (!ySize) ySize=300;
	scrollBary='no';
	xPos=20;
	lastWin = window.open('blank.html','zoomOkno','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars='+scrollBary+',resizable=yes,fullscreen=no,channelmode=no,width='+xSize+',height='+ySize+',top=0,left='+xPos);
	
	setImg (imgSrc,reSize);
	void(0);
}

function oW (path,Xsiz,Ysiz,Xp,Yp) {
	var przed = '';
	if (!(Xsiz > 0)) { Xsiz = 300; }
	if (!(Ysiz > 0)) { Ysiz = 300; }
	if (Xp == 'right') Xp = screen.width - 20 - Xsiz;
	if (!(Xp > 0)) { Xp = 30; }
	if (!(Yp > 0)) { Yp = 30; }
	var 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='+Yp+',left='+Xp);
	w.focus();
	void(0);
}
function oP (kodKat) {
	oW('opis.php?prd_id='+kodKat,780,560,'yes');
	void(0);
}

function el (id) {
        return document.getElementById(id);
}

function tf (txt,id) {
		if (el(id).value == '') {
	        alert(txt);
			el(id).focus();
			return false;
		}
		else return true;
}

function ts (txt,id) {
		if (el(id).selectedIndex == 0) {
	        alert(txt);
			el(id).focus();
			return false;
		}
		else return true;
}

function te (txt,id) {
		if (el(id).value != '' && el(id).match(/^.*\@.*\..*$/)==null) {
	        alert(txt);
			el(id).focus();
			return false;
		}
		else return true;
}

function tc (txt,id) {
		if (!(el(id).checked)) {
		
	        if (txt != '') { alert(txt); el(id).focus(); }
			return false;
		}
		else return true;
}

function flash(name,src,x,y,ver,opcja) {
		
	if (is_ie) { b = 'ie' }
	
	else if (is_gecko) { b = 'gecko' }
	else if (is_opera) { b = 'opera' }

	if (opcja == 'w3c' || (opcja == 'jsOpti' && b != 'ie')) {
		document.write ('<object id="'+name+'" type="application/x-shockwave-flash" data="'+src+'?browser='+b+'" width="'+x+'" height="'+y+'" >');
		document.write ('<param name="movie" value="'+src+'?browser='+b+'" >');
		document.write ('<param name="wmode" value="opaque">');
		document.write ('<param name="swliveconnect" value="true">');
		document.write ('</object>');
	}
	else if (opcja == 'fsc' || (opcja == 'jsOpti' && b == 'ie') || (opcja == 'transparent' && b == 'ie')) {

		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+'?browser='+b+'">');
		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+'?browser='+b+'" 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 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żno¶ć (domy¶lnie tydzień)
    // je¶li 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 sprawdz()
{
var fundament = document.getElementById("zainteresowanie").value;
if(fundament=="profesjonalnie")
  {
  document.getElementById("ukryte1").style.visibility="visible";
  document.getElementById("ukryte2").style.visibility="visible";
  document.getElementById("ukryte3").style.visibility="visible";
  document.getElementById("ukryte4").style.visibility="visible";
  document.getElementById("ukryte5").style.visibility="visible";
  document.getElementById("ukryte6").style.visibility="visible";
  document.getElementById("komunikat_pro").style.visibility="visible";	
	}
else
  {
  document.getElementById("ukryte1").style.visibility="hidden";
  document.getElementById("ukryte2").style.visibility="hidden";
  document.getElementById("ukryte3").style.visibility="hidden";
  document.getElementById("ukryte4").style.visibility="hidden";
  document.getElementById("ukryte5").style.visibility="hidden";
  document.getElementById("ukryte6").style.visibility="hidden";
  document.getElementById("komunikat_pro").style.visibility="hidden";		
  }
}


function searchMode(obj) {

	document.getElementById('search_www').className = 'radioOff';
	document.getElementById('search_prod').className = 'radioOff';
	document.getElementById('search_' + obj).className = 'radioOn';
	rejestruj('searchMode',obj,0);
	if (obj == 'www') {
		document.forms['search'].action = 'search.php';
		document.forms['search'].cat.value = '7';
	}
	else {
		document.forms['search'].action = 'page.php';
		document.forms['search'].cat.value = '100';
	}
	void(0);
}

function init() {
	smode = pobierz('searchMode')
//	alert (smode);
	if (smode) {
		searchMode(smode)	
	}
	if (komunikat && komunikat != '')  alert(komunikat);
	if (akomunikat == 'loginOK') document.location.href='page.php?cat=2640';
	blinkie();
}

function blinkie() {
		if (is_ie) {
			allb = document.getElementsByTagName('b');
			for (a = 0; a < allb.length; ++a) if (allb[a].className == 'promo') allb[a].style.visibility = (allb[a].style.visibility=='hidden') ? 'visible' : 'hidden'; 
			setTimeout("blinkie()", 500); 
		}
}

function testForm(formName) {
		tf = document.forms[formName];
		argv = testForm.arguments;
		result = true;
		a = 1;
		while (argv[a]) {
			if (tf[argv[a]].tagName.toLowerCase() == 'input') {
				if (tf[argv[a]].value == '') {
					alert ('Proszę wypełnić pole "'+argv[a+1]+'"');
					tf[argv[a]].focus();
					result = false;		
					break;
				}
			}
			else {
				if (tf[argv[a]].selectedIndex == 0) {
					alert ('Proszę wybrać "'+argv[a+1]+'"');
					tf[argv[a]].focus();
					result = false;		
					break;
				}
			}
			a += 2;
		}
		if (result && !el['jestem_zainteresowany1']) result = true;
		else if (result && (tf['jestem_zainteresowany1'].checked || tf['jestem_zainteresowany2'].checked || tf['jestem_zainteresowany3'].checked || tf['jestem_zainteresowany4'].checked || tf['jestem_zainteresowany5'].checked || tf['jestem_zainteresowany6'].checked)) result = true;
		else if (result) { alert('Proszę wybrać rodzaj oferty'); result = false; }
		return result;

}

var activeSubMenu = false;
var timeOut = 1000;

function subMenu(obj,show) {

	activeSubMenu = t = obj.nextSibling;	

	if (show) {
		allul = document.getElementsByTagName('ul');
		for (a = 0; a < allul.length; ++a) if (allul[a].className == 'submenu') allul[a].style.display = 'none';
		t.style.display = 'block';
		//alert (obj.parentNode.parentNode.scrollLeft);
		t.style.left = (obj.scrollLeft<230)?obj.scrollLeft+ 'px':'190px';
	}
	else {
		activeSubMenu = false;
	 	setTimeout ("hideSubmenu(document.getElementById('"+t.id+"'))",timeOut);
	}
}
function hideSubmenu(t) {
	if (!activeSubMenu || activeSubMenu != t) t.style.display = 'none';
}

function overMenu(t) {
	activeSubMenu = t;
}

function outMenu(t) {
	activeSubMenu = false;
 	setTimeout ("hideSubmenu(document.getElementById('"+t.id+"'))",timeOut);
}
function add(pid) {
	document.location.href="page.php?cat=203&add["+pid+"]=1";
}

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').style.color = "#f00";
		}
}

function rq (kod,zm) {
		var tmpIl = eval( "document.grupa[\"il["+kod+"]\"].value;");
		++tmpIl;
		--tmpIl;
		reszta = tmpIl%zm;
		if (!(tmpIl >= 0)) {
			alert ("Wprowadzono nie poprawną warto¶!");
			eval( "document.grupa[\"il["+kod+"]\"].value = 0;");
		}
		else if (reszta > 0) {
			alert ("Ilo¶ć musi być wielokrotno¶cią liczby "+zm);
			eval( "document.grupa[\"il["+kod+"]\"].value = tmpIl - reszta;");
		}
		if (document.getElementById('zzm')) {
			
			document.getElementById('zzm').style.color = "#f00";
		}

}
var komunikat = '';
var akomunikat = '';

var wojs = ['ini', 'dls', 'kpm', 'lbl', 'lub', 'ldz', 'mlp', 'maz', 'opl', 'pdk', 'pdl', 'pom', 'sla', 'swi', 'wrm', 'wlp', 'zpm'];
function switchWoj(woj) {
	for (a in wojs) {
		if (document.getElementById(wojs[a])) document.getElementById(wojs[a]).style.display = 'none';
	}
	if (document.getElementById(woj)) document.getElementById(woj).style.display = 'block';
	void(0);
}
var byldruk = false;

function printQ() {
	if (!byldruk && confirm('Czy chcesz wydrukować zamównienie przed wysłaniem?')) { print(); byldruk = true; return false }
	else return true;
}

function getValue(varname)
{

  var url = window.location.href;
  var qparts = url.split("?");
  if (qparts.length == 0)
  {
    return "";
  }
  var query = qparts[1];
  var vars = query.split("&");
  var value = "";

  for (i=0;i<vars.length;i++)
  {
    var parts = vars[i].split("=");
    if (parts[0] == varname)
    {
      value = parts[1];
      break;
    }
  }
  
  value = unescape(value);
  value.replace(/\+/g," ");

  return value;
}

function addFav(url,title,txtalert) {
  if(window.external &&
     typeof window.external.AddFavorite != "undefined")
    window.external.AddFavorite(url,title);
  else{
	if (typeof txtalert=="undefined") txtalert = "Proszę użyć skrutu CTRL+D";
	alert (txtalert);
  }
}

function switchGImg(no, garray, glname, glimg) {
	for (a in garray) {
		if (document.getElementById(glname+a))	document.getElementById(glname+a).className = '';
	}
	document.getElementById(glname+no).className = 'selected';
	document.getElementById(glimg).src = garray[no+1];
	void(0);
}
