﻿
var i = 4;
var Timer;

$(document).ready(function() {
    $("input[@name=right]").mousedown( function() { ScrollRight(); });
    $("input[@name=right]").mouseup( function() { clearInterval(Timer); AutoScrollRight(); });
    
    $("input[@name=left]").mousedown( function() { ScrollLeft(); });
    $("input[@name=left]").mouseup( function() { clearInterval(Timer); AutoScrollLeft(); });
    
    //Hide and show the proper divs for JS and no JS for Pros
    $(".pros-hide").css("display", "none");
    $(".pros-js").css("display", "block");
    
    //Position the pros
    $("div.headline:eq(0)").css('left','5px');
    $("div.headline:eq(1)").css('left','120px');
    $("div.headline:eq(2)").css('left','235px');
    $("div.headline:eq(3)").css('left','350px');
    $("div.headline:eq(4)").css('left','465px');
    $("div.headline:eq(5)").css('left','580px');
    $("div.headline:eq(6)").css('left','695px');
    $("div.headline:eq(7)").css('left','810px');
    $("div.headline:eq(8)").css('left','925px');
    $("div.headline:eq(9)").css('left','1040px');
    $("div.headline:eq(10)").css('left','1155px');
    $("div.headline:eq(11)").css('left','1270px');
    $("div.headline:eq(12)").css('left','1385px');
    $("div.headline:eq(13)").css('left','1500px');
    $("div.headline:eq(14)").css('left','1615px');
    $("div.headline:eq(15)").css('left','1730px');
    
    document.getElementById('scroll-left').scrollLeft = 0;
    setTimeout("AutoScrollRight();", 3000);
});

function Tab(currentField, nextField)
{
    var strTempHolder;

    // Determine if the current field's max length has been reached.
    strTempHolder = $(currentField).val();

    if (strTempHolder.length == $(currentField).attr("maxlength"))
    {
        // Retreive the next field in the tab sequence, and give it the focus.
        $(nextField).focus();
    }
}

function LeftDivCheck()
{
    if (document.getElementById('scroll-left').scrollLeft == 0)
    {
        AutoScrollRight();
    }
}

function RightDivCheck()
{
    if (document.getElementById('scroll-left').scrollLeft >= 1730 - 460)
    {
        AutoScrollLeft();
    }
}

//Pro scroll functions
function AutoScrollLeft()
{
  clearInterval(Timer);
  Timer = setInterval("document.getElementById('scroll-left').scrollLeft -= 1; LeftDivCheck();", 100);
}
function AutoScrollRight()
{
  clearInterval(Timer);
  Timer = setInterval("document.getElementById('scroll-left').scrollLeft += 1; RightDivCheck();", 100);
}
function ScrollLeft()
{
  clearInterval(Timer);
  Timer = setInterval("document.getElementById('scroll-left').scrollLeft -= 5", 15);
}
function ScrollRight()
{
  clearInterval(Timer);
  Timer = setInterval("document.getElementById('scroll-left').scrollLeft += 5", 15);
}