    // 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));
							 if($(this).parent().attr('class') != 'selected')
							 {
							 	$(this).parent().addClass('selected2');
							 }});
	$('#menu ul li ul.submenu').mouseout(function(){outMenu($(this).get(0));
							if($(this).parent().attr('class') != 'selected')
							{
								$(this).parent().removeClass('selected2');
							}});
});

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 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 *******************

$(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');}});



	// search pages
	$('#searchform .searchsitebtn').click(function(){
		if ($('#searchform .searchsiteedit').attr('value').match(/^[0-9a-zA-ZąćęłńóśźżĄĆĘŁŃÓŚŹŻ\_\-\ ]{0,}$/)) {
			window.location.href = $('#searchform').attr('action') + '/q,' + $('#searchform .searchsiteedit').attr('value') + '.html';
		}
		else {
			//alert($('#badquery').attr('value'));
			data = $('#badquery').attr('value');
			$('#alertwin .message').html(data);
			$('#alertwin').fadeIn();
			setTimeout("$('#alertwin').fadeOut()", 2000);
		}
		return false; 
	});


	// logowanie 
	$('.loginminibtn, .loginboxclose, .loginbutton').click(function(){	
		if($('.loginbox').css('top') == '50px'){
			$('.loginbox').animate({'top': '-200px', 'opacity': 0.0}, 800);
		}else{
			$('.loginbox').animate({'top': '50px', 'opacity': 1}, 400);
		}
		return false;

	});



	/*************** newsletter AJAX **********************/
	$('#nl_form').submit(function() {
		v_imie = $('[name="imie"]', $(this)).val();
		v_email = $('[name="email"]', $(this)).val();

		$.get('/newsletter.php', {method:"ajax", action:"save", imie:v_imie, email:v_email}, function(data) {
			//alert(data);
			$('#alertwin .message').html(data);
			$('#alertwin').animate({'top': '50px', 'opacity': 1}, 400);
			setTimeout("$('#alertwin').animate({'top': '-200px', 'opacity': 0.0}, 800);", 3000);
		});
		return false;
	});	


	$('#platnosc').submit(function(){
		$.post("/platnosc.php", $(this).serialize(), function(data){
			$('#alertwin .message').html(data);
			$('#alertwin').animate({'top': '50px', 'opacity': 1}, 400);
			setTimeout("$('#alertwin').animate({'top': '-200px', 'opacity': 0.0}, 800);", 3000);

			if(data.substr(0,2) == 'OK'){
				$('.paymentswitch').slideToggle();
				$('.paymentswitchhide').slideToggle();
			}
		});
		return false;
	});


	//licytuj, kup, potwierdzenie
	$('.aukcjaform').submit(function(){

		var forma   = $(this);
		var pytanie = $('[name="alert"]', $(this)).val();
		var oferta  = $('[name="oferta"]', $(this)).val().replace(',','.');
		$('[name="oferta"]', $(this)).val(oferta);
		pytanie = pytanie.replace('%%cena%%', !isNaN(oferta) ? oferta : 0);


		$('#alertwin .message').html(pytanie);
		$('#alertwin').animate({'top': '50px', 'opacity': 1}, 400);


		$('#alertwin .anuluj').live('click', function(){
			$('#alertwin').animate({'top': '-200px', 'opacity': 0.0}, 800);
			$('[name="confirm"]', forma).val('0');
		});


		$('#alertwin .kontynuuj').live('click', function(){
			$('[name="confirm"]', forma).val('1');
			forma.submit();
		});


		if($('[name="confirm"]', forma).val() == '0') return false;
	});





	// dostawa
	$('#dostawa').change(function(){
		var nowa = (parseFloat($(this).val()) + parseFloat($('#kwota').text())).toFixed(2);
		$('#total').text(nowa);
		//$('#przelew [name=kwota]').val(nowa); 
	});


	
	
	//wysylanie przelewu
	function sprawdzCene(check){
		var cena;
		$.get('/pl/platnosc-za-usluge/check,' + check + '.html', function(data) {
			cena = data;
		//alert(cena);
		return cena;
		});
	}




/*	$('#przelew').submit(function(){
		var check = $('input[name=control]', $(this)).val();
		var oldamount = $('input[name=kwota]', $(this)).val();
		var dostawa = $('select[name=dostawa]', $(this)).val();
		var total = $('#total', $(this)).text();
		var oukei = false;


*/
/*		$.get('/pl/platnosc-za-usluge/check,' + check + '.html', function(data) {

			if(isNaN(dostawa)){
				if(parseFloat(oldamount) != parseFloat(data)){
					alert('nieok1');
					return false;
					//oukei = true;
				}

			}

			else{
				if(parseFloat(total) != (parseFloat(data) + parseFloat(dostawa))  ||  total != oldamount  ||  parseFloat(oldamount) < parseFloat(data)){ 
					alert('nieok2');
					return false;	
					//oukei = true;
				}

			}

		});
		alert('ok');
*/
/*

		if(isNaN(dostawa)){
			//alert('nie ma dostaw');
			$.get('/pl/platnosc-za-usluge/check,' + check + '.html', function(data) {

				if(parseFloat(oldamount) == parseFloat(data)){
					alert('ok');
					//return true;
					$('[name=dosubmit]', $(this)).value('ok');
				}
			});
		}
		else{
			//alert('sa dostawy' + dostawa);
			$.get('/pl/platnosc-za-usluge/check,' + check + '.html', function(data) {

				if(parseFloat(total) == (parseFloat(data) + parseFloat(dostawa))  &&  total == oldamount  &&  parseFloat(oldamount) >= parseFloat(data)){ 
					alert('ok');
					//return true;	
					$('[name=dosubmit]', $(this)).value('ok');
				}
			});
		}

		if($('[name=dosubmit]', $(this)).value() != 'ok') return false;


	});
*/

	// wyszukiwarka
	$('#searchform').submit(function(){

		var query = $('input.searchinput', $(this)).val().replace(/\./gi, "");
		var base  = $('select[name=base]', $(this)).val();
		var cat   = $('input[name=cat]', $(this)).val();

		link = cat + '/base,' + base + ',q,' + query + '.html';
		location.href = link;

		return false;

	});


	// sponsorzy
	$('.partnerzy tr td a.more').click(function(){
		$('span a.notshow', $(this).parent()).slideDown();
		$(this).hide();
		$(this).next().show();
		return false;
	});
	$('.partnerzy tr td a.less').click(function(){
		$('span a.notshow', $(this).parent()).slideUp();
		$(this).hide();
		$(this).prev().show();
		return false;
	});



	// pokaz formularz zapytania
	$('.pokazformbtn').click(function(){
		$('.pokazform').slideDown();
		$(this).slideUp();
	});


	// podpowiedz wg słów kluczowych
	$('.keyword').keyup(function(){

		$('#wynik').text('');
		var word = $(this).val();
		var rids = $('input[name=rid]').val();
		var link = '/podpowiedz.php?podpowiedz='+word+'&sa='+rids;
		
		if(word.length > 0){
			$.getJSON(link, function(data) {

				$.each(data, function(key, val) {
					$('#wynik').append('<a id="podpowiedz_' + key + '">' + val + '</a>');
				});

			});
		}

	});
	$('#wynik a').live('click', function(){

		$('#wybrane').append($(this));
		$('#wynik').text('');
		$('.keyword').val('');

		$('input[name=rid]').val($('input[name=rid]').val() + $(this).attr('id').replace('podpowiedz_','') + ',');
		$('#wybrane #' + $(this).attr('id')).append('<span class="close"><img src="/img/mx.gif" alt=""/></span>');

	});
	$('#wybrane .close').live('click', function(){

		var pid = $(this).parent().attr('id').replace('podpowiedz_','');
		$(this).parent().remove();

		$('input[name=rid]').val(
			$('input[name=rid]').val().replace(',' + pid + ',', ',')
		);
	});


	//wyszukiwarka prac
	$('#szukajprac').submit(function(){

		action = $(this).attr('action');
		query = $('[name=praca]', $(this)).val().replace('+', '%2B').replace('%20', '+').replace('*', '%2A').replace('/', '%2F').replace('@', '%40').replace(/\./g, '');

		link = action + '/praca,' + escape(query) + '.html';
	
		window.location.href = link;

		return false;

	});


	//rozwijanie kontaktu
	$('.prawybanner .prawybannertext, .contact_close').click(function(){

		if($('.prawybanner .kontaktarea').width() == 880){
			$('.prawybanner .kontaktarea').animate({'width': '56px'});
			$('.prawybanner .kontaktarea').removeClass('noopacity');
		}
		else{
			$('.prawybanner .kontaktarea').animate({'width': '880px'});
			$('.prawybanner .kontaktarea').addClass('noopacity');
		}

		return false;

	});


	$('.menubottomitem .kontakt').click(function(){
		scroll(0,0);
		$('.prawybanner .prawybannertext').trigger('click');
		return false;
	});


	/* PROMOCJE */

	// rozwijanie i chowanie rodzaju promocji
	$('#promocja .rodzaj').hide();
	$('#promocja [name=rodzaj]').change(function(){
		$('#promocja .rodzaj').slideUp(200);

		var div = $(this).val()
		var label = $('option:selected', $(this)).text();
		var jest = 0;

		$('#promocja .' + div).slideDown(600);
		$('#promocja .' + div + ' form [name=label]').remove();
		$('#promocja .' + div + ' form').append('<input type="hidden" name="label" value="' + label + '" />');

	});


	// limit pól formularza wg pola tag
	$('#promocja .limit').change(function(){
		var nfo = $(this).val();
		var max = $(this).attr('tag');
		$(this).val(nfo.substr(0,max));
		if(nfo.length > max)
			info('Limit tego pola wynosi ' + max + 'znaków.');
	}).keyup(function(){
		var nfo = $(this).val();
		var max = $(this).attr('tag');
		$(this).val(nfo.substr(0,max));
		if(nfo.length > max)
			info('Limit tego pola wynosi ' + max + ' znaków.');
	});


	// limit checkboxów
	$('.max :checkbox').change(function(){
		var len = $(':checkbox:checked', $(this).parents('.max')).length;
		var max = $(this).parents('.max').attr('tag');
		if(len > max)
			info('Możesz zaznaczyć tylko ' + max + ' kategorie.');
	});


	// dodawanie tego co wyżej (input)
	$('.dodajtocowyzej').click(function(){
		$(this).prev().prev().after($(this).prev().prev().clone());

		$('#promocja .date').datepicker({
			minDate: 0,
			dateFormat: 'dd.mm.yy',
			monthNames: ['Styczeń','Luty','Marzec','Kwiecień','Maj','Czerwiec', 'Lipiec','Sierpień','Wrzesień','Październik','Listopad','Grudzień'],
			monthNamesShort: ['Sty','Lut','Mar','Kwi','Maj','Cze', 'Lip','Sie','Wrz','Paź','Lis','Gru'],
			dayNames: ['Niedziela','Poniedziałek','Wtorek','Środa','Czwartek','Piątek','Sobota'],
	                dayNamesShort: ['Nie','Pon','Wto','Śro','Czw','Ptą','Sob'],
			dayNamesMin: ['Nd','Pn','Wt','Śr','Cz','Pt','So'],
			firstDay: 1,
			onSelect: function(){$(this).removeClass('formerror')}
		});
		return false;
	});

	
	// dodanie /usuwanie klasy błędy formularza
	/*var sprawdzone = 0;
	var wszystkich = 0;
	var dosprawdzenia = '#promocja form input[type=text], #promocja form textarea';
	$(dosprawdzenia).blur(function(){
		var tempval = $(this).val();
		if(tempval.length == 0){
			$(this).addClass('formerror');
			//$('.mceEditor', $(this).parent()).addClass('formerror');
		}
		else{
			$(this).removeClass('formerror');
			//$('.mceEditor', $(this).parent()).removeClass('formerror');
		}
	});
	$('.formerror').live('focus', function(){
		$(this).removeClass('formerror');
		//$('.mceEditor', $(this).parent()).removeClass('formerror');
	});

	// sprawdzanie czy pole jest uzupelnione
	$('#promocja form').submit(function(){
		wszystkich = 0;
		$(dosprawdzenia.replace('#promocja form', '').replace('#promocja form', '').replace('#promocja form', ''), $(this)).each(function(i){
			//alert();
			var tempval = $(this).val();
			if(tempval.length == 0){
				$(this).addClass('formerror');
				//$('.mceEditor', $(this).parent()).addClass('formerror');
				wszystkich++;
			}
		});
		if(wszystkich == 0) sprawdzone = 1;
		if(!sprawdzone) return false;
	});*/
	$('#promocja .date').datepicker({
				//minDate: 0,
				dateFormat: 'dd.mm.yy',
				monthNames: ['Styczeń','Luty','Marzec','Kwiecień','Maj','Czerwiec', 'Lipiec','Sierpień','Wrzesień','Październik','Listopad','Grudzień'],
				monthNamesShort: ['Sty','Lut','Mar','Kwi','Maj','Cze', 'Lip','Sie','Wrz','Paź','Lis','Gru'],
				dayNames: ['Niedziela','Poniedziałek','Wtorek','Środa','Czwartek','Piątek','Sobota'],
		                dayNamesShort: ['Nie','Pon','Wto','Śro','Czw','Ptą','Sob'],
				dayNamesMin: ['Nd','Pn','Wt','Śr','Cz','Pt','So'],
				firstDay: 1,
				onSelect: function(){$(this).removeClass('formerror')}
	});

	
	//potwierdzenie suunięcia rekordu
	$('.remove').click(function(){
		link = $(this).attr('href');
		info = $(this).attr('tag');

		if(confirm(info)){
			window.loaction.href = link;
		}
		return false;
	});
});


