document.write("<iframe id=MsgBoxFrame name=MsgBoxFrame  src='' frameborder=0 scrolling=no style='display:none;position:absolute;z-index:100;' allowtransparency=true></iframe>");
document.write("<iframe id=mapframe src='' width=310 height=210 frameborder=0 marginHeight=0 marginwidth=0 style='display:none;position:absolute;z-indent:10;' allowtransparency=false></iframe>");
//document.onclick=hideMsgBox;

function showMsgBox(sImg,title,type,Theme)
{	
	var oImg=document.getElementById(sImg);
	if(!oImg){alert("控制对象不存在！");return;}
		
	var cf=document.getElementById("MsgBoxFrame");
	if(cf.style.display=="block"){cf.style.display="none";return;}
	
	var cH = "0px";
	var cW = "0px";
	
	cf.src="";
	
	if (type=="mobile")
	{
				
		if (Theme=="eLongEn" ||Theme == "OnLineEn")
		{
			cf.src="./Script/MsgBox/MsgBoxMobileEn.htm";
			cH = "80px";
			cW = "303px";
		} 
		else
		{
			cf.src="./Script/MsgBox/MsgBoxMobile.htm";
			cH = "80px";
			cW = "303px";
		}
		
	}
	else if (type=="card")
	{
		if (Theme=="eLongEn"||Theme == "OnLineEn")
		{
			cf.src="./Script/MsgBox/MsgBoxCardEn.htm";
			cH = "177px";
			cW = "303px";
		}
		else
		{
			cf.src="./Script/MsgBox/MsgBoxCard.htm";
			cH = "117px";
			cW = "303px";
		}
		
	}
	else if (type=="image")
	{
		if (Theme=="eLongEn")
		{
		   cf.src="./Themes/eLongEn/DisplayImage.aspx?name="+ escape(title);
		}	
		else if (Theme=="OnLine")
		{
			cf.src="./Themes/OnLine/DisplayImage.aspx?name="+ escape(title);
		}
		else if (Theme=="OnLineEn")
		{
			cf.src="./Themes/OnLineEn/DisplayImage.aspx?name="+ escape(title);
		}
		else
		{
			cf.src="./Themes/eLongCn/DisplayImage.aspx?name="+ escape(title);
		}
		cH = "310px";
		cW = "380px";
	}
	
	else if (type=="virtual")
	{
		if (Theme=="eLongEn")
		{
		   cf.src="./Themes/eLongEn/DisplayVirtual.aspx?name="+ escape(title);
		}	
		else if (Theme=="OnLine")
		{
			cf.src="./Themes/OnLine/DisplayVirtual.aspx?name="+ escape(title);
		}
		else if (Theme=="OnLineEn")
		{
			cf.src="./Themes/OnLineEn/DisplayVirtual.aspx?name="+ escape(title);
		}
		else
		{
			cf.src="./Themes/eLongCn/DisplayVirtual.aspx?name="+ escape(title)
		}
		cH = "320px";
		cW = "340px";
	}
	else if (type=="HotelStar")
	{
		cf.allowTransparency = false;
		if (Theme=="eLongEn" ||Theme == "OnLineEn")
		{
		   cf.src="./Script/MsgBox/MsgBoxHotelStarEn.htm";
		   cH = "505px";
		   cW = "405px";
		}	
		else
		{
			cf.src="./Script/MsgBox/MsgBoxHotelStar.htm";
			cH = "312px";
			cW = "403px";
		}		
	}	
	else if (type=="HotelGATDES")
	 {
		   cf.src="./Script/MsgBox/MsgBoxHotelGAT.htm";
		   cH = "110px";
		   cW = "250px";
	 }
	 else if (type=="HotelGATDESelong")
	 {
		   cf.src="./Script/MsgBox/MsgBoxHotelGATElong.htm";
		   cH = "110px";
		   cW = "250px";
	 }
	
		
	else if (type == "price")
	{
	
		cf.src="./Script/MsgBox/MsgBoxPrice.htm";
		cH = "98px";
		cW = "303px";
	
	}
	else if (type == "copyRight")
	{
	
		cf.src="./Script/MsgBox/MsgBoxImgCopyRight.htm";
		cH = 140;
		cW = 303;
	
	}
	else if (type == "Activity")
	{
	
		cf.src="./Script/MsgBox/activity.aspx?params=" + escape(title);
		cH = "140px";
		cW = "303px";
	
	}
	else if (type == "MsgContent")
	{
	
		cf.src="./Script/MsgBox/MsgBoxContent.aspx?params=" + escape(title);
		cH = "140px";
		cW = "303px";
	
	}
	else if (type=="PickReason")
	{
		if (Theme=="eLongEn")
		{
		   cf.src="./Script/MsgBox/MsgBoxPickReasonEn.htm";
		   cH = "185px";
		   cW = "280px";
		}	
		else if (Theme=="OnLine")
		{
			cf.src="./Script/MsgBox/MsgBoxPickReasonOnLine.htm";
			cH = "255px";
			cW = "280px";
		}
		else if (Theme=="OnLineEn")
		{
			cf.src="./Script/MsgBox/MsgBoxPickReasonEn.htm";
			cH = "255px";
			cW = "280px";
		}
		else
		{
			cf.src="./Script/MsgBox/MsgBoxPickReason.htm";
			cH = "255px";
			cW = "280px";
		}
	}
	else if (type=="HotelOverview")
	{
		cf.src="./Script/MsgBox/HotelOverview.aspx?theme=" + Theme + "&overview=" + escape(title);
		cH = "100px";
		cW = "280px";
	}
		
	var eT=0,eL=0,p=oImg;
	//var sT=document.body.scrollTop,sL=document.body.scrollLeft;
	//var eH=oImg.height,eW=oImg.width;
	var eT=0,eL=0,p=oImg;
	
	var sT=(document.body.scrollTop > document.documentElement.scrollTop)? document.body.scrollTop:document.documentElement.scrollTop;

	var sL=(document.body.scrollLeft > document.documentElement.scrollLeft )? document.body.scrollLeft:document.documentElement.scrollLeft;
	
	var h1 = document.body.clientHeight;

	var h2 = document.documentElement.clientHeight;

	var isXhtml = (h2<=h1&&h2!=0)?true:false;
	
	var myClient = getMsgClient();
	
	var myScroll = getMsgScroll();		

	var eH=oImg.height,eW=oImg.width;
	
	while(p&&p.tagName.toUpperCase() !="BODY"){eT+=p.offsetTop;eL+=p.offsetLeft;p=p.offsetParent;}	
	
	var bottomSpace = myClient.clientHeight - ( eT - myScroll.sTop );
	if( bottomSpace == null || bottomSpace < 0 )
	{
		bottomSpace = 0;
	}
	eH=0;

	while(p&&p.tagName.toUpperCase()!="BODY")
	{
		eT+=p.offsetTop;
		eL+=p.offsetLeft;
		p=p.offsetParent;
	}		
	
	if(type=="virtual" || type=="image")
	{
		//cf.style.top = ( (bottomSpace>=cf.height)?eT+eH+20:eT-cf.height ).toString() + "px";		
		if(document.body.clientWidth > 740)
		{
			cf.style.left= ( (document.body.clientWidth-740)/2 + 320 ).toString() + "px";
		}
		else
		{
			cf.style.left= "113px";
		}
		cf.style.left = (document.body.clientWidth /2 -300).toString() + "px";
		if(type=="virtual")
		{
		    //详细页360图片始终在屏幕中间显示 by zhuzhijia on 20081204
		    cf.style.top=(myScroll.sTop+document.body.clientHeight /13).toString() + "px";	
		
		}
		else{
		    cf.style.top = (document.body.clientHeight /2 -200).toString() + "px";
		}
		
		//alert(document.body.clientWidth);
		//alert(document.body.clientHeight);
	}
	else
	{ 
		cf.height = cH;
		cf.width = cW;
		
		cf.style.top = ( (bottomSpace>=cf.height)?eT+eH+20:eT-cf.height ).toString() + "px";		
		//cf.style.left=( (isXhtml?document.documentElement.clientWidth:document.body.clientWidth-(eL-sL)>=cf.width)?eL:eL+eW-cf.width ).toString() + "px";
			//cf.style.top=((sT + document.body.clientHeight - eT) < cH && (eT - sT - 5) >= cH && type != "copyRight" && type!="HotelStar" && type!="PickReason")?eT-cH-5:(type != "Activity")? eT+15 : eT + 27;			
			cf.style.left=((eL-100) <= sL)?sL:eL-100;
	}
	
	cf.style.display="block";	

}
function showSeoMsgBox(sImg,title,type,Theme)
{	
	var oImg=document.getElementById(sImg);
	if(!oImg){alert("控制对象不存在！");return;}
		
	var cf=document.getElementById("MsgBoxFrame");
	if(cf.style.display=="block"){cf.style.display="none";return;}
	
	var cH = "0px";
	var cW = "0px";
	
	cf.src="";
	
	if (type=="mobile")
	{
				
		if (Theme=="eLongEn" ||Theme == "OnLineEn")
		{
			cf.src="http://www.elong.com/hotels/Script/MsgBox/MsgBoxMobileEn.htm";
			cH = "80px";
			cW = "303px";
		}
		else
		{
			cf.src="http://www.elong.com/hotels/Script/MsgBox/MsgBoxMobile.htm";
			cH = "80px";
			cW = "303px";
		}
		
	}
	else if (type=="card")
	{
		if (Theme=="eLongEn" ||Theme == "OnLineEn")
		{
			cf.src="http://www.elong.com/hotels/Script/MsgBox/MsgBoxCardEn.htm";
			cH = "177px";
			cW = "303px";
		}
		else
		{
			cf.src="http://www.elong.com/hotels/Script/MsgBox/MsgBoxCard.htm";
			cH = "117px";
			cW = "303px";
		}
		
	}
	
	else if (type=="HotelStar")
	{
		cf.allowTransparency = false;
		if (Theme=="eLongEn" ||Theme == "OnLineEn")
		{
		   cf.src="http://www.elong.com/hotels/Script/MsgBox/MsgBoxHotelStarEn.htm";
		   cH = "505px";
		   cW = "405px";
		}	
		else
		{
			cf.src="http://www.elong.com/hotels/Script/MsgBox/MsgBoxHotelStar.htm";
			cH = "312px";
			cW = "403px";
		}		
	}	
	else if (type=="HotelGATDES")
	 {
		   cf.src="http://www.elong.com/hotels/Script/MsgBox/MsgBoxHotelGAT.htm";
		   cH = "110px";
		   cW = "250px";
	 }
	 else if (type=="HotelGATDESelong")
	 {
		   cf.src=".http://www.elong.com/hotels/Script/MsgBox/MsgBoxHotelGATElong.htm";
		   cH = "110px";
		   cW = "250px";
	 }
	
		
	else if (type == "price")
	{
	
		cf.src="http://www.elong.com/hotels/Script/MsgBox/MsgBoxPrice.htm";
		cH = "98px";
		cW = "303px";
	
	}
	else if (type == "copyRight")
	{
	
		cf.src="http://www.elong.com/hotels/Script/MsgBox/MsgBoxImgCopyRight.htm";
		cH = 140;
		cW = 303;
	
	}
	else if (type == "Activity")
	{
	
		cf.src="http://www.elong.com/hotels/Script/MsgBox/activity.aspx?params=" + escape(title);
		cH = "140px";
		cW = "303px";
	
	}
	else if (type == "MsgContent")
	{
	
		cf.src="http://www.elong.com/hotels/Script/MsgBox/MsgBoxContent.aspx?params=" + escape(title);
		cH = "140px";
		cW = "303px";
	
	}
	else if (type=="PickReason")
	{
		if (Theme=="eLongEn" ||Theme == "OnLineEn")
		{
		   cf.src="http://www.elong.com/hotels/Script/MsgBox/MsgBoxPickReasonEn.htm";
		   cH = "185px";
		   cW = "280px";
		}	
		else if (Theme=="OnLine")
		{
			cf.src="http://www.elong.com/hotels/Script/MsgBox/MsgBoxPickReasonOnLine.htm";
			cH = "255px";
			cW = "280px";
		}
		else if (Theme=="OnLineEn")
		{
			cf.src="http://www.elong.com/hotels/Script/MsgBox/MsgBoxPickReasonEn.htm";
			cH = "255px";
			cW = "280px";
		}
		else
		{
			cf.src="http://www.elong.com/hotels/Script/MsgBox/MsgBoxPickReason.htm";
			cH = "255px";
			cW = "280px";
		}
	}
	else if (type=="HotelOverview")
	{
		cf.src="http://www.elong.com/hotels/Script/MsgBox/HotelOverview.aspx?theme=" + Theme + "&overview=" + escape(title);
		cH = "100px";
		cW = "280px";
	}
		
	var eT=0,eL=0,p=oImg;
	//var sT=document.body.scrollTop,sL=document.body.scrollLeft;
	//var eH=oImg.height,eW=oImg.width;
	var eT=0,eL=0,p=oImg;
	
	var sT=(document.body.scrollTop > document.documentElement.scrollTop)? document.body.scrollTop:document.documentElement.scrollTop;

	var sL=(document.body.scrollLeft > document.documentElement.scrollLeft )? document.body.scrollLeft:document.documentElement.scrollLeft;
	
	var h1 = document.body.clientHeight;

	var h2 = document.documentElement.clientHeight;

	var isXhtml = (h2<=h1&&h2!=0)?true:false;
	
	var myClient = getMsgClient();
	
	var myScroll = getMsgScroll();		

	var eH=oImg.height,eW=oImg.width;
	
	while(p&&p.tagName.toUpperCase() !="BODY"){eT+=p.offsetTop;eL+=p.offsetLeft;p=p.offsetParent;}	
	
	var bottomSpace = myClient.clientHeight - ( eT - myScroll.sTop );
	if( bottomSpace == null || bottomSpace < 0 )
	{
		bottomSpace = 0;
	}
	eH=0;

	while(p&&p.tagName.toUpperCase()!="BODY")
	{
		eT+=p.offsetTop;
		eL+=p.offsetLeft;
		p=p.offsetParent;
	}		
	
	if(type=="virtual" || type=="image")
	{
		cf.style.top = ( (bottomSpace>=cf.height)?eT+eH+20:eT-cf.height ).toString() + "px";		
		if(document.body.clientWidth > 740)
		{
			cf.style.left= ( (document.body.clientWidth-740)/2 + 320 ).toString() + "px";
		}
		else
		{
			cf.style.left= "113px";
		}
		alert(document.body.clientWidth);
		alert(document.body.clientHeight);
	}
	else
	{ 
		cf.height = cH;
		cf.width = cW;
		
		cf.style.top = ( (bottomSpace>=cf.height)?eT+eH+20:eT-cf.height ).toString() + "px";		
		cf.style.left=( (isXhtml?document.documentElement.clientWidth:document.body.clientWidth-(eL-sL)>=cf.width)?eL:eL+eW-cf.width ).toString() + "px";
			//cf.style.top=((sT + document.body.clientHeight - eT) < cH && (eT - sT - 5) >= cH && type != "copyRight" && type!="HotelStar" && type!="PickReason")?eT-cH-5:(type != "Activity")? eT+15 : eT + 27;			
			//cf.style.left=((eL-100) <= sL)?sL:eL-100;
	}
	cf.style.display="block";	

}
function getAbsolutePosition(obj)
{
	position = new Object();
	position.x = 0;
	position.y = 0;
	var tempobj = obj;
	while (tempobj != null && tempobj != document.body)
	{
		position.x += tempobj.offsetLeft + tempobj.clientLeft;
		position.y += tempobj.offsetTop + tempobj.clientTop;
		tempobj = tempobj.offsetParent;
	}
	return position;
}

