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


// ****************  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)
{
	$(document).ready( function(){

		// submenu - show/hide
  		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);
      				}
    			}
  		}
	});
}

$(document).ready( function(){
	// horizontal submenu ie6 hack
	if($.browser.className == 'msie6')
	{
		var li_width   = 0;
		var submenuobj = 0;

		$('.submenu').each(function(){
			li_width   = 0;
			submenuobj = $(this);

			$('#'+submenuobj.attr('id')+' li').each(function(){
				li_width += $(this).width();
			});

			$(submenuobj).css("width", li_width);
		});
	}
});

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 links = document.location.href;
	if(links.indexOf('#') != -1) {
		links=document.location.href.substring(0,links.indexOf('#'));

	}

	if(links[links.length-1] != '/') {
		links = links+'&print=1';
	}
	else {
		links = links+'page.php?print=1';
	}

	oW(links,740,740);

}


// **************** JQUERY *******************
var alert_timer = 0;

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


	// colorbox init
	$('a.colorbox').colorbox({opacity:0.8,title:function(){return $(this).attr('name');}});



	// --------------------- article box -----------------------

	$('.article_tabs a').click(function() {
		$('.article_tabs a').removeClass('sel');
		$(this).addClass('sel');

		$('.article').css('display','none');
		$('#c'+$(this).attr('id')).css('display','block');

		$('.article_tabsml a').removeClass('sel');
		$('#c'+$(this).attr('id')+'1').addClass('sel');

		$('.article_contents').css('display','none');
		$('#sc'+$(this).attr('id')+'1').css('display','block');

		$('.article_content').css('display','none');
		$('#sc'+$(this).attr('id')+'11').css('display','block');

		$('.article_list a').removeClass('sel');
		$('#c'+$(this).attr('id')+'11').addClass('sel');

		return false;
	});

	$('.article_tabsml a').click(function() {
		$('.article_tabsml a').removeClass('sel');
		$(this).addClass('sel');

		$('.article_contents').css('display','none');
		$('#s'+$(this).attr('id')).css('display','block');

		$('.article_content').css('display','none');
		$('#s'+$(this).attr('id')+'1').css('display','block');

		$('.article_list a').removeClass('sel');
		$('#'+$(this).attr('id')+'1').addClass('sel');

		return false;
	});

	$('.article_list a').hover(function() {
		$('.article_content').css('display','none');
		$('#s'+$(this).attr('id')).css('display','block');

		$('.article_list a').removeClass('sel');
		$(this).addClass('sel');
	}, function() {});



	$('.pb_share1').hover(function(){
		$('.pb_share1 .addthis_toolbox .vertical').fadeIn('fast');
		$('.pb_share1 .addthis_custom_button').addClass("addthis_custom_button_hover");
		$('.pb_share1 .addthis_custom_button').removeClass("addthis_custom_button");
	},function(){
		$('.pb_share1 .addthis_toolbox .vertical').fadeOut('fast');
		$('.pb_share1 .addthis_custom_button_hover').addClass("addthis_custom_button");
		$('.pb_share1 .addthis_custom_button_hover').removeClass("addthis_custom_button_hover");
	});

	$('.pb_share2').hover(function(){
		$('.pb_share2 .addthis_toolbox .vertical').fadeIn('fast');
		$('.pb_share2 .addthis_custom_button').addClass("addthis_custom_button_hover");
		$('.pb_share2 .addthis_custom_button').removeClass("addthis_custom_button");
	},function(){
		$('.pb_share2 .addthis_toolbox .vertical').fadeOut('fast');
		$('.pb_share2 .addthis_custom_button_hover').addClass("addthis_custom_button");
		$('.pb_share2 .addthis_custom_button_hover').removeClass("addthis_custom_button_hover");
	});

	$('.pb_share3').hover(function(){
		$('.pb_share3 .addthis_toolbox .vertical').fadeIn('fast');
		$('.pb_share3 .addthis_custom_button').addClass("addthis_custom_button_hover");
		$('.pb_share3 .addthis_custom_button').removeClass("addthis_custom_button");
	},function(){
		$('.pb_share3 .addthis_toolbox .vertical').fadeOut('fast');
		$('.pb_share3 .addthis_custom_button_hover').addClass("addthis_custom_button");
		$('.pb_share3 .addthis_custom_button_hover').removeClass("addthis_custom_button_hover");
	});




	$('.chb_remember').click(function(){
		if($(this).hasClass("chb_true"))
		{
			$('.chb_remember').removeClass('chb_true');
			$('.chb_remember').addClass('chb_false');
			$('.chb_al').attr("checked","");
		}
		else
		{
			$('.chb_remember').removeClass('chb_false');
			$('.chb_remember').addClass('chb_true');
			$('.chb_al').attr("checked","checked");
		}
	});


	$('.topbtn').click(function(){
		var newbox = '#top_' + $(this).attr('id');
		var lnkid = '#' + $(this).attr('id');
		$('.top_box.active').fadeOut('', function(){
			$('.top_box.active').removeClass("active");
			$('.topnavi a.active').removeClass("active");
			$(newbox).addClass("active");
			$(lnkid).addClass("active");
			$(newbox).fadeIn();
		});
		return false;
	});


	$('.home_akt .box_side a').hover(function(){
		var lnkid = '#' + $(this).attr('id');
		var tabid = '#' + $(this).attr('id') + 'tab';

		$('.home_akt .box_side a.active').removeClass("active");
		$('.home_akt .box_main div.active').removeClass("active");
		$(lnkid).addClass("active");
		$(tabid).addClass("active");
	});


	$('.gal_cycle').cycle();
	

	/*************** forum - wyszukiwarka **********************/
	$('#fs5btn').click(function(){
		var fq5 = $("#fq5").val().replace(/[\.,\/]/g,'');
		var fq6 = $("#fq6").val();
		var fq7 = $("#fq7").val();
		var fq8 = $("#fq8").val();
		var fq9 = $("#fq9").val();

		document.location.href=fq9+'/phrase,'+fq5+',fcat,'+fq7+',ftype,'+fq6+',ftime,'+fq8+'.html';
	});

	$("#fq6").change(function () {
		var str = "";
		$("#fq6 option:selected").each(function () {
			str += $(this).text() + " ";
		});
		$("#fq6div").text(str);
		})
	.trigger('change');

	$("#fq7").change(function () {
		var str = "";
		$("#fq7 option:selected").each(function () {
			str += $(this).text() + " ";
		});
		$("#fq7div").text(str);
		})
	.trigger('change');

	$("#fq8").change(function () {
		var str = "";
		$("#fq8 option:selected").each(function () {
			str += $(this).text() + " ";
		});
		$("#fq8div").text(str);
		})
	.trigger('change');



	/*************** forum - pokazywanie wyszukiwarki **********************/
	$(".forumNewIco2").click(function(event){
		event.preventDefault();
	}).toggle(function(){
		$(".forumNewTopSearch").fadeIn('fast');
	},function(){
		$(".forumNewTopSearch").fadeOut('fast');
	});



	/*************** sonda AJAX **********************/
	$('#sonda_form').submit(function() {
		$('.sonda .anim_box').css('display', 'block');

		var tmpsel=0;
		$('#sonda_form').find('[name=vote]').each(function() {
			if($(this).attr('checked'))
			{
				tmpsel=$(this).val();
			}
		});

		v_akcja = $('#sonda_form').find('[name=akcja]').val();
		v_cat = $('#sonda_form').find('[name=cat]').val();
		v_sondaID = $('#sonda_form').find('[name=sondaID]').val();

		//alert(v_akcja + ', ' + v_cat + ', ' + v_sondaID + ', ' + tmpsel);

		$.get('/page.php', {akcja:v_akcja, cat:"118", sondaID:v_sondaID, vote:tmpsel}, function(data) {
			//alert(data);
			//$('.sonda').remove();
			$('.sonda').html(data);
		});
		return false;

	});



	/*************** newsletter AJAX **********************/
	$('#nl_form').submit(function() {
		v_imie = $('#newsImieF').val();
		v_email = $('#newsEmailF').val();

		$.get('/newsletter.php', {method:"ajax", action:"save", imie:v_imie, email:v_email}, function(data) {
			//alert(data);
			$('#alertwin .message').html(data);
			$('#alertwin').fadeIn();
			setTimeout("$('#alertwin').fadeOut()", 2000);
		});
		return false;
	});

	

	/*************** komentarze AJAX **********************/
	$('#com_form').submit(function() {

		v_redirect = $('#com_form').find('[name=redirect]').val();
		v_id = $('#com_form').find('[name=id]').val();
		v_title = $('#com_form').find('[name=title]').val();
		v_location = $('#com_form').find('[name=location]').val();
		v_user = $('#com_form').find('[name=user]').val();
		v_userid = $('#com_form').find('[name=userid]').val();
		v_comment = $('#com_form').find('[name=comment]').val();
		v_captcha = $('#com_form').find('[name=captcha]').val();

		$.post('/hit_comment_art.php', {
			method:"ajax", 
			redirect:v_redirect, 
			id:v_id, 
			title:v_title,
			location:v_location,
			user:v_user,
			userid:v_userid,
			comment:v_comment,
			captcha:v_captcha
		}, function(data) {
			//alert(data);
			if (data == 'sukces') {
				$.get('/ajax-komentarze&_item='+v_id, {}, function(data){
					$('#com_ajax').html(data);
				});
			}
			else {
				$('#alertwin .message').html(data);
				$('#alertwin').fadeIn();
				setTimeout("$('#alertwin').fadeOut()", 2000);
			}
		});

		return false;
	});



	$('#comments_login').click(function(){
		$('#lg').click();
	});
	
	

});



