function set_lang(lang){
	$('lang_form_lang').value = lang;
	$('lang_form').submit();
}

function edit_language(obj, id){
	if(id){
		parent = obj.parentNode;
		field = $('edit_language_field');

		field.type = 'text';
		field.setStyle({
			width: obj.getWidth() + 'px',
			height: obj.getHeight() + 'px',
			left: parent.offsetLeft + 'px',
			top: parent.offsetTop + 'px'
		});
		field.value = obj.innerHTML;
		$('edit_language_id').value = id;
		field.focus();
	}
}

function edit_data(obj, language_id, string_id){
	if(language_id && string_id){
		parent = obj.parentNode;
		field = $('edit_data_field');

		field.type = 'text';
		field.setStyle({
			width: obj.getWidth() + 'px',
			height: obj.getHeight() - 2 + 'px',
			left: obj.offsetLeft + 'px',
			top: obj.offsetTop + 'px'
		});
		field.value = obj.innerHTML;
		$('edit_language_id').value = language_id;
		$('edit_string_id').value = string_id;
		field.focus();
	}
}


//Nzo

function callme_load(lang){
	if($('callme_flash')){
		//var flash = "http://flaphone.com/callme.swf?callme_id=bceddef6-4405-102c-b7f4-0030488ac7c6&showDtmfPad=false&callbutton_width=160&callbutton_height=50&cancelbutton_width=160&cancelbutton_height=50&disconnectbutton_width=160&disconnectbutton_height=50&poweredText_color=#FF0000&callbutton_color=#FFFFFF&callbutton_themeColor=#00AFF0&callbutton_fontFamily=Arial&callbutton_fontWeight=bold&callbutton_fontSize=14&callbutton_fillAlphas=1,1&callbutton_fillColors=#00A8F0,#00A8F0&callbutton_borderAlpha=1&callbutton_borderColors=#00A8F0,#00A8F0&callbutton_overBorderColors=#00A8F0,#00A8F0&callbutton_overFillColors=#73D3FB,#00A8F0&callbutton_textRollOverColor=#FFFFFF&showConnectionAnimation=true&cancelbutton_color=#FFFFFF&cancelbutton_themeColor=#00AFF0&cancelbutton_fontFamily=Arial&cancelbutton_fontWeight=bold&cancelbutton_fontSize=14&cancelbutton_fillAlphas=1,1&cancelbutton_fillColors=#00A8F0,#00A8F0&cancelbutton_borderAlpha=1&cancelbutton_borderColors=#00A8F0,#00A8F0&cancelbutton_overBorderColors=#00A8F0,#00A8F0&cancelbutton_overFillColors=#73D3FB,#00A8F0&cancelbutton_textRollOverColor=#FFFFFF&disconnectbutton_color=#FFFFFF&disconnectbutton_themeColor=#00AFF0&disconnectbutton_fontFamily=Arial&disconnectbutton_fontWeight=bold&disconnectbutton_fontSize=14&disconnectbutton_fillAlphas=1,1&disconnectbutton_fillColors=#00A8F0,#00A8F0&disconnectbutton_borderAlpha=1&disconnectbutton_borderColors=#00A8F0,#00A8F0&disconnectbutton_overBorderColors=#00A8F0,#00A8F0&disconnectbutton_overFillColors=#73D3FB,#00A8F0&disconnectbutton_textRollOverColor=#FFFFFF&connectinglabel_fontFamily=Tahoma&connectinglabel_fontSize=10&connectinglabel_fontWeight=bold&connectinglabel_color=#000000";
		if(lang == 'en'){
			var flash = "http://flaphone.com/callme.swf?callme_id=a3518ed8-2a60-102d-a778-0030488ac7c6&showDtmfPad=false&callbutton_width=160&callbutton_height=50&cancelbutton_width=160&cancelbutton_height=50&disconnectbutton_width=160&disconnectbutton_height=50&poweredText_color=#00AFF0&callbutton_color=#FFFFFF&callbutton_themeColor=#00AFF0&callbutton_fontFamily=Arial&callbutton_fontWeight=bold&callbutton_fontSize=14&callbutton_fillAlphas=1,1&callbutton_fillColors=#00A8F0,#00A8F0&callbutton_borderAlpha=1&callbutton_borderColors=#00A8F0,#00A8F0&callbutton_overBorderColors=#00A8F0,#00A8F0&callbutton_overFillColors=#73D3FB,#00A8F0&callbutton_textRollOverColor=#FFFFFF&showConnectionAnimation=true&cancelbutton_color=#FFFFFF&cancelbutton_themeColor=#00AFF0&cancelbutton_fontFamily=Arial&cancelbutton_fontWeight=bold&cancelbutton_fontSize=14&cancelbutton_fillAlphas=1,1&cancelbutton_fillColors=#00A8F0,#00A8F0&cancelbutton_borderAlpha=1&cancelbutton_borderColors=#00A8F0,#00A8F0&cancelbutton_overBorderColors=#00A8F0,#00A8F0&cancelbutton_overFillColors=#73D3FB,#00A8F0&cancelbutton_textRollOverColor=#FFFFFF&disconnectbutton_color=#FFFFFF&disconnectbutton_themeColor=#00AFF0&disconnectbutton_fontFamily=Arial&disconnectbutton_fontWeight=bold&disconnectbutton_fontSize=14&disconnectbutton_fillAlphas=1,1&disconnectbutton_fillColors=#00A8F0,#00A8F0&disconnectbutton_borderAlpha=1&disconnectbutton_borderColors=#00A8F0,#00A8F0&disconnectbutton_overBorderColors=#00A8F0,#00A8F0&disconnectbutton_overFillColors=#73D3FB,#00A8F0&disconnectbutton_textRollOverColor=#FFFFFF&connectinglabel_fontFamily=Tahoma&connectinglabel_fontSize=10&connectinglabel_fontWeight=bold&connectinglabel_color=#000000";
		}else{
			var flash = "http://flaphone.com/callme.swf?callme_id=ee1eaa7a-2643-102d-a778-0030488ac7c6&showDtmfPad=false&callbutton_width=160&callbutton_height=50&cancelbutton_width=160&cancelbutton_height=50&disconnectbutton_width=160&disconnectbutton_height=50&poweredText_color=#00AFF0&callbutton_color=#FFFFFF&callbutton_themeColor=#00AFF0&callbutton_fontFamily=Arial&callbutton_fontWeight=bold&callbutton_fontSize=14&callbutton_fillAlphas=1,1&callbutton_fillColors=#00A8F0,#00A8F0&callbutton_borderAlpha=1&callbutton_borderColors=#00A8F0,#00A8F0&callbutton_overBorderColors=#00A8F0,#00A8F0&callbutton_overFillColors=#73D3FB,#00A8F0&callbutton_textRollOverColor=#FFFFFF&showConnectionAnimation=true&cancelbutton_color=#FFFFFF&cancelbutton_themeColor=#00AFF0&cancelbutton_fontFamily=Arial&cancelbutton_fontWeight=bold&cancelbutton_fontSize=14&cancelbutton_fillAlphas=1,1&cancelbutton_fillColors=#00A8F0,#00A8F0&cancelbutton_borderAlpha=1&cancelbutton_borderColors=#00A8F0,#00A8F0&cancelbutton_overBorderColors=#00A8F0,#00A8F0&cancelbutton_overFillColors=#73D3FB,#00A8F0&cancelbutton_textRollOverColor=#FFFFFF&disconnectbutton_color=#FFFFFF&disconnectbutton_themeColor=#00AFF0&disconnectbutton_fontFamily=Arial&disconnectbutton_fontWeight=bold&disconnectbutton_fontSize=14&disconnectbutton_fillAlphas=1,1&disconnectbutton_fillColors=#00A8F0,#00A8F0&disconnectbutton_borderAlpha=1&disconnectbutton_borderColors=#00A8F0,#00A8F0&disconnectbutton_overBorderColors=#00A8F0,#00A8F0&disconnectbutton_overFillColors=#73D3FB,#00A8F0&disconnectbutton_textRollOverColor=#FFFFFF&connectinglabel_fontFamily=Tahoma&connectinglabel_fontSize=10&connectinglabel_fontWeight=bold&connectinglabel_color=#000000";
		}
		var flashvars = {};
		var params = {
			menu: "false",
			wmode: "transparent"
		};
		var attributes = {};
//		swfobject.embedSWF(flash, "callme_flash", "198", "110", "9.0.0", "expressInstall.swf", flashvars, params, attributes);
		swfobject.embedSWF(flash, "callme_flash", "240", "140", "9.0.0", "expressInstall.swf", flashvars, params, attributes);
	}

	window.onbeforeunload = unload;

}
function unload(e){
//	ShowProps(e);
//	event.stop();
//	if(event.preventDefault)
//		event.preventDefault();

	if(document.all){
		event.returnValue = nzo_leave_alert_text;
	}else{
		e.returnValue = nzo_leave_alert_text;
	}
	return nzo_leave_alert_text;
}
function ShowProps(obj, str){
	var output='';
	for(var i in obj){
		if(str){
			if(i.include(str)){
				output += i + '=' + obj[i] + '<br>\n';
			}
		}else if(!is_function(obj[i]) && i != 'innerHTML'){
			output += i + '=' + obj[i] + '<br>\n';
		}
	}
	document.write(output);
}

