document.write('<iframe id=oklxCalFrame name=oklxCalFrame frameborder=0 src="" width=0 height=0 style=display:none;position:absolute;z-index:100></iframe>');
document.onclick=hideCalendar;
var isFirst = true;

function showCalendarOne(fldone, sImg, fld1, fld2, hiddendate) {
    var cf = document.getElementById("oklxCalFrame");
    var oImg = document.getElementById(sImg);
    var wcf = window.frames.oklxCalFrame;
    var eT = 0, eL = 0, p = oImg;
    var sT = document.body.scrollTop, sL = document.body.scrollLeft;
    //var eH = oImg.height + 25, eW = oImg.width;
    var eH = 25, eW = 0;
    cf.src = "/inc/Calendarone.htm?fld1=" + fld1 + "&fld2=" + fld2 + "&isFirst=" + isFirst + "&hiddendate=" + hiddendate + "&fldone=" + fldone;
    while (p && p.tagName != "BODY") { eT += p.offsetTop; eL += p.offsetLeft; p = p.offsetParent; }
    cf.style.top = ((document.body.clientHeight - (eT - sT) - eH >= cf.height) ? eT + eH : eT - cf.height) + "px";
    cf.style.left = ((document.body.clientWidth - (eL - sL) >= cf.width) ? eL : eL + eW - cf.width) + "px";
    if (!oImg) { alert("控制对象不存在！"); return; }
    if (oImg.tagName != "INPUT" || oImg.type != "text") { alert("输入控件类型错误！"); return; }
    cf.style.display = "block";
}

function showCalendar(fldone, sImg, fld1, fld2, hiddendate) {
	var cf=document.getElementById("oklxCalFrame");
	var oImg = document.getElementById(sImg);
	var wcf = window.frames.oklxCalFrame;
	var eT=0,eL=0,p=oImg;
	var sT=document.body.scrollTop,sL=document.body.scrollLeft;
	//var eH = oImg.height + 25, eW = oImg.width;
	var eH = 25, eW =0;
	cf.src = "/inc/Calendar.htm?fld1=" + fld1 + "&fld2=" + fld2 + "&isFirst=" + isFirst + "&hiddendate=" + hiddendate + "&fldone=" + fldone;
	while (p && p.tagName != "BODY") { eT += p.offsetTop; eL += p.offsetLeft; p = p.offsetParent; }
	cf.style.top = ((document.body.clientHeight - (eT - sT) - eH >= cf.height) ? eT + eH : eT - cf.height) + "px";
	cf.style.left = ((document.body.clientWidth - (eL - sL) >= cf.width) ? eL : eL + eW - cf.width)+"px";
	if(!oImg){alert("控制对象不存在！");return;}
	if(oImg.tagName!="INPUT"||oImg.type!="text"){alert("输入控件类型错误！");return;}
	cf.style.display = "block";	
}

function showCalendar1(fldone, sImg, fld1, hiddendate) {

    var fld101 = document.getElementById(fldone);
    todayDate101 = new Date(fld101.value.substring(0, 4), fld101.value.substring(5, 7) - 1, fld101.value.substring(8));
    
    var fld102 = document.getElementById(hiddendate);
    todayDate102 = new Date(fld102.value.substring(0, 4), fld102.value.substring(5, 7) - 1, fld102.value.substring(8));

    if (todayDate101 > todayDate102) { hiddendate = fldone; }
    
    var cf = document.getElementById("oklxCalFrame");
    var oImg = document.getElementById(sImg);
    var wcf = window.frames.oklxCalFrame;

    var eT = 0, eL = 0, p = oImg;
    var sT = document.body.scrollTop, sL = document.body.scrollLeft;
    var eH = oImg.height + 25, eW = oImg.width;
    cf.src = "/inc/Calendar1.htm?fld1=" + fld1 + "&fld2=null&isFirst=" + isFirst + "&hiddendate=" + hiddendate + "&fldone=" + fldone;
    
    while (p && p.tagName != "BODY") { eT += p.offsetTop; eL += p.offsetLeft; p = p.offsetParent; }
    cf.style.top = ((document.body.clientHeight - (eT - sT) - eH >= cf.height) ? eT + eH : eT - cf.height) + "px";
    cf.style.left = ((document.body.clientWidth - (eL - sL) >= cf.width) ? eL : eL + eW - cf.width) + "px";
	
    if (!oImg) { alert("控制对象不存在！"); return; }
    if (oImg.tagName != "INPUT" || oImg.type != "text") { alert("输入控件类型错误！"); return; }
    cf.style.display = "block";

}
function showCalendar_new(fldone, sImg, fld1, fld2, hiddendate) {

    var cf = document.getElementById("oklxCalFrame");
    var oImg = document.getElementById(sImg);
    var wcf = window.frames.oklxCalFrame;

    var eT = 0, eL = 0, p = oImg;
    var sT = document.body.scrollTop, sL = document.body.scrollLeft;
    var eH = oImg.height + 25, eW = oImg.width;
    cf.src = "/inc/Calendar_new.htm?fld1=" + fld1 + "&fld2=" + fld2 + "&isFirst=" + isFirst + "&hiddendate=" + hiddendate + "&fldone=" + fldone;

    while (p && p.tagName != "BODY") { eT += p.offsetTop; eL += p.offsetLeft; p = p.offsetParent; }
    cf.style.top = ((document.body.clientHeight - (eT - sT) - eH >= cf.height) ? eT + eH : eT - cf.height) + "px";
    cf.style.left = ((document.body.clientWidth - (eL - sL) >= cf.width) ? eL : eL + eW - cf.width) + "px";
	
    if (!oImg) { alert("控制对象不存在！"); return; }
    if (oImg.tagName != "INPUT" || oImg.type != "text") { alert("输入控件类型错误！"); return; }
    cf.style.display = "block";

}

