﻿

// IMAGE SWAPS //

function SwapImage(strImage, strNew){

    //get image
    var imgImageObj = document.getElementById(strImage);

    //set src
    imgImageObj.src =  strNew;
    
    
}

// Globals
var alertTimerId = 0;
var ArtworkWindow


//hide img
function HideImage(strInputID){

    var ipScrollBtn = document.getElementById(strInputID);
    
    ipScrollBtn.style.display = "none"   

}

//Artwork Icons
function ShowArtworkThumb(pstrInputID){

    var ipArtworkBtn = document.getElementById(pstrInputID);
    
    ipArtworkBtn.className = "ArtworkThumb_Current";

}


function HideArtworkThumb(pstrInputID){

    var ipArtworkBtn = document.getElementById(pstrInputID);
    
    ipArtworkBtn.className = "ArtworkThumb";

}

//Artwork Previews
function ShowArtworkPopUp(pstrImagePath, pintWidth, pintHeight){


    ArtworkWindow = window.open("/artworkpreview.aspx?p=" + pstrImagePath, "Window2", "left=0,top=0,width=" + pintWidth + ",height=" + pintHeight + ",scrollbars=no,resizable=yes");
    //ArtworkWindow.resizeTo(pintWidth,pintHeight);
    //ArtworkWindow.moveTo(0, 0);
    ArtworkWindow.focus();
}

// Vertical Scroll
function ScrollUpProcedure() {

    var objDiv = document.getElementById("ScrollContent");
    objDiv.scrollTop = objDiv.scrollTop-15;
    
    alertTimerId = setTimeout("ScrollUpProcedure()",50);  


}

function ScrollDownProcedure() {

    var objDiv = document.getElementById("ScrollContent");
    objDiv.scrollTop = objDiv.scrollTop+15;
    
    alertTimerId = setTimeout("ScrollDownProcedure()",50);  

}


//Horzontal Scroll
function ScrollLeftProcedure() {

    //timeout
    alertTimerId = setTimeout("ScrollLeftProcedure()",400); 

    //table
    var objTable = document.getElementById("ctl00_ctl00_phMain_phMainBottom_dlYearsNavigation");
 
    //loop all cells
    var allCells = objTable.getElementsByTagName("td");
    var intCellCount = allCells.length;
    for(var i=0; i<intCellCount; i++){       
       // find first visible cell and make prev cell visible (unless it's first cell)
        if(allCells[i].className == "" && i > 0){
            //show
            allCells[i-1].className = "";
            
            //set current
            var allInputs = allCells[i-1].getElementsByTagName("input");
            var hfCurrent = document.getElementById("ctl00_ctl00_phMain_phMainBottom_hfCurrentYear");
            hfCurrent.value = allInputs[0].alt;
            
            //break     
            break;                                                
        } 
    }
}

function ScrollRightProcedure() {
    //timeout
    alertTimerId = setTimeout("ScrollRightProcedure()",400); 
    
    //test
    var Test = document.getElementsByTagName("input");

    //table
    var objTable = document.getElementById("ctl00_ctl00_phMain_phMainBottom_dlYearsNavigation");
 
    //loop all cells
    var allCells = objTable.getElementsByTagName("td");
    var intCellCount = allCells.length;
    var bytFirstYear = 0
    for(var i=0; i<intCellCount; i++){
       
       // hide first cell that's visable
        if(allCells[i].className == "" && intCellCount-i > 8){
            //hide
            allCells[i].className = "YearsNavTable_Hidden";    
            
            //set current
            var allInputs = allCells[i+1].getElementsByTagName("input");
            var hfCurrent = document.getElementById("ctl00_ctl00_phMain_phMainBottom_hfCurrentYear");
            hfCurrent.value = allInputs[0].alt;
            
            //flag
            bytFirstYear = i; 
            
            //break
            break;                                                                    
        } 
    }
    

}


//RECENT Scroll
function ScrollRecentLeftProcedure() {

    //timeout
    alertTimerId = setTimeout("ScrollRecentLeftProcedure()",400); 

    //table
    var objTable = document.getElementById("ctl00_ctl00_phMain_phMainBottom_dlCategoryNavigation");
 
    //loop all cells
    var allCells = objTable.getElementsByTagName("td");
    var intCellCount = allCells.length;
    for(var i=0; i<intCellCount; i++){       
       // find first visible cell and make prev cell visible (unless it's first cell)
        if(allCells[i].className == "" && i > 0){
            //show
            allCells[i-1].className = "";
            
            //save as current
            var hfCurrent = document.getElementById("ctl00_ctl00_phMain_phMainBottom_hfFirstCategory");
            hfCurrent.value = i-1
            
            //break     
            break;                                                
        } 
    }

//    //timeout
//    alertTimerId = setTimeout("ScrollRecentLeftProcedure()",100); 

//    var objDiv = document.getElementById("YearsNav");
//    objDiv.scrollLeft = objDiv.scrollLeft-15;  

}

function ScrollRecentRightProcedure() {
    //timeout
    alertTimerId = setTimeout("ScrollRecentRightProcedure()",400); 

    //table
    var objTable = document.getElementById("ctl00_ctl00_phMain_phMainBottom_dlCategoryNavigation");
 
    //loop all cells
    var allCells = objTable.getElementsByTagName("td");
    var intCellCount = allCells.length;
    for(var i=0; i<intCellCount; i++){
       
       // hide first cell that's visable
        if(allCells[i].className == "" && intCellCount-i > 3){
            //hide
            allCells[i].className = "YearsNavTable_Hidden";    
            
            //save as current
            var hfCurrent = document.getElementById("ctl00_ctl00_phMain_phMainBottom_hfFirstCategory");
            hfCurrent.value = i+1
            
            //break
            break;                                                                    
        } 
    }


//    //timeout
//    alertTimerId = setTimeout("ScrollRecentRightProcedure()",100); 

//    var objDiv = document.getElementById("YearsNav");
//    objDiv.scrollLeft = objDiv.scrollLeft+15;   

}


// Archive Item Vert Scroll
function ScrollArchiveUpProcedure() {

    var objDiv = document.getElementById("Item_Top");
    objDiv.scrollTop = objDiv.scrollTop-15;
    
    alertTimerId = setTimeout("ScrollArchiveUpProcedure()",50);  

}

function ScrollArchiveDownProcedure() {

    var objDiv = document.getElementById("Item_Top");
    objDiv.scrollTop = objDiv.scrollTop+15;
    
    alertTimerId = setTimeout("ScrollArchiveDownProcedure()",50);  

}

// SCroll Sto
function StopProcedure(){
    clearTimeout(alertTimerId);
}