﻿var CONST_Grid_Over_Color = "#e1edf6";
var CONST_Grid_Choosed_Color = "#e1edf6";
var CONST_Grid_Favorite_Color = "#fff7d2";

var active;
function getElement(id) {
    return document.getElementById(id);
}

function createElement(type) {
    return document.createElement(type);
}

function removeElement(element) {
    try {
        if (element) {
            element.parentNode.removeChild(element);
        }
    }
    catch (e) {
    }
}

function hideElement(element) {
    if (element) {
        element.style.display = "none";
    }
}

function hideElementV(element) {
    if (element) {
        element.style.visibility = "hidden";
        element.style.display = "";
    }
}

function showElement(element) {
    if (element) {
        element.style.display = "";
        element.style.visibility = "";
    }
}

function clearElement(element) {
    for (var i in element) {
        try {

            element[i] = null;
        }
        catch (e) {
            continue;
        }
    }
}

function getWindowSize() {
    var myWidth = 0, myHeight = 0;
    if (typeof (window.innerWidth) == 'number') {
        //Non-IE
        myWidth = window.innerWidth;
        myHeight = window.innerHeight;
    } else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
        //IE 6+ in 'standards compliant mode'
        myWidth = document.documentElement.clientWidth;
        myHeight = document.documentElement.clientHeight;
    } else if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
        //IE 4 compatible
        myWidth = document.body.clientWidth;
        myHeight = document.body.clientHeight;
    }
    return ([myWidth, myHeight]);
}

function GetOffsetPos(element) {
    var flag = element.tagName.toUpperCase() == "INPUT" ? true : false;
    var posTop = 0, posLeft = 0;
    do {
        posTop += element.offsetTop || 0;
        posLeft += element.offsetLeft || 0;
        element = element.offsetParent;
    } while (element);
    return [posLeft, posTop];
}

function hideSelects(zIndexNow) {
    if (navigator.appVersion.indexOf("MSIE 6.0") != -1) {
        var selects = document.getElementsByTagName("select");
        var length = selects.length;
        for (var i = 0; i < length; i++) {
            if (selects[i].zIndexNow != zIndexNow && selects[i].style.visibility != "hidden") {
                selects[i].style.visibility = "hidden";
                selects[i].zIndexNow = zIndexNow;
            }
        }
    }
}

function showSelects(zIndexNow) {
    if (navigator.appVersion.indexOf("MSIE 6.0") != -1) {
        var selects = document.getElementsByTagName("select");
        var length = selects.length;
        for (var i = 0; i < length; i++) {
            if (selects[i].zIndexNow == zIndexNow) {
                selects[i].style.visibility = "";
                selects[i].zIndexNow = -1;
            }
        }
    }
}

function __InitPos(str) {
    try {
        var nav = document.getElementById("positionSpan");
        nav.innerHTML = str;
    }
    catch (e) { }
}

//Cookie
function SetCookie(key, value) {
    SetCookieEx(key, value, 365);
}

function SetCookieEx(key, value, expiresTime, expiresDate) {
    var argv = SetCookieEx.arguments;
    var argc = SetCookieEx.arguments.length;
    var expires;
    if (expiresDate) {
        expires = expiresDate;
    }
    else {
        var now = new Date();
        now.setDate(now.getDate() + expiresTime);
        expires = now; //(2 < argc) ? argv[2] : null;
    }
    var path = (4 < argc) ? argv[4] : null;
    var domain = '.fund123.cn'; //(5 < argc) ? argv[5] : null; 
    var secure = (6 < argc) ? argv[6] : false;
    var cookieValue = key + '=' + escape(value)
		+ ((expires == null) ? '' : ('; expires=' + expires.toGMTString()))
		+ ((path == null) ? '' : ('; path=' + path))
		+ ((domain == null) ? '' : ('; domain=' + domain))
		+ ((secure == true) ? '; secure' : '');
    document.cookie = cookieValue;
}

function GetCookie(key) {
    var arg = key + '=';
    var alen = arg.length;
    var clen = document.cookie.length;
    var i = 0;
    while (i < clen) {
        var j = i + alen;
        if (document.cookie.substring(i, j) == arg) {
            var offset = j;
            var endstr = document.cookie.indexOf(';', offset);
            if (endstr == -1) {
                endstr = document.cookie.length;
            }
            return unescape(document.cookie.substring(offset, endstr));
        }
        i = document.cookie.indexOf(' ', i) + 1;
        if (i == 0) break;
    }
    return null;
}

function SaveUserData(objPersistent, key, name, value) {
    objPersistent.setAttribute(name, value);
    objPersistent.save(key);
}

function LoadUserData(objPersistent, key, name) {
    objPersistent.load(key);
    return objPersistent.getAttribute(name);
}

//FundList
var getFFVersion = navigator.userAgent.substring(navigator.userAgent.indexOf("Firefox")).split("/")[1];
var FFextraHeight = getFFVersion >= 0.1 ? 16 : 0;
function ResizeIframe() {
    try {
        document.getElementById("loadingFrame").style.display = "none";
    } catch (e) { }
    dyniframesize('iframeContent');
}

function ResizeLoadFrame() {
    document.getElementById("loadingFrame").style.display = "none";
}

function dyniframesize(iframename) {
    var pTar = null;
    if (document.getElementById) {
        pTar = document.getElementById(iframename);
    }
    else {
        eval('pTar = ' + iframename + ';');
    }
    if (pTar && !window.opera) {
        //begin resizing iframe
        pTar.style.display = "block";
        if (pTar.contentDocument && pTar.contentDocument.body.offsetHeight) {
            //ns6 syntax
            pTar.height = pTar.contentDocument.body.offsetHeight + FFextraHeight + 1;
        }
        else if (pTar.Document && pTar.Document.body.scrollHeight) {
            //ie5+ syntax
            pTar.height = pTar.Document.body.scrollHeight + 1;
        }
    }
}

var isVip;
function InitVip(flag) {
    isVip = flag;
}

var lastVisterTime = new Date();
lastVisterTime.setMinutes(lastVisterTime.getMinutes() + 2);
function RefreshPage(auto, time, refreshNow) {
    //开方式基金用的
    if (document.getElementById("frmLoadData")) {
        document.getElementById("loadingFrame").style.display = "";
        document.getElementById("frmLoadData").src = "cache_LatestData.html?" + Math.random();
        return;
    }
    //没有iframeContent用的
    if (!document.getElementById("iframeContent")) {
        window.location.reload();
        return;
    }
    parent.iframeContent.location.reload();
}

