﻿var _TS_TimerIncrement = 1;
var _TS_IMovementPixels = 5;
var _TS_Interval = 0;
var _TS_PanelIsOpen = false;
var _TS_OpenPanelName = "";

var _TS_iNewTop;
var _TS_TotalHeight;
var _TS_ViewHeight;

var _TS_Processing = false;

function TS_SlidePanelUp(PanelName, ViewName) {
    if (_TS_Processing == true) {
        return;
    }

    _TS_Processing = true;
    _TS_OpenPanelName = PanelName;

    var oPanel = document.getElementById(PanelName);
    var oView = document.getElementById(ViewName);

    oPanel.style.visibility = "visible";
    oPanel.style.display = "block";
    var iTop = parseInt(oPanel.style.top);
    _TS_TotalHeight = parseInt(oPanel.style.height) * -1;
    _TS_ViewHeight = parseInt(oView.style.height) * 1;

    _TS_iNewTop = iTop - 170;


    if (iTop <= _TS_TotalHeight + _TS_ViewHeight) {
        _TS_Processing = false;
        return;
    }
    _TS_Interval = setInterval("TS_SlideUpWindow('" + PanelName + "')", _TS_TimerIncrement);


}


function TS_SlideUpWindow(PanelName) {

    var oPanel = document.getElementById(PanelName);
    var iTop = parseInt(oPanel.style.top);

    if (iTop <= (_TS_iNewTop)) {
        // we have slided up the content so the whole thing is invisible.
        // we do not need to slide anymore
       
        clearInterval(_TS_Interval);
        _TS_Processing = false;
        return;
    }


    oPanel.style.visibility = 'visible';
    var newpos = iTop - _TS_IMovementPixels + "px";
    oPanel.style.top = newpos;
}


function TS_SlidePanelDown(PanelName) {

    if (_TS_Processing == true) {
        return;
    }

    _TS_Processing = true;
    _TS_OpenPanelName = PanelName;

    var oPanel = document.getElementById(PanelName);
    oPanel.style.visibility = "visible";
    oPanel.style.display = "block";
    var iTop = parseInt(oPanel.style.top);
    _TS_iNewTop = iTop + 170;


    if (iTop == 0) {
        _TS_Processing = false;
        return;
    }
    _TS_Interval = setInterval("TS_SlideDownWindow('" + PanelName + "')", _TS_TimerIncrement);


}


function TS_SlideDownWindow(PanelName) {

    var oPanel = document.getElementById(PanelName);
    var iTop = parseInt(oPanel.style.top);

    if (iTop >= _TS_iNewTop) {
        // we have slided up the content so the whole thing is invisible.
        // we do not need to slide anymore
      
        clearInterval(_TS_Interval);
        _TS_Processing = false;
        return;
    }


    oPanel.style.visibility = 'visible';
    var newpos = iTop + _TS_IMovementPixels + "px";
    oPanel.style.top = newpos;
}





function TS_moveUp(sAreaID, sViewID) 
{
    TS_SlidePanelUp(sAreaID, sViewID);
}

function TS_moveDown(sID) {
 
    TS_SlidePanelDown(sID);
}

