﻿// begin absolutely positioned scrollable area object scripts
/*
Extension developed by David G. Miles (www.z3roadster.net/dreamweaver)
Original Scrollable Area code developed by Thomas Brattli
To add more shock to your site, visit www.DHTML Shock.com
*/

function verifyCompatibleBrowser(){
    this.ver=navigator.appVersion;
    this.dom=document.getElementById?1:0;
    this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom)?1:0;
    this.ie4=(document.all && !this.dom)?1:0;
    this.ns5=(this.dom && parseInt(this.ver) >= 5) ?1:0;
    this.ns4=(document.layers && !this.dom)?1:0;
    this.bw=(this.ie5 || this.ie4 || this.ns4 || this.ns5);
    return this;
}
bw=new verifyCompatibleBrowser();


var speed=50;

var loop, timer;

function ConstructObject(obj, nest, upAId, downAId)
{
    nest=(!nest) ? '':'document.'+nest+'.';
    this.el=bw.dom?document.getElementById(obj):bw.ie4?document.all[obj]:bw.ns4?eval(nest+'document.'+obj):0;
    this.bcss=bw.dom?document.getElementById(obj).style:bw.ie4?document.all[obj].style:bw.ns4?eval(nest+'document.'+obj):0;
    this.scrollHeight=bw.ns4?this.bcss.document.height:this.el.offsetHeight;
    this.clipHeight=bw.ns4?this.bcss.clip.height:this.el.offsetHeight;
    this.up=MoveAreaUp;
    this.down=MoveAreaDown;
    this.MoveArea=MoveArea;
    this.x;
    this.y;
    this.upA = upAId;
    this.downA = downAId;
    this.obj = obj + "Object";
    eval(this.obj + "=this");
    return this;
}
function MoveArea(x,y){
    this.x = x;
    this.y = y;
    this.bcss.left = this.x +"px";
    this.bcss.top = this.y +"px";
}

function MoveAreaDown(move){
    var clipHeight  = 0;
    switch(this.downA)
    {
        case 'down-1':
            clipHeight = objContainer.clipHeight;
            break;
        case 'down-2':
            clipHeight = objContainerTopDist.clipHeight;
            break;
        case 'down-3':
            clipHeight = objContainerTopPace.clipHeight;
            break;
        case 'down-4':
            clipHeight = objContainerTopOther.clipHeight;
            break;        
    }

    if(this.y  > -this.scrollHeight+clipHeight){
        this.MoveArea(0,this.y-move);
        if(loop) setTimeout(this.obj+".down("+move+")",speed);
   }
   else
   {
        
            if(objContainer)
            {
                if(objContainer.downA == this.downA)
                    disableDown();
            }
            try{
            if(objContainerTopDist)
            {
                if(objContainerTopDist.downA == this.downA)
                    disableDownTopDist();
            }
            }
            catch(e)
            {
            }
            try{
            if(objContainerTopPace)
            {
                if(objContainerTopPace.downA == this.downA)
                    disableDownTopPace();
            }
            }
            catch(e)
            {
            }
            try{
            if(objContainerTopOther)
            {
                if(objContainerTopOther.downA == this.downA)
                    disableDownTopOther();
            }
            }
            catch(e)
            {
            }        
   }
}
function MoveAreaUp(move){
    if(this.y < 0)
    {
        this.MoveArea(0,this.y-move);
        if(loop) 
            setTimeout(this.obj+".up("+move+")",speed);
    }
    else
    {
            if(objContainer)
            {
                if(objContainer.upA == this.upA)
                    disableUp();
            }
            try{
            if(objContainerTopDist)
            {
                if(objContainerTopDist.upA == this.upA)
                    disableUpTopDist();
            }
            }
            catch(e)
            {
            }
            try{
            
            if(objContainerTopPace)
            {
                if(objContainerTopPace.upA == this.upA)
                    disableUpTopPace();
            }
            }
            catch(e)
            {
            
            }
            try{
            
            if(objContainerTopOther)
            {
                if(objContainerTopOther.upA == this.upA)
                    disableUpTopOther();
            }
            }
            catch(e)
            {
            
            }        
    }
}

function enableUp(speed)
{
    var a = document.getElementById(objScroller.upA);
    a.onmouseover = function() { PerformScroll(speed * -1); };
    a.onmouseout = function () { CeaseScroll(); };
    a.className = "navTop";
}

function disableUp()
{
    var a = document.getElementById(objScroller.upA);
    a.onmouseover = function () {};
    a.onmouseout = function () {};
    a.className = "navTop navDis";
}

function enableDown(speed)
{
    var a = document.getElementById(objScroller.downA);
    a.onmouseover = function() { PerformScroll(speed * -1); };
    a.onmouseout = function () { CeaseScroll(); };
    a.className = "navBot";
}

function disableDown()
{
    var a = document.getElementById(objScroller.downA);
    a.onmouseover = function () {};
    a.onmouseout = function () {};
    a.className = "navBot navDis";
}


function PerformScroll(speed){
   if(initialised){
      loop = true;
      if(speed > 0)
      {
        enableUp(speed);
        objScroller.down(speed);
      }
      else 
      {
        enableDown(speed);
        objScroller.up(speed);
      }
   }
}

function CeaseScroll(){
    loop=false;
    if(timer) clearTimeout(timer);
}
var initialised;
function InitialiseScrollableArea(ContainerID, ContentID, upA, downA){
    objContainer=new ConstructObject(ContainerID, null, upA, downA);
    objScroller=new ConstructObject(ContentID,ContainerID, upA, downA);
    objScroller.MoveArea(0,0);
    disableUp();
    objContainer.bcss.visibility='visible';
    initialised=true;
}

