function addslashes(str){return (str+'').replace(/([\\"'])/g, "\\$1").replace(/\u0000/g, "\\0");}// confirmed link
function confirmedLink(theLink, theAppendix){
	theLink.href += theAppendix;
	return true;
}

// confirm link
function confirmLink(theLink, theTitle, theAppendix){
	var is_confirmed = confirm(theTitle);
	if (is_confirmed) {
	theLink.href += theAppendix;
	}
	return is_confirmed;
}

// centrovanie
function center_t(h){
	t=(screen.height-h)/2;
	return t;
}
function center_l(w){
	l=(screen.width-w)/2;
	return l;
}

// foto
function show_foto(id, sirka, pocet_foto){
	for(i=1;i<=pocet_foto;i++){
		foto_id="foto_m_"+i;
		document.getElementById(foto_id).style.display="none";
		link_id="foto_link_"+i;
		document.getElementById(link_id).className="foto";
		zoom_id="zoom_"+i;
		document.getElementById(zoom_id).style.display="none";
	}
	foto_id="foto_m_"+id;
	document.getElementById("objekt_foto").style.width=sirka+"px";
	document.getElementById(foto_id).style.display="block";
	link_id="foto_link_"+id;
	document.getElementById(link_id).className="foto_act";
	zoom_id="zoom_"+id;
	document.getElementById(zoom_id).style.display="block";
	actual = id;
}

function popup_foto(){
	var foto_url = "/popup.php?pic="+idf[actual];
	var foto_name = "foto_"+objekt+"_"+actual;
	var foto_properties = "width="+w[actual]+", height="+h[actual]+", top="+center_t(h[actual])+", left="+center_l(w[actual])+", scrollbars=no";
	window.open(foto_url, foto_name, foto_properties);
}

// change_nazov_en

function change_nazov_en(){
	var selectbox = document.forms['form_editor'].nazvy_en;
	var preklad = selectbox.options[selectbox.selectedIndex].value;
	if(preklad!=""){
		document.forms['form_editor'].nazov_en.value = preklad;
	}
}

// change_infos_en

function change_infos_en(){
	var selectbox = document.forms['form_editor'].infos_en;
	if(selectbox.selectedIndex>1){
		document.forms['form_editor'].add_info.disabled = "";
	}else{
		document.forms['form_editor'].add_info.disabled = "disabled";
	}
}

// change_infos_en

function change_info_en(){
	var selectbox = document.forms['form_editor'].info_en;
	if(selectbox.selectedIndex>1){
		document.forms['form_editor'].remove_info.disabled = "";
	}else{
		document.forms['form_editor'].remove_info.disabled = "disabled";
	}
}

function processRequest(){
	if (httpRequest.readyState==4){
		if(httpRequest.status==200){
			//alert("OK "+httpRequest.status+": "+httpRequest.responseText);
		}else{
			alert("Error "+httpRequest.status+": "+httpRequest.statusText);
		}
	}
}

// add info
function addinfo(tabulka){
	document.forms['form_editor'].add_info.disabled = "disabled";
	document.forms['form_editor'].add_info.value = "moment...";
	var selectbox = document.forms['form_editor'].infos_en;
	var selectbox2 = document.forms['form_editor'].info_en;
	var objekt = selectbox.options[0].value;
	var temp_array = "";
	var i = 0;
	for(i=2;i<selectbox.options.length;i++){
		if(selectbox.options[i].selected){
			temp_array += selectbox.options[i].value+":";
		}
	}
	var request = "tabulka="+tabulka+"&objekt="+objekt+"&infos="+temp_array;
	var url = "/admin/add_info.php";
	if (window.ActiveXObject){
		httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
	}else{
		httpRequest = new XMLHttpRequest();
	}
	httpRequest.open("POST", url, true);
	httpRequest.onreadystatechange = function() { processRequest(); };
	httpRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
	httpRequest.send(request);
	for(i=2;i<selectbox.options.length;i++){
		if(selectbox.options[i].selected){
			var newone = document.createElement("option");
			selectbox2.appendChild(newone);
			selectbox2.options[selectbox2.options.length-1].value = selectbox.options[i].value;
			selectbox2.options[selectbox2.options.length-1].text = selectbox.options[i].text;
		}
	}
	for(i=selectbox.options.length-1;i>1;i--){
		if(selectbox.options[i].selected){
			selectbox.removeChild(selectbox.options[i]);
		}
	}
	document.forms['form_editor'].add_info.value = "\u00A0 pridať \u21D2 \u00A0";
	document.forms['form_editor'].add_info.disabled = "";
}

// remove info
function removeinfo(tabulka){
	document.forms['form_editor'].remove_info.disabled = "disabled";
	document.forms['form_editor'].remove_info.value = "moment...";
	var selectbox = document.forms['form_editor'].info_en;
	var selectbox2 = document.forms['form_editor'].infos_en;
	var objekt = selectbox.options[0].value;
	var temp_array = "";
	var i = 0;
	for(i=2;i<selectbox.options.length;i++){
		if(selectbox.options[i].selected){
			temp_array += selectbox.options[i].value+":";
		}
	}
	var request = "tabulka="+tabulka+"&objekt="+objekt+"&infos="+temp_array;
	var url = "/admin/remove_info.php";
	if (window.ActiveXObject){
		httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
	}else{
		httpRequest = new XMLHttpRequest();
	}
	httpRequest.open("POST", url, true);
	httpRequest.onreadystatechange = function() { processRequest(); };
	httpRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
	httpRequest.send(request);
	for(i=2;i<selectbox.options.length;i++){
		if(selectbox.options[i].selected){
			var newone = document.createElement("option");
			selectbox2.appendChild(newone);
			selectbox2.options[selectbox2.options.length-1].value = selectbox.options[i].value;
			selectbox2.options[selectbox2.options.length-1].text = selectbox.options[i].text;
		}
	}
	for(i=selectbox.options.length-1;i>1;i--){
		if(selectbox.options[i].selected){
			selectbox.removeChild(selectbox.options[i]);
		}
	}
	document.forms['form_editor'].remove_info.value = "\u21D0 odobrať";
	document.forms['form_editor'].remove_info.disabled = "";
}