var xmlHttp


function powiaty(x) { 
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
 	{
 		alert ("Twoja przegladarka nie obsluguje HTTP Request")
		return
 	}
	
	var url="get_powiaty.php";
	url+="?woj="+x;
	
	xmlHttp.onreadystatechange=stateChanged ;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function stateChanged() { 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { 
 		document.getElementById("powiatownia").innerHTML=xmlHttp.responseText
 	} //else {
		//document.getElementById("powiatownia").innerHTML='<img src="images/loading.gif" />';
	//}
}

function GetXmlHttpObject() {
	var xmlHttp=null;
	try
 	{
 		// Firefox, Opera 8.0+, Safari
 		xmlHttp=new XMLHttpRequest();
 	}
	catch (e)
 	{
 		//Internet Explorer
 		try
  		{
  			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  		}
 		catch (e)
  		{
  			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  		}
 	}
	return xmlHttp;
}


function rozwin(x) {
	
	var style = document.getElementById(x).style.display;
	
	$("#"+x).css({display: "none"}); // Opera Fix
	if (style == 'inline') {
		$("#"+x).css({visibility: "hidden"}).slideUp(400);
	}
	if (style == 'none') {
		$("#"+x).css({visibility: "visible",display: "none"}).slideDown(400);
	}
}
	
function resize_iframe()
{
	//var height;
	
	
	var iebody=(document.compatMode && document.compatMode != "BackCompat")? document.documentElement : document.body
	var height=document.all? (iebody.clientHeight+160) : innerHeight
	
	//var height=window.innerWidth;//Firefox
	//if (document.body.clientHeight)
	//{
	//	height=document.body.clientHeight;//IE
	//}
	//resize the iframe according to the size of the
	//window (all these should be on the same line)
	document.getElementById("folderframe").style.height=parseInt(height-
	document.getElementById("folderframe").offsetTop-8)+"px";
	//alert(parseInt(height-
	//document.getElementById("folderframe").offsetTop-8));
}

function fontsizeup() {
	$(".center").css("font-size","17px");
	$(".center").css("line-height","21px");
	
	$(".article").css("font-size","17px");
	$(".article").css("line-height","21px");
	
	$(".btn").css("font-size","17px");
	
	$("#navi").css("font-size","17px");
	$("#navi").css("line-height","21px");
	
	$("#ocenazrodlo").css("font-size","17px");
	$("#ocenazrodlo").css("line-height","21px");
	
	$("#col-1").css("font-size","17px");
	$("#col-1").css("line-height","21px");
	$("#col-2").css("font-size","17px");
	$("#col-2").css("line-height","21px");
	$("#col-3").css("font-size","17px");
	$("#col-3").css("line-height","21px");
}

function fontsizedown() {
	$(".center").css("font-size","11px");
	$(".center").css("line-height","15px");
	
	$(".article").css("font-size","11px");
	$(".article").css("line-height","15px");
	
	$(".btn").css("font-size","11px");
	
	$("#navi").css("font-size","11px");
	$("#navi").css("line-height","15px");
	
	$("#ocenazrodlo").css("font-size","11px");
	$("#ocenazrodlo").css("line-height","15px");
	
	$("#col-1").css("font-size","11px");
	$("#col-1").css("line-height","15px");
	$("#col-2").css("font-size","11px");
	$("#col-2").css("line-height","15px");
	$("#col-3").css("font-size","11px");
	$("#col-3").css("line-height","15px");
}

function kontrast() {
	var color = $(".center").css("color");
	var color2 = $(".article").css("color");
	if (color == undefined) color = $("#col-1").css("color");
	if (color2 == undefined) color2 = $("#col-1").css("color");
	//alert(color+' '+color2);
	
	if ((color == '#0c2451') || (color == 'rgb(12, 36, 81)')) {
		$(".center").css("color","#17469e");
		$("h1").css("color","#17469e");
		$(".article").css("color","#17469e");
		$("h2").css("color","#17469e");
		//alert(color);
		$("#col-1").css("color","#17469e");
		$("#col-2").css("color","#17469e");
		$("#col-3").css("color","#17469e");
	} else {
		$(".center").css("color","#0c2451");
		$("h1").css("color","#0c2451");
		$(".article").css("color","#0c2451");
		$("h2").css("color","#0c2451");
		
		$("#col-1").css("color","#0c2451");
		$("#col-2").css("color","#0c2451");
		$("#col-3").css("color","#0c2451");
	}
	
	if ((color2 == '#0c2451') || (color2 == 'rgb(12, 36, 81)')) {
		$(".center").css("color","#17469e");
		$("h1").css("color","#17469e");
		$(".article").css("color","#17469e");
		$("h2").css("color","#17469e");
		
		$("#col-1").css("color","#17469e");
		$("#col-2").css("color","#17469e");
		$("#col-3").css("color","#17469e");
		//alert(color2);
	} else {
		$(".center").css("color","#0c2451");
		$("h1").css("color","#0c2451");
		$(".article").css("color","#0c2451");
		$("h2").css("color","#0c2451");
		
		$("#col-1").css("color","#0c2451");
		$("#col-2").css("color","#0c2451");
		$("#col-3").css("color","#0c2451");
	}
}

function confirmation(link, about) {
	var answer = confirm(about); 
	if (answer) {
		window.location = link;
	} 
}


// this will resize the iframe every
// time you change the size of the window.
if (document.getElementById("folderframe")) {
	window.onresize=resize_iframe; 
}


function doIframe(){
	o = document.getElementsByTagName('iframe');
	for(i=0;i<o.length;i++){
		if (/\bautoHeight\b/.test(o[i].className)){
			setHeight(o[i]);
			addEvent(o[i],'load', doIframe);
		}
	}
}

function setHeight(e){
	if(e.contentDocument){
		e.height = e.contentDocument.body.offsetHeight + 35;
	} else {
		e.height = e.contentWindow.document.body.scrollHeight;
	}
}

function addEvent(obj, evType, fn){
	if(obj.addEventListener)
	{
	obj.addEventListener(evType, fn,false);
	return true;
	} else if (obj.attachEvent){
	var r = obj.attachEvent("on"+evType, fn);
	return r;
	} else {
	return false;
	}
}

if (document.getElementById && document.createTextNode){
 addEvent(window,'load', doIframe);	
}


$(document).ready(function() {

	//Select all anchor tag with rel set to tooltip
	$('a[rel=tooltip]').mouseover(function(e) {
		
		//Grab the title attribute's value and assign it to a variable
		var tip = $(this).attr('title');	
		
		//Remove the title attribute's to avoid the native tooltip from the browser
		$(this).attr('title','');
		
		//Append the tooltip template and its value
		$(this).append('<div id="tooltip"><div class="tipHeader"></div><div class="tipBody">' + tip + '</div><div class="tipFooter"></div></div>');		
				
		//Show the tooltip with faceIn effect
		$('#tooltip').fadeIn('500');
		$('#tooltip').fadeTo('10',0.9);
		
	}).mousemove(function(e) {
	
		//Keep changing the X and Y axis for the tooltip, thus, the tooltip move along with the mouse
		$('#tooltip').css('top', e.pageY + 10 );
		$('#tooltip').css('left', e.pageX + 20 );
		
	}).mouseout(function() {
	
		//Put back the title attribute's value
		$(this).attr('title',$('.tipBody').html());
	
		//Remove the appended tooltip template
		$(this).children('div#tooltip').remove();
		
	});

})




//wybrane na dzis - zmiana
function zmien_fotos(x, ile, now) {
		for (var i=1; i<=ile; i++) {
			$('#wnd'+i).css({opacity:0.0});
		}
		$('#wnd'+x).css({opacity:1});
		
		var n;
		//alert(now);
		if (x=='left') {
			n = now;
			now--;
			if (now==0) now=ile;
			
			$('#wnd'+n).animate({opacity:0.0},1000);
			document.getElementById('wnd'+n).style.display="none";
			document.getElementById('wnd'+now).style.display="inline";
			$('#wnd'+now).animate({opacity:1},1000);
			
			document.getElementById('navigacjao').innerHTML='<a style="cursor:pointer;" class="prev" onclick="zmien_fotos(\'left\',\''+ile+'\',\''+now+'\')"></a><a style="cursor:pointer;" onclick="zmien_fotos(\'right\',\''+ile+'\',\''+now+'\')" class="next"></a>';
		} else {
			n = now;
			now++;
			if (now>ile) now=1;
			
			$('#wnd'+n).animate({opacity:0.0},1000);
			document.getElementById('wnd'+n).style.display="none";
			document.getElementById('wnd'+now).style.display="inline";
			$('#wnd'+now).animate({opacity:1},1000);
			
			document.getElementById('navigacjao').innerHTML='<a style="cursor:pointer;" onclick="zmien_fotos(\'left\',\''+ile+'\',\''+now+'\')" class="prev"></a><a style="cursor:pointer;" onclick="zmien_fotos(\'right\',\''+ile+'\',\''+now+'\')" class="next"></a>';
		}
}



//zarzadzanie kultura - zmiana
function zmien_fotos2(x, ile, now) {
		for (var i=1; i<=ile; i++) {
			$('#zk'+i).css({opacity:0.0});
		}
		$('#zk'+x).css({opacity:1});
		
		var n;
		if (x=='left') {
			n = now;
			now--;
			if (now==0) now=ile;
			
			$('#zk'+n).animate({opacity:0.0},1000);
			document.getElementById('zk'+n).style.display="none";
			document.getElementById('zk'+now).style.display="inline";
			$('#zk'+now).animate({opacity:1},1000);
			
			document.getElementById('navigacjao2').innerHTML='<a style="cursor:pointer;" class="prev" onclick="zmien_fotos2(\'left\',\''+ile+'\',\''+now+'\')"></a><a style="cursor:pointer;" onclick="zmien_fotos2(\'right\',\''+ile+'\',\''+now+'\')" class="next"></a>';
		} else {
			n = now;
			now++;
			if (now>ile) now=1;
			
			$('#zk'+n).animate({opacity:0.0},1000);
			document.getElementById('zk'+n).style.display="none";
			document.getElementById('zk'+now).style.display="inline";
			$('#zk'+now).animate({opacity:1},1000);
			
			document.getElementById('navigacjao2').innerHTML='<a style="cursor:pointer;" onclick="zmien_fotos2(\'left\',\''+ile+'\',\''+now+'\')" class="prev"></a><a style="cursor:pointer;" onclick="zmien_fotos2(\'right\',\''+ile+'\',\''+now+'\')" class="next"></a>';
		}
}




//zarzadzanie kultura - zmiana
function zmien_fotos3(x, ile, now) {
		for (var i=1; i<=ile; i++) {
			$('#knd'+i).css({opacity:0.0});
		}
		$('#knd'+x).css({opacity:1});
		
		var n;
		if (x=='left') {
			n = now;
			now--;
			if (now==0) now=ile;
			
			$('#knd'+n).animate({opacity:0.0},1000);
			document.getElementById('knd'+n).style.display="none";
			document.getElementById('knd'+now).style.display="inline";
			$('#knd'+now).animate({opacity:1},1000);
			
			document.getElementById('navigacjao3').innerHTML='<a style="cursor:pointer;" class="prev" onclick="zmien_fotos3(\'left\',\''+ile+'\',\''+now+'\')"></a><a style="cursor:pointer;" onclick="zmien_fotos3(\'right\',\''+ile+'\',\''+now+'\')" class="next"></a>';
		} else {
			n = now;
			now++;
			if (now>ile) now=1;
			
			$('#knd'+n).animate({opacity:0.0},1000);
			document.getElementById('knd'+n).style.display="none";
			document.getElementById('knd'+now).style.display="inline";
			$('#knd'+now).animate({opacity:1},1000);
			
			document.getElementById('navigacjao3').innerHTML='<a style="cursor:pointer;" onclick="zmien_fotos3(\'left\',\''+ile+'\',\''+now+'\')" class="prev"></a><a style="cursor:pointer;" onclick="zmien_fotos3(\'right\',\''+ile+'\',\''+now+'\')" class="next"></a>';
		}
}

function displayWindow(url, width, height) {
        var Win = window.open(url,"displayWindow",'width=' + width + ',height=' + height + ',resizable=no,scrollbars=no,menubar=no,left=0,top=0,screenx=50,screeny=50' );
}

