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 pokaz_typy(x) {
	$("#ludzie").css({display: "none"}); // Opera Fix
	$("#miejsca").css({display: "none"}); // Opera Fix
	$("#klimat").css({display: "none"}); // Opera Fix
	$("#"+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");
	
	$("h2").css("font-size","26px");
	$("h2").css("line-height","26px");
	
	$("h1").css("font-size","26px");
	$("h1").css("line-height","26px");
	
	$("h3").css("font-size","26px");
	$("h3").css("line-height","26px");
	
}

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");
	
	$("h2").css("font-size","16px");
	$("h2").css("line-height","16px");
	
	$("h1").css("font-size","16px");
	$("h1").css("line-height","16px");
	
	$("h3").css("font-size","16px");
	$("h3").css("line-height","16px");
	
}

function kontrast() {
	var color = $(".center").css("color");
	var color2 = $(".article").css("color");
	//alert(color+' '+color2);
	
	if ((color == '#000002') || (color == 'rgb(0, 0, 2)')) {
		$(".center").css("color","#737373");
		//alert(color);
	} else {
		$(".center").css("color","#000002");
	}
	
	if ((color2 == '#000002') || (color2 == 'rgb(0, 0, 2)')) {
		$(".article").css("color","#737373");
		//alert(color2);
	} else {
		$(".article").css("color","#000002");
	}
}

function confirmation(link, about) {
	var answer = confirm(about); 
	if (answer) {
		window.location = link;
	} 
}


function deletes(link)
{
  var answer = confirm('Czy na pewno chcesz usunac ten produkt z koszyka?');
  
	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();
		
	});

})

