﻿/*	
	双日历控件 ziqiu.zhang 2007.11.5日 
	改版自elong.com 原单日历控件
	增加了对XHtml的支持.
 */
document.write('<iframe id=mudi name=mudi frameborder=0 src=../index_js/citymudidi.aspx?keyword=0 style=display:none;position:absolute;z-index:110 width=288 height=250></iframe>');
document.onclick=hideCalendar;

function showmudicity(sImg,bOpenBound,sFld1,sNextP,sNextD,sStartD,sEndD,sVD,sOE,sVDE,sOT,s3F,sFld2,sCallback,sNextVDE)
{
	//1.sImg日历弹出位置的控件的名称,
	//2.bOpenBound,
	//3.sFld1取得日期的控件名称,
	
	
	//4.sNextP选取日期后新日历弹出的位置的控件名称,可不输入,
	//5.sNextD选取日期后新日历弹出从中取值的控件名称,可不输入,
	
	//6.sStartD开始有效时间,
	//7.sEndD截至有效时间,
	
	//8.sVD周几有效,例如：'1,3,5',注意星期日应输入'0'
	//9.sOE,单双日有效,'0'表示双日,'1'表示单日
	//10.sVDE特殊日期,例如'2004-10-11,2004-11-20,',最后一定要输入','
	//11.sOT如果是直接在文本框中点击则值为'text',
	//12.s3F下一个日历弹出并选择后点取日期后定位到新的控件
	
	//sFld2,弹出日历默认日期
	//sCallback
	
	// sNextVDE 下一次焦点的有效时间.
	
	var fld1,fld2;
	var cf=document.getElementById("mudi");
        

         cf.src="../index_js/citymudidi.aspx?keyword="+document.getElementById("mudidicity").value;


	var wcf=window.frames.CalFrame;
	var oImg=document.getElementById(sImg);
	if(!oImg){alert("控制对象不存在！");return;}
	if(!sFld1){alert("输入控件未指定！");return;}
	fld1=document.getElementById(sFld1);
	if(!fld1){alert("输入控件不存在！");return;}
	if(fld1.tagName!="INPUT"||fld1.type!="text"){alert("输入控件类型错误！");return;}
	
	if(cf.style.display=="block"){cf.style.display="none";return;}
	
	//==============新版本更新: 关于日历显示位置的更改 ziqiu.zhang 开始	=================
	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 = getClient();
	var myScroll = getScroll();		
	
	var eH=oImg.height,eW=oImg.width;
	while(p&&p.tagName.toLowerCase() != "body"){eT+=p.offsetTop;eL+=p.offsetLeft;p=p.offsetParent;}	

	
	
	var bottomSpace = myClient.clientHeight - eT - myScroll.sTop;
	
	eH=5;
	if(sOT=="text")
	{
		
		cf.style.top= (eT+eH+45).toString() + "px";	
	}
	else
	{
		
		cf.style.top= (eT+eH+45).toString() + "px";	
	}
	
	//==============新版本更新: 关于日历显示位置的更改 ziqiu.zhang 结束	=================
	
	
	cf.style.left= ((isXhtml?document.documentElement.clientWidth:document.body.clientWidth-(eL-sL)>=cf.width)?eL:eL+eW-cf.width).toString() + "px";
if (document.getElementById("mudidicity").value!='')
{	
cf.style.display="block";
}
	
	
}
function hideCalendar()
{
	var cf=document.getElementById("mudi");
	cf.style.display="none";
}

function getScroll() 
{     
		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 getClient()
{
    			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 getname_city(cityname)
{
	document.getElementById("mudidicity").value=cityname;
	hideCalendar();
	}
	function getmudi_height_city()
	{
//document.getElementById("mudi").height=mudi.document.body.scrollHeight+"px";
	}
	