function SetBackground() {
}

function ShowWin(url,x,y,name,isscrollbars) { 
cx=screen.width/2-(x/2);
cy=screen.height/2-(y/2);
isscrollbars=(isscrollbars=="no")?"no":"yes";
window.open(url,name,"toolbar=no,status=no,directories=no,menubar=no,resizable=yes,width="+x+",height="+y+",scrollbars="+isscrollbars+",top="+cy+",left="+cx);
}
function ShowWin2(obj,x,y,name,isscrollbars) { 
	url = obj.href;
	var hotel_link = obj.parentNode.parentNode.getElementsByTagName("A")[0].href;
	var re = /\/al(\d+)\//;
	if (re.test(hotel_link)) {
		var f = hotel_link.match(re);
		if (f.length == 2) {
			url = url + "&hotel_id=" + f[1];
		}
	}

	cx=screen.width/2-(x/2);
	cy=screen.height/2-(y/2);
	isscrollbars=(isscrollbars=="no")?"no":"yes";

	window.open(url,name,"toolbar=no,status=no,directories=no,menubar=no,resizable=yes,width="+x+",height="+y+",scrollbars="+isscrollbars+",top="+cy+",left="+cx);
}

function toggle(name) {
	if(document.getElementById) {
		var toggler=document.getElementById(name).style.visibility;
		if (toggler=="visible") {
			document.getElementById(name).style.visibility="hidden";
			document.getElementById(name).style.display="none";
		}else{
			document.getElementById(name).style.visibility="visible";
			document.getElementById(name).style.display="block";
		}
	}else if(document.all){
		var toggler=document.all(name).style.visibility;
		if (toggler=="visible") {
			document.all(name).style.visibility="hidden";
			document.all(name).style.display="none";
		}else{
			document.all(name).style.visibility="visible";
			document.all(name).style.display="block";
		}
	}	
	SetBackground();
}
function hide(name) {
	if(document.getElementById)
	{
		document.getElementById(name).style.visibility="hidden";
		document.getElementById(name).style.display="none";
	}else if(document.all){
		document.all(name).style.visibility="hidden";
		document.all(name).style.display="none";
	}
	SetBackground();
}

