﻿var m_iCount = 0;
var m_iTimeout = 0;
function ChangeImage(sEventName,imageID){
    var oImg = document.getElementById(imageID);
    if(oImg != null){
        if(sEventName == "over"){
            oImg.className = oImg.className.replace("Off","On");
        }
        if(sEventName == "out"){
            oImg.className  = oImg.className.replace("On","Off");
        }
    }
}
function ChangeImageMenu(sEventName, imageID, imageTitle) {
    var oImg = document.getElementById(imageID);
    var oImgTitle = document.getElementById(imageTitle);
    if (oImgTitle != null && oImgTitle.parentElement.style.display=="inline") {
        if (sEventName == "over") {
            oImgTitle.src = oImgTitle.getAttribute("imageOver");
        }
        if (sEventName == "out") {
            oImgTitle.src = oImgTitle.getAttribute("imageNormal");
        }
    } else {
        if (oImg != null) {
            if (sEventName == "over") {
                oImg.className = oImg.className.replace("Off", "On");
            }
            if (sEventName == "out") {
                oImg.className = oImg.className.replace("On", "Off");
            }
        }
    }
}

function ChangeImageByUrl(sEventName, imageID, sID) {
    var oImg = document.getElementById(imageID);
    if (oImg != null) {
        if (sEventName == "over") {
            oImg.className = oImg.className.replace("Off", "On");
        }
        var oHref = document.getElementById(sID);
        var sLink = "";
        if (oHref != null)
            sLink = oHref.href;
        if (sEventName == "out") {
            if(window.location.href != sLink)
                oImg.className = oImg.className.replace("On", "Off");
        }
    }
}
var millisec = 250;
function opacity(id, opacStart, opacEnd, sCurrentOpac, doTable) {
    //alert(sCurrentOpac);
    var speed = Math.round(millisec / 100);
    var timer = 0;

    //determine the direction for the blending, if start and end are the same nothing happens
    if (opacStart > opacEnd) {
        for (i = opacStart; i >= opacEnd; i--) {
            setTimeout("changeOpac(" + i + ",'" + id + "'," + doTable + ")", (timer * speed));
            timer++;
        }
    } else if (opacStart < opacEnd) {
        for (i = opacStart; i <= opacEnd; i++) {
            setTimeout("changeOpac(" + i + ",'" + id + "',"+doTable+")", (timer * speed));
            timer++;
        }
    }
}

//change the opacity for different browsers
function changeOpac(opacity, id,doTable) {
    
    
    var img = document.getElementById(id);
    var oTable = document.getElementById('tblEngineIfo');
    var oTableStyle;
    if (oTable != null) {
        oTableStyle = oTable.style
    }
    if (img != null) {
        var object = document.getElementById(id).style;
        
        object.opacity = (opacity / 100);
        if (oTableStyle != null && doTable != 0) {
            oTableStyle.opacity = (opacity / 100);
            oTableStyle.MozOpacity =  (opacity / 100) ;
            oTableStyle.KhtmlOpacity = (opacity / 100);
            oTableStyle.filter = "alpha(opacity=" + opacity + ")";
        }
        object.MozOpacity = (opacity / 100);
        object.KhtmlOpacity = (opacity / 100);
        object.filter = "alpha(opacity=" + opacity + ")";
        
    }
}
function ChangeTableOpac(id) {
    opacity(id, 0, 100, 0);
}

function FadeIt(sObjectId) {
    var iMillisec=1500;
    var speed = Math.round(iMillisec / 100);
    var timer = 1;
    var iOpacStart = 100;
    var iOpacEnd = 0;
    var iTimeout;
    //determine the direction for the blending, if start and end are the same nothing happens
    if (iOpacStart > iOpacEnd) {
        for (i = iOpacEnd; i <= iOpacStart; i++) {
            iTimeout = setTimeout("FadeObject('" + sObjectId + "', " + i + ",'')", (timer * speed));
            timer++;
        }
    }
    
    clearTimeout(iTimeout);
}