var saveText, saveValue;
function InitMode(text, value) {
    saveText = text;
    saveValue = value;
}
function ChangeMode(text, value) {
    if (text) {
        saveText = text;
        saveValue = value;
    }
    else {
        if (saveText) {
            text = saveText;
            value = saveValue;
        }
        else {
            text = "全部基金";
            value = "0";
        }
    }
    try {
        SortListTableVarMode(text, value);
    }
    catch (e) {
        var iframe = document.getElementById("iframeContent");
        iframe.contentWindow.SortListTableVarMode(text, value);
    }
}
function CustomFund(obj) {
    if (obj.tag == "") {
        SetCustom();
    }
    else {
        ChangeMode(obj);
    }
}

function Analyze(sort) {
    if (!sort) sort = "percentvalue";
    var CalendarStart = document.getElementById("ctl00_ContentPlaceHolder_CalendarStart");
    var CalendarEnd = document.getElementById("ctl00_ContentPlaceHolder_CalendarEnd");
    var startDate = new Date(CalendarStart.value.replace("-", ","));
    var endDate = new Date(CalendarEnd.value.replace("-", ","));
    if (startDate == "Invalid Date") startDate = new Date(CalendarStart.value.replace("-", ",").replace("-", ","));
    if (endDate == "Invalid Date") endDate = new Date(CalendarEnd.value.replace("-", ",").replace("-", ","));
    if (startDate > endDate) {
        alert("后面的日期需大于前面的日期！");
        return false;
    }
    document.getElementById("loading").style.display = "";
    var iframeContent = document.getElementById("iframeContent");
    iframeContent.src = "/AnalyzeFundData.aspx?startdate=" + CalendarStart.value + "&enddate=" + CalendarEnd.value + "&sort=" + sort;
}

var currCodes = null;
var mTitle = null;
var mType = null;
function InitFundData() {
    try {
        document.getElementById("all").onclick = function () {
            this.parentNode.onclick = function () {
                onActive(this);
                ChangeMode('全部', '0');
                ResizeIframe();
            };
        };
        document.getElementById("stock").onclick = function () {
            this.parentNode.onclick = function () {
                onActive(this);
                ChangeMode('股票型', stockFund[1]);
                ResizeIframe();
            };
        };
        document.getElementById("bond").onclick = function () {
            this.parentNode.onclick = function () {
                onActive(this);
                ChangeMode('债券型', bondFund[1]);
                ResizeIframe();
            };
        };
        document.getElementById("mix").onclick = function () {
            this.parentNode.onclick = function () {
                onActive(this);
                ChangeMode('混合型', mixFund[1]);
                ResizeIframe();
            };
        };
        document.getElementById("keep").onclick = function () {
            this.parentNode.onclick = function () {
                onActive(this);
                ChangeMode('保本型', keep[1]);
                ResizeIframe();
            };
        };
        document.getElementById("eetf").onclick = function () {
            this.parentNode.onclick = function () {
                onActive(this);
                ChangeMode('EFT', etfFund[1]);
                ResizeIframe();
            };
        }; 
        document.getElementById("eqdii").onclick = function () {
            this.parentNode.onclick = function () {
                onActive(this);
                InitMode("QDII", QDIIFund[1]);
                ChangeMode('QDII', QDIIFund[1]);
                ResizeIframe();
            };
        };
        document.getElementById("innovate").onclick = function () {
            this.parentNode.onclick = function () {
                onActive(this);
                InitMode("innovate", innovateFund[1]);
                ChangeMode('innovate', innovateFund[1]);
                ResizeIframe();
            };
        };
    } catch (e) { }
}

function OnChangeCompany(e) {
    var text = e.options[e.selectedIndex].innerHTML;
    var codes = e.options[e.selectedIndex].value;
    currCodes = codes.split(';');
    ChangeMode(text, codes);
    ResizeIframe();
}

function ShowFavPopups(type, title) {
    mTitle = title;
    mType = type;
    if (typeof (Popups) == 'undefined') {
        __loadPopups(initPopup);
    }
    else {
        showPupup();
    }
}

function initPopup() {
    showPupup();
}

function showPupup() {
    var popup = new Popups("popupContainer");
    popup.createPopup(mType, mTitle).show();
}

function onActive(e) {
    var el = e.childNodes[0];
    if (el.id == "myfundlist") {
        if (typeof (userFavCodes) == "undefined"||typeof(User)=="undefined") {
            LoadDefault();
            return false;
        }
        else if (typeof (userFavCodes) != "undefined" && userFavCodes == '') {
            alert("请先设置我关注的基金,或者您已经设置了我关注的基金但没有保存");
            return false;
        }
        else {
            ChangeMode('我关注的', userFavCodes);
        }
    }

    var CompanySelect = document.getElementById("CompanySelect");
    if (CompanySelect)
        CompanySelect.selectedIndex = 0;

    if (typeof (active) == "undefined") {
        active = document.getElementById("all").parentNode;
    }
    if (active == e)
        return;
    document.getElementById('myfundlist').parentNode.className = "";
    var text = el.innerHTML;
    if (text.length > 3 && text != "QDII") {
        e.className = "jt_4text";
    }
    else if (text == '创新型') {
        e.className = "jt_3text";
    } else {
        e.className = "jt_2text";
    }
    active.className = "";
    active = e;
}

function InitCompany() {
    try {
        var CompanySelect = document.getElementById("CompanySelect");
        if (companyData) {
            for (var i = 0; i < companyData.length; i++) {
                if (companyData[i]) {
                    var oOption = document.createElement("OPTION");
                    oOption.innerHTML = companyData[i][0];
                    oOption.value = companyData[i][1];
                    CompanySelect.appendChild(oOption);
                }
            }
        }
    }
    catch (e)
	{ }
}

function AutoScroolSelect(objSelect, evt) {
    //列表自动滚动处理函数
    var KeywordList = "b|宝|c|长|d|大|f|富|g|工|h|海|j|嘉|n|南|p|鹏|r|融|s|上|t|泰|w|万|x|新|y|易|z|招";
    var arrKeyItem;
    arrKeyItem = KeywordList.split("|");

    var keyCode = String.fromCharCode(evt.keyCode);
    keyCode = keyCode.toLowerCase();

    //根据按下的鍵查找关键字

    var Keyword = "";
    for (var i = 0; i < arrKeyItem.length; i += 2) {
        if (keyCode == arrKeyItem[i]) {
            //找到
            Keyword = arrKeyItem[i + 1];
            //查找列表中第一个以此开头的项目
            for (i = 0; i < objSelect.length; ++i) {
                if (0 == objSelect.options[i].text.indexOf(Keyword)) {
                    //找到
                    objSelect.selectedIndex = i;
                    break;
                }
            }
            break;
        }
    }
}

