﻿
$(document).ready(function(){ 
    divScrollHeight = parseInt($('div[@id="divScroll"]').get(0).offsetHeight);
})

function Clear()
{
    ($('input:text').val(''));
    ($('textarea').val(''));
}

// ------------------------- SCROLL ------------------------- //
var down_interval,up_interval; // hold an int value represent the current interval to stop
var divScrollHeight = 0;

function StartScrollDown()
{
    ($('img[@id="imgArrowUp"]').attr('src','Images/Box/ArrowUp.png'));  
    down_interval = setInterval("ScrollDown()",100); // run timer each 100 millisecond
}

function StartScrollUp()
{
    ($('img[@id="imgArrowDown"]').attr('src','Images/Box/ArrowDown.png'));
    up_interval = setInterval("ScrollUp()",100);// run timer each 100 millisecond
}

function StopScrollDown()
{
    clearInterval(down_interval); // stop the spesific timer
}

function StopScrollUp()
{
    clearInterval(up_interval); // stop the spesific timer
}

function ScrollDown()
{
    // increase X pixels to the div top position each call
    var divCurrentPos = parseInt($('div[@id="divScroll"]').css('top'));
    
    // stop when reach the div scroll end text - height of the div minus the container height
    if(divCurrentPos<=-(divScrollHeight-330))
    {
        ($('img[@id="imgArrowDown"]').attr('src','Images/Box/ArrowDownDisabled.png'))
        StopScrollDown(); 
        return; 
    }
    
    ($('div[@id="divScroll"]').css('top',(divCurrentPos-5) + "px"));
}

function ScrollUp()
{
    // decrease X pixels to the div top position each call
    var divCurrentPos = parseInt($('div[@id="divScroll"]').css('top'));
    if(divCurrentPos>=0)
    {
        ($('img[@id="imgArrowUp"]').attr('src','Images/Box/ArrowUpDisabled.png'))
        StopScrollUp(); 
        return; 
    }
      
    ($('div[@id="divScroll"]').css('top',(divCurrentPos+5) + "px"));
}
// ---------------------------------------------------------- //