function showCalendar_new_1(fldone, sImg, fld1, hiddendate) {

    var fld101 = document.getElementById(fldone);
    todayDate101 = new Date(fld101.value.substring(0, 4), fld101.value.substring(5, 7) - 1, fld101.value.substring(8));

    var fld102 = document.getElementById(hiddendate);
    todayDate102 = new Date(fld102.value.substring(0, 4), fld102.value.substring(5, 7) - 1, fld102.value.substring(8));

    if (todayDate101 > todayDate102) { hiddendate = fldone; }

    var cf = document.getElementById("oklxCalFrame");
    var oImg = document.getElementById(sImg);
    var wcf = window.frames.oklxCalFrame;

    var eT = 0, eL = 0, p = oImg;
    var sT = document.body.scrollTop, sL = document.body.scrollLeft;
    var eH = oImg.height + 25, eW = oImg.width;
    cf.src = "/inc/Calendar_new_1.htm?fld1=" + fld1 + "&fld2=null&isFirst=" + isFirst + "&hiddendate=" + hiddendate + "&fldone=" + fldone;

    while (p && p.tagName != "BODY") { eT += p.offsetTop; eL += p.offsetLeft; p = p.offsetParent; }
    cf.style.top = ((document.body.clientHeight - (eT - sT) - eH >= cf.height) ? eT + eH : eT - cf.height) + "px";
    cf.style.left = ((document.body.clientWidth - (eL - sL) >= cf.width) ? eL : eL + eW - cf.width) + "px";
	
    if (!oImg) { alert("控制对象不存在！"); return; }
    if (oImg.tagName != "INPUT" || oImg.type != "text") { alert("输入控件类型错误！"); return; }
    cf.style.display = "block";

}


function hideCalendar() {
	var cf=document.getElementById("oklxCalFrame");
	cf.style.display="none";
}

//给页面用的不是日历控件的函数
function getNowDate() {
	var nowDate = new Date();
	return parseDateToString(nowDate.getMonth(),nowDate.getDate(),nowDate.getFullYear());
}

function addDate(nowDate, intDay) {
	nowDate.setTime(parseInt(nowDate.getTime()) + 86400000 * intDay);
	return parseDateToString(nowDate.getMonth(), nowDate.getDate(), nowDate.getFullYear());
}

function parseDateToString(gMonth, gDay, gYear) {
	var parseDateToString;
	parseDateToString = fillYear(gYear) + "-" + fillZero(gMonth + 1) + "-" + fillZero(gDay);
	return parseDateToString;
}

function fillZero(number) {
	var m_int
	if (number < 10)
		m_int = '0' + number.toString();
	else
		m_int = number.toString();
	return m_int
}

function fillYear(year_) {
	var m_year = year_.toString();
	
	if (m_year.length < 4 && m_year.length == 3) {
		return "20" + m_year.substring(m_year.length-2,m_year.length);
	}
	return m_year;
}

function setCheckInDate()
{
    showCalendar1('CnFirstCityDate', 'CnSecondCityDate', 'CnSecondCityDate', 'hiddendate')
}

function setCheckInDatenew() {
    showCalendar1('WorldFirstCityDate', 'WorldSecondCityDate', 'WorldSecondCityDate', 'hiddendate')
}