﻿function doDropDownMenu( strMenu, strMode ) {
    var objLink = document.getElementById( "link_" + strMenu );
    var objMenu = document.getElementById( "dropdownmenu_" + strMenu );

    //  Show the menu.
    objMenu.className = "dropdownmenu_" + strMode;
    
    //  Highlight the link.
    if ( strMode == "off" && strMenu == strPageType ) {
        objLink.className = "navitem_on";
    } else {
        objLink.className = "navitem_" + strMode;
    }
}

function enlargeImage( strImage ) {
    
    //  Open a new window.
    objWin = window.open( "/app/enlarge-image.aspx?imagefilename=" + strImage, "mywin", "status=0, toolbar=0, location=0, menubar=0, resizable=0, scrollbars=0, height=560, width=640" );
    objWin.focus();
}

function imageGallery( strMode ) {
    
    //  Open a new window.
    objWin = window.open( "/app/image-gallery.aspx?mode=" + strMode, "mywin", "status=0, toolbar=0, location=0, menubar=0, resizable=0, scrollbars=0, height=560, width=640" );
    objWin.focus();
}

function gotoURL( strURL ) {

    //  Change URL.
    window.location = strURL;
}

function setAction( strActionName, strActionValue, strConfirm ) {
    var bConfirm;


    //  Request confirmation if necessary.
    if ( strConfirm != null ) {
        bConfirm = confirm( strConfirm );
    } else {
        bConfirm = true;
    }
    
    if ( bConfirm == true ) {

        //  Set the action.
        document.getElementById( "action_name" ).value = strActionName;
        document.getElementById( "action_value" ).value = strActionValue;

        //  Submit the form.
        document.getElementById( "aspnetForm" ).submit();
    }
}

function showImage( strImage ) {
    var imgLarge = document.getElementById("imgLarge");
    
    //  Set image.
    imgLarge.src = "/media/images/" + strImage;
}

function showNextImage( strMode, curNum, maxImages ) {
    // INCREMENT
    if(curNum >= maxImages) {
        curNum = 1;
    } else {
        curNum++;
    }
    
    // UPDATE LINKS
    updateImageScrollers( strMode, curNum, maxImages );
    
    //  Set image.
    showImage(strMode + "-" + curNum + "-large.jpg");
    
}

function showPreviousImage( strMode, curNum, maxImages ) {
    
    // DECREASE
    if(curNum <= 1) {
        curNum = maxImages;
    } else {
        curNum--;
    }
    
    // UPDATE LINKS
    updateImageScrollers( strMode, curNum, maxImages );
    
    //  SET IMAGE
    showImage(strMode + "-" + curNum + "-large.jpg");
    
}

function updateImageScrollers( strMode, curNum, maxImages ) {
    var goNext = document.getElementById("goNext" + strMode);
    var goPrevious = document.getElementById("goPrevious" + strMode);
    
    var href = "Image('" + strMode + "', '" + curNum + "', '" + maxImages + "');"
    goNext.href = "javascript:showNext" + href;
    goPrevious.href = "javascript:showPrevious" + href;
}