// *** SCROLLER OBJECT SETUP AND LOADING CONTENT ***

// First, you have to create one or more scroller objects corresponding to divs in your page.
// Pass it the name of a file to load (or an empty string to scroll HTML already in the page).
//  var objectName = new DHTMLScroller('objectName', 'firstFileToLoad.html');     // Loads file.
//  var objectName = new DHTMLScroller('objectName', '');       // Scrolls pre-existing content.

var content = new DHTMLScroller('content', '');

// When you 'load' files, there are some important restrictions:
//  * You can't load files from other domains, files can ONLY come from the same server.
//  * In non-NS4 browsers, only the BODY of the file is transferred to the DIV in this page.
//  * Regular links and forms in the loaded file will reload the whole window.
//    See later in the script for how to dynamically load HTML files.
// Upon 'loading' a file, it is inserted into the DIV in this page, so all links or images
// will be relative to this page, NOT the external file! The pages are MERGED together.
// I recommend keeping loaded content simple, for instance avoid loading scripts if you can.
// Instead, keep any important JS functions in this page; merged files can still access them.



// *** SCROLLER LAYOUT AND CUSTOMISATION ***

// divs[n] = new ScrDiv('ID-of-div', 'Left', 'Top', 'Width', 'Height', Visibility, 'Parent');

with (content)
{
 // The first three divs you add are special! The first is the scroller area itself into which
 // files are loaded. The second is the scrollbar area, and he third is the scrollbar thumb (the
 // draggable bit). Anything after that is positioned and sized by the scroller engine on window
 // resize but does not have any special properties.

 // CONTENT: This div has an ID of 'contentOuter', is positioned at (x=50, y=50), and is
 // most of the window wide and high. If you want to centre the div, try something like:
 //divs[0] = new ScrDiv('contentOuter', 'page.winW()/2 - 300', 'page.winH()/2 - 200', '600', '400');

  if (navigator.appName == "Microsoft Internet Explorer")
  {
    divs[0] = new ScrDiv('contentOuter','45','290','640','240', 2);
    divs[1] = new ScrDiv('contentBar','704','298','1','228',2);
  }
  else
  {
    divs[0] = new ScrDiv('contentOuter','45','300','640','240', 2);
    divs[1] = new ScrDiv('contentBar','704','308','1','228',2);

  }

    divs[2] = new ScrDiv('contentThumb','703','','3','',1);
    divs[3] = new ScrDiv('contentUpArrows','702','292','5','4',2);
    divs[4] = new ScrDiv('contentDownArrows','702','530','5','4',2);

 // OPTIONAL SETTINGS: Uncomment these to further customise the script if you want.
 // They're all properties of this scroller object, except the 'page' object which is global.
 //
 // For a "floating" effect... set to a decimal number between 0 and 1 for 'sticky' scrolling,
 // where you drag the scroller thumb and the content chases it to the new position.
 //stick = 0.25;
 //
 // You can set scroller padding at the top and bottom of loaded files like this:
 //padTop = 100;
 //padBot = 50;
 // If your web host sticks banner ads at the top of every page you load, you could always
 // declare 'padTop' to be slightly negative... don't say you heard it from me... :)
 //
 // Other useful optional properties: manual thumb height control. Defaults are:
 //minThmHeight = 20;
 //maxThmHeight = 9999;
 // These might be useful if you want to use a fixed-size image as your scrollbar thumb.
 //
 // The page object mentioned above can have minimum sizes set. By default, the winW() and winH()
 // functions just return the window area, but you can set minima like so:
 page.minW = 400;
 page.minH = 300;
 // I highly recommend doing this otherwise interesting crashes can result when the window sizes
 // too small and objects start to overlap and get negative heights etc.
 //
 // XFrame behaviour: This script will set the current URI bookmark to something like this as
 // you load files: #frames(content=file.html). This allows users to bookmark files within the
 // scroller(s) in the page. To disable this behaviour, uncomment this:
 //noXFrame = true;


 // Next you can assign scroller events. They are 'onbeforeload', 'onload', 'onscroll', 'onsetup',
 // 'onlayout', 'onthumbdown' and 'onthumbup'. The load events fire whenever a file is loaded into
 // the scroller, and the thumb events whenever you start or stop dragging the thumb. The scroll
 // event fires when you scroll or drag, the setup event fires when the scroller is initialised
 // but hasn't loaded its first file, and the layout event fires whenever the layout function is
 // called (on load completion and window resize).
 //   I've only provided one here, to hide the example loading message in the page below onload.
 // Feel free to add others to highlight the thumb, animate things, etc. etc... if you want to.

 onload = function() { var lm = getSty('loadMessage'); if (lm) lm.visibility = 'hidden'; }
}





// *** SCROLLING BY MOUSEWHEEL HANDLER - delete if you want to restore normal mousewheeling ***

/*var mwHandler = function(evt)
{
 evt=evt?evt:window.event;
 // You have to manually specify a scroller name in here (like 'content').
 if (evt.wheelDelta) content.scrollBy(evt.wheelDelta / (window.opera ? 3 : -3));
 else if (evt.detail) content.scrollBy(evt.detail * 12);
 return false;
};
if (window.addEventListener && !window.opera)
 window.addEventListener('DOMMouseScroll', mwHandler, false);
else window.onmousewheel = document.onmousewheel = mwHandler;*/


// *** SCROLLING BY KEYPRESS HANDLER - delete this too if you want ***

// This will capture keypresses and scroll up/down depending on the key code.
// You must manually specify a scroller name here ('content'), as only one can respond to keys.
function scrKeyDown(evt) { with (content)
{
 if (!loaded) return;

 // Find the correct event object and property.
 var evt = evt?evt:window.event;
 var key = evt.keyCode?evt.keyCode:(evt.charCode?evt.charCode:evt.which);

 //alert(key);
 // Depending on key press (capital || lowercase || function key), scroll div.
 // Uncomment the above 'alert(key)' line to figure out your own keycodes.
 if (key==84 || key==116 || key==36) scrollTo(0);         // 'T', 't' or 'Home'
 if (key==83 || key==115 || key==33) scrollBy(0-cHeight); // 'S', 's' or 'PgUp'
 if (key==65 || key==97  || key==38) scrollBy(-10);       // 'A', 'a' or 'Up'
 if (key==90 || key==122 || key==40) scrollBy(10);        // 'Z', 'z' or 'Down'
 if (key==88 || key==120 || key==34) scrollBy(cHeight);   // 'X', 'x' or 'PgDn'
 if (key==66 || key==98  || key==35) scrollTo(divHeight); // 'B', 'b' or 'End'
}};

// Capture key presses.
if (isIE && !isOp) document.onkeydown = scrKeyDown;
else
{
 if (isNS4) document.captureEvents(Event.KEYPRESS);
 document.onkeypress = scrKeyDown;
}