function CombineArray(source, codes) {
    var returnAry = [];
    for (var j = 0; j < codes.length; ++j) {
        for (var i = 0; i < source.length; ++i) {
            if (codes[j] == source[i]) {
                returnAry.push(codes[j]);
            }
        }
    }

    return returnAry;
}

function ClearActiveID() {
    if (active) {
        if (active.childNodes[0].id == "highlight") {
            return;
        }
    }
    var all = document.getElementById("all").parentNode;
    if (active) {
        active.className = "";
    }

    active = all;
    all.className = "jt_2text";
}

function InitDp() {
    var esh = document.getElementById("sh");
    var esz = document.getElementById("sz");

    var shisdown = parseFloat(sh[4].replace("%", "")) < 0 ? "green" : "red";
    var szisdown = parseFloat(sz[4].replace("%", "")) < 0 ? "green" : "red";

    var shStr = "<font color='black'><strong>上证指数：</strong></font><font color='" + shisdown + "'>" + sh[0] + "(" + sh[4] + ")</font>&nbsp;&nbsp;<font color='red'>涨(" + sh[1] + ")</font>&nbsp;&nbsp;平(" + sh[2] + ")&nbsp;&nbsp;<font color='green'>跌(" + sh[3] + ")</font>";
    esh.innerHTML = shStr;

    var szStr = "<font color='black'>深证指数：</font><font color='" + szisdown + "'>" + sz[0] + "(" + sz[4] + ")</font>&nbsp;&nbsp;<font color='red'>涨(" + sz[1] + ")</font>&nbsp;&nbsp;平(" + sz[2] + ")&nbsp;&nbsp;<font color='green'>跌(" + sz[3] + ")</font>";
    esz.innerHTML = szStr;
}

function InitOldDp() {
    try {
        var esh = document.getElementById("sh");
        var esz = document.getElementById("sz");

        var shisdown = parseFloat(oldshzs[4].replace("%", "")) < 0 ? "green" : "red";
        var szisdown = parseFloat(oldszzs[4].replace("%", "")) < 0 ? "green" : "red";

        var shStr = "<font color='black'><strong>上证指数：</strong></font><font color='" + shisdown + "'>" + oldshzs[0] + "(" + oldshzs[4] + ")</font>&nbsp;&nbsp;<font color='red'>涨(" + oldshzs[1] + ")</font>&nbsp;&nbsp;平(" + oldshzs[2] + ")&nbsp;&nbsp;<font color='green'>跌(" + oldshzs[3] + ")</font>";
        esh.innerHTML = shStr;

        var szStr = "<font color='black'><strong>深证指数：</strong></font><font color='" + szisdown + "'>" + oldszzs[0] + "(" + oldszzs[4] + ")</font>&nbsp;&nbsp;<font color='red'>涨(" + oldszzs[1] + ")</font>&nbsp;&nbsp;平(" + oldszzs[2] + ")&nbsp;&nbsp;<font color='green'>跌(" + oldszzs[3] + ")</font>";
        esz.innerHTML = szStr;
        var loading = document.getElementById("loading");
        loading.innerHTML = "<a href='javascript:RefreshPage();'><u>立即刷新</u></a>";
    } catch (e) { }
}

function OnChangeCompanyNoFrame(e) {
    var text = e.options[e.selectedIndex].innerHTML;
    var codes = e.options[e.selectedIndex].value;
    currCodes = codes.split(';');
    ChangeModeNoFrame(text, codes);
}

function ChangeModeNoFrame(text, value) {
    if (text) {
        saveText = text;
        saveValue = value;
    }
    else {
        if (saveText) {
            text = saveText;
            value = saveValue;
        }
        else {
            text = "全部基金";
            value = "0";
        }
    }

    SortListTableVarModeNoFrame(text, value);
}

function SortListTableVarModeNoFrame(text, value) {
    alert(QDIIFund[1]);
    var currCodes = window.parent.currCodes;
    var tblContent = document.getElementById("tblContent");
    var trs = tblContent.getElementsByTagName("TR");

    if (currCodes == null && value == "-1") value = "0";

    if (value == "0") {
        for (var i = 0; i < trs.length; i++) {
            if (trs[i].getAttribute("type") == "code") {
                trs[i].style.display = "";
            }
        }

        currCodes = null;
    }
    else {
        var codes;
        if (value == "-1") {
            codes = currCodes;
        }
        else {
            codes = value.split(";");
            if (currCodes != null && text != "我关注的") {
                codes = window.parent.CombineArray(currCodes, codes);
            }
        }

        for (var i = 0; i < trs.length; i++) {
            if (trs[i].getAttribute("type") == "code") {
                trs[i].style.display = "none";
                for (var k = 0; k < codes.length; k++) {
                    if (codes[k] == trs[i].getAttribute("code")) {
                        trs[i].style.display = "";
                        break;
                    }
                }
            }
        }
    }
}

//tagsBall.js
function $$(id) {
    return document.getElementById(id);
}

var wittingHiddenTimer;
var tagBoxWidth = "243px"; //宽度
var tagBoxHeight = "320px"; //高度

function showTagsearch(name, code, xsltname, e, doc) {
    try {
        var box = $$('tagShowBox');
        if (!box) {
            createTagShowBox();
            box = $$('tagShowBox');
        }

        try { clearTimeout(wittingHiddenTimer); } catch (e) { }
        moveTagBox(e, doc);
        $$('tagShowBoxBartitle').innerHTML = name;
        box.style.display = "block";

        var str_tip = "<iframe scrolling=\"no\" name=\"info\" marginwidth=\"0\" src=\"http://hqqd.fund123.cn/Show.html?" + code + "," + xsltname + "\" frameborder=\"0\" width=\"100%\" height=\"283px\"></iframe>";

        oprGetdata(str_tip);
    } catch (e) { }
}

function moveTagBox(e, doc) {
    if (document.documentElement.clientWidth < 1107) {
        $$('tagShowBox').style.left = (e.clientX - 180) + "px";
    }
    else {
        $$('tagShowBox').style.left = (e.clientX + 70) + "px";
    }
    $$('tagShowBox').style.top = (e.clientY + 353) + "px";
}

