﻿function setHtmlControlMinHeight(ctrlID, offset) {
    var contentWrapper = document.getElementById(ctrlID);
    if (contentWrapper != null) {
        //contentWrapper.style.minHeight = document.documentElement.clientHeight - 220 + "px";
        contentWrapper.style.minHeight = document.documentElement.clientHeight - offset + "px";
    }
}

function rotateHomeImg() {
    var imgHomeMiddle = document.getElementById("imgHomeMiddle");
    //alert(imgHomeMiddle);
    if (imgHomeMiddle) {
        do {
            var randomImg = Math.floor(Math.random() * 6); // random.
        } while (randomImg == 0 || randomImg == currentImg);
        //alert(random);
        imgHomeMiddle.src = "/images/home" + randomImg + ".jpg"
        currentImg = randomImg;
    }
    setTimeout("rotateHomeImg()", "15000"); // Recursive
}

function onLoadExternalHost() {
    ddsmoothmenu.init({
        mainmenuid: "smoothmenu1", //menu DIV id
        orientation: 'h', //Horizontal or vertical menu: Set to "h" or "v"
        classname: 'ddsmoothmenu', //class added to menu's outer DIV
        //customtheme: ["#1c5a80", "#18374a"],
        contentsource: "markup" //"markup" or ["container_id", "path_to_menu_file"]
    })

    showMenu();
    setHtmlControlMinHeight("contentWrapper", 220);
}

function onLoadDefault() {
    showMenu();
    setHtmlControlMinHeight("contentWrapper", 220);
    setHtmlControlMinHeight("ctl00_bodyContent_rptViewer", 245);        
}

function showMenu() {
    var smoothmenu1 = document.getElementById("smoothmenu1");
    if (smoothmenu1 != null)
        smoothmenu1.style.visibility = "visible";
}

function gSearchExternalHost() {
    txtGoogleSearch = document.getElementById('ctl00_txtGoogleSearch');
    if (txtGoogleSearch.value == '') {
        alert('Please enter your search word(s).');
        return;
    }
    window.location = "http://www.textainer.com/Public/Search.aspx?searchWords=" + txtGoogleSearch.value;
}

function displayDepotInfoModal(depotCode) {
    var url = '/Contacts/DepotLookupModal.aspx?depotCode=' + depotCode;
    depotInfo = dhtmlmodal.open('DepotLookup', 'iframe', url, 'Depot Information', 'width=350px,height=250px,center=1,resize=0,scrolling=1');
}
