	
	var newWindow = true;
	var hide = false;

	function show_mouseposition(posX, posY, minX, minY, scale){
		if (navigator.appName=="Microsoft Internet Explorer" || navigator.appName=="Opera"){
			scrollX = document.documentElement.scrollLeft;
			scrollY = document.documentElement.scrollTop;
	   	}
		if (navigator.appName=="Netscape"){
			scrollX = document.body.scrollLeft;
			scrollY = document.body.scrollTop;
    	}
		X = 195 - scrollX;
		Y = 219 - scrollY;
		text = "min X: " + minX + ", min Y: " + minY;
		text = "pos X: " + posX + ", pos Y: " + posY;
		realX = (posX - X + minX) * scale;
		realY = (posY - Y + minY) * scale;
		//alert(scale);
		if (newWindow){
			text = "pos X: " + realX + ", pos Y: " + realY + ", scale: " + scale;
			//url = "edit/new_object.php?action=new&axis_x=" + realX + "&axis_y=" + realY;
			url = "new_object.php?action=new&axis_x=" + realX + "&axis_y=" + realY;
			window.open(url, '', 'location=no,alwaysRaised=yes,toolbar=no,width=700, height=800');
		}
		newWindow = true;
		//alert(text);	
	}
	
	a = new Array();
	a[0] = "A";

	
//	Zobrazení okna s detaily
	function showDetail(label, address, tel, fax, email, web, description, image, width, height){
		show = "<div onmouseover='hide=false;' onmouseout='hideDetail();'>";
		//show = show + "<div class='top'><img src='images/blank.gif' width='150' height'1'></div>";  
		//alert(description);
		// ***** LABEL *****
		if (label != ""){
			show = show + "<div class='headline'>" + label + "</div>";  
		}
		
		// ***** IMAGE *****
		if (image != ""){
			show = show + "<img id='imgShowDetail' src='" + image + "' widht='" + width + "' height='" + height + "'>";
		}
		
		// ***** ADDRESS *****
		if (address != ""){
			show = show + "<div class='address'><span class='label'>" + show_map_detail_address + ": </span>" + address + "</div>";  
		}
		
		// ***** TEL *****
		if (tel != ""){
			show = show + "<div class='text'><span class='label'>" + show_map_detail_tel + ": </span>" + tel + "</div>";  
		}
		// ***** FAX *****
		if (fax != ""){
			show = show + "<div class='text'><span class='label'>" + show_map_detail_fax + ": </span>" + fax + "</div>";  
		}
		// ***** EMAIL *****
		if (email != ""){
			show = show + "<div class='text'><span class='label'>" + show_map_detail_email + ": </span>" + email + "</div>";  
		}
		// ***** WEB *****
		if (web != ""){
			show = show + "<div class='text'><span class='label'>"+ show_map_detail_web + ": </span><a href='http://" + web + "' target='_blank'>" + web + "</a></div>";  
		}

		// ***** POPIS *****
		if (description != ""){
			show = show + "<div class='text'>" + description + "</div>";  
		}
		//show = show + "<div class='set_width'><img src='images/blank.gif' width='150' height'1'></div>";  
		//show = show + "<div>ahoj&nbsp;ahoj&nbsp;ahoj&nbsp;ahoj&nbsp;ahoj&nbsp;ahoj&nbsp;ahoj&nbsp;ahoj&nbsp;</div>";  
		
		//alert(show);
		show = show + "</div>";
	    document.getElementById('showDetail').innerHTML = show;    
    	document.getElementById('showDetail').style.visibility = "visible";
    	hide=false;
    }
    
	function getMouse(e){
		var x;
		var y;
		
		//alert(document.body.scrollTop);
		if (navigator.appName=="Microsoft Internet Explorer" || navigator.appName=="Opera"){
			x = window.event.x + 120 + document.documentElement.scrollLeft;
			y = window.event.y + 118 + document.documentElement.scrollTop;
	   	}
/*		if (navigator.appName=="Microsoft Internet Explorer" || navigator.appName=="Opera"){
			x = e.clientX-210;
			y = e.clientY+5;
    	}
*/		if (navigator.appName=="Netscape"){
			x = e.clientX - 100 + document.body.scrollLeft ;
			y = e.clientY - 100 + document.body.scrollTop ;
    	}
 //   	alert(document.folder);
/*		if (navigator.appName=="Netscape"){
			x = e.clientX-200;
			y = e.clientY-100;
    	}
    	x =  x + document.documentElement.scrollLeft;
    	y =  y + document.documentElement.scrollTop;
    	x =  x + document.body.scrollLeft;
    	y =  y + document.body.scrollTop;
 */   	x = x.toString() + "px"
    	y = y.toString() + "px"
		document.getElementById('showDetail').style.left = x;
    	document.getElementById('showDetail').style.top  = y;
    	hide=false;
    	//alert(document.getElementById('showDetail').style.width);
    	
	}

	function hideDetail(){
		hide = true;
    	a=setTimeout('hideDetailExpiration();', 1000);
    }
    
	function hideDetailExpiration(){
		if (hide == true){
    		document.getElementById('showDetail').style.visibility = "hidden";
		}
    }
    
    function potvrzeni(txtText){
	if (confirm(txtText)){
		return true;
	} else {
		return false;
	}
}

	function zprava(txtText){
		alert(txtText);
	}

	function nacist_stranu(txtText){
		location.reload(txtText);
	}

	function hodnota_0_1(text){
		cislo = parseInt(text);
		cislo = (-1)*cislo + 1;
		return cislo;
	}

	function delete_record(txtZprava, txtHref){
		if (potvrzeni(txtZprava)){
			location.replace(txtHref);	
		}
	}

