function orderConfirm(url, header, content, options){
	confirmDialog = new YAHOO.widget.SimpleDialog("dlg", {
		width: "500px",
		effect:{effect:YAHOO.widget.ContainerEffect.FADE,
				duration:0.25},
		fixedcenter:true,
		zIndex: 10000,
		modal:false,
		visible:true,
		underlay: "shadow",
		draggable:false });

	confirmDialog.setHeader(header);
	confirmDialog.setBody(content);
	confirmDialog.cfg.setProperty("icon",YAHOO.widget.SimpleDialog.ICON_WARN);
	
	var handleYes = function() {
		this.hide();
		document.location = url + '?new_order=1' + ( ! options ? '' : '&' + options );
		return false;
	}
	var handleNo = function() {
		this.hide();
		document.location = url + ( ! options ? '' : '?' + options );
		return false;
	}
	var buttons = [ { text:"Создать новый заказ",
						handler:handleYes,
						isDefault:true  },
					{ text:"Продолжить работу с существующим заказом",
						handler:handleNo }
					];

	confirmDialog.cfg.queueProperty("buttons", buttons);
	confirmDialog.render(document.body);
	confirmDialog.show();

	return false;
}

function searchHotelConfirm( options ){
	if(! options)
		options = '';
	return orderConfirm("/main/search_hotel/", "Внимание!", "Выберите дальнейшее действие", options);
}

function searchTransferConfirm(){
	return orderConfirm("/main/search_transfer/", "Внимание!", "Выберите дальнейшее действие");
}

function getE(id){
	return document.getElementById(id);
}

function ShowWin(url,x,y,name,isscrollbars, menubar) {
cx=screen.width/2-(x/2);
cy=screen.height/2-(y/2);
isscrollbars=(isscrollbars=="no")?"no":"yes";
if(name == null) name="_blank";
if(menubar == null) menubar = 'no';
window.open(url,name,"toolbar=no,status=no,directories=no,menubar="+menubar+",resizable=yes,width="+x+",height="+y+",scrollbars="+isscrollbars+",top="+cy+",left="+cx);
}

function defined(x){
	return typeof(x) != 'undefined' && x != null;
}

function addListener(element, event, func){
	if(element.attachEvent)
		element.attachEvent('on' + event, function(){ func(window.event) });
	else if(element.addEventListener)
		element.addEventListener(event, func, false);
}


function popupHotel(url, print) {
	ShowWin(url, 800, 600, '', 'yes', print?print:'no');
	return false;
}


var HintObj, HintOpacity;

function ShowHint(element, hint_id, class_name, src_id) {
	HintObj = getE(hint_id);
	HintObj.className = class_name;
	HintObj.innerHTML = getE(src_id).innerHTML;
	HintOpacity = 0.1;
	HintObj.style.opacity = HintOpacity;
    HintObj.style.visibility = "visible";
    element.onmousemove = PositionTip;
    Appear();
}

function HideHint(element, hint_id) {
	getE(hint_id).style.visibility = 'hidden';
	element.onmousemove = '';
}

function ShowOfferHint(element, id_offer, offer_type) {
	ShowHint(element, 'id_OfferHint', "special_offer_hint_" + offer_type, 'id_offer_' + id_offer);
}

function IeTrueBody() {
	return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
} 
 
function PositionTip(e) {
	var ie = document.all && !window.opera;
	var ns6 = document.getElementById && !document.all;
	
	var curX = (ns6)?e.pageX : event.clientX+IeTrueBody().scrollLeft; 
	var curY = (ns6)?e.pageY : event.clientY+IeTrueBody().scrollTop; 
	var winwidth = ie&&!window.opera? IeTrueBody().clientWidth : window.innerWidth-20 
	var winheight = ie&&!window.opera? IeTrueBody().clientHeight : window.innerHeight-20 
	 
	var rightedge = ie&&!window.opera? winwidth-event.clientX : winwidth-e.clientX; 
	var bottomedge = ie&&!window.opera? winheight-event.clientY-15 : winheight-e.clientY-15; 
	
	if (rightedge < HintObj.offsetWidth && curX-HintObj.offsetWidth > 0)
		HintObj.style.left = curX-HintObj.offsetWidth+"px"; 
	else
		HintObj.style.left = curX+"px"; 
	
	if (bottomedge<HintObj.offsetHeight)
		HintObj.style.top = curY-HintObj.offsetHeight-15+"px" 
	else
		HintObj.style.top = curY+15+"px"; 
} 
 
function Appear() {
	var ua = navigator.userAgent.toLowerCase();
	
	if (HintOpacity < 1) { 
		(ua.indexOf('opera') == -1) ? HintOpacity+=0.1 : HintOpacity+=100; // special exeption on Opera
		HintObj.style.opacity = HintOpacity; 
		HintObj.style.filter = 'alpha(opacity='+HintOpacity*100+')'; 
		t = setTimeout('Appear()', 30); 
	}
}