function oprGetdata(doc) {
    if (doc) {
        $$('tagShowBoxContent').innerHTML = doc;
    }
    else {
        $$('tagShowBoxContent').innerHTML = "系统错误！";
    }
}

//document.onmouseover=doDocumentMove;
function doDocumentMove(e) {
    e = e || window.event;
    var eSrc = e.target || e.srcElement;
    if (eSrc.name != "t_tags") {
        try {
            clearTimeout(wittingHiddenTimer);
        }
        catch (e) { }

        wittingHiddenTimer = setTimeout("hiddenTagShowBox()", 2000);
    }
    else {
        try {
            clearTimeout(wittingHiddenTimer);
        }
        catch (e) { }
    }
}

function hiddenTagShowBox() {
    try {
        clearTimeout(wittingHiddenTimer);
        $$('tagShowBox').style.display = "none";
    }
    catch (e) { }
}

function createTagShowBox() {
    var tagShowBox = document.createElement("div");
    tagShowBox.id = "tagShowBox";
    tagShowBox.setAttribute("id", "tagShowBox");
    tagShowBox.setAttribute("name", "t_tags");
    tagShowBox.style.width = tagBoxWidth;
    tagShowBox.style.height = tagBoxHeight;
    tagShowBox.style.position = "absolute";
    tagShowBox.style.zIndex = "999999";
    tagShowBox.innerHTML = "<div id=\"tagShowBoxBar\" name=\"t_tags\"><div id=\"tagShowBoxBartitle\" name=\"t_tags\"></div><div id=\"tagShowBoxBarClose\" name=\"t_tags\"><img name=\"t_tags\" src=\"/images/close_icon_mout.jpg\" width=\"14\" height=\"14\" border=\"0\" onclick=\"hiddenTagShowBox()\" onmouseover=\"this.src='/images/close_icon_mover.jpg'\" onmouseout=\"this.src='/images/close_icon_mout.jpg'\" /></div></div><div id=\"tagShowBoxContent\" name=\"t_tags\"></a></div>";
    document.getElementsByTagName("body")[0].appendChild(tagShowBox);
}

function getElement(et) {
    return document.getElementById(et);
}

//弹出统一登陆窗口
function popupdialog(width, height, src, title, drag) {
    PDClassInatance.Popup(width, height, src, title, drag);
}
function LoadPopupDialog(width, height, src, title, drag) {
    if (window.PDClassInatance == undefined) {
        __CssLoader("http://inc.fund123.cn/Js/Class/PopupDialog/PopupDialog.css");
        if (drag)
            __JavascriptLoader("http://inc.fund123.cn/Js/Class/PopupDialog/Move.js");
        __JavascriptLoader("http://inc.fund123.cn/Js/Class/PopupDialog/PopupDialog.js", function () { popupdialog(width, height, src, title, drag); });
    }
    else
        popupdialog(width, height, src, title, drag);
}

function LoadDefault() {
    var desc = escape("此功能需要登录后才能使用!");
    var buttonName = escape("登陆,关闭");
    LoadPopupDialog(420, 200, "http://user.fund123.cn/PopupLogin.htm?isSave=save&buttons=1,3&buttonNames=" + buttonName + "&desc=" + desc + "&Login=CallLogin&Close=CallClose", "登陆", false);
}
function CallLogin() {
    PDClassInatance.Close();
    window.location.reload();
}
function CallClose() {
    PDClassInatance.Close();
}

