function $_(n) {
	if(!n) return false;
	if(!document.getElementById(n)) return false;
	return document.getElementById(n)
}


function show_title(obj) {
	obj.className = "item hover";

	if (!document.getElementsByTagName || !document.createTextNode) return;
	var titles = this.document.getElementsByTagName("span");

	for(i = 0; i < titles.length; i++) {
		if(titles[i].className.indexOf("item-right") != -1) {
			titles[i].style.marginLeft = - titles[i].offsetWidth + obj.offsetWidth + "px";
		}
	}
}
function hide_title(obj) {
	obj.className = "item";
}


function page_url(obj,url,vars) {
	if (url.indexOf("?") == -1) tmp = "?" + vars;
		else tmp = "&" + vars;
	window.document.location.href = url + tmp + "=" + obj.options[obj.selectedIndex].value;
}


function print_version(url) {
	pos_left = (screen.width) ? (screen.width-830)/2 : 0;
	pos_top  = (screen.height) ? (screen.height-600)/3 : 0;

	settings = "width=830,height=600,top=" + pos_top + ",left=" + pos_left + ",scrollbars=yes";
	win = window.open(url,"print",settings)
	win.focus();
}


function gallery(url) {
	pos_left = (screen.width) ? (screen.width-620)/2 : 0;
	pos_top  = (screen.height) ? (screen.height-510)/3 : 0;

	settings = "width=620,height=510,top=" + pos_top + ",left=" + pos_left + ",scrollbars=no";
	win = window.open(url,"gallery",settings)
	win.focus();
}


function map(url) {
	pos_left = (screen.width) ? (screen.width-530)/2 : 0;
	pos_top  = (screen.height) ? (screen.height-407)/3 : 0;

	settings = "width=530,height=407,top=" + pos_top + ",left=" + pos_left + ",scrollbars=no";
	win = window.open(url,"gallery",settings)
	win.focus();
}


function reserv(url) {
	pos_left = (screen.width) ? (screen.width-820)/2 : 0;
	pos_top  = (screen.height) ? (screen.height-600)/3 : 0;

	settings = "width=820,height=600,top=" + pos_top + ",left=" + pos_left + ",scrollbars=yes";
	win = window.open(url,"gallery",settings)
	win.focus();
}


function popupText( url ) {
	pos_left = (screen.width) ? (screen.width-620)/2 : 0;
	pos_top  = (screen.height) ? (screen.height-510)/3 : 0;

	settings = "width=610,height=400,top=" + pos_top + ",left=" + pos_left + ",scrollbars=no";
	win = window.open(url,"gallery",settings)
	win.focus();
}

function popup_toggle(id) {
	if($_(id)) $_(id).className = $_(id).className == "" ? id : "";
}


function popup_open(id) {
	if($_(id)) $_(id).className = id;
}


function popup_close(id) {
	if($_(id)) $_(id).className = "";
}

function toggle_offer(obj,els) {
	if (!document.getElementsByTagName || !document.createTextNode) return;
	if ($_("offer-items")) {
		var rows = document.getElementById("offer-items").getElementsByTagName("tr");
		var btns = document.getElementById("offer-items").getElementsByTagName("h3");
		for (i = 0; i < rows.length; i++) {
			if (rows[i].className.indexOf("offer") != -1) rows[i].style.display = "none";
			if (rows[i].className.indexOf(els) != -1) rows[i].style.display = "";
		}
		for (i = 0; i < btns.length; i++) {
			btns[i].className = "";
		}
		obj.className = "visible";
	}
}

