    // 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>');
	}
}



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('','Zoom', '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 zoom2(imgSrc) {
	lastWin = window.open('sdgsdgsd','zoomOkno','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,fullscreen=no,channelmode=no,width=300,height=300,top=0,left=150');

	void(0);
}

function oW (path,Xsiz,Ysiz,Xp,Yp,resi,scrollb) {
	if (path.indexOf('zoom.php') != -1) path = '/heuristic2/'+path;
	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; }
	if (resi == null) resi = 'yes';
	if (scrollb == null) scrollb = 'yes';
	var w = window.open(przed+path, 'fotozoom', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars='+scrollb+',resizable='+resi+',fullscreen=no,channelmode=no,width='+Xsiz+',height='+Ysiz+',top='+Yp+',left='+Xp);
	w.focus();
	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?a (domy?lnie tydzien)
    // je?li dni==0 to wa?ne w ci1gu 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 setLogMode(obj){
	rejestruj('logmode',obj,0);
	//alert('zapisalem '+obj);	
}
function logMode(obj) {
	//setLogMode(obj);
	//alert('zapisalem '+obj);
	if(obj == 'rozwiniete'){
		zwin(1000,8,64);
	}
	void(0);
}
//var kart;
function init() {
	log_mode = pobierz("logmode");
	//alert(log_mode);
	if (log_mode == 'rozwiniete') {
		rozwiniete=false;
		top=-64;
		setTimeout ("logMode('"+log_mode+"')",500);	
	}
	//if (komunikat && komunikat != '')  alert(komunikat);
	//blinkie();


/************poprawa banerow pod IE i Opera*************************/
/*	var o,n,j,i,p,t,ob = new Array(),objs = document.getElementsByTagName('object');
	for(i=0;i<objs.length;i++)if (!objs[i].className.match(/(^|\s)noninteractive($|\s)/)) ob.push(objs[i]);
	//objs=null;
	for(i=0;i<ob.length;i++)
	{
		t='';
		for(j=0;j<ob[i].childNodes.length;j++)
		{
			if (ob[i].childNodes[j].tagName != 'OBJECT')
			t += ob[i].childNodes[j].outerHTML;
		}
		t = ob[i].outerHTML.replace("</OBJECT>",t + "</OBJECT>");
		
		n = ob[i].nextSibling;
		p = ob[i].parentNode;
		
		p.removeChild(ob[i]);
		ob[i] = null;
	
		o = document.createElement('span');
		o.innerHTML = t;
		o = o.firstChild;
	
		p.insertBefore(o,n);
	}
*/
}

//window.onload = init();

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); 
		}
}

// ****************  MENU *******************

var activeSubMenu = false;
var timeOut = 1000;

$(document).ready(function(){
	$('#menu ul li a.menu').mouseover(function(){subMenu($(this).get(0), 1);});
	$('#menu ul li a.menu').mouseout(function(){subMenu($(this).get(0), 0);});
	$('#menu ul li ul.submenu').mouseover(function(){overMenu($(this).get(0))});
	$('#menu ul li ul.submenu').mouseout(function(){outMenu($(this).get(0))});
});

function subMenu(obj,show)
{
  if(obj.nextSibling)
  {
    if(obj.nextSibling.innerHTML)
    {
      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.visibility = 'hidden';
	t.style.visibility = 'visible';
      }
      else
      {
        activeSubMenu = false;
	setTimeout ("hideSubmenu(document.getElementById('"+t.id+"'))",timeOut);
      }
    }
  }
}

function hideSubmenu(t) {
	if (!activeSubMenu || activeSubMenu != t) t.style.visibility = 'hidden';
}

function overMenu(t) {
	activeSubMenu = t;
}

function outMenu(t) {
	activeSubMenu = false;
 	setTimeout ("hideSubmenu(document.getElementById('"+t.id+"'))",timeOut);
}

