if ($(document).ready!=undefined && $("a[rel^='prettyPhoto']").prettyPhoto!=undefined){
	$(document).ready(function(){
		$('#range').change(function(){
			if($("#range").val()!=null && $("#range").val()!="")
			{
				$.ajax({
				  url: 'fileadmin/templates/ajaxSelect.php?id=1',
				  data: "w="+$(this).val()+"&w2="+$('#range2').val(),
				  success: function(data) 
				  {
					$('#range2').html(data);
				  }
				});
			}
		});
		$('#range2').change(function(){
			if($("#range2").val()!=null && $("#range2").val()!="")
			{
				$.ajax({
				  url: 'fileadmin/templates/ajaxSelect.php?id=2',
				  data: "w="+$(this).val()+"&w2="+$('#range').val(),
				  success: function(data) 
				  {
					$('#range').html(data);
				  }
				});
			}
		});
		$("a[rel^='prettyPhoto']").prettyPhoto({
			animation_speed: 'fast',
			slideshow: true,
			slideshow:5000,
			autoplay_slideshow: true,
			default_width: "800px",
			default_height: "600px",
			allow_resize: true
		});
		$("a[rel^='lightbox']").prettyPhoto({
			animation_speed: 'fast',
			slideshow: true,
			slideshow:5000,
			autoplay_slideshow: true,
			default_width: "800px",
			default_height: "600px",
			allow_resize: true
		});
		try
		{
			initialize();
		}
		catch(err)
		{
	
		}
		$('#chkall').click(function(){
			if(this.checked == false)
			{
				$('input[name^="district"]').attr('checked','');
			}
			else
			{
				$('input[name^="district"]').attr('checked','checked');
			}
		});
	});
}
function link(){
					var loc=location.toString();
					if (loc.indexOf('convertbuttons')!=-1) loc=loc.substr(0,loc.indexOf('convertbuttons')-1);
					if (loc.indexOf("?")==-1) loc+="?convertbuttons";
					return loc;
				}
function printc(){
					var DocumentContainer;
					DocumentContainer=document.getElementById("center");
					if (DocumentContainer==undefined || DocumentContainer==null) DocumentContainer=document.getElementById("center2");
					if (DocumentContainer==undefined || DocumentContainer==null) DocumentContainer=document.getElementById("content");
					if (DocumentContainer!=undefined && DocumentContainer!=null){
						var WindowObject = window.open("","PrintWindow","width=420,height=225,top=250,left=345,toolbars=no,scrollbars=no,status=no,resizable=no");
						WindowObject.document.write(DocumentContainer.innerHTML);
						WindowObject.document.close();
						WindowObject.focus();
						WindowObject.print()
						WindowObject.close();
					}
					else{
						window.print();
					}
				}
				
function convertbuttons_ajax(email,friend){
					if (email.indexOf("@")!=-1 && email.lastIndexOf(".")>email.indexOf("@")){
						var ajax;
						var ok=false;
						if (window.XMLHttpRequest){//Object of the current windows
							ajax = new XMLHttpRequest();//Firefox, Safari, ...
							ok=true;
						}
						else if (window.ActiveXObject){//ActiveX version
							ajax = new ActiveXObject("Microsoft.XMLHTTP");//Internet Explorer
							ok=true;
						}
						else{
							ok=false;
						}
						//ok=false;
						if (ok==true){
							ajax.onreadystatechange = function(){if (ajax.readyState==4 && ajax.status==200) document.getElementById('convertbutons_eml').style.display="none";};
							ajax.open("GET",link()+"&convertbuttons_eml="+email+"&convertbuttons_eml_friend="+friend+"&no_cache=1",true);
							ajax.send(null);
						}
						else{
							location=link()+"&convertbuttons_eml="+email+"&convertbuttons_eml_friend="+friend+"&no_cache=1";
						}
					}
					else{
						setTimeout("document.getElementById('convertbutons_eml').style.display='none'",1000);
					}
				}