/*
日历控件
================*/
function MzCalendar(handleId) {
    this.id = handleId;
    this.colors =
  {
      "dark": "#a1bbd5",
      "word": "#000040",
      "light": "#FFFFFF",
      "today": "#FF9933",
      "weekend": "#FFA000",
      "wordDark": "#C0C0C0",
      "dayBgColor": "#ffffff",
      "borderDark": "#ffffff"
  };
    try { var NS = navigator.userAgent.indexOf("Netscape") > 1; } catch (e) { var NS = false; }
    this.chinese = { "song": (NS ? unescape("%CB%CE%CC%E5") : unescape("%u5B8B%u4F53")) };
    this.elements = { "days": new Array(40), "table": {}, "button": {} };
    this.monthLen = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
    this.dateBase = new Array(40);

    this.format = "yyyy-MM-dd";
    this.binder = null;
    this.target = null;
    this.usePopup = true;
    this.yearSpan = 60;
    this.now = new Date();
    this.min = -8640000000000000;
    this.max = 8640000000000000;
    try { this.object = window.createPopup(); } catch (e) { this.usePopup = false; }
    if (typeof (this.object) == "undefined") {
        this.usePopup = false;
        document.write("<iframe id='MzCalendarIframe' name='MzCalendarIframe' scrolling='no'" +
      " frameborder='0' style='position:absolute;z-index:999;width:0;height:0;'></iframe>");
        this.initIframe();
    }
    else {
        var style = this.object.document.createStyleSheet();
        var rule = "font-size: 9pt; cursor: default; font-family: " + this.chinese["song"];
        style.addRule("TD", rule);
        style.addRule("INPUT", rule + "; border: 0px; height: 18; width: 18; cursor: pointer");
        style.addRule("TD.day", "font-weight: bold; height: 19");
        style.addRule("TD.day DIV", "height: 17; padding-top: 2px");
        style.addRule(".selected", rule + "; background-color: #0A246A; color: #FFFFFF");
        style.addRule(".layer", rule + "; position: absolute; z-index: 1; top: 3");
        this.object.document.body.innerHTML = this.InitHTML();
        this.object.document.domain = "fund123.cn";
    }
}
//init iframe
MzCalendar.prototype.initIframe = function () {
    if (typeof (this.object) == "undefined") {
        this.object = window.frames["MzCalendarIframe"];
        setTimeout(this.id + ".initIframe()", 10);
        return false;
    }
    else {
        try {
            this.object.document.write(this.InitHTML());
            this.object.document.close();
            this.iframe = GetElementById("MzCalendarIframe");
        }
        catch (e) { setTimeout(this.id + ".initIframe()", 10); }
    }
}
//previous year
MzCalendar.prototype.prevYear = function () {
    if (new Date(this.curYear, 0, 0).getTime() > this.min) {
        this.datetime.setFullYear(this.curYear - 1); this.write();
    }
};
//next year
MzCalendar.prototype.nextYear = function () {
    if (new Date(this.curYear, 12, 1).getTime() < this.max) {
        this.datetime.setFullYear(this.curYear + 1); this.write();
    }
};
//previous month
MzCalendar.prototype.prevMonth = function () {
    if (new Date(this.curYear, this.curMonth, 0).getTime() > this.min) {
        this.datetime.setMonth(this.curMonth - 1); this.write();
    }
};
//next month
MzCalendar.prototype.nextMonth = function () {
    if (new Date(this.curYear, (this.curMonth + 1), 1).getTime() < this.max) {
        this.datetime.setMonth(this.curMonth + 1); this.write();
    }
};
//hide calendar layer
MzCalendar.prototype.hide = function () {
    if (this.usePopup) this.object.hide();
    else this.iframe.style.height = "0";
    this.target.blur();
};
//HTMLElement.getElementById extend
function GetElementById(id) {
    if (typeof (id) != "string" || id == "") return null;
    if (document.getElementById) return document.getElementById(id);
    if (document.all) return document.all(id);
    try { return eval(id); } catch (e) { return null; }
};
//show calendar layer
MzCalendar.prototype.show = function (binder) {
    if (!binder) { alert("Binder is wrong!"); return false; } 0
    this.now = new Date();
    try {
        if (typeof (this.elements["body"]) == "undefined") {
            this.elements["body"] = this.object.document;
            this.setElement();
        }
        this.elements["button"]["today"].title = this.now.Format(this.format);
        this.elements["divYear"].style.display = "none";
        this.elements["divMonth"].style.display = "none";
    }
    catch (e) { }
    this.write();

    try {
        var e = binder, x = e.offsetLeft, y = e.offsetTop;
        while (e = e.offsetParent) { x += e.offsetLeft; y += e.offsetTop; }
        var DL = document.body.scrollLeft, DT = document.body.scrollTop;

        if (this.usePopup) {
            var SH = window.screen.height, b = binder.offsetHeight;
            if (SH - (window.screenTop + y + b - DT) < 191) b = -191;
            this.object.show(0, b, 180, 191, binder);
        }
        else {
            var DW = document.body.clientWidth;
            var DH = document.body.clientHeight;
            if (DT + DH - y - binder.offsetHeight < 191 && y - DT > 191)
                this.iframe.style.top = y - 191 + "px";
            else this.iframe.style.top = y + binder.offsetHeight + "px";
            if (x + 180 > DL + DW) this.iframe.style.left = DW + DL - 180 + "px";
            else if (x - DL < 0) this.iframe.style.left = DL + "px";
            else this.iframe.style.left = x + "px";
            this.iframe.style.width = 180 + "px";
            this.iframe.style.height = 191 + "px";
        }
    }
    catch (e) { alert("Your browser unsupport offsetParent or clientWidth!"); }
};
//print date into calendar
MzCalendar.prototype.write = function () {
    var y = this.curYear = this.datetime.getFullYear();
    var m = this.curMonth = this.datetime.getMonth();
    var d = this.curDay = this.datetime.getDate();
    var w = new Date(y, m, 1).getDay();
    this.monthLen[1] = (0 == y % 4 && (0 != y % 100 || 0 == y % 400)) ? 29 : 28;

    try {
        this.elements["year"].innerHTML = y + " &#24180;";
        var mm = ("00" + (m + 1)).substr(((m + 1) + "").length);
        this.elements["month"].innerHTML = mm + " &#26376;";
    }
    catch (e) { this.setElement() };

    var PMLength = 0 == m ? this.monthLen[11] : this.monthLen[m - 1];
    for (var i = w; i > 0; i--) this.dateBase[i - 1] = new Date(y, m - 1, PMLength - w + i);
    for (var i = 0; i < this.monthLen[m]; i++) this.dateBase[i + w] = new Date(y, m, i + 1);
    for (var k = i + w; k < 40; k++) this.dateBase[k] = new Date(y, m + 1, k - (i + w - 1));

    for (var i = 0; i < 40; i++) {
        var time = this.dateBase[i];
        if (time.getTime() < this.min || time.getTime() > this.max) var str = "&nbsp;"; else {
            var str = "<div onclick='parentNode.style.backgroundColor=parentNode.style.color" +
        "=\"\"; parent." + this.id + ".returnDate(" + i + ")' style='";
            //weekend
            if (0 == time.getDay() || 6 == time.getDay()) str += "color:" + this.colors["weekend"] + ";";
            //Is not current month
            if (m != time.getMonth()) str += "color: " + this.colors["wordDark"] + ";";
            //focus day
            if (this.inputdatetime
        && time.getFullYear() == this.inputdatetime.getFullYear()
        && time.getMonth() == this.inputdatetime.getMonth()
        && time.getDate() == this.inputdatetime.getDate())
                str += "background-color: " + this.colors["dark"]
            + "; color:" + this.colors["light"] + ";";
            //today
            if (time.getFullYear() == this.now.getFullYear()
        && time.getMonth() == this.now.getMonth()
        && time.getDate() == this.now.getDate())
                str += "background-color: " + this.colors["today"]
            + "; color:" + this.colors["light"] + ";";

            str += "' title='" + time.Format(this.format) +
             "' align='center'>" + this.dateBase[i].getDate(); +"</div>";
        }

        this.elements["days"][i].innerHTML = str;
    }
};
//event year select onchange
MzCalendar.prototype.selYearChange = function (e) {
    this.elements["divYear"].style.display = "none";
    var yyyy = parseInt(e.innerHTML, 10);
    if (yyyy != this.datetime.getFullYear()) {
        this.datetime.setFullYear(yyyy);
        this.write();
        this.elements["year"].innerHTML = e.innerHTML;
    }
};
//event month select onchange
MzCalendar.prototype.selMonthChange = function (e) {
    this.elements["divMonth"].style.display = "none";
    var mm = parseInt(e.innerHTML, 10);
    if (mm != (this.datetime.getMonth() + 1)) {
        this.datetime.setMonth(mm - 1);
        this.write();
        this.elements["month"].innerHTML = e.innerHTML;
    }
};
//[extended method] Date.toString by format string
Date.prototype.Format = function (format) //author: meizz
{
    var o = {
        "M+": this.getMonth() + 1, //month
        "d+": this.getDate(),    //day
        "h+": this.getHours(),   //hour
        "H+": this.getHours(),   //hour
        "m+": this.getMinutes(), //minute
        "s+": this.getSeconds(), //second
        "q+": Math.floor((this.getMonth() + 3) / 3),  //quarter
        "w": "日一二三四五六".indexOf(this.getDay()),  //week
        "S": this.getMilliseconds() //millisecond
    }
    if (/(y+)/.test(format)) format = format.replace(RegExp.$1,
    (this.getFullYear() + "").substr(4 - RegExp.$1.length));
    for (var k in o) if (new RegExp("(" + k + ")").test(format))
        format = format.replace(RegExp.$1,
      RegExp.$1.length == 1 ? o[k] :
        ("00" + o[k]).substr(("" + o[k]).length));
    return format;
};
//return user checked date
MzCalendar.prototype.returnDate = function (i) {
    if (arguments.length == 0 || typeof (i) != "number") var time = new Date();
    else var time = this.dateBase[i];
    if (this.target && this.target.tagName == "INPUT")
        this.target.value = time.Format(this.format);
    else alert("Cannot evaluate, because the target element is wrong!")
    if (this.target.getAttribute("Event")) {
        eval(this.target.getAttribute("Event"));
    }
    this.hide();
    if (!typeof (parent.queryHistory) == 'undefined')
        parent.queryHistory();
    if (typeof queryHistory != 'undefined')
        queryHistory();
    //QueryHistoryNetValue();
};
//set min date(yyyy/MM/dd[ hh:mm[:ss]])
MzCalendar.prototype.setMin = function (datestr) {
    var n = Date.parse(datestr);
    if (!isNaN(n) && n < this.max) this.min = n;
    else alert(datestr + " isn't Date String![setMin method]");
}
//set max date(yyyy/MM/dd[ hh:mm[:ss]])
MzCalendar.prototype.setMax = function (datestr) {
    var n = Date.parse(datestr);
    if (!isNaN(n) && n > this.min) this.max = n;
    else alert(datestr + " isn't Date String![setMax method]");
}
//fill in year div layer
MzCalendar.prototype.fillYear = function () {
    this.curYear = this.datetime.getFullYear();
    var div = this.elements["divYear"];
    with (div.style) {
        width = "80px";
        border = "solid 1px #ccc";
    }
    var n = Math.floor(this.yearSpan / 2);
    var min = new Date(this.min).getFullYear();
    if (this.curYear - n > min) min = this.curYear - n;
    var max = new Date(this.max).getFullYear();
    if (min + this.yearSpan < max) max = min + this.yearSpan;

    if (div.childNodes.length > 0) {
        var n = div.childNodes.length;
        for (var i = min; i <= max && i - min < n; i++) {
            var dc = div.childNodes[i - min];
            dc.innerHTML = i + " &#24180;";
            dc.className = "";
            if (i == this.curYear) {
                try {
                    if (window.attachEvent) {
                        this.elements["divYear"].style.top = -1;
                        dc.scrollIntoView(true);
                        this.elements["divYear"].style.top = 3;
                    }
                    else {
                        this.elements["divYear"].scrollTop = (i - min) * 14;
                    }
                } catch (e) { }
                dc.className = "selected";
            }
        }
    }
    else {
        var str = "";
        for (var i = min; i <= max; i++) {
            str += "<div align='center' style='padding-right: 1px;' onclick='parent." + this.id +
        ".selYearChange(this)' onmouseover='this.style.backgroundColor=parent." + this.id +
        ".colors[\"dark\"]; this.style.color=parent." + this.id + ".colors[\"light\"]' " +
        "onmouseout='style.backgroundColor=style.color=\"\"'>" + i + " &#24180;</div>";
        }
        div.innerHTML = str;
    }
};
MzCalendar.prototype.fillMonth = function () {
    this.curMonth = this.datetime.getMonth();
    var div = this.elements["divMonth"];
    with (div.style) {
        width = "54px";
        border = "solid 1px #ccc";
    }
    if (div.childNodes.length > 0) {
        for (var i = div.childNodes.length - 1; i >= 0; i--)
            div.childNodes[i].className = "";
        div.childNodes[this.curMonth].className = "selected";
    }
    else {
        var str = "";
        for (var i = 1; i < 13; i++) {
            str += "<div align='center' style='padding-right: 3px' onclick='parent." + this.id +
        ".selMonthChange(this)' onmouseover='this.style.backgroundColor=parent." + this.id +
        ".colors[\"dark\"]; this.style.color=parent." + this.id + ".colors[\"light\"]' " +
        "onmouseout='style.backgroundColor=style.color=\"\"'>" +
        ("00" + i).substr((i + "").length) + " &#26376;</div>";
        }
        div.innerHTML = str;
    }
}
MzCalendar.prototype.InitHTML = function () {
    var BK = /(MSIE)|(Netscape)/i.test(window.navigator.userAgent);
    var PM = (BK ? " value='3' style='font-family: Webdings' " : " value='&lt;' ");
    var NM = (BK ? " value='4' style='font-family: Webdings' " : " value='&gt;' ");
    var PY = (BK ? " value='7' style='font-family: Webdings' " : " value='&lt;&lt;' ");
    var NY = (BK ? " value='8' style='font-family: Webdings' " : " value='&gt;&gt;' ");
    var s = "", id = this.id;   //Base HTML

    s += "<form name='meizz'>" +
    "<div id='divYear'  class='layer' style='z-index: 2; left: 22px; width: 66px;" +
    " height: 140px; display: none; overflow: auto'></div>" +
    "<div id='divMonth' class='layer' style='z-index: 2; left: 102px; width: 38px;" +
    " height: 170px; display: none'></div>" +
    "<div id='areaYear'  align='center' class='layer'" +
    " title='&#28857;&#20987;&#24555;&#36895;&#36873;&#25321;&#24180;&#20221;'" +
    " style='font-size:14px; font-weight:bold; color:#1d646a; cursor: pointer; left: 22px; width: 82px; height: 18px; padding-top: 2px'" +
    " onmouseout='style.backgroundColor=style.color=\"\"'></div>" +
    "<div id='areaMonth' align='center' class='layer'" +
    " title='&#28857;&#20987;&#24555;&#36895;&#36873;&#25321;&#26376;&#20221;'" +
    " style='font-size:14px; font-weight:bold; color:#1d646a; cursor: pointer; left: 104px; width: 54px; height: 18px; padding: 2px 3px 0 0'" +
    " onmouseout='style.backgroundColor=style.color=\"\"'></div>";

    s += "<table id='tabMain' border='0' cellpadding='0' cellspacing='2' width='176'>" +
    "<tr><td height='18'>" +
    " <table id='tabHead' width='176' border='0' cellspacing='1' cellpadding='0'>" +
    " <tr align='right'><td width='18'><input style='background-color:#fff; border:1px solid #fff;' type='button' name='btPrevMonthHead' " +
    "onclick='parent." + id + ".prevMonth()' " + PM + " onfocus='this.blur()' " +
    "title='&#21521;&#21069;&#32763;&#19968;&#26376;'></td>" +
    " <td width='100' height='18'></td><td width='18'><input style='background-color:#fff; border:1px solid #fff;' type='button' " +
    "title='&#21521;&#21518;&#32763;&#19968;&#26376;' name='btNextMonthHead' " +
    "onclick='parent." + id + ".nextMonth()' onfocus='blur()' " + NM + ">" +
    "</td></tr></table></td></tr>";

    s += "<tr><td height='18'><table width='176' height='18' " +
    "id='tabWeek' cellpadding='0' border='0' cellspacing='0'><tr align=center>" +
    "<td>&#26085;</td><td>&#19968;</td><td>&#20108;</td><td>&#19977;</td>" +
    "<td>&#22235;</td><td>&#20116;</td><td>&#20845;</td></tr></table></td></tr>";

    s += "<tr><td height='120' id='areaDay'><table border='0' " +
    "id='tabDay' height='120' width='176' cellspacing='1' cellpadding='0'>";
    for (var i = 0; i < 5; i++) {
        s += "<tr>";
        for (var y = 0; y < 7; y++) s += "<td class='day'></td>";
        s += "</tr>";
    }
    s += "<tr>"; for (var i = 0; i < 5; i++) s += "<td class='day'></td>";
    s += "<td colspan=2 title='" + "regInfo" + "' align='right'><input style='padding-top: 2px; width: 38px; height: 19px;background-color:#fff; border:1px solid #fff;' type='button' " +
    "name='btClose' " +
    "onclick='parent." + id + ".hide()' value='&#20851; &#38381;' tabindex='1'>" +
    "</td></tr></table></td></tr>";

    s += "<tr><td height='18'>" +
    "<table id='tabBtn' border='0' width='100%' cellpadding='0' cellspacing='1'><tr>" +
    "  <td  width='18'><input style='background-color:#fff; border:1px solid #fff;' type='button' onfocus='this.blur()' " +
    "name='btPrevYear' onclick='parent." + id + ".prevYear()' " + PY +
    "  title='&#21521;&#21069;&#32763;&#19968;&#24180;'></td>" +
    "  <td  width='18'><input style='background-color:#fff; border:1px solid #fff;' type='button' onfocus='this.blur()' " +
    "name='btPrevMonth' onclick='parent." + id + ".prevMonth()' " + PM +
    "  title='&#21521;&#21069;&#32763;&#19968;&#26376;'></td>" +
    "  <td height='18' width='82'><input style='background-color:#fff; border:1px solid #fff; padding-top: 2px; width: 100%' type='button' onfocus='this.blur()' " +
    "name='btToday' value='&#20170; &#22825;' onclick='parent." + id +
    ".returnDate()'></td>" +
    "  <td  width='18'><input style='background-color:#fff; border:1px solid #fff;' type='button' onfocus='this.blur()' " +
    "name='btNextMonth' onclick='parent." + id + ".nextMonth()' " + NM +
    "  title='&#21521;&#21518;&#32763;&#19968;&#26376;'></td>" +
    "  <td  width='18'><input style='background-color:#fff; border:1px solid #fff;' type='button' onfocus='this.blur()' " +
    "name='btNextYear'  onclick='parent." + id + ".nextYear()' " + NY +
    "  title='&#21521;&#21518;&#32763;&#19968;&#24180;'></td></tr>" +
    "</table></td></tr></table></form>";
    if (!this.usePopup) {
        s = "<html><head><meta http-equiv='Content-Type' content='text/html; charset=gb2312'>" +
      "\r\n<style type='text/css'>INPUT, SELECT, TD, DIV" +
      "{font-size: 9pt; cursor: default; font-family: " + this.chinese["song"] + "}" +
      "INPUT{border: 0px; height: 18; width: 18; cursor: pointer}" +
      "TD.day{font-weight: bold; height: 19}" +
      "TD.day DIV{height: 15; padding-top: 2px}" +
      ".layer{position: absolute; z-index: 1; top: 3}" +
      ".selected{background-color: #0A246A; color: #FFFFFF}</style>\r\n" +
      "<script language='javascript'><!--\r\nwindow.get = function(id){" +
      "if (document.getElementById) return document.getElementById(id); " +
      "if (document.all) return document.all(id); " +
      "try {return eval(id);} catch(e){ return null;}};\r\n//--><\/script></head>" +
      "<body style='margin:0; border:0'>" + s + "</body></html>";
    }
    return s;
};
//set calendar color
MzCalendar.prototype.setColor = function (color) {
    if (typeof (color) == "object")
        for (var i in color)
            this.colors[i] = color[i];
    var tabs = this.elements["table"];
    this.object.document.body.style.backgroundColor = this.colors["dark"];
    with (tabs["week"].style) {
        borderTop = borderLeft = "0px solid " + this.colors["dark"];
        borderRight = borderBottom = "0px solid " + this.colors["light"];
    }
    for (var i = tabs["week"].rows[0].cells.length - 1; i >= 0; i--) {
        var td = tabs["week"].rows[0].cells[i].style;
        td.color = this.colors["light"];
        td.paddingTop = "2px";
        td.borderTop = td.borderLeft = "0px solid " + this.colors["light"];
        td.borderRight = td.borderBottom = "0px solid " + this.colors["dark"];
    }
    for (var i in this.elements["button"]) {
        //var button = this.elements["button"][i].style;
        //button.color = this.colors["light"];
        //button.backgroundColor = this.colors["dark"];
    }
    tabs["head"].style.backgroundColor = this.colors["light"];
    tabs["button"].style.backgroundColor = this.colors["light"];
    tabs["day"].style.backgroundColor = this.colors["dayBgColor"];
    for (var i = this.elements["days"].length - 1; i >= 0; i--) {
        var td = this.elements["days"][i].style;
        td.borderTop = td.borderLeft = "0px solid " + this.colors["borderDark"];
        td.borderRight = td.borderBottom = "0px solid " + this.colors["light"];
    }
    this.elements["divYear"].style.backgroundColor = this.colors["light"];
    this.elements["divMonth"].style.backgroundColor = this.colors["light"];
    this.elements["divYear"].style.border = "0px solid " + this.colors["dark"];
    this.elements["divMonth"].style.border = "0px solid " + this.colors["dark"];
};
//Object.attachEvent extend
function AttachEvent(object, eventName, Function, cancelBubble) {
    var cb = cancelBubble ? true : false; eventName = eventName.toLowerCase();
    if (document.attachEvent) object.attachEvent(eventName, Function);
    else object.addEventListener(eventName.substr(2), Function, cb);
};
//get calendar children element
MzCalendar.prototype.setElement = function () {
    this.iframe = GetElementById("MzCalendarIframe");
    var doc = this.object.document;
    var tabs = this.elements["table"];
    var btns = this.elements["button"];
    var form = doc.forms["meizz"];
    if (this.usePopup) {
        var tds = doc.all.tabDay.getElementsByTagName("TD");
        tabs["main"] = doc.all.tabMain;
        tabs["head"] = doc.all.tabHead;
        tabs["week"] = doc.all.tabWeek;
        tabs["day"] = doc.all.tabDay;
        tabs["button"] = doc.all.tabBtn;
        this.elements["year"] = doc.all.areaYear;
        this.elements["month"] = doc.all.areaMonth;
        this.elements["divYear"] = doc.all.divYear;
        this.elements["divMonth"] = doc.all.divMonth;
    }
    else {
        var tds = this.object.get("tabDay").getElementsByTagName("TD");
        tabs["main"] = this.object.get("tabMain");
        tabs["head"] = this.object.get("tabHead");
        tabs["week"] = this.object.get("tabWeek");
        tabs["day"] = this.object.get("tabDay");
        tabs["button"] = this.object.get("tabBtn");
        this.elements["year"] = this.object.get("areaYear");
        this.elements["month"] = this.object.get("areaMonth");
        this.elements["divYear"] = this.object.get("divYear");
        this.elements["divMonth"] = this.object.get("divMonth");
        AttachEvent(document, "onclick", function (e) {
            e = e || window.event; var element = e.target || e.srcElement;
            var height = parseInt(WebCalendar.iframe.style.height, 10);
            if (height > 0 && WebCalendar.binder != element) WebCalendar.hide();
        });
        try {
            AttachEvent(window, "onresize", function () { WebCalendar.hide(); });
            AttachEvent(window, "onscroll", function () { WebCalendar.hide(); });
        }
        catch (e) { }
    }
    this.fillYear();
    this.fillMonth();
    var me = this;
    tabs["main"].onclick = function () {
        me.elements["divYear"].style.display = "none";
        me.elements["divMonth"].style.display = "none";
    }
    this.elements["year"].onclick = function () {
        me.elements["divYear"].style.display = "";
        me.elements["divMonth"].style.display = "none";
        WebCalendar.fillYear();
    }
    this.elements["month"].onclick = function () {
        me.elements["divYear"].style.display = "none";
        me.elements["divMonth"].style.display = "";
        WebCalendar.fillMonth();
    }
    for (var i = 0; i < 40; i++) {
        this.elements["days"][i] = tds[i];
        tds[i].onmouseover = function () {
            this.style.backgroundColor = WebCalendar.colors["dark"];
            this.style.color = WebCalendar.colors["light"];
        }
        tds[i].onmouseout = function () {
            this.style.backgroundColor = this.style.color = "";
        }
        this.elements["days"][i].innerHTML = (i + 1);
    }
    btns["PMH"] = form.btPrevMonthHead;
    btns["NMH"] = form.btNextMonthHead;
    btns["PY"] = form.btPrevYear;
    btns["PM"] = form.btPrevMonth;
    btns["NM"] = form.btNextMonth;
    btns["NY"] = form.btNextYear;
    btns["today"] = form.btToday;
    btns["close"] = form.btClose;
    this.elements["year"].onmouseover = function () {
        this.style.backgroundColor = WebCalendar.colors["dark"];
        this.style.color = WebCalendar.colors["light"];
    }
    this.elements["month"].onmouseover = function () {
        this.style.backgroundColor = WebCalendar.colors["dark"];
        this.style.color = WebCalendar.colors["light"];
    }
    this.setColor(null);
};
//calendar starting
MzCalendar.prototype.start = function (binder, target, format) {
    if (arguments.length == 0 || typeof (binder) != "object") {
        try { this.binder = this.target = event.srcElement; }
        catch (e) { alert("parameter is wrong!"); return false; }
    }
    else {
        if (target) {
            if (typeof (target) == "object") this.target = target;
            else if (typeof (target) == "string") { this.format = target; this.target = binder; }
        }
        else this.target = binder;
        if (format && typeof (format) == "string") this.format = format;
        if (binder && typeof (binder) == "object") this.binder = binder;
    }
    this.datetime = new Date(); this.inputdatetime = null;
    if (this.target && this.target.value && /[^\s\x09]/.test(this.target.value)) {
        var value = this.target.value.replace(/(^[\s\x09　]*)|([　\x09\s]*$)/, "");
        if (!isNaN(Date.parse(value))) {
            this.datetime = new Date(Date.parse(value));
            this.inputdatetime = new Date(Date.parse(value));
        }
        else if (value != "") {
            var r1 = /^(\d{2,4})\D?(\d{1,2})\D?(\d{1,2})\D?$/;
            var r2 = /^(\d{1,2})\D?(\d{1,2})\D?(\d{2,4})\D?$/, str = "";
            var r3 = /^(\d{2,4})\D?(\d{1,2})\D?(\d{1,2})\D?(\d{1,2})\D?(\d{1,2})\D?(\d{1,2})?\D?$/;
            if (r1.test(value)) str = RegExp.$1 + "/" + RegExp.$2 + "/" + RegExp.$3;
            else if (r2.test(value)) str = RegExp.$3 + "/" + RegExp.$1 + "/" + RegExp.$2;
            else if (r3.test(value)) str = RegExp.$1 + "/" + RegExp.$2 + "/" + RegExp.$3
        + " " + RegExp.$4 + ":" + RegExp.$5 + ":" + RegExp.$6;
            if (!isNaN(Date.parse(str))) {
                this.datetime = new Date(Date.parse(str));
                this.inputdatetime = new Date(Date.parse(str));
            }
        }
    }

    if (typeof (this.elements["body"]) == "undefined") {
        this.elements["body"] = this.object.document;
        this.setElement();
    }
    this.show(this.binder);
};

window.WebCalendar = new MzCalendar("WebCalendar");