function FadeItDown(sObjectId, oCallingObj) {
    var iMillisec=1500;
    var speed = Math.round(iMillisec / 100);
    var timer = 1;
    var iOpacStart = 0;
    var iOpacEnd = 100;
    var bGoPostBack = false;
    if (document.getElementById(sObjectId) == null || document.getElementById(sObjectId) == undefined) {
        bGoPostBack = true;
    }
    
    if (!bGoPostBack) {
        var iTimeout;
        //determine the direction for the blending, if start and end are the same nothing happens
        if (iOpacEnd > iOpacStart) {
            for (i = iOpacEnd; i >= iOpacStart; i--) {
                iTimeout = setTimeout("FadeObject('" + sObjectId + "', " + i + ",'" + oCallingObj.id + "')", (timer * speed));
                timer++;
            }
        }
        clearTimeout(iTimeout);
    }
}

function FadeObject(sObjectId, iOpacity, oCallerID) {
    var oObject = document.getElementById(sObjectId);
    var oTable = document.getElementById('tblEngineIfo');
    var sImgSrc = '';
    var bFadeObject = true;
    var oTableStyle = null;
    if (oTable != null) {
        oTableStyle = oTable.style;
    }
    if (document.getElementById(sObjectId).src) {
        sImgSrc = document.getElementById(sObjectId).src.replace(window.location.href, "");
        if (sImgSrc == "") {
            document.getElementById(sObjectId).style.display == "none";
            bFadeObject = false;
        }
    }
    if (oObject != null && bFadeObject) {
        var oStyle = oObject.style;
        if (oStyle != null) {
            oStyle.opacity = (iOpacity / 100);
            oStyle.MozOpacity = (iOpacity / 100);
            oStyle.KhtmlOpacity = (iOpacity / 100);
            oStyle.filter = "alpha(opacity=" + iOpacity + ")";
        }
    }
    if (oTableStyle != null) {
        oTableStyle.opacity = (iOpacity / 100);
        oTableStyle.MozOpacity = (iOpacity / 100);
        oTableStyle.KhtmlOpacity = (iOpacity / 100);
        oTableStyle.filter = "alpha(opacity=" + iOpacity + ")";
    }
    if (iOpacity <= 1 && oCallerID != "") {
        __doPostBack(oCallerID, '');
    }
}
function ChangeModel(oDDL) {
    with (document) {
        if (oDDL == null || oDDL == undefined) {
            return false;
        }
        var bRetValue=false;
        switch (oDDL.id.substr(oDDL.id.lastIndexOf("_") + 1)) {
            case "ddlModelCol1":
                if (getElementById(hid1ID).value != String(oDDL.selectedIndex)) {
                    bRetValue = true;
                }
                getElementById(hid1ID).value = oDDL.selectedIndex;
                break;
            case "ddlModelCol2":
                if (getElementById(hid2ID).value != String(oDDL.selectedIndex)) {
                    bRetValue = true;
                }
                getElementById(hid2ID).value = oDDL.selectedIndex;
                break;
            case "ddlModelCol3":
                if (getElementById(hid3ID).value != String(oDDL.selectedIndex)) {
                    bRetValue = true;
                }
                getElementById(hid3ID).value = oDDL.selectedIndex;
                break;
        }
        return bRetValue;
    }
}
function DirectShow(oImage) {
    oImage.style.opacity = 1;
    oImage.style.MozOpacity = 1;
    oImage.style.KhtmlOpacity = 1;
    oImage.style.filter = "alpha(opacity=100)";
}
function OpenSmallWindow(sLocation, sTitle) {
    var sParams;
    sParams = "status=no,toolbar=no,menubar=no,directories=no,resizable=no,scrollbars=yes,width=1020";
    window.open(sLocation, sTitle, sParams);
}