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

}


function pickWoj(){
	alert(e.pageX);
	return false;
}
	


// **************** JQUERY *******************

$(document).ready( function(){
	
	$('map area').click(function(){
		var cords = new Array();
		cords[1] = '34.106';
		cords[2] = '71.43';
		cords[3] = '155.100';
		cords[4] = '10.72';
		cords[5] = '91.91';
		cords[6] = '110.147';
		cords[7] = '126.66';
		cords[8] = '63.120';
		cords[9] = '147.146';
		cords[10] = '157.30';
		cords[11] = '58.10';
		cords[12] = '83.130';
		cords[13] = '119.116';
		cords[14] = '119.19';
		cords[15] = '51.72';
		cords[16] = '15.28';
		var woj = $(this).attr('id');
		var explode = cords[woj].split(".");
		$("#woj_input").attr('value',woj);
		$(".mapWojActive").css('left',explode[0]+"px");
		$(".mapWojActive").css('top',explode[1]+"px");
		$(".mapWojActive").show();
	});
	
	$('.gielda_duze_fotom a').click(function() {
		$('.gielda_duze_foto').hide();
		//$('.gielda_duze_foto').removeClass('tex');
		$('#'+$(this).attr('class')).show();
		//$('#'+$(this).attr('class')).addClass('tex');
  		//alert($(this).attr('class'));
		
		return false;
	});

	var tmpp = 0;var tmppx = 0;
	$('.gielda_next').click(function() {
		
		tmpp = $("#ssf div:visible").attr("id");

		tmppx = $("#ssf div:last-child").attr('id');
		if (tmpp == tmppx){
			$('.gielda_duze_foto').hide();
			$('div#1').show();
		}
		else{
			tmpp = parseInt(tmpp)+1;
			$('.gielda_duze_foto').hide();
			$('div#'+tmpp).show();
		}
		
		

		return false;
	});


	$('#info_g').click(function(){
		$(this).addClass('active');
		$('#lokal_g').removeClass('active');
		$('#koment_g').removeClass('active');
		$('#sonda_g').removeClass('active');
		$('.gielda_informacje').css("display","block");
		$('.gielda_lokalizacja').css("display","none");
		$('.gielda_komentarze').css("display","none");
		$('.gielda_sonda').css("display","none");
		return false;
	});

	$('#lokal_g').click(function(){
		$(this).addClass('active');
		$('#info_g').removeClass('active');
		$('#koment_g').removeClass('active');
		$('#sonda_g').removeClass('active');
		$('.gielda_lokalizacja').css("display","block");
		$('.gielda_informacje').css("display","none");
		$('.gielda_komentarze').css("display","none");
		$('.gielda_sonda').css("display","none");
		return false;
	});
	$('#koment_g').click(function(){
		$(this).addClass('active');
		$('#info_g').removeClass('active');
		$('#lokal_g').removeClass('active');
		$('#sonda_g').removeClass('active');
		$('.gielda_lokalizacja').css("display","none");
		$('.gielda_informacje').css("display","none");
		$('.gielda_sonda').css("display","none");
		$('.gielda_komentarze').css("display","block");
		return false;
	});
	$('#sonda_g').click(function(){
		$(this).addClass('active');
		$('#info_g').removeClass('active');
		$('#lokal_g').removeClass('active');
		$('#koment_g').removeClass('active');
		$('.gielda_lokalizacja').css("display","none");
		$('.gielda_informacje').css("display","none");
		$('.gielda_komentarze').css("display","none");
		$('.gielda_sonda').css("display","block");
		return false;
	});
	/*
	$('.chmura_kosz2').hover(function() { 
		var top = $(this).offset().top;
		var h = $('.chmura_kosz2 .kosz_chmura').height();
		if($.browser.msie || $.browser.opera){
		
		
		if (parseInt($.browser.version.substr(0,3)) < 7.0 )
		{
			var newtop = top-h;	
		}
		else{
			var newtop = top-h-210;
		}

		}else{
		var newtop = top-h-255;}
        
		$('.chmura_kosz2 .kosz_chmura').css({'top':newtop+'px'});
		$(this).find('.kosz_chmura').css('display','block');
		//$(+'div').css('display','block');		
		}, function() {
			$(this).find('.kosz_chmura').css('display','none');
	});

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

	
	//banery promocyjne home
	$('.prom_box_home').cycle({fx: 'fade',
		                       speed: 2000,
	        	               timeout: 10000});
	
	$('#forumCats ul li:last a').css('border-bottom','none');
	/**********************TABSY********************/
	$('#forumBox .tabsCont,#searchBestPoint .tabsCont,#serviceItemCom .tabsCont').children('div').hide();
	$('#forumBox .tabsCont div').eq(0).show();
	$('#searchBestPoint .tabsCont div').eq(0).show();
	$('#homeComments .tabsCont div').eq(0).show();
	//$('#serviceDetails .tabsCont div').eq(0).show();
	$('#serviceItemCom .tabsCont div').eq(0).show();
	//$('#serviceDetails2 .tabsCont div').eq(0).show();
	
	//$('#compareService .tabsCont div').eq(0).show();
	$('#forumBox .tabs a, #searchBestPoint .tabs a,#homeComments .tabs a,#compareService .tabs a,#serviceDetails .tabs a').eq(0).addClass('active');
	$('#forumBox .tabs a, #searchBestPoint .tabs a,#homeComments .tabs a,#compareService .tabs a,#serviceItemCom .tabs a').click(function(){
		$(this).parent().parent().find('a').removeClass('active');
		$(this).addClass('active');
		var parent2 = $(this).parent().parent().parent().attr('id');
		var element = $('#'+parent2 + ' .tabs a').index(this);
		var parent = $(this).parent().parent().parent().find('.tabsCont').children('div');
		$(parent).hide();
		$(parent).eq(element).show();
		return false;


	});
	
	/******TABSY GOOGLE MAPS ZAWARTOSC*****/
		$("#serviceDetails .tabs a,#serviceDetails2 .tabs a").live("click", function(event){
		  	$(this).parent().parent().find('a').removeClass('active');
			$(this).addClass('active');
			var parent2 = $(this).parent().parent().parent().attr('id');
			var element = $('#'+parent2 + ' .tabs a').index(this);
			var parent = $(this).parent().parent().parent().find('.tabsCont').children('div');
			$(parent).hide();
			$(parent).eq(element).show();
			

			
			
			return false;
		});	

	

	if($("#dbformFis_service").attr('checked')){
		$('.registerFormService').show();
	}
	else{
		$('.registerFormService').hide();
	}			

	$("#dbformFis_service").click(function(){

		if($(this).attr('checked')){
			$('.registerFormService,.regF').show();
			
		}
		else{
			$('.registerFormService,.regF,.carBrandsForm,.bikeBrandsForm,.truckBrandsForm').hide();
			$("#dbformFcats0,#dbformFcats1,#dbformFcats5").attr('checked','');
		
		}		

	});
	$("#dbformFcats0").click(function(){

		if($(this).attr('checked')){
			$('.carBrandsForm').show();
		}
		else{
			$('.carBrandsForm').hide();
		}		

	});
	$("#dbformFcats1").click(function(){

		if($(this).attr('checked')){
			$('.truckBrandsForm').show();
		}
		else{
			$('.truckBrandsForm').hide();
		}		

	});
	$("#dbformFcats2").click(function(){

		if($(this).attr('checked')){
			$('.bikeBrandsForm').show();
		}
		else{
			$('.bikeBrandsForm').hide();
		}		

	});
	if($("#dbformFcats0").attr('checked')){
		$('.carBrandsForm').show();
	}
	else{
		$('.carBrandsForm').hide();
	}
	if($("#dbformFcats1").attr('checked')){
		$('.truckBrandsForm').show();
	}
	else{
		$('.truckBrandsForm').hide();
	}
	if($("#dbformFcats2").attr('checked')){
		$('.bikeBrandsForm').show();
	}
	else{
		$('.bikeBrandsForm').hide();
	}
	
	

	$('.homeCommentsMain').cycle({fx: 'scrollHorz',
		                   speed: 300,
		                   timeout: 0,
			           prev: '.itemBestPrev',
			           next: '.itemBestNext'});
	$('.homeCommentsMain2').cycle({fx: 'scrollHorz',
		                   speed: 300,
		                   timeout: 0,
			           prev: '.itemMorePrev',
			           next: '.itemMoreNext'});
	$('.homeCommentsMain3').cycle({fx: 'scrollHorz',
		                   speed: 300,
		                   timeout: 0,
			           prev: '.itemMostlyPrev',
			           next: '.itemMostlyNext'});
	$('.homeCommentsMain4').cycle({fx: 'scrollHorz',
		                   speed: 300,
		                   timeout: 0,
			           prev: '.itemMostlyComPrev',
			           next: '.itemMostlyComNext'});

	$('#newsBoxrWorldCont').cycle({fx: 'scrollHorz',
		                   speed: 300,
		                   timeout: 0,
			           prev: '.newsWorldPrev',
			           next: '.newsWorldNext'});
	$('#newsBoxrPolandCont').cycle({fx: 'scrollHorz',
		                   speed: 300,
		                   timeout: 0,
			           prev: '.newsPolandPrev',
			           next: '.newsPolandNext'});
	$('#newsBoxrSiteCont').cycle({fx: 'scrollHorz',
		                   speed: 300,
		                   timeout: 0,
			           prev: '.newsSitePrev',
			           next: '.newsSiteNext'});



$('.get_form_data').click(function(){
	$.colorbox({inline:true, href:"#get_form_data"});
	$("#error").hide();
   	$(".loader").hide(); 
	return false; 
});

$('#get_form_data_submit').submit(function(){
	var href = $('#href').val();
	$.getJSON('/_my/get_data.php', {href:href}, function(data) {
	  if(data.length > 0){
	  	$("#error").hide(); 
   		$(".loader").show();
   		$.each(data, function(index, array) {
   			$.each('.tableForm tr.formRow td.label',function(index2,item2){
   				var label = $('.tableForm tr.formRow td.label').eq(index2);
   				// alert(label.html()+"=="+array['label']);
   				if(label.html() == array['label']){
   					//alert('aa');
   					if($(label).parent().find('input,textarea,select').is('select')){
   						$.each($(label).parent().find('select option'),function(index3,item3){
   							var  select_value = $(label).parent().find('select option').eq(index3);
   							//alert(select_value.val()+"=="+array['value']);
   							if(select_value.val() == array['value'] || select_value.html().toLowerCase() == array['value'] || select_value.html() == array['value']){
   								
   								$(select_value).attr('selected', 'selected');
   							}
   						});
   						//alert('select');
   					}
   					else{
   						$(label).parent().find('input,textarea').val(array['value']);
   					}
   					
   				} 

   			});
           
        });
     	$("#error").hide();
   		$(".loader").hide();
   		$.colorbox({inline:true, href:"#ex_thx"});
   		$('select[name$="rel_vehicle_type"],#dbformFrel_brands,#dbformFrel_models,#dbformFrel_types').css('border','1px solid #ce0000'); 

	  }
	  else{
	  	$("#error").show();
	  }
	  /* 
      $.each(data, function(index, array) {
            alert(array['label']);
        });
        */
    });

	

	return false;
});

  
/*
	var services = [];
	var subservices = [];
	var services_count = $('.serviceList li').size();
	var cat_count = $('#mapCat input').size();
	var subcat_count = $('#mapSubcat input').size();
	var cat_split;
	

	$('#mapCat input').click(function(){
			
			for(var i = 1;i <= services_count; i++){
				var show_service = 0;
				for(var j = 1;j <= cat_count; j++){
					if(document.getElementById('mapCat'+j).checked)
					{
						if(services[i].substring(j-1,j) == '1'){
							show_service = 1;
						}
					}
					
				}
				if(show_service==1)
				$('.'+services[i]).show();
				else
				$('.'+services[i]).hide();
			
			}
		
		
	});

	$('#mapSubcat input').click(function(){
			
			for(var i = 1;i <= services_count; i++){
				var show_subservice = 0;
				for(var j = 1;j <= subcat_count; j++){
					if(document.getElementById('mapSubcat'+j).checked)
					{
						if(subservices[i].substring(j-1,j) == '1'){
							show_subservice = 1;
						}
					}
					
				}
	
				if(show_subservice==1)
				$('#'+subservices[i]).show();
				else
				$('#'+subservices[i]).hide();
			}
		
		
		
	});
*/

	/**zaznacz wszystkie**/
	$('.car_brands').click(function(){
		
		return false;
	}).toggle(function(){
		$(this).html('Odznacz wszystkie');
		$('.carBrandsForm input').attr('checked','checked');
	},
	function(){
		$(this).html('Zaznacz wszystkie');
		$('.carBrandsForm input').attr('checked','');
	});
	$('.truck_brands').click(function(){
		
		return false;
	}).toggle(function(){
		$(this).html('Odznacz wszystkie');
		$('.truckBrandsForm input').attr('checked','checked');
	},
	function(){
		$(this).html('Zaznacz wszystkie');
		$('.truckBrandsForm input').attr('checked','');
	});
	$('.bike_brands').click(function(){
		
		return false;
	}).toggle(function(){
		$(this).html('Odznacz wszystkie');
		$('.bikeBrandsForm input').attr('checked','checked');
	},
	function(){
		$(this).html('Zaznacz wszystkie');
		$('.bikeBrandsForm input').attr('checked','');
	});
/********************Podkategorie mapa*******************************************/

$('#mapCat input').click(function(){
		
		var cat_count = $('#mapCat input').size();
		$('#mapSubcat input').each(function (i) {
			var show = 0;
			
			var parent = $(this).attr('rel');
				
			for( var j = 1; j <= cat_count; j++){
						
				if($('#mapCat'+j).attr('checked'))
					{
						var children = $('#mapCat'+j).attr('rel');
						if(parent.substring(children-1,children)=='1') show=1;
					}
			}
			i++;
			if (show == 1){
		
				$('#mapSubcat'+i).parent().show();
			}
			else{
				$('#mapSubcat'+i).parent().hide();
			}
					
					
				

			
		});
		
		//alert(';)');
	


});

/********************Podkategorie imprezy*******************************************/

$('#eventCat input').click(function(){
		
		var cat_count = $('#eventCat input').size();
		$('#eventSubcat input').each(function (i) {
			var show = 0;
			
			var parent = $(this).attr('rel');
				
			for( var j = 1; j <= cat_count; j++){
						
				if($('#eventCat'+j).attr('checked'))
					{
						var children = $('#eventCat'+j).attr('rel');
						if(parent.substring(children-1,children)=='1') show=1;
					}
			}
			i++;
			if (show == 1){
		
				$('#eventSubcat'+i).parent().show();
			}
			else{
				$('#eventSubcat'+i).parent().hide();
			}
					
					
				

			
		});
		
		//alert(';)');
	


});


$('#dbformFgmap').attr('readonly',true);
//$('#dbformFprof_city').attr('readonly',true);
$('#dbformFex_gmap').attr('readonly',true);
$('#dbformFev_gmap').attr('readonly',true);



/*
$('.clickAll').click(function(){
		
		
	}).toggle(function(){
		$(this).html('Odznacz wszystkie');
		$('#mapCat input').attr('checked',false);
		$('#mapSubcat input').attr('checked',false);
		$('#mapCat input').each(function(i){
		
			var catClass = $(this).attr('class');
			var catClassSplit = catClass.split(",");
			i= i+1;
			showHideCat(catClassSplit[0],i);
		});
		var cat_count = $('#mapCat input').size();


		for (var i = 0;i < services_count; i++){
		
			var show_service = 0;
			for(var j = 1;j <= cat_count; j++){

				if(document.getElementById('mapCat'+j).checked)
				{
					if(services[i].substring(j-1,j) == '1'){
						show_service = 1;
					}
				}
					
			}
				if(show_service==1)
				$('.'+services[i]).show();
				else
				$('.'+services[i]).hide();
		}
	return false;
	},
	function(){
		$(this).html('Zaznacz wszystkie');
		$('#mapCat input').attr('checked',true);
		$('#mapSubcat input').attr('checked',true);
		$('#mapCat input').each(function(i){
		
			var catClass = $(this).attr('class');
			var catClassSplit = catClass.split(",");
			i= i+1;
			showHideCat(catClassSplit[0],i);
		});
		var cat_count = $('#mapCat input').size();


		for (var i = 0;i < services_count; i++){
		
			var show_service = 0;
			for(var j = 1;j <= cat_count; j++){

				if(document.getElementById('mapCat'+j).checked)
				{
					if(services[i].substring(j-1,j) == '1'){
						show_service = 1;
					}
				}
					
			}
				if(show_service==1)
				$('.'+services[i]).show();
				else
				$('.'+services[i]).hide();
		}
	return false;
	

	});



});
*/
$('.clickAll').click(function(){
		
		
	}).toggle(function(){
		$(this).html('Zaznacz wszystkie');
		$('#mapSubcat input').attr('checked',false);
		
	return false;
	},
	function(){
		
		$(this).html('Odznacz wszystkie');
		$('#mapSubcat input').attr('checked',true);
		
		
	return false;
	

	});




	$('.clickAllType').click(function(){
		
		
	}).toggle(function(){
		$(this).html('Zaznacz wszystkie');
		$('#mapCat input').attr('checked',false);
		
	return false;
	},
	function(){
		
		$(this).html('Odznacz wszystkie');
		$('#mapCat input').attr('checked',true);
		
		
	return false;
	

	});
	
	$('.clickAllRate').click(function(){
		
		
	}).toggle(function(){
		$(this).html('Zaznacz wszystkie');
		$('#rateFiltr input').attr('checked',false);
		
		
		return false;
	},
	function(){

		
		$(this).html('Odznacz wszystkie');
		$('#rateFiltr input').attr('checked',true);
		
		
		return false;
	

	});
	

	$('.clearFiltr').click(function(){
		$('#rateFiltr input').attr('checked',true);
		$('#mapCat input').attr('checked',true);
		$('#mapSubcat input').attr('checked',true);
		$(".mapWojActive").hide();
		$("#woj_input").attr('value','');
		$("[name=service_name]").attr('value','Nazwa punktu');
		$("[name=zip_code]").attr('value','Kod pocztowy');
		$("[name=city]").attr('value','Miasto');
		$(".pickWoj b").html("Wszystkie");	
		return false;
	});

	$('.filtr_up').click(function(){
		$(".sr_cnt").hide();
		$.cookie("up", "1");
		$('.filtr_down').show();
		return false;
	});
	$('.filtr_down').click(function(){
		$(".sr_cnt").show();
		$(".filtr_down").hide();
		$.cookie("up", "0");
		return false;
	});		

	
	
	$('.clickAllEv').click(function(){
		
		
	}).toggle(function(){
		$(this).html('Zaznacz kategorie');
		$('#eventCat input').attr('checked',false);
		
	return false;
	},
	function(){
		$(this).html('Odznacz kategorie');
		$('#eventCat input').attr('checked',true);
		
		
		
	return false;
	

	});
	$('.clickAllEv2').click(function(){
		
		
	}).toggle(function(){
		$(this).html('Zaznacz charakter imprezy');
		$('#eventSubcat input').attr('checked',false);
		
	return false;
	},
	function(){
		$(this).html('Odznacz charakter imprezy');
		$('#eventSubcat input').attr('checked',true);
		
		
		
	return false;
	

	});


	$('.exchangeSearchMore').click(function(){
		
		
	}).toggle(function(){
		$('.exsearchTable2.displayNone').show();
		
		
	return false;
	},
	function(){
		$('.exsearchTable2.displayNone').hide();
		
		
		
		
	return false;
	

	});
	/********************Film promocyjne banery****************************/
	$(".vid_ico").colorbox({iframe:true, innerWidth:640, innerHeight:480});

	/**********************Dodaj do schowka****************************/
	
	$('.cbAdd').click(function(){

		var href = $(this).attr('href');
		$.get(href);
		
		$(this).parent().find('.cbAdd').hide();
		$(this).parent().find('.cbDel').show();
		return false;
	});
	/******************Usun ze schowka**********************************/
	$('.cbDel').click(function(){

		var href = $(this).attr('href');
		$.get(href);

		$(this).parent().find('.cbDel').hide();
		$(this).parent().find('.cbAdd').show();
		return false;
	});
	/******************Dodaj profil**********************************/
	$('#exAddProf').click(function(){

		$.post("/add_ex_prof.php", {profile: $("#exForm").serialize()});

		$(this).hide();
  		$('#exAddProfOk').show();	
  			
		
		return false;
	});

	/***************Imprezy kategorie**********************/
	
	$('.ev_cat').change(function(){
		var cat_id = $(this).val();
		if(cat_id){
			$.post("/ajax_events_form.php", { cat_id: cat_id },
   				function(data){	
				$('.ev_subcat').html('');
				$('.ev_subcat').append(data);
     				
   			});
		}
		else{
			$('#ev_subcat').html('<option value="" label="dowolne">dowolny</option>');
			//return false;
		}
	});
	
	/***************Promocje miasta**********************/
	
	$('#prom_rel_woj,#dbformFrel_woj,#prom_rel_woj2').change(function(){
		var woj_id = $(this).val();
		//alert(woj_id);
		if(woj_id > 0){
			$.post("/_my/ajax.php", { woj_id: woj_id, action : 'cities' },
   				function(data){	
					$('#dbformFrel_city,#dbformFrel_city2').html('');
					$('#dbformFrel_city,#dbformFrel_city2').append(data);
     				
   			});
		}
		else{
			$('#dbformFrel_city,#dbformFrel_city2').html('<option value="" label="-wybierz-">-wybierz-</option>');
			//return false;
		}
	});
	/**********************Walidacja boksu Twoja lokalizacja home**************************/
	$("#change2").validate({
			 rules: {
				 rel_woj2:{
					required: true,	
				 },
				  rel_city2:{
					required: {
						 depends: function(element) {
                   			 return $("#change2 #prom_rel_woj2").val() > '0';
               			}
					},
				 }
				
				 
			   },
			   messages: {
				rel_woj2:{
					required: "Pole wymagane"					
				 },
				 rel_city2:{
					required: "Pole wymagane"	
				 }
				 
				
				
			   }
			   
		  });
	

	/*
	$('body').click(function(){
		
		 if($('.DatePicker').is(":visible"))
				$('.DatePicker').css('visibility','hidden');
		
	
	});
	*/
	
	
	
	
	/*zakladki home - filmy uzytkownikow - przelaczanie*/
	$("#usermovTabs li a").click(function(){
		$("#usermovTabs li a").removeClass("active");
		$(this).addClass("active");
		var path = $(this).attr('href');
		$(".userGal div.usermovLast").hide();
		$(".userGal div.usermovBest").hide();
		//$(".userGal div.usergalBest2").hide();
		$("."+path).show();
		
		return false;
	});
	
	/*zakladki home - galerie uzytkownikow - przelaczanie*/
	$("#usergalTabs li a").click(function(){
		$("#usergalTabs li a").removeClass("active");
		$(this).addClass("active");
		var path = $(this).attr('href');
		$(".userGal div.usergalLast").hide();
		$(".userGal div.usergalBest").hide();
		$(".userGal div.usergalBest2").hide();
		$("."+path).show();
		
		return false;
	});

	

	/*zakladki home - newsy - przelaczanie*/
	$("#newsTabs li a").click(function(){
		$("#newsTabs li a").removeClass("active");
		$(this).addClass("active");
		var path = $(this).attr('href');
		$(".news div.newsWorld").hide();
		$(".news div.newsPoland").hide();
		$(".news div.newsSite").hide();
		$("."+path).show();
		
		return false;
	});

	



	$(".newsBoxrItem").hover(
  		function () {
			var link = $(this).attr('id');
			var news_name = $(this).attr('rel');
			var news_id = $(this).attr('rel2');
			$("."+news_name).hide();
			$("#"+news_name+news_id).show();
			//alert($(this).index());
    			$(this).find('.newsBoxrItemTxt').css("background","#ae2f40");
			$(this).find('.newsBoxrItemDate').css("color","#fff");
			$(this).find('.newsBoxrItemDesc a').css("color","#fff");

  		}, 
  		function () {
    			$(this).find('.newsBoxrItemTxt').css("background","transparent");
			$(this).find('.newsBoxrItemDate').css("color","#145677");
			$(this).find('.newsBoxrItemDesc a').css("color","#145677");
  		}
	);

	//miasta autocomplete
		$("#city_complete").autocomplete("/addfun.php?action=city_complete", {
		width: 175,
		selectFirst: false, 
		autoFill: true,
		formatItem: function(row, i, max) { 
        		return row[0]; 
    		},
    		formatMatch: function(row, i, max) { 
        		return row[0]; 
    		}, 
    		formatResult: function(row) { 
        		return row[0];  
    		}  
	});

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


	/************ forum - przewijanie strony do góry **********/
	$('a[href=#top]').click(function(){
 		//$('html, body').animate({scrollTop:0}, 'fast');
 		$('html, body').scrollTop(0);
 		return false;
	});
	
	/*
	$('.news').cycle({
		fx:	'fade', 
		speed:       300,
		timeout:     8000,
		pager:      '#newsTabs li',
		pagerEvent: 'mouseover'
	});
	*/
	

	
});