// zm�na po�tu ��dk� zobrazovan�ch na stran� (number of rows listed)
	function norl0(intValue, txtPage, intFirstRow, intSelRowNum){
		intFrow = Math.floor((intSelRowNum+intFirstRow)/intValue)*intValue;
		txtLink = txtPage + "?lrow=" + intValue + "&frow=" + intFrow; //+ "&change=1";
		document.location.href = txtLink;
	}

	function norl(intValue, txtPage, intLog, intFirstRow, intSelRowNum){
		intFrow = Math.floor((intSelRowNum+intFirstRow)/intValue)*intValue;
		txtLink = txtPage + "?log=" + intLog + "&lrow=" + intValue + "&frow=" + intFrow; //+ "&change=1";
		document.location.href = txtLink;
	}

	function goToPage_logged(intPageNumber, txtPage, intLog, intSelRowNum){
		intFrow = (intPageNumber - 1) * intSelRowNum;
//		alert(intPageNumber);
		txtLink = txtPage + "?log=" + intLog + "&frow=" + intFrow + "&change=1";
		document.location.href = txtLink;	
	}

	function filter(txtType, txtName, txtPage, txtTableJoin, txtTableField, txtTableFieldJoin, txtTableFieldWhere, mixValue){
		txtLink = txtPage + "?type=" + txtType + "&name=" + txtName+ "&table_join=" + txtTableJoin + "&table_field=" + txtTableField + "&table_field_join=" +  txtTableFieldJoin + "&field=" + txtTableFieldWhere + "&value=" + mixValue + "&change=1";
//		alert(txtLink);
		document.location.href = txtLink;	
	}


// kontrola spravnosti emailu
	function valid_email(lcAddress, alert_valid_email){
		if (lcAddress == "") {
			return true;
		}
		mailRegexp = /^[a-zA-Z0-9._%-]+@[a-zA-Z0-9-]+\.[a-zA-Z]{2,4}$/;
		if (!lcAddress.match(mailRegexp)){
			alert(alert_valid_email);
			return false;	
		} else {
			return true;
		}
}

