function $(id) {
	return document.getElementById(id);
}

function showMenu(id) {
	if (!id || id == 0) return true;
	var m = $('m' + id);
	if (!m) return true;
	if (m.style.display == 'block') {
		m.style.display = 'none';
	} else {
		m.style.display = 'block';
	}
	return false;
}

/* Menu javascript code */
var cssmenuids = ["topmenu1"]; //Enter id(s) of CSS Horizontal UL menus, separated by commas
var csssubmenuoffset = -1; //Offset of submenus from main menu. Default is 0 pixels.

function createcssmenu2(){
	for (var i=0; i<cssmenuids.length; i++){
		var ultags=document.getElementById(cssmenuids[i]).getElementsByTagName("ul");
		for (var t=0; t<ultags.length; t++){
			ultags[t].style.top=ultags[t].parentNode.offsetHeight+csssubmenuoffset+"px";
			var spanref=document.createElement("span");
			spanref.className="arrowdiv";
			spanref.innerHTML="&nbsp;&nbsp;&nbsp;&nbsp;";
			ultags[t].parentNode.getElementsByTagName("a")[0].appendChild(spanref);
			ultags[t].parentNode.onmouseover=function(){
				this.style.zIndex=100;
				this.getElementsByTagName("ul")[0].style.visibility="visible";
				this.getElementsByTagName("ul")[0].style.zIndex=0;
			}
			ultags[t].parentNode.onmouseout=function(){
				this.style.zIndex=0;
				this.getElementsByTagName("ul")[0].style.visibility="hidden";
				this.getElementsByTagName("ul")[0].style.zIndex=100;
			}
		}
	}
}

if (window.addEventListener) window.addEventListener("load", createcssmenu2, false)
else if (window.attachEvent) window.attachEvent("onload", createcssmenu2);

function showPhoto(url) {
	var width = 720, height = 700;
	var left = parseInt((screen.availWidth/2)-(width/2));
    var top = parseInt((screen.availHeight/2)-(height/2));
    var windowProperties = "width="+width+",height="+height+",left="+left+",top="+top;
	win = window.open(url, name, windowProperties+",resizable=no,toolbar=0,location=0,status=yes,menubar=0,directories=0,scrollbars=yes");
	win.focus();
	return false;
}

function imgOnClick(img, file, over) {
	if (over == 1) {
		img.src = '/i/' + file + '-o.jpg'; 
	} else { 
		img.src = '/i/' + file + '.jpg'; 
	}
	return true;
}

function sendForm(o) {
	o.action = '?send';
	return true;
}

function sendToFriend() {
	$('send-to-friend').style.display = 'block';
	return false;
}

function showPrintable() {
	window.location.href += '?print';
	return false;
}

function checkForm(form) {
	var imp = '', focused_form = '';
	var send_form = true;
	for (i = 0; i < form.elements.length; i++) {
		imp = form.elements[i].getAttribute('imp');
		if (imp != null && form.elements[i].value.length < 3) {
			send_form = false;
			focused_form = form.elements[i];
			//form.elements[i].style.border = 'solid 1px #FF8585';
			alert('Вы некорректно заполнили поле: ' + imp);
			break;
		}
	}
	if (send_form && form.elements.email) {
		if (!checkEmail(form.elements.email.value)) {
			send_form = false;
			focused_form = form.elements.email;
			alert('Пожалуйста, укажите правильный E-mail адрес');
		}
	}
	if (!send_form) {
		focused_form.focus();
	}
	return send_form;
}

function orderHotel() {
	$('hotel-order').style.display = 'block';
	return false;
}