    // 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]; }


function chS(obj, new_style) {
    obj.className = new_style;
}


function oW (path,Xsiz,Ysiz) {
	var przed = '';
	if (!(Xsiz > 0)) { Xsiz = 300; }
	if (!(Ysiz > 0)) { Ysiz = 300; }
	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');
	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 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 init() {
}

function testForm(formName) {
		tf = document.forms[formName];
		argv = testForm.arguments;
		result = true;
		a = 1;
		while (argv[a]) {
			if ((tf[argv[a]].tagName.toLowerCase() == 'input' && tf[argv[a]].type.toLowerCase() == 'text' ) || tf[argv[a]].tagName.toLowerCase() == 'textarea') {
				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]].type.toLowerCase() == 'checkbox') {
				if (!tf[argv[a]].checked) {
					alert (argv[a+1]);
					tf[argv[a]].focus();
					result = false;		
					break;
				}
			}
			else if (tf[argv[a]].type.toLowerCase() == 'radio') {
				if (!tf[argv[a]].checked) {
					alert (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;
		}
		alert ("'" + tf['email'].value + "'::'" +  tf['telefon'].value + "'" );
		if (result && tf['email'].value == '' && tf['telefon'].value == '') {
				alert ('Proszę podać adres e-mail lub numer telefonu');
				result = false;
		}
		return result;

}



var dragapproved=false
var z,x,y

function lclose(obj){
	document.getElementById('tableOferta').style.display = 'none';
}

function openTable(obj){
	document.getElementById('tableOferta').style.display = 'block';
	void(0);
}

function tclose(obj){
	objP=is_gecko? obj.parentNode : obj.parentElement;
	objP.style.display = 'none';
}
function topen(obj){
	document.getElementById(obj).style.display = 'inline';
}


function move(e){
	if (dragapproved){
		xs=is_gecko?(temp1+(e.clientX-x)): (temp1+event.clientX-x);
		ys=is_gecko?(temp2+(e.clientY-y)): (temp2+event.clientY-y);
	//	window.status = temp1;
		z.style.left = xs + 'px';
		z.style.top = ys + 'px';
		return false
	}
}

function drags(e){

	if (!is_ie&&!is_gecko) return
	
	var firedobj=is_gecko? e.target : event.srcElement
	var topelement=is_gecko? "HTML" : "BODY"
//	alert (firedobj.tagName);
/*
	while (firedobj.tagName!=topelement&&firedobj.className!="drag"&&firedobj.id!="tableOferta"&&firedobj.className!="tableOferta"){
		firedobj=is_gecko? firedobj.parentNode : firedobj.parentElement
		
	}
*/
	if (firedobj.className=="drag" || firedobj.id == "tableOferta" || firedobj.className == "tableOferta"){
		dragapproved=true
		z=firedobj
		temp1=(z.style.left)?parseInt(z.style.left+0):250;
		temp2=(z.style.top)?parseInt(z.style.top+0):230;
		x=is_gecko? e.clientX: event.clientX
		y=is_gecko? e.clientY: event.clientY
		document.onmousemove=move
		return false
	}
}
function ups (e) {
	dragapproved=false;
}
document.onmousedown=drags
document.onmouseup=ups



function zoomImg(url,title,xs,ys){

	xs = (xs)?xs:720;
	ys = (ys)?ys:640;
	var okno;
	if (okno){ okno.close(); }

	okno = window.open(url,title,'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,fullscreen=no,channelmode=no,width='+xs+',height='+ys+',top=0,left=0');
    okno.document.open();
    okno.document.write("<HEAD><title>"+title+"</title></head><BODY style=\"margin:0;padding:0;overflow:auto;\"><IMG src="+url+" id=\"obrazek\" onload=\"a=(this.height <= 730)?(this.height+30):730;window.resizeTo(this.width + 30,a);window.moveTo(10,10);\"></body>");
    okno.document.close();
    okno.focus();
		void(0);

}

function zoomThis(obj){
	msrc = obj.src;
	bsrc = msrc.substring(0,msrc.length-4)+'_big.jpg';
	zoomImg(bsrc,"Ilustracja",720,640);
	void(0);
}

var muLastSel = 0;
function muSwitch(ob) {
  if (document.getElementById('muO' + ob).style.display == 'none') {
    if (muLastSel > 0) {
      document.getElementById('muO' + muLastSel).style.display = 'none';
      document.getElementById('muR' + muLastSel).className = 'muRN';
    }
    document.getElementById('muO' + ob).style.display = '';
	document.getElementById('muR' + ob).className = 'muRA';
    muLastSel = ob;
  }
  else {
    document.getElementById('muO' + ob).style.display = 'none';
	document.getElementById('muR' + ob).className = 'muRN';
  
  }
}


function CheckAndContinue() {

	if (tf ('Proszę wypełnić pole  "imię"','fimie'))
	if (tf ('Proszę wypełnić pole "nazwisko"','fnazwisko'))
	if (el('ftel').value == '' && el('femail').value == '') alert ('Proszę podać adres e-mail lub numer telefonu');
	else if (el('ftak').checked == false && el('fnie').checked == false) alert ('Proszę wyrazić zgodę na przetwarzanie danych osobowych');
	else { 
		el('ankform').submit();
		void(0); 
	}
	
}



winIEpass = ((navigator.appName.indexOf("Microsoft") != -1) && 
(navigator.appVersion.indexOf("Windows") != -1)) && 
(parseFloat(navigator.appVersion) >= 4) ? true : false;

NNpass = ((navigator.appName == "Netscape") && 
(navigator.userAgent.indexOf("Mozilla") != -1) && 
(parseFloat(navigator.appVersion) >= 4) && 
(navigator.javaEnabled())) ? true : false;


NNpass = NNpass || is_gecko;
supportedBrowser = (winIEpass || NNpass) ? true : false;

// check for Flash Plug-in in Mac or Win Navigator. Get plug-in version.

minPlayer = 4;

function Flash_checkForPlugIn() {
	var plugin = (navigator.mimeTypes && 
	navigator.mimeTypes["application/x-shockwave-flash"]) ?
	navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;

	if (plugin) {
		var pluginversion = parseInt(plugin.description.substring(plugin.description.indexOf(".")-1)) 
		if(pluginversion >= minPlayer) {return true;}
	}
	return false;
}


// vbscript check for Flash ActiveX control in windows IE
if(supportedBrowser && winIEpass)
{
	document.write(
		'<script language=VBScript>' + '\n' +
		'Function Flash_checkForActiveX()' + '\n' +
			'Dim hasPlayer, playerversion' + '\n' +
			'hasPlayer = false' + '\n' +
			'playerversion = 10' + '\n' +
			'Do While playerversion >= minPlayer' + '\n' +
				'On Error Resume Next' + '\n' +
				'hasPlayer = (IsObject(CreateObject(\"ShockwaveFlash.ShockwaveFlash.\" & playerversion & \"\")))' + '\n' +
				'If hasPlayer = true Then Exit Do' + '\n' +
				'playerversion = playerversion - 1' + '\n' +
			'Loop' + '\n' +
			'Flash_checkForActiveX = hasPlayer' + '\n' +
		'End Function' + '\n' +
		'<\/script>'
		);
}

function Flash_checkForMinPlayer() {
	if(!supportedBrowser) return false;
	if(NNpass) return (Flash_checkForPlugIn());
	if(winIEpass) return (Flash_checkForActiveX());
}


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+'" width="'+x+'" height="'+y+'" >');
		document.write ('<param name="movie" value="'+src+'" >');
		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+'">');
		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 showSubMenu(obj) {

	if (document.getElementsByTagName)
		var x = document.getElementsByTagName('ul');
	else if (document.all)
		var x = document.all.tags('ul');
	for (var i=0;i<x.length;i++) 
		if (x[i].className == 'menuProd') x[i].style.display = "none";


	kids = obj.childNodes;
 	for (var i = 0; i < kids.length; i++) {
 
    	// do something with each kid as kids[i]
		t = kids[i].tagName;
 		if (t == 'UL') {
//			if (kids[i].style.display == "") kids[i].style.display = "none";
//			else 
			kids[i].style.display = "";
			break;
		}
 
	}
//	obj.blur();
//	if (obj.childNodes[1].style.display == "") obj.childNodes[1].style.display = "none";
//	else obj.childNodes[1].style.display = "";
	void(0);
}