// Kontrola formularu
	function valid_fields(laFields, laTypes){
		length = laFields.length;
		ret = true;
		empty_fields = "";
		for (i = 0; i <= length - 1; i++){
			switch (laTypes[i]){
				case "N":
					if (document.forms[0].elements[laFields[i]].value == 0){
        				name = document.forms[0].elements[laFields[i]].title;
						empty_fields = empty_fields + "- " + name + "\n";
						ret = false;
					}
					break;
				case "EMAIL":
					break;
				default:
					if (document.forms[0].elements[laFields[i]].value==""){
						name = document.forms[0].elements[laFields[i]].title;
						empty_fields = empty_fields + "- " + name + "\n";
					ret = false;
				}			
    	    }	
		}	
		if (ret == false){
			empty_fields = empty_fields.substring(0, empty_fields.length-1);
			text = "<? echo ALERT_VALID_EMPTY; ?>\n" + empty_fields;
			alert(text);
		}
		return ret;
	}

		function pageReload_jizdni_rady(linka, smer, stop){
		rep = "?linka=" + linka + "&smer=" + smer + "&stop=" + stop;
		location.replace(rep);
	}

	function pageReload(page, value){
		rep = page + value;
		location.replace(rep);
	}

	function ActivateFlashIE(width, height, bgcolor, wmode, movie, xml){  
	 	document.write("<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,79,0' width='" + width + "' height='" + height + "'>");
	 	document.write("<param name='width' value='" + width + "'>");
	 	document.write("<param name='height' value='" + height + "'>");
	 	document.write("<param name='movie' value=" + movie + ">");
	 	document.write("<param name='type' value='application/x-shockwave-flash'>");
	 	document.write("<param name='flashvars' value='" + xml + "'>");
	 	document.write("<param name='allowScriptAccess' value='sameDomain'>");
	 	document.write("<param name='bgcolor' value='" + bgcolor + "'>");
	 	document.write("<param name='pluginspage' value='http://www.macromedia.com/go/getflashplayer'>");
	 	document.write("<param name='quality' value='high'>");
	 	document.write("<param name='wmode' value='" + wmode + "'>");
	 	document.write("<embed src='" + movie + "' flashvars='" + xml + "' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer'  type='application/x-shockwave-flash' width='" + width + "' height='" + height + "'  wmode='" + wmode + "'></embed></object>");
	}

function show_mouseposition(){
	alert(event.clientX);
}
	

function valid_form(laFields, lcAddress, lcError_Empty, lcError_Email){
	ret = true;
	ret_fields = true;
	ret_email = true;
	ret_fields = valid_fields(laFields, lcError_Empty);
	if (lcAddress.length > 0){
		ret_email = valid_email(lcAddress, lcError_Email);
	}
	if (ret_fields == false || ret_email == false){
		ret = false;
	}
	return ret;
}


function valid_fields(laFields, lcError_Empty){
	length = laFields.length;
	ret = true;
	empty_fields = "";
	for (i = 0; i <= length - 1; i++){
		if (document.getElementById["formular"].elements[laFields[i]].value==""){
			alert(document.forms[1].elements[laFields[i]].name);
			name = document.getElementById["formular"].elements[laFields[i]].title;
			empty_fields = empty_fields + "- " + name + "\n";
			ret = false;
		}
	}
	if (ret == false){
		empty_fields = empty_fields.substring(0, empty_fields.length-1);
		text = lcError_Empty + "\n" + empty_fields;
		alert(text);

	}
	return ret;
}

function valid_email(lcAddress, lcError_Email){
	if (lcAddress == "") {
		return true;
}
	mailRegexp = /^[a-zA-Z0-9._%-]+@[a-zA-Z0-9-]+\.[a-zA-Z]{2,4}$/;
	if (!lcAddress.match(mailRegexp)){
		alert(lcError_Email);
		return false;	
	} else {
		return true;
	}
}