function nzo_show(){
//Старое
	$('cc').style.overflow = 'hidden';
	$('nzo_overlay').show();
}
function nzo_hide(){
	if(confirm(nzo_hide_alert_text)){
		window.onbeforeunload = null;
		$('nzo_overlay').hide();
		$('cc').style.overflow = '';
	}
}
function nzo_step(num){
//	$('nzo_step'+num).show();
	Effect.BlindUp('nzo_step' + (num - 1), {'duration': '0.5'});
	Effect.BlindDown('nzo_step' + num, {'duration': '0.5'});
	$('nzo_step'+num+'_num').src='/i/ico_step'+num+'_num_active.png';
	$('nzo_step'+(num-1)+'_num').src='/i/ico_step'+(num-1)+'_num_done.png';
//	$('nzo_step'+(num-1)).hide();
//	if(num==3){
//		$('nzo_bottom').hide();
//	}
}


//Gallery
document.gallery_scrollto = 0
iw = 106; //Image width
function gallery_left(){
	left = $('photos_list').offsetLeft;
	if(document.gallery_scrollto < 0){
		document.gallery_scrollto = document.gallery_scrollto + iw;
		gallery_loop();
	}
}
function gallery_right(){
	left = $('photos_list').offsetLeft;
	w = $('photos_list_table').getWidth();
	if(document.gallery_scrollto > -(w - (3 * iw))){
		document.gallery_scrollto = document.gallery_scrollto - iw;
		gallery_loop();
	}
}