/* remove stylesheet parameter and insert new value if necessary */
function changeCSS(name,value){
	var loc=location.toString();
	if (loc.indexOf('#')!=-1) loc=loc.substr(0,loc.indexOf('#')-1);
	if (loc.indexOf(name+'=')!=-1) {
		if (loc.lastIndexOf('&')>loc.indexOf(name+'=')){
			var tmp=loc.substr(loc.indexOf(name+'='));
			tmp=tmp.substr(tmp.indexOf('&'));
			loc=loc.substr(0,loc.indexOf(name+'=')-1)+tmp;
		}
		else{
			loc=loc.substr(0,loc.indexOf(name+'=')-1);
		}
	}
	if (loc.indexOf('?')==loc.length) loc=loc.substr(0,loc.length-1);
	if (value!=''){
		if (loc.indexOf('?')!=-1)
			loc=loc+'&'+name+'='+value;
		else
			loc=loc+'?'+name+'='+value;
	}
	location=loc;
}
function makeFavorite(){
	if (window.sidebar) {
		window.sidebar.addPanel(document.title,document.location.href,'');
	}
	else if (window.external.AddFavorite) {
		window.external.AddFavorite(document.location.href,document.title);
	}
}
function makeHomePage(obj){
	if (navigator.appName=='Microsoft Internet Explorer'){//msie
		document.body.style.behavior='url(#default#homepage)';
		document.body.setHomePage(document.location.href);
	}
	else{
		obj.href=document.location.href;
		if (navigator.appName=='Opera'){//opera
			alert('OPERA\nAby ustawić stronę jako startową otwórz narzędzia\ni w zakładce preferencje kliknij "Użyj bieżącej".');
		}
		else if (navigator.appName=='Netscape'){//firefox+safari
			if (navigator.userAgent.indexOf('Chrome')!=-1){
				alert('CHROME\nAby ustawić stronę jako startową otwórz opcje\ni w zakładce podstawy kliknij "Użyj bieżącej".');
			}
			else if (navigator.userAgent.indexOf('Safari')!=-1){
				alert('SAFARI\nAby ustawić stronę jako startową otwórz preferencje (ctrl+,)\ni w zakładce ogólne kliknij "Ustaw na bieżącą stronę".');
			}
			else if (navigator.userAgent.indexOf('Firefox')!=-1){
				alert('FIREFOX\nAby ustawić stronę jako startową przeciągnij tego linka na ikonkę domu znajdującą się obok paska adresu.');
			}
			else{
				//alert('Nieznana przeglądarka z rodziny Netscape:\n'+navigator.appVersion+'\n'+navigator.appCodeName+'\n'+navigator.userAgent);
			}
		}
		else{
			//alert('Nieznana przeglądarka:\n'+navigator.appName+'\n'+navigator.appVersion+'\n'+navigator.appCodeName+'\n'+navigator.userAgent);
		}
	}
}


var tempo = 5000;
			var position = 0;
			var timeout=false;
			function mouve(k){
				if (timeout!=false) clearInterval(timeout);
				var ref=document.getElementById("ma_liste");
				var refa=document.getElementById("ma_liste_slider").getElementsByTagName("a");
				if (k!=-1)
					position=k;
				else
					position=position+1;
				if (position>=refa.length) position=0;
				for (var i=0;i<refa.length;i++) {if (i==position) {refa[i].style.fontWeight="bold";refa[i].style.textDecoration="underline";} else {refa[i].style.fontWeight="normal";refa[i].style.textDecoration="none";}}
				ref.scrollTop=145*position;
				timeout=setTimeout("mouve(-1)",tempo);
			}
			

			var t = 5000;
			var num=1;
			var timeout2=false;
			function changeNews(id){
				if(id>num)
				id=1;
				
				for(var i=1;i<=num;i++){
					document.getElementById('news'+i).style.display="none";
				}
				document.getElementById('news'+id).style.display="";
				clearTimeout(timeout2);
				timeout2=setTimeout("changeNews("+(id+1)+")",t);
			}
