// ==============================================================
// HANDLES SCROLLER/S
// Modified from Aaron Boodman http://webapp.youngpup.net/?request=/components/ypSimpleScroll.xml
// mixed ypSimpleScroll with dom-drag script and allowed multiple scrolelrs through array instances
// (c)2004 Sergi Meseguer (http://zigotica.com/), 04/2004:
// ==============================================================
var theHandle = []; var theRoot = []; var theThumb = []; var theScroll = []; var thumbTravel = []; var ratio = [];

function instantiateScroller(count, id, left, top, width, height, speed) {
	if( _proxy_jslib_handle(document, 'getElementById', '', 0, 0)) {
		 _proxy_jslib_assign('', theScroll, (count), '=', ( new (ypSimpleScroll)(id, left,  _proxy_jslib_handle(null, 'top', top, 0, 0), width, height, speed)));
	}
}

function createDragger(count, handler, root, thumb, minX, maxX, minY, maxY) {
		var buttons = '<div id="scrollrail"></div><div class="up" id="up'+count+'"><a href="#" onmouseover="theScroll['+count+'].scrollNorth(\''+count+'\')" onmouseout="theScroll['+count+'].endScroll()" onclick="return false;"><img src="http://creative.myspace.com/matt/ss/v1/images/up.gif" width="17" height="18"></a></div><div class="dn"  id="dn'+count+'""><a href="#" onmouseover="theScroll['+count+'].scrollSouth(\''+count+'\')" onmouseout="theScroll['+count+'].endScroll()" onclick="return false;"><img src="http://creative.myspace.com/matt/ss/v1/images/up.gif" width="17" height="18"></a></div><div class="thumb" id="'+thumb+'" style="top: 25px;"><img src="http://creative.myspace.com/matt/ss/v1/images/scrollbar.gif" width="14" height="110"></div>';
		 _proxy_jslib_assign('',  _proxy_jslib_handle(document, 'getElementById', '', 1, 0)(root), 'innerHTML', '=', ( buttons +  _proxy_jslib_handle( _proxy_jslib_handle(document, 'getElementById', '', 1, 0)(root), 'innerHTML', '', 0, 0)));

		 _proxy_jslib_assign('', theRoot, (count), '=', (  _proxy_jslib_handle(document, 'getElementById', '', 1, 0)(root)));
		 _proxy_jslib_assign('', theThumb, (count), '=', (  _proxy_jslib_handle(document, 'getElementById', '', 1, 0)(thumb)));
		var thisup =  _proxy_jslib_handle(document, 'getElementById', '', 1, 0)("up"+count);
		var thisdn =  _proxy_jslib_handle(document, 'getElementById', '', 1, 0)("dn"+count);
		 _proxy_jslib_handle(theThumb, (count), 0, 0).style.left = parseInt(minX+0) + "px";
		thisup.style.left = parseInt(minX+0) + "px";
		thisdn.style.left = parseInt(minX+0) + "px";
		 _proxy_jslib_handle(theThumb, (count), 0, 0).style.border =0;
		 _proxy_jslib_assign('',  _proxy_jslib_handle(theThumb, (count), 0, 0).style, 'top', '=', ( parseInt(minY) + "px"));
		 _proxy_jslib_assign('', thisup.style, 'top', '=', ( 0 + "px"));
		 _proxy_jslib_assign('', thisdn.style, 'top', '=', ( parseInt(minY+maxY) + "px"));
		//thisdn.style.top = 15 + "px";

		 _proxy_jslib_handle( _proxy_jslib_handle(theScroll, (count), 0, 0), 'load', '', 1, 0)();

		//Drag.init(theHandle[count], theRoot[count]); //not draggable on screen
		Drag.init( _proxy_jslib_handle(theThumb, (count), 0, 0), null, minX+0, maxX+0, minY, maxY);
		
		// the number of pixels the thumb can travel vertically (max - min)
		 _proxy_jslib_assign('', thumbTravel, (count), '=', (  _proxy_jslib_handle(theThumb, (count), 0, 0).maxY -  _proxy_jslib_handle(theThumb, (count), 0, 0).minY));

		// the ratio between scroller movement and thumbMovement
		 _proxy_jslib_assign('', ratio, (count), '=', (  _proxy_jslib_handle(theScroll, (count), 0, 0).scrollH /  _proxy_jslib_handle(thumbTravel, (count), 0, 0)));

		 _proxy_jslib_handle(theThumb, (count), 0, 0).onDrag = function(x, y) {
			 _proxy_jslib_handle(theScroll, (count), 0, 0).jumpTo(null, Math.round((y -  _proxy_jslib_handle(theThumb, (count), 0, 0).minY) *  _proxy_jslib_handle(ratio, (count), 0, 0)));
		}
}	

// INITIALIZER:
// ==============================================================
// ala Simon Willison http://simon.incutio.com/archive/2004/05/26/addLoadEvent
function addLoadEvent(fn) {
      var old = window.onload;
      if (typeof window.onload != 'function') {
         window.onload = fn;
      }
      else {
         window.onload = function() {
         old();
         fn();
         }
      }
   }
addLoadEvent(function() {
		if(theScroll.length>0) {
		for(var i=0;i<theScroll.length;i++){
			createDragger(i, "handle"+i, "root"+i, "thumb"+i,  _proxy_jslib_handle(theScroll, (i), 0, 0).clipW,  _proxy_jslib_handle(theScroll, (i), 0, 0).clipW, 20,  _proxy_jslib_handle(theScroll, (i), 0, 0).clipH-68);
		}
	}
})  ;
_proxy_jslib_flush_write_buffers() ;