﻿//全局变量
//var loginPageUrl  = "http://www.elong.com/myelong/smalllogin.aspx";
//var checkLoginUrl = "http://localhost/myelong/AjaxProxy/UserLoginProxy.aspx";

//弹出登录框函数 loginUrl:登录页url  isCn:是否中文
function smallLogin(loginUrl,isCn)
{
    //为body添加主题样式,添加后弹出框才会使用主题样式
    if(navigator.userAgent.indexOf('MSIE') >= 0)
    {
        //当URL长度大于2048个字符时，IE无法显示，这时使用原有逻辑
        if(loginUrl.toString().length > 2000 && document.location.toString().toLowerCase().indexOf("/flights/") > -1)
        {
            var nextUrl;
            if(document.location.toString().toLowerCase().indexOf("http://www.elong.com")>-1)
                nextUrl = "http://www.elong.com/flights/fill.aspx";
            else if(document.location.toString().toLowerCase().indexOf("http://www.elong.net")>-1)
                nextUrl = "http://www.elong.net/flights/fill.aspx";
            var rn = Math.random();
	        document.FlightForm.action=nextUrl + "?rn=" + rn;
	        document.FlightForm.submit();
	        return;
        }
        document.getElementsByTagName("body")[0].setAttribute("className","tundra");
    }
    else
    {
        document.getElementsByTagName("body")[0].setAttribute("class","tundra");
    }

    //内嵌iframe对象
    var contentHtml = '<iframe frameborder="0"  src="'+loginUrl+'" width="480px" height="250px" ></iframe>'; 
    if(isCn)
    {
        djAlert("登录提示",contentHtml,"返回");
    }
    else
    {
        djAlert("Sign In",contentHtml,"Back");
    }
    return false;
}

function smallBooking(loginUrl,isCn)
{
    //为body添加主题样式,添加后弹出框才会使用主题样式
    if(navigator.userAgent.indexOf('MSIE') >= 0)
    {
        //当URL长度大于2048个字符时，IE无法显示，这时使用原有逻辑
        if(loginUrl.toString().length > 2000 && document.location.toString().toLowerCase().indexOf("/flights/") > -1)
        {
            var nextUrl;
            if(document.location.toString().toLowerCase().indexOf("http://www.elong.com")>-1)
                nextUrl = "http://www.elong.com/flights/fill.aspx";
            else if(document.location.toString().toLowerCase().indexOf("http://www.elong.net")>-1)
                nextUrl = "http://www.elong.net/flights/fill.aspx";
            var rn = Math.random();
	        document.FlightForm.action=nextUrl + "?rn=" + rn;
	        document.FlightForm.submit();
	        return;
        }
        document.getElementsByTagName("body")[0].setAttribute("className","tundra");
    }
    else
    {
        document.getElementsByTagName("body")[0].setAttribute("class","tundra");
    }

    //内嵌iframe对象
    var contentHtml = '<iframe id="hotelframe" name="hotelframe" frameborder="0"  src="'+loginUrl+'"  width="300px" height="280px" ></iframe>'; 
    if(isCn)
    {
        djAlert("预订",contentHtml,"返回");
    }
    else
    {
        djAlert("Booking",contentHtml,"Back");
    }
    return false;
}
    
//弹出图层,内嵌iframe的方法
function djAlert(title,content,closeMsg,closeCallback)
{
    var dialogDiv = document.createElement("div");
    document.body.appendChild(dialogDiv);
    dialogDiv.setAttribute("id","divUserLoginDialog");
    dialogDiv.innerHTML = "<div>"+content+"</div>";
    dialogDiv.firstChild.setAttribute("id","dialog-widget-loading");
    var dialog = new dijit.Dialog(
    {
        draggable: true,
        title:title,
        onCancel: function() 
        {
            dialog.destroy();
            if(closeCallback!='undefined' && closeCallback!=null)
            {
                closeCallback();
            }
            else
            {
                return false;
            }     
        }                                   
    },
    dialogDiv);
    dialog.show();               
}

//关闭登录框的函数
function closeUserLoginDialog()
{
	if(dijit != null && dijit.byId != null)
	{
		var divUserLoginDialog = dijit.byId("divUserLoginDialog");
		if( divUserLoginDialog!=null && divUserLoginDialog.destroy != null )
		{
				divUserLoginDialog.destroy();	
		}
	}
}



