function show_photo(text,file,width,height){
	no=window.open("", "zoom", "left=5, top=5, width="+width+", height="+height+", toolbar=no, location=no, status=no, scrollbars=auto");
	with (no.document)
	{
		open();
		writeln('<body style="margin: 0px;"><a href="javascript:void window.close();"><img src="'+file+'" style="border: 0px;" /></a></body>');
		close();
		no.focus();
	}
}

function openWindow(text,file,width,height,type){
	if (type=='img'){
		no=window.open("", "zoom", "left=5, top=5, width="+width+", height="+height+", toolbar=no, location=no, status=no, scrollbars=auto");
		with (no.document)
		{
			open();
			writeln('<body style="margin: 0px;"><a href="javascript:void window.close();"><img src="'+file+'" alt="'+text+'"style="border: 0px;" /></a></body>');
			close();
			no.focus();
		}
	}
	if (type=='file'){
		window.open(file, "zoom", "left=5, top=5, resizable,toolbar=no, location=no, status=no, scrollbars=yes");
		
		
	}
	return false;
}

function changeImage (url,foto) {
	if (document.getElementById) {
    	//window.alert(foto);    
                document.getElementById('mainphoto').src = url;
                document.getElementById('largephoto').href = foto;
               // photo_id = fotka_id;
        }
        return false;
}

function showLargeImage(url,width,height,type) {
	if (screen.height) {
		screenY = screen.height
		screenX = screen.width
	}
	var top = ((screenY/2)-(height/2));
	var left = ((screenX/2)-(width/2));
	window.open(url,'','resizable=no,status=no,scrollbars=no,width='+width+',height='+height+',top=50,left=50');
	return false;
}

function newWindow(url){
	x = window.open(url, "new_win", "");
	if (x) return false;
}

function ajax(url,idElement){
	if (url != 0){
		if (window.ActiveXObject){
    		httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
		}
        else{
			httpRequest = new XMLHttpRequest();
		}
    	httpRequest.open("GET", url+'&popisek='+idElement, true);
        httpRequest.onreadystatechange= function () {processRequest(idElement); } ;
        httpRequest.send(null);
	}
	else{
		document.getElementById(idElement).innerHTML = "";
	}
	//setTimeout("alert('"+idElement+"')",10);
}

function processRequest(element){
	if (httpRequest.readyState == 4){
		if(httpRequest.status == 200){
			var vystup = document.getElementById(element);
			vystup.innerHTML = httpRequest.responseText;
		}
		else{
			alert("Chyba pri nacitani stanky"+ httpRequest.status +":"+ httpRequest.statusText);
		}
	}
}

// vlozime id prvku jako parametr, pokud je viditelny, skryje se a naopak
function ShowORhidden(prvek){
	if (document.getElementById(prvek).style.display == 'none' || document.getElementById(prvek).style.display == '')
		document.getElementById(prvek).style.display='block';
	else
		document.getElementById(prvek).style.display='none'
}

function setRegion(region,id){
	var text = $(".krajValue").attr("value");
	var nalezeno = text.search(region);

	if (nalezeno<0){
		val1 = $(".krajValue").attr("value");
		$(".krajValue").attr("value", val1 + region + ', ');
		val2 = $(".krajInfo").text();
		$(".krajInfo").text(val2 + region + ', ');
		$("."+id).css("display", "block");
	}
	else{
		val1 = $(".krajValue").attr("value");
		$(".krajValue").attr("value", val1.replace(region + ", ", ""));
		val2 = $(".krajInfo").text();
		$(".krajInfo").text(val2.replace(region + ", ", ""));
		$("."+id).css("display", "none");
	}
	
	$(".fullbox .body").css("height", "auto");
	return false;
}

function changeMap(img) {
	$("#mapa").attr("src", '/images/maps/' + img);
 

}

function testik(id){
	if ($("#"+id).is(':checked')){
		$("#"+id).attr('checked', false);
	}
	else{
		$("#"+id).attr('checked', true);
	}
	
	return false;
}

function calculateHeightCols(){
	if (location.href != 'http://www.sklady.cz/' & location.href != 'http://www.sklady.cz/#search'){
		if ($(".fullbox .body").height() < $("#right-column").height()){
			//alert($(".fullbox .body").height() + ' | ' + $("#right-column").height());
			$(".fullbox .body").height($("#right-column").height()-50);
		}
		else{
			
			$("#right-column .halfbox .body").height($(".fullbox .body").height());
			//alert($("#right-column").height());
		}
		$(".error_message .body").height('auto');
		//alert($(".error_message .body").height('auto'));
	}
	else{
		//$(".article .body").height(  ($(".first").height()-50)-($(".search").height())  +  ($(".second").height())  );
	}
}

function callEvent() {
	var url = window.location.href;	
	var qparts = url.split("?");

  	if (qparts.length == 1) {
    	return "";
  	}
	
  	var query = qparts[1];
  	var value = "";
  
    var parts = query.split("=");
    if (parts[0] == "id") {
      	value = parts[1];
    }

	if (value == "") {
    	return "";
  	}
	
	switch(value) {
		case("id10"):
			setRegion('Praha','id10');
			break;
		case("id1"):
			setRegion('Jihočeský kraj','id1');
			break;
		case("id9"):
			setRegion('Plzeňský kraj','id9');
			break;
		case("id4"):
			setRegion('Karlovarský kraj','id4');
			break;
		case("id12"):
			setRegion('Ústecký kraj','id12');
			break;
		case("id11"):
			setRegion('Středočeský kraj','id11');
			break;
		case("id6"):
			setRegion('Liberecký kraj','id6');
			break;
		case("id5"):
			setRegion('Královéhradecký kraj','id5');
			break;
		case("id8"):
			setRegion('Pardubický kraj','id8');
			break;
		case("id13"):
			setRegion('Kraj Vysočina','id13');
			break;
		case("id7"):
			setRegion('Olomoucký kraj','id7');
			break;
		case("id2"):
			setRegion('Moravskoslezský kraj','id2');
			break;
		case("id14"):
			setRegion('Zlínský kraj','id14');
			break;
		case("id3"):
			setRegion('Jihomoravský kraj','id3');
			break;
		default:
			return "";	
	}
}