/*****************Ocenianie na ajaxie**************************/

	function AjaxRate(rate,rid,basename){
		$.post("/addfun.php",{
			rid: rid, 
			rate: rate,
			basename: basename, 
			action: "AjaxRate"
		}, function(data){
			
			$(".galStarsCont2").html(data);
			if(basename == 1){
				var info = 'Zdjęcie';
				$("#rateInfo"+rid).html('['+info+' zostało ocenione]');
			}
			else if( basename == 2 ){
				var info = 'Film';
				$("#rateInfo"+rid).html('['+info+' został oceniony]');
			}
			else{
				var info = 'Artykuł';
				$("#rateInfo"+rid).html('['+info+' został oceniony]');
			}			
		});
		
		
	}

/*************************newsy home przeskakiwanie miedzy zakldkami*****************/
/*
function newsJump(){
	var news = [];
	news['newsPoland'] = 0;
	news['newsWorld'] = 1;
	news['newsSite'] = 2;

	var active = $("#newsTabs li a.active").attr("href");
	//alert(news[active]+1);
	var cnt = news[active]+1;
	if(cnt == 3){
		cnt = 0;
	}
	$("#newsTabs li a").removeClass('active');
	$("#newsTabs li a:eq("+cnt+")").addClass('active');
	var active = $("#newsTabs li a.active").attr("href");
	$(".news .newsPoland").hide();
	$(".news .newsWorld").hide();
	$(".news .newsSite").hide();
	$(".news ."+active).show();	

}
*/
/************************** Dymek przy mapie województw ****************************/
var ua = navigator.userAgent.toLowerCase();
var divw=0;
var divh=0;