function show(name) {
	if(document.getElementById)
	{
		document.getElementById(name).style.visibility="visible";
		document.getElementById(name).style.display="block";
	}
	else if(document.all)
	{
		document.all(name).style.visibility="visible";
		document.all(name).style.display="block";
	}
	SetBackground();
}
function ShowPhotoSmall(im) {
	SwitchSelects(false);
    var div = document.getElementById("div_image");
    div.style.top = 10 + document.body.scrollTop;
	div.style.left = 100;
    
    var i = document.getElementById("big_image");
    var t = document.getElementById("big_image_title");
    
    t.innerHTML = im.title;
    i.title = im.title;
    i.alt = im.alt;
    i.src = im.src.replace("photos_small", "photos").replace("s50.", ".");
	
    AttachGallery();
    div.style.display = "block";
}
function ShowLoader() {
    var i = document.getElementById("big_image");
	i.src = "/img/loader.gif";
	i.title = "";
	i.alt = "";
}
function ShowPhoto(h) {
	var img = h.getElementsByTagName("IMG")[0];
	ShowLoader();
    ShowPhotoSmall(img);
}
function HidePhoto() {
    var div = document.getElementById("div_image");
    var i = document.getElementById("big_image");
    var t = document.getElementById("big_image_title");
    
    t.innerHTML = "";
    i.src = "/i/pr.gif";
    i.title = "";
    i.alt = "";
    div.style.display = "none";
	DetachGallery();
	SwitchSelects(true);
}
function SwitchSelects (vis) {
    var sels = document.getElementsByTagName("SELECT");
    for (var i = 0; i < sels.length; i++) {
        if (vis) {
            sels[i].style.display = "block";
        }
        else {
            sels[i].style.display = "none";
        }
    }
    var objs = document.getElementsByTagName("OBJECT");
    for (var i = 0; i < objs.length; i++) {
        if (vis) {
            objs[i].style.display = "block";
        }
        else {
            objs[i].style.display = "none";
        }
    }
	var map = document.getElementById("div_map");
	if (map != null) {
        if (vis) {
            map.style.display = "block";
        }
        else {
            map.style.display = "none";
        }
	}
}
function SetWeather() {
	// nothing todo
}
function SetWeather2() {
	// nothing todo
}
var wObj = null;
var op = 0;
function ShowDiv (id) {
	var el = document.getElementById(id);
	if (el.style.visibility != "visible" || el.style.display != "block") {
		el.style.visibility = "visible";
		el.style.display = "block";
		wObj = el;
		appear();
	}
}
function HideDiv (id) {
	var el = document.getElementById(id);
	if (el.style.visibility != "hidden" || el.style.display != "none") {
		el.style.visibility="hidden";
		el.style.display="none";
	}
}
function appear() {	
	if (wObj == null) { return; }
	if(op < 1) {
		op += 0.1;
		wObj.style.opacity = op;
		wObj.style.filter='alpha(opacity='+op*100+')';
		t = setTimeout('appear()', 30);
	}
	else {
		op = 0;
		wObj = null;
	}
}
// * * * * * * * * * * * * * * * * * * * * * * * * * *
// message
// * * * * * * * * * * * * * * * * * * * * * * * * * *
function ShowMessage (str, sec) {
	if (isNaN(sec)) 
		sec = 120;
	ShowStatus(str, false);
	setTimeout("HideMessage()", sec*1000);
}
function HideMessage() {
	var d = document.getElementById("div_show_status");
	if (d != null) {
		d.style.display = "none";
	}
	if (showStatusTimeoutID != null) {
		window.clearTimeout(showStatusTimeoutID);
	}
	if (playStatusTimeoutID != null) {
		window.clearTimeout(playStatusTimeoutID);
	}
}
// * * * * * * * * * * * * * * * * * * * * * * * * * *
// status
// * * * * * * * * * * * * * * * * * * * * * * * * * *
var showStatusTimeoutID;
var playStatusTimeoutID;
function ShowStatus (str, play) {
	var d = document.getElementById("div_show_status");
	if (d == null) {
		d = window.document.createElement("DIV");
	}
	d.style.display = "none";
    d.style.top = document.body.scrollTop + document.body.clientHeight / 2 - 100 / 2;
    d.style.left = document.body.scrollLeft + document.body.clientWidth / 2 - 600 / 2;
	d.id = "div_show_status";
	var ihtml = "<img src=\"/img/fish_message_big.gif\" class=\"message_image\"><div class=message_text>" + str + "</div>";
	d.innerHTML = ihtml;
	d.className = "show_status";
	window.document.body.appendChild(d);
	if (play != false) {
		var valid = true;
		try {
			valid = Page_ClientValidate();
		}
		catch(e) {
		}
		if (valid) {
			showStatusTimeoutID = setTimeout("DisplayDivShowStatus()",1500); // òàéìàóò äî ïîêàçà ñòàòóñà
			playStatusTimeoutID = setTimeout("playDivShowStatus()",4500);
		}
	}
	else {
		if (d.addEventListener)
			d.addEventListener('click', HideMessage, false);
		else
			d.attachEvent('onclick', HideMessage);
		DisplayDivShowStatus();
		wObj = d;
		appear();
	}
}
function DisplayDivShowStatus() {
	var d = document.getElementById("div_show_status");
	d.style.display = "block";
}
function ShowStatusBackBorder() {
	var d = document.getElementById("div_show_status");
	d.style.borderColor = "#000000";
	d.style.borderWidth = "1px";
}
var playCount = 0;

function playDivShowStatus() {
	var d = document.getElementById("div_show_status");
	
    d.style.top = document.body.scrollTop + document.body.clientHeight / 2 - 100 / 2 + (Math.random() - 0.5) * 5;
    d.style.left = document.body.scrollLeft + document.body.clientWidth / 2 - 200 / 2 + (Math.random() - 0.5) * 5;
    if (playCount < 30) {
		playCount++;
		playStatusTimeoutID = setTimeout("playDivShowStatus()",40);
    } else {
		playCount = 0;
		playStatusTimeoutID = setTimeout("playDivShowStatus()",6000);
    }
}
function chVcard(form) {
	if (form.email.value == '' || form.email.value == 'ââåäèòå e-mail') {
		ShowMessage("Ââåäèòå e-mail.", 5);
		form.email.focus();
		return false;
	}
	try {
		var email = form.email.value;
		var re = new RegExp("^[A-Za-z0-9\.-_]+\@[A-Za-z0-9\.-_]+\.[A-Za-z]{2,4}$");
		
		if (!re.test(email)) {
			ShowMessage("Ââåäèòå e-mail â ôîðìàòå email@domain.ru", 5);
			form.email.focus();
			return false;
		}
	}
	catch(e) {
	}
	return true;
}

