﻿function bookmarksite(title,url)
{
	if (window.sidebar) // firefox
		window.sidebar.addPanel(title, url, "");
	else if(window.opera && window.print){ // opera
		var elem = document.createElement('a');
		elem.setAttribute('href',url);
		elem.setAttribute('title',title);
		elem.setAttribute('rel','sidebar');
		elem.click();
	}
	else if(document.all)// ie
		window.external.AddFavorite(url, title);
}
var marginTop = 100;
var marginLeft = 250;
function sendToFriend(isDetail)
{
	hideZIndexInsensetiveCtrl("hidden");
	// Получает div для затемнения заднего фона
	var interVeil = document.getElementById("interVeil");
	
	// Определяет ширину и высоту документа
	var totalWidth = document.body.clientWidth > screen.width ? document.body.clientWidth : screen.width;
	var totalHeight = document.body.offsetHeight + document.body.scrollHeight;
		

	var marginTop = isDetail ? "0": "-"+100;
	var marginLeft = isDetail ? "0": "-"+250;
	
	try
	{
		eraseCookie("print_tour");
		var  value = "";
		value = value + currDurationValue + "|";
		value = value + calendarFiled.value + "|";
		value = value + callbackDate.innerHTML + "|";
		value = value + dropDownList.options[dropDownList.selectedIndex].outerText+ "|";
		value = value + priceControl.innerHTML;
		createCookie("print_tour", value, 1);
	}
	catch(ex)
	{
		eraseCookie("print_tour");
	}
	
	// Устанавливает параметры div-а (местоположение и цвет)
	interVeil.style.width=totalWidth+"px";
	interVeil.style.height=totalHeight+"px";
	interVeil.style.left=marginTop;
	interVeil.style.top=marginLeft;
	interVeil.style.visibility="visible";
	interVeil.style.display="block";
	interVeil.className = "modalBackground";
	interVeil.style.position="absolute";
	
	// Скролит в исходное место
	document.body.scrollTop = totalWidth;
	document.body.scrollLeft = totalHeight;
	scroll(0,0);
	
	// Прячет скрол
	document.body.scroll = "no";
	document.body.style.overflowY = "hidden";
	document.body.style.overflowX = "hidden";
	
	// Получает div диалога
	var dialog = document.getElementById("divDialog");

	// Устанавливает координаты для диалога
	dialog.style.position="absolute";
	dialog.style.display = "inline";
	var dialogWidth = dialog.offsetWidth;
	var dialogHeight = dialog.offsetHeight;
	dialog.style.left = ((screen.width - dialogWidth)/2 - marginLeft) + "px";
	dialog.style.top = ((screen.height - dialogHeight)/2 - marginTop) - dialogHeight+ "px";
	
}

function cancelClick()
{
	eraseCookie("print_tour");
	// Получает div для затемнения заднего фона
	var interVeil = document.getElementById("interVeil");
	interVeil.style.display="none";
	// Получает div диалога
	var dialog = document.getElementById("divDialog");
	dialog.style.display="none";

	// Востанавливает скрол
	document.body.scroll = "yes";
	document.body.style.overflowY = "auto";
	document.body.style.overflowX = "auto";
	
	hideZIndexInsensetiveCtrl("");
}
function openPrintWnd(url)
{
	try {
		eraseCookie("print_tour");
		var  value = "";
		value = value + currDurationValue + "|";
		value = value + calendarFiled.value + "|";
		value = value + callbackDate.innerHTML + "|";
		value = value + dropDownList.options[dropDownList.selectedIndex].outerText+ "|";
		value = value + priceControl.innerHTML;
		createCookie("print_tour", value, 1);
	}
	catch(ex)
	{
		eraseCookie("print_tour");
	}
	window.open(url, 'Turne', 'width=700, height=520, location=yes, toolbar=yes, directories=yes, status=yes, resizable=yes, scrollbars=yes, fullsize=yes');
}
function hideZIndexInsensetiveCtrl(value){
	var tags = new Array("applet", "iframe", "select");
	for (var k = 0; k < tags.length; k++) {
		var ar = document.getElementsByTagName(tags[k]);
		for (var i = 0; i < ar.length; i++) {
			var cc = ar[i];
			cc.style.visibility = value;
		}
	}
}

