/* ====================================================================== */
/* ======       <a href="#" onmouseover="mOver(this);"></a>     ========= */
/* ====================================================================== */

function mOver(aObj) {
    imgObj = aObj.getElementsByTagName('img');

    imgObj[0].src = imgObj[0].src.replace("_normal.", "_over.");

    aObj.onmouseout = function() {
        imgObj[0].src = imgObj[0].src.replace("_over.", "_normal.");
    }
}


/* ==================================================== */
/* ShowHide Layer											*/

var currentBlok = null;

function showBlok(aElm, BlokId) {
    var BlokObj = document.getElementById(BlokId);
    BlokObj.style.display = "block";
    //alert(BlokObj.id);
    for (var i = 1; i <= 6; i++) {  // alert(i);
        if (BlokObj.id != ("BLok" + i)) {
            //alert(i);
            document.getElementById("BLok" + i).style.display = "none";
        }
    }

}

/* ShowHide Layer											*/
function showSheet(aElm, sheetId) {
    var SheetObj = document.getElementById(sheetId);
    var tempObj;
    aElmObj = document.getElementById(aElm);
    if (aElmObj != null)
        aElm = aElmObj;
    aElm.className = "active";
    SheetObj.style.display = "block";
    //alert(sheetId);
    if (sheetId == 'sheet6')
        gload();
    for (var i = 1; i <= 9; i++) {
        if (aElm.id != ("ctl00_ContentPlaceHolder1_tab" + i)) {
            tempObj = document.getElementById("ctl00_ContentPlaceHolder1_tab" + i);
            if (tempObj != null)
                tempObj.className = "";

        }
        if (SheetObj.id != ("sheet" + i)) {
            var sheetObject = document.getElementById("sheet" + i);
            if (sheetObject != null)
                sheetObject.style.display = "none";
        }

    }

    if (document.getElementById("ctl00_ContentPlaceHolder1_tab9") != null) {
        document.getElementById("ctl00_ContentPlaceHolder1_tab9").style.background = "rgb(255, 255, 0)";
    }

    if (sheetId != "sheet2") {
        document.getElementById("acco-intro-1").style.display = "block";
        document.getElementById("acco-intro-2").style.display = "none";
    }
    else {
        document.getElementById("acco-intro-1").style.display = "none";
        document.getElementById("acco-intro-2").style.display = "block";
    }

    if (sheetId == "sheet2") {
        $(".page-icons").hide();
    }
    else {
        $(".page-icons").show();
    }
}
function removeDefaultFill(el, s) {
    if (el.value == s) {
        el.value = '';
    }
}

function insertDefaultFill(el, s) {
    if (el.value == '') {
        el.value = s;
    }
}

function checkDefault(value, defaultValue) {
    if (value != defaultValue) {
        return true;
    }
    else {
        return false;
    }
}
function valDateTime(datetime) {
    var arys = datetime.value.split('/');

    var myDate = new Date(arys[2], --arys[1], arys[0]);
    var dd = DateDiff('d', myDate, new Date());
    //alert(dd);
    if (dd < 0) {
        datetime.value = "";
        return false;
    }

}
function valDateTime2(datetime1, datetime2) {
    var arys1 = datetime1.value.split('/');
    var arys2 = datetime2.value.split('/');
    var vd1 = new Date(arys1[2], --arys1[1], arys1[0]);
    var vd2 = new Date(arys2[2], --arys2[1], arys2[0]);
    if (vd1 == 'NaN') {
        return false;
    }
    if (vd2 == 'NaN') {
        return false;
    }
    if (DateDiff('d', vd2, new Date()) < 0) {
        datetime2.value = "";
        return false;
    }
    if (vd1 > vd2) {
        datetime2.value = "";
        return false;
    }
    return true;
}

function DateDiff(strInterval, dtEnd, dtStart) {
    // var dtStart = new Date();   
    if (typeof dtEnd == 'string') {
        dtEnd = StringToDate(dtEnd);
    }
    switch (strInterval) {
        case 's': return parseInt((dtEnd - dtStart) / 1000);
        case 'n': return parseInt((dtEnd - dtStart) / 60000);
        case 'h': return parseInt((dtEnd - dtStart) / 3600000);
        case 'd': return parseInt((dtEnd - dtStart) / 86400000);
        case 'w': return parseInt((dtEnd - dtStart) / (86400000 * 7));
        case 'm': return (dtEnd.getMonth() + 1) + ((dtEnd.getFullYear() - dtStart.getFullYear()) * 12) - (dtStart.getMonth() + 1);
        case 'y': return dtEnd.getFullYear() - dtStart.getFullYear();
    }
}
function Dayminus(asStartvalue, asEndvalue) {
    if (asStartvalue != null && asEndvalue != null) {
        loinStart = asStartvalue.split("-");
        loinEnd = asEndvalue.split("-");
        var loStart = new Date(loinStart[0], loinStart[1] - 1, loinStart[2], 0, 0, 0, 0);
        var loEnd = new Date(loinEnd[0], loinEnd[1] - 1, loinEnd[2], 0, 0, 0, 0);
        var days = (loEnd.getTime() - loStart.getTime()) / (1000 * 24 * 3600);
        if (days < 0) days = -days;
        return days;
    }
}  