function gallery_loop(){
	to = document.gallery_scrollto;
	now = $('photos_list').offsetLeft;
	if(to > now){
		next = now + Math.max( ((to - now) / 4), 1);
	}else{
		next = now - Math.max( ((now - to) / 4), 1);
	}
	$('photos_list').style.left = Math.floor(next) + 'px';
	if(next != to){
		setTimeout('gallery_loop()', 50);
	}
}

function show_photo(pic, num){
	$('photo').src = '/get.php?filename=' + pic;

	pic_left = num * iw;

	w = $('photos_list_table').getWidth();

	next = -pic_left + iw;

	if(pic_left >= iw && pic_left < w - iw && next != $('photos_list').offsetLeft){
		document.gallery_scrollto = next;
		gallery_loop();
	}
}

//Функция для формы бронирования отеля
function setTodayDate_proto(){
	var d = new Date();
	var dtIn = $('dtIn');
	if (dtIn.length == 0)
		return;
	d.setDate(d.getDate() + 1);
	dtIn.options.selectedIndex = d.getDate() - 1;
	$('mnIn').options.selectedIndex = d.getMonth();
	var dtOut = $('dtOut');
	if(dtOut){
		if (dtOut.length != 0){
			d.setDate(d.getDate() + 1);
			dtOut.options.selectedIndex = d.getDate() - 1;
			$('mnOut').options.selectedIndex = d.getMonth();
		}
	}
}

//Выбор звёздности в форме поиска отелей
function bookhotels_search_select_star(num){
	if(!(num>=0 && num<=5)){
		return false;
	}

	$('bookhotels_search_form_stars').value = num;
	bookhotels_search_stars_highlight(num);

	if(num == 0){
		$('bookhotels_search_star_no').style.visibility = 'hidden';
	}else{
		$('bookhotels_search_star_no').style.visibility = 'visible';
	}
}
//Подсветка звёзд в форме поиска отелей
function bookhotels_search_stars_highlight(num){
	if(!(num>=0 && num<=5)){
		return false;
	}
	if(num == 0){
		for(i=1; i<=5; i++){
			$('bookhotels_search_star_' + i).src = '/i/gray_star_big.png';
		}
	}else{
		for(i=1; i<=5; i++){
			if(i <= num){
				$('bookhotels_search_star_' + i).src = '/i/yellow_star_big.png';
			}else{
				$('bookhotels_search_star_' + i).src = '/i/blue_star_big.png';
			}
		}
	}
}


//Функция отображения праздника
function show_holiday(id){
//	$('holiday_name').update(name);
//	$('holiday_name').update($('holiday_' + id).innerHTML.toUpperCase());

//	$('holiday_picture').src = '/get.php?filename=thmb_m_' + picture + '.png';
//	$('holiday_content').update($('holiday_content_' + id).innerHTML);
//	$('holiday_picture').className = 'png';
	$$('.holiday_block').invoke('hide');
	$('holiday_' + id).show();
}

function sleep(num){
	var sleeping = true;
	var now = new Date();
	var alarm;
	var startingSeconds = now.getTime();
	while(sleeping){
		alarm = new Date();
		alarmSeconds = alarm.getTime();
		if(alarmSeconds - startingSeconds > 1000*num){
			sleeping = false;
		}
	}
}

function select_city(){

	var flash = "/swf/clock.swf";
	var flashvars = {
		tz: $F('clock_city_selected')
	};
	var params = {
		menu: "false",
		wmode: "transparent"
	};
	var attributes = {};
	swfobject.embedSWF(flash, "clock_city", "75", "75", "9.0.0", "/swf/expressInstall.swf", flashvars, params, attributes);

}

function events_main_select(selection){
	$$('DIV.events_main').invoke('hide');
	$$('DIV.events_main_select').invoke('setStyle', {'fontWeight': 'normal'});


	$('events_' + selection + '_event').appear({'duration': '0.2'});
	$('event_select_' + selection).setStyle({'fontWeight': 'bold'});
}

function events_recommended_select(id){
	$$('DIV.events_recommended').invoke('hide');

	$('events_recommended_' + id).appear({'duration': '0.2'});
}
function events_week_select(id){
	$$('DIV.events_week').invoke('hide');

	$('events_week_' + id).appear({'duration': '0.2'});
}