/* ****************************** map 1 ***************************************/
if (document.getElementById || document.all)
	document.write('<div id="opiss" class="map_woj" style="position:absolute;visibility:hidden; z-index:200"></div>')

function getopissobject(){
	if (document.getElementById)
		return document.getElementById("opiss")
	else if (document.all)
		return document.all.opiss
}

function getopissobj(){
	if (document.getElementById)
		return document.getElementById("opiss").style
	else if (document.all)
		return document.all.opiss.style
}

function truebody(){
	return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function opisOff(){
	document.onmousemove='';
	getopissobj().visibility="hidden";
}

function opisOn(opis,thh){
	if(ua.indexOf('safari') == -1){
		getopissobj().left="-500px";
		//divthw = parseInt(thw) + 2;
		divthh = parseInt(thh) + 2;
		getopissobject().innerHTML = '<span class="accsearchmapindic">'+opis+'</span>';
		getopissobj().visibility="visible";
		//alert(gettrailobject().height);
		//divw = parseInt(thw)+25;
		divh = parseInt(thh)+30;
		document.onmousemove=followmouse;
	}
}

function followmouse(e){
	var docwidth=document.all? truebody().scrollLeft+truebody().clientWidth : pageXOffset+window.innerWidth-15
	var docheight=document.all? Math.min(truebody().scrollHeight, truebody().clientHeight) : Math.min(document.body.offsetHeight, window.innerHeight)
	if(typeof e != "undefined"){
		xcoord = 15+e.pageX;
		ycoord = -5+e.pageY;
	}
	else if (typeof window.event != "undefined"){
		xcoord = truebody().scrollLeft+15+event.clientX;
		ycoord = truebody().scrollTop-5+event.clientY;
	}
	getopissobj().left=xcoord+"px"
	getopissobj().top=ycoord+"px"
}