function zoomThis(obj){
	// x = obj.firstChild;
	msrc = obj.src;
	//bsrc = msrc.substring(0,msrc.length-4)+'_big.jpg';
	bsrc = msrc.replace(/m_/ig, "");

	zoomImg(bsrc,"Ilustracja");
	void(0);
}

function email(user,site) {
	document.write('<a href=\"mailto:'+user+'@'+site+'\">');
	document.write(user+'@'+site+'<\/a>');
}

function openWin (obj,w,h,x,y,cent,rs,sb,mb,ab,nb,surl) {
	if (sb == null) sb = 1;
	if (rs == null) rs = 1;
	if (w == null) w = this.popupW;
	if (h == null) h = this.popupH;
	if ((cent == null && x == null && y == null) || cent) {
		x = Math.floor((screen.availWidth-w)/2);
		y = Math.floor((screen.availHeight-h)/2);
	}
	
	surl = surl?surl:obj.href;

	
	nid = parseInt(Math.random()*10000000);	
	
	if (this.popupRef == null || this.popupRef.closed || this.popupUrl != surl) 
		this.popupRef = window.open(surl,'pp'+nid,
		'scrollbars='+((sb)?'yes':'no') +
		',menubar='+((mb)?'yes':'no') +
		',resizable='+((rs)?'yes':'no') +
		',toolbar='+((nb)?'yes':'no') +
		',location='+((ab)?'yes':'no') +
		',left='+x+',top='+y+',width='+w+',height='+h
		);
	this.popupUrl = surl;
	this.popupRef.focus();
}