function addslashes(str) {
	str=str.replace(/\'/g,'\\\'');
	str=str.replace(/\"/g,'\\"');
	str=str.replace(/\\/g,'\\\\');
	str=str.replace(/\0/g,'\\0');
	return str;
}
function stripslashes(str) {
	str=str.replace(/\\'/g,'\'');
	str=str.replace(/\\"/g,'"');
	str=str.replace(/\\\\/g,'\\');
	str=str.replace(/\\0/g,'\0');
	return str;
}

function emailValid(t,im,em) {
	
	var imie = document.getElementById('newsImieF');
	var mail = document.getElementById('newsEmailF');
	var er = document.getElementById('newsEmailI');
	
	try{
	if (!imie.value) {
		er.innerHTML = im;
		mail.focus(); 
		mail.parentNode.parentNode.className = 'alertRow';
		return false;
	}
	else {
		if (mail.value.indexOf('@',0) == -1 || mail.value.indexOf('.',0) == -1){
			er.innerHTML = em;
			mail.focus(); 
			mail.parentNode.parentNode.className = 'alertRow';
			return false;
		}
	}
	}
	catch(e){}
}

function emailPassValid(t,g) {
	
	var email = document.getElementById('emailF');
	var eror = document.getElementById('emailI');
	
	try{
	if (email.value.indexOf('@',0) == -1 || email.value.indexOf('.',0) == -1){
		eror.innerHTML = g;
		email.focus(); 
		email.parentNode.parentNode.className = 'alertRow';
		return false;
	}
	}catch(e){}
}


function prints(a) {

var link = a.indexOf('#');

if(link != -1) {
	links=document.location.href.substring(0,link);
	oW(links+'&print=1',750,750);
}
else {
	oW(document.location.href+'&print=1',750,750);
}
}


// ---------------------------------------------------- jQuery -------------------------------------------------------------------
$(document).ready(function(){

	// mp3 player
        $('img.actItemMp3').each(function(){

               if (this.alt != '') {
		
                       $(this).after('<object type="application/x-shockwave-flash" style="width: ' + this.width + 'px; height:' + this.height + 'px;" data="/mp3player.swf?mp3file=' + this.alt + '&txt=' + this.title + '"><param name="movie" value="/mp3player.swf?mp3file=' + this.alt + '&txt=' + this.title + '"/><param name="wmode" value="transparent" /></object>');
               }
        });
        $('img.actItemMp3').remove();


	// youtube player
        $('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>');
		}		
	});
	$('img.actItemYoutube').remove();


	// last gallery
	$('.last_gallery').cycle({fx: 'fade',
		                       speed: 300,
	        	               timeout: 5000});

	// site color
	$('.bkgcol1').click(function(){
		$.ajax({
			url: "/page.php",
			type: "POST",
			data: "color=1&persvars=1"
		});

		$('body').removeClass('background');
		$('body').removeClass('background2');
		$('body').addClass('background');

		$('#topcorners').removeClass('bkg');
		$('#bottomcorners').removeClass('bkg');
	});

	$('.bkgcol2').click(function(){
		$.ajax({
			url: "/page.php",
			type: "POST",
			data: "color=2&persvars=1"
		});

		$('body').removeClass('background');
		$('body').removeClass('background2');
		$('body').addClass('background2');

		$('#topcorners').addClass('bkg');
		$('#bottomcorners').addClass('bkg');
	});
	

	// home-news next-prev
	$('.aktualnoscigroup').cycle({fx: 'scrollHorz',
		                     speed: 300,
		                     timeout: 0,
			             prev: '.aktualnosci_prev',
			             next: '.aktualnosci_next'});

	// home-porady next-prev
	$('.poradygroup').cycle({fx: 'scrollHorz',
		                     speed: 300,
		                     timeout: 0,
			             prev: '.porady_prev',
			             next: '.porady_next'});
});

$(window).load(function(){

	// equal columns: content, right_panel
	if($('.content').height() > $('.right_panel').height() && !$('body').attr('onload'))
	{
		$('.right_panel').height($('.content').height());
		$('.right_panel').css('min-height', $('.content').height()+'px');
		$('.right_panel').css('height', $('.content').height()+'px');
	}
});