/******** WYSZUKIWARKA COMBO **********/

$(document).ready(function() {
	
	$('#combosearch .headgroup').click(function() {
		if($(this).find('.thicon').hasClass('off')) {
			$(this).find('.thicon').removeClass('off').addClass('on');
			$(this).next().css('display', 'block');
		} else {
			$(this).find('.thicon').removeClass('on').addClass('off');
			$(this).next().css('display', 'none');
		}
	});

});


/*** kalendarium wydarzeń ***/
$(document).ready(function(){

	wybrana = '';
	purecaturl = $('.purecaturl').text();

	if(window.location.href.indexOf('lteq') == -1)
		wybrana = window.location.href.substr(window.location.href.lastIndexOf(',')+1, 10);


	$('.dateinline').datepicker({
		dateFormat: 'yy-mm-dd',
		monthNames: ['Styczeń','Luty','Marzec','Kwiecień','Maj','Czerwiec', 'Lipiec','Sierpień','Wrzesień','Październik','Listopad','Grudzień'],
            	monthNamesShort: ['Sty','Lut','Mar','Kwi','Maj','Cze', 'Lip','Sie','Wrz','Paź','Lis','Gru'],
             	dayNames: ['Niedziela','Poniedziałek','Wtorek','Środa','Czwartek','Piątek','Sobota'],
	        dayNamesShort: ['Nie','Pon','Wto','Śro','Czw','Pią','Sob'],
        	dayNamesMin: ['Nd','Pn','Wt','Śr','Cz','Pt','So'],
		firstDay: 1,
		changeMonth: true,
		changeYear: true,
		defaultDate: wybrana,
		onSelect: function(dateText, inst) {
			purecaturl = purecaturl + '/eq-date,' + dateText + '.html';
			window.location.href = purecaturl;
		},
		beforeShowDay: function(date){
			for (var i = 0; i < dates.length; i++) {
				if (String(dates[i]) == String(date)) {
					return [true, 'highlight'];
				}
			}
			return [true, ''];
		}			
	});

	$('.ui-datepicker-today a').removeClass('ui-state-highlight');

	$('.showmonth').click(function(){

			//data = $('.dateinline').datepicker("getDate").getFullYear() + '-' + $('.dateinline').datepicker("getDate").getMonth() + '-';
		
			max = ['', 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];

			mie = parseInt($('.ui-datepicker-month').val()) + 1;
			mie2 = '0' + mie;
			mie2 = mie2.substr(-2);
			rok = $('.ui-datepicker-year').val();

			purecaturl = purecaturl + '/gteq-date,' + rok + '-' + mie2 + '-01' + ',lteq-date,' + rok + '-' + mie2 + '-' + max[mie] + '.html';

			window.location.href = purecaturl;
	});
});

