﻿// Global Var to hold javascript timer id
var timer;

$(document).ready(function() {
    // Grab our DOM element to scroll to
    var bookmark = $('#' + $("input[id$='hdfSelectedProjectName']").val());
    
    // Scroll to the project being viewed (if the bookmark exists
    if ($(bookmark).length) {        
        $('#ProjectList').scrollTo(bookmark, { duration: 100, axis: "y", onAfter: function() {
            // Add an effect to the chosen element
            $(bookmark).find('.ele').removeClass('hide');
        }
        });
    }
    
    // Rotate the customer quotes
    $('#QuotesRotator').innerfade({
        speed: 1000,
        timeout: 12000,
        type: 'sequence',
        containerheight: '142px'
    });

    // Scroll up button hoverered over
    $('#ScrollUp').mouseover(function(evt) {
        // Start a timer to scroll up
        timer = setInterval("ScrollUp();", 10);
    });

    // Scroll up button moved off
    $('#ScrollUp').mouseout(function(evt) {
        // Stop the scroll up timer
        clearInterval(timer);
    });

    // Scroll project list down
    $('#ScrollDown').mouseover(function(evt) {
        timer = setInterval("ScrollDown();", 10);
    });
    
    // Stop scrolling down
    $('#ScrollDown').mouseout(function(evt) {
        clearInterval(timer);
    });

});

// Scroll the project list down
function ScrollDown(){
    $('#ProjectList').scrollTo("+=1px", { duration: 0, axis: "y" });
}

// Scroll the project list up
function ScrollUp() {
    $('#ProjectList').scrollTo("-=1px", { duration: 0, axis: "y" });
}