var initialisedTopDist;
function InitialiseScrollableAreaTopDist(ContainerID, ContentID, upA, downA){
    objContainerTopDist = new ConstructObject(ContainerID, null, upA, downA);
    objScrollerTopDist = new ConstructObject(ContentID,ContainerID, upA, downA);
    objScrollerTopDist.MoveArea(0,0);
    disableUpTopDist();
    objContainerTopDist.bcss.visibility='visible';
    initialisedTopDist=true;
}

function PerformScrollTopDist(speed){
   if(initialisedTopDist){
      loop = true;
      if(speed > 0)
      {
        enableUpTopDist(speed);
        objScrollerTopDist.down(speed);
      }
      else 
      {
        enableDownTopDist(speed);
        objScrollerTopDist.up(speed);
      }
   }
}

function CeaseScrollTopOther(){
    loop=false;
    if(timer) clearTimeout(timer);
}


function CeaseScrollTopDist(){
    loop=false;
    if(timer) clearTimeout(timer);
}
function enableUpTopDist(speed)
{
    var a = document.getElementById(objScrollerTopDist.upA);
    a.onmouseover = function() { PerformScrollTopDist(speed * -1); };
    a.onmouseout = function () { CeaseScrollTopDist(); };
    a.className = "navTop";
}

function disableUpTopDist()
{
    var a = document.getElementById(objScrollerTopDist.upA);
    a.onmouseover = function () {};
    a.onmouseout = function () {};
    a.className = "navTop navDis";
}

function enableDownTopDist(speed)
{
    var a = document.getElementById(objScrollerTopDist.downA);
    a.onmouseover = function() { PerformScrollTopDist(speed * -1); };
    a.onmouseout = function () { CeaseScrollTopDist(); };
    a.className = "navBot";
}

function disableDownTopDist()
{
    var a = document.getElementById(objScrollerTopDist.downA);
    a.onmouseover = function () {};
    a.onmouseout = function () {};
    a.className = "navBot navDis";
}



var initialisedTopPace;
function InitialiseScrollableAreaTopPace(ContainerID, ContentID, upA, downA){
    objContainerTopPace = new ConstructObject(ContainerID, null, upA, downA);
    objScrollerTopPace = new ConstructObject(ContentID,ContainerID, upA, downA);
    objScrollerTopPace.MoveArea(0,0);
    disableUpTopPace();
    objContainerTopPace.bcss.visibility='visible';
    initialisedTopPace=true;
}

function PerformScrollTopPace(speed){
   if(initialisedTopPace){
      loop = true;
      if(speed > 0)
      {
        enableUpTopPace(speed);
        objScrollerTopPace.down(speed);
      }
      else 
      {
        enableDownTopPace(speed);
        objScrollerTopPace.up(speed);
      }
   }
}

function CeaseScrollTopPace(){
    loop=false;
    if(timer) clearTimeout(timer);
}
function enableUpTopPace(speed)
{
    var a = document.getElementById(objScrollerTopPace.upA);
    a.onmouseover = function() { PerformScrollTopPace(speed * -1); };
    a.onmouseout = function () { CeaseScrollTopPace(); };
    a.className = "navTop";
}

function disableUpTopPace()
{
    var a = document.getElementById(objScrollerTopPace.upA);
    a.onmouseover = function () {};
    a.onmouseout = function () {};
    a.className = "navTop navDis";
}

function enableDownTopPace(speed)
{
    var a = document.getElementById(objScrollerTopPace.downA);
    a.onmouseover = function() { PerformScrollTopPace(speed * -1); };
    a.onmouseout = function () { CeaseScrollTopPace(); };
    a.className = "navBot";
}

function disableDownTopPace()
{
    var a = document.getElementById(objScrollerTopPace.downA);
    a.onmouseover = function () {};
    a.onmouseout = function () {};
    a.className = "navBot navDis";
}
function disableDownTopOther()
{
    var a = document.getElementById(objScrollerTopOther.downA);
    a.onmouseover = function () {};
    a.onmouseout = function () {};
    a.className = "navBot navDis";
}


function enableDownTopOther(speed)
{
    var a = document.getElementById(objScrollerTopOther.downA);
    a.onmouseover = function() { PerformScrollTopOther(speed * -1); };
    a.onmouseout = function () { CeaseScrollTopOther(); };
    a.className = "navBot";
}


var initialisedTopOther;
function InitialiseScrollableAreaTopOther(ContainerID, ContentID, upA, downA){
    objContainerTopOther = new ConstructObject(ContainerID, null, upA, downA);
    objScrollerTopOther = new ConstructObject(ContentID,ContainerID, upA, downA);
    objScrollerTopOther.MoveArea(0,0);
    disableUpTopOther();
    objContainerTopOther.bcss.visibility='visible';
    initialisedTopOther=true;
}

function PerformScrollTopOther(speed){
   if(initialisedTopOther){
      loop = true;
      if(speed > 0)
      {
        enableUpTopOther(speed);
        objScrollerTopOther.down(speed);
      }
      else 
      {
        enableDownTopOther(speed);
        objScrollerTopOther.up(speed);
      }
   }
}


function enableUpTopOther(speed)
{
    var a = document.getElementById(objScrollerTopOther.upA);
    a.onmouseover = function() { PerformScrollTopOther(speed * -1); };
    a.onmouseout = function () { CeaseScrollTopOther(); };
    a.className = "navTop";
}

function disableUpTopOther()
{
    var a = document.getElementById(objScrollerTopOther.upA);
    a.onmouseover = function () {};
    a.onmouseout = function () {};
    a.className = "navTop navDis";
}

// end absolutely positioned scrollable area object scripts