function hideMsgBox()
{
	var cf=document.getElementById("MsgBoxFrame");
	cf.style.display="none";
	cf.src="";
	
}

function getElementTop(e){
	var t=e.offsetTop;
	while(e=e.offsetParent){
		t+=e.offsetTop;
    }
	return(t);
}

function hideMapMsgBox()
{
	var cf=document.getElementById("mapframe");
	cf.style.display="none";
	cf.src="";
	
}

function showMapBox(sImg,title,type,Theme) {
    smallLogin(title, Theme);
    return;
	var oImg=document.getElementById(sImg);
	if(!oImg){alert("控制对象不存在！");return;}
	var cf=document.getElementById("mapframe");
	var eT=0,eL=0,p=oImg;
	
	var sT=(document.body.scrollTop > document.documentElement.scrollTop)? document.body.scrollTop:document.documentElement.scrollTop;

	var sL=(document.body.scrollLeft > document.documentElement.scrollLeft )? document.body.scrollLeft:document.documentElement.scrollLeft;
	
	var h1 = document.body.clientHeight;

	var h2 = document.documentElement.clientHeight;

	var isXhtml = (h2<=h1&&h2!=0)?true:false;
	
	var myClient = getMsgClient();
	
	var myScroll = getMsgScroll();		

	var eH=oImg.height,eW=oImg.width;
	
	while(p&&p.tagName.toUpperCase() !="BODY"){eT+=p.offsetTop;eL+=p.offsetLeft;p=p.offsetParent;}	
	
	var bottomSpace = myClient.clientHeight - ( eT - myScroll.sTop );
	if( bottomSpace == null || bottomSpace < 0 )
	{
		bottomSpace = 0;
	}

	eH=0;
	
	cf.height = 210;
	cf.width = 310;
	
	cf.style.top = ( (bottomSpace>=cf.height)?eT+eH+20:eT-cf.height ).toString() + "px";		
        
	if(cf.style.display=="block"){cf.style.display="none";return;}
    
    
	cf.src="";
    
	if (type=="map")
	{        		
		if (Theme=="eLongEn" ||Theme == "OnLineEn")
		{
			cf.src=title;
		}
		else
		{
			cf.src=title;
		}        
	}		
    
	cf.style.left=( (isXhtml?document.documentElement.clientWidth:document.body.clientWidth-(eL-sL)>=cf.width)?eL:eL+eW-cf.width ).toString() + "px";
	cf.style.display="block";
}
//得到浏览器当前显示区域的大小 clientHeight 与 clientWidth
/*	用法与测试:
	var myScroll = getScroll();	
	alert("myScroll.sTop:" + myScroll.sTop);
	alert("myScroll.sLeft:" + myScroll.sLeft);
*/
function getMsgClient()
{
    			var h1 = document.body.clientHeight;
			var h2 = document.documentElement.clientHeight;
			var isXhtml = (h2<=h1&&h2!=0)?true:false;
				
			this.clientHeight = isXhtml?document.documentElement.clientHeight:document.body.clientHeight;
			this.clientWidth  = isXhtml?document.documentElement.clientWidth:document.body.clientWidth;
            
    return {clientHeight:this.clientHeight,clientWidth:this.clientWidth};        
}
function getMsgScroll() 
{     
		var sTop = 0, sLeft = 0, sWidth = 0, sHeight = 0; 
        
		sTop = (document.body.scrollTop > document.documentElement.scrollTop)? document.body.scrollTop:document.documentElement.scrollTop;
		if( isNaN(sTop) || sTop <0 ){ sTop = 0 ;}
        
		sLeft = (document.body.scrollLeft > document.documentElement.scrollLeft )? document.body.scrollLeft:document.documentElement.scrollLeft;
		if( isNaN(sLeft) || sLeft <0 ){ sLeft = 0 ;}
		
		return { sTop:sTop, sLeft: sLeft, sWidth: sWidth, sHeight: sHeight }; 
}

function ShowMiniMap(loginUrl, isCn) {
    if (navigator.userAgent.indexOf('MSIE') >= 0) {
        document.getElementsByTagName("body")[0].setAttribute("className", "tundra");
    }
    else {
        document.getElementsByTagName("body")[0].setAttribute("class", "tundra");
    }

    //内嵌iframe对象
    var contentHtml = '<iframe frameborder="0"  src="' + loginUrl + '" width="500px" height="350px" style="z-index:10000;"></iframe>';
    if (isCn) {
        djAlert("酒店地图", contentHtml, "返回");
    }
    else {
        djAlert("Hotel map", contentHtml, "Back");
    }
    return false;
}
