var pre1 = new Image();
var pre2 = new Image();
var pre3 = new Image();


pre1.src="loading_image.gif";
pre2.src="dotted.gif";
pre3.src="arrow.gif";
	
function show(image_text)
// this function shows a picture in the BevShortPhotography gallery
{
	show_pic("gallerypix", image_text,0,"pixmemory", true);
}

function nextpix(delta)
// this function shows the next picture in the BevShortPhotography gallery
{
	next_pic("gallerypix", "pixmemory", delta);
}

var lastActive=null;
function infoshow(ele, image_text)
// this function shows a picture in the BevShortPhotography info page
{
	show_pic("infopix", image_text);
	ele.className="active";
	if (!lastActive) lastActive=xGetElementById("first");
	if (lastActive != ele) lastActive.className=''; 
	lastActive=ele;
}
/*================================================*/
function thumbsshow(image_text)
// this function shows a group of images in the BevShortPhotography thumbnails -- it is not used!!
{
	show_pic("gallerythumbs", image_text);
}

function nextthumbs(delta)
// this function shows the next group of images in the BevShortPhotography thumbnails
{
	next_pic("gallerythumbs", "thumbsmemory", delta);
	//alert(gallery_position);
	xGetElementById("previous_arrow").style.visibility="visible";
	xGetElementById("next_arrow").style.visibility="visible";
	if (gallery_position == "first") xGetElementById("previous_arrow").style.visibility="hidden" ;
	if (gallery_position == "last") xGetElementById("next_arrow").style.visibility="hidden" ;
}
/*================================================*/
function textshow(unique_text)
// this function shows a block of text in the BevShortPhotography infotext -- it is not used!!
{
	show_pic("infotext", unique_text);
}

function nexttext(delta)
// this function shows the next block of text in the BevShortPhotography infotext
{
	next_pic("infotext", "textmemory", delta);
	//alert(gallery_position);
	if (xGetElementById("previous_text")) xGetElementById("previous_text").style.visibility="visible";
	if (xGetElementById("next_text")) xGetElementById("next_text").style.visibility="visible";
	if ((gallery_position == "first") && xGetElementById("previous_text")) xGetElementById("previous_text").style.visibility="hidden" ;
	if ((gallery_position == "last") && xGetElementById("next_text")) xGetElementById("next_text").style.visibility="hidden" ;
}
/*================================================*/

var splash_image = "loading_image.gif";

var currentpix, currentthumbs, currenttext;

function checkpix()
	// IE resets the form value after the page has loaded. It was not therefore picked up before,
	// and we check for it now, and fix it. Firefox doesn't neeed this check.
{
		//alert('in check pix');
		IEcheck_images("gallery", "gallerypix", "pixmemory", currentpix);
		IEcheck_images("gallery", "gallerythumbs", "thumbsmemory", currentthumbs);
		IEcheck_images("info", "infopix", "pixmemory", currentpix);
		IEcheck_images("info", "infotext", "textmemory", currenttext);

}

window.onload=(checkpix);
/*================================================*/


//====================================================//
//	HilderBuild photo gallery support functions       //
//  copyright 2006 Chris Hilder						  //
//  version 3, 6 June 2006
//====================================================//
	
var gallery_position="";

function IEcheck_images(template_name, division_classname, form_element_name, pre_loaded_pic_number)
/* 	IE resets the form value *after* the page has loaded. It was not therefore picked up before,
   	and we check for it now, and fix it. Firefox doesn't neeed this check.

	Use: 	You need a variable to keep the current image number in. As soon as the picture gallery is defined in the HTML
			insert a script that calls 	cancel_all_images and saves the answer e.g. 
	
				currentpix = cancel_all_images("gallerypix", xGetElementById("pixmemory").value);

			This will not pick up the correct value in IE. For that you need to wait for the onload event, and try again.
			That looks like this, e.g.
				
				window.onload=(checkpix);
				function checkpix()
				{
					IEcheck_images("gallery", "gallerypix", "pixmemory", currentpix);
				}
*/
{
		if (
			(Template == template_name) 
			&& 
			(xGetElementById(form_element_name).value != pre_loaded_pic_number)
		   ) 
		show_pic(division_classname, '',xGetElementById(form_element_name).value, form_element_name);
}
function next_pic(division_classname, form_element_name, delta)
/* 	switches to the next picture in a gallery
	delta==1 for next, delta==-1 for previous, other numbers can be used for greater jumps
	returns the new picture number
	also sets the global variable gallery_position to "first", "last", or "" depending on whether 
	the picture is the first, last, or in between
*/
{
	if (!form_element_name) return 0;
	var x=galleryGetElementsByTagName("P",galleryGetElementsByClassName(division_classname,"DIV")[0]);
	var newpic = parseInt(xGetElementById(form_element_name).value)+delta;
	if (newpic < 1) newpic=x.length;
	if (newpic > x.length) newpic=1;
	gallery_position="";
	if (newpic==1) gallery_position="first";
	if (newpic==x.length) gallery_position="last";
	return show_pic(division_classname, '', newpic, form_element_name);
}
function show_pic(division_classname, image_text, image_number, form_element_name, force_progressive)
/*	shows a picture in a gallery either by name or number
	returns the picture number
*/
{
	var x=galleryGetElementsByTagName("P",galleryGetElementsByClassName(division_classname,"DIV")[0]);
	var to_restore = null;
	if (x)
		for (var i=0; i<x.length; i++) 
			if (tester(image_text, x[i].innerHTML) || (image_number &&(image_number==(i+1)))) 
			{
				//alert('show_pic restoring '+x[i].innerHTML+', classname='+x[i].className);
				to_restore=i+1;
				restore_images(x[to_restore-1], division_classname, i, force_progressive); // restore before show
				if (xDef(x[i].className) && (x[i].className.indexOf("shown")==-1)) x[i].className+="shown";
			}
			else 
			{
				//alert('hiding '+x[i].innerHTML+'\nHaving failed to match: '+image_text);
				if (x[i].className) x[i].className=
	                x[i].className.replace(new RegExp("shown\\b"), "");
	        };
	 if (form_element_name) xGetElementById(form_element_name).value=to_restore;
	 return to_restore
}
function cancel_all_images(division_classname, except_image_number)
{
	if(parent&&parent.HBeditContext&&(parent.HBeditContext=='hilderbuild')){show_pic(division_classname,'',1);return}
	var x=galleryGetElementsByTagName("P",galleryGetElementsByClassName(division_classname,"DIV")[0]);
	//alert('cancelling all images in '+x+'\nExcept '+except_image_number);
	if (x)
		for (var i=0; i<x.length; i++) 
		{
			//cancel_images(x[i]);
			//alert(except_image_number && (except_image_number==(i+1)));
			if (except_image_number && (except_image_number==(i+1))) show_pic(division_classname,'',i+1);
			else cancel_images(x[i]);
		}
	return except_image_number;
}

function cancel_images(ele)
{
	if (ele.innerHTML)
	{
		//alert('cancel_images squashing (p)'+ele.innerHTML+'(/p)');
		var x = ele.innerHTML;
		ele.innerHTML="<br />";
		ele.firstChild.setAttribute("originalHTML", x);
		//alert('cancel_images squashed as (p)'+ele.innerHTML+'(/p)');
	}	
}
function restore_images(ele)
{
	//alert('restore_images restoring '+ele.innerHTML);
	var x;
	if (ele.firstChild && ele.firstChild.getAttribute) x=ele.firstChild.getAttribute("originalHTML");
	//alert('now changed to '+x);
	if (x) ele.innerHTML=x;	
}
function tester(needle,haystack)
{
		if (!(needle && haystack)) return false
		needle=needle.replace(new RegExp("\\."),"\\.");
		needle=needle.replace(new RegExp("\\-"),"\\-");
		var regPass=new RegExp('\\b'+needle+'\\b','i');
		var regFail=new RegExp('([\\.\\-]'+needle+'|'+needle+'[\\.\\-])','i');
		return(regPass.test(haystack)&&!regFail.test(haystack));

}
function galleryGetElementsByClassName(clsName, tagName)
{
  var found = new Array();
  var re = new RegExp('\\b'+clsName+'\\b', 'i');
  var list = galleryGetElementsByTagName(tagName, document);
  if (!list) return found;
  for (var i = 0; i < list.length; ++i) {
    if (list[i].className.search(re) != -1) {
      found[found.length] = list[i];
    }
  }
  return found;
}
function galleryGetElementsByTagName(tagName, parentEle)
{
  var list = null;
  if (!parentEle) return list;
  if (parentEle.all) {
    list = parentEle.all.tags(tagName);
  }
  else if (parentEle.getElementsByTagName) list = parentEle.getElementsByTagName(tagName);
  return list || new Array();
}
/**************************************************
 * dom-drag.js
 * 09.25.2001
 * www.youngpup.net
 **************************************************
 * 10.28.2001 - fixed minor bug where events
 * sometimes fired off the handle, not the root.
 **************************************************/

var Drag = {

	obj : null,

	init : function(o, oRoot, minX, maxX, minY, maxY, bSwapHorzRef, bSwapVertRef, fXMapper, fYMapper)
	{
		o.onmousedown	= Drag.start;

		o.hmode			= bSwapHorzRef ? false : true ;
		o.vmode			= bSwapVertRef ? false : true ;

		o.root = oRoot && oRoot != null ? oRoot : o ;

		if (o.hmode  && isNaN(parseInt(o.root.style.left  ))) o.root.style.left   = "0px";
		if (o.vmode  && isNaN(parseInt(o.root.style.top   ))) o.root.style.top    = "0px";
		if (!o.hmode && isNaN(parseInt(o.root.style.right ))) o.root.style.right  = "0px";
		if (!o.vmode && isNaN(parseInt(o.root.style.bottom))) o.root.style.bottom = "0px";

		o.minX	= typeof minX != 'undefined' ? minX : null;
		o.minY	= typeof minY != 'undefined' ? minY : null;
		o.maxX	= typeof maxX != 'undefined' ? maxX : null;
		o.maxY	= typeof maxY != 'undefined' ? maxY : null;

		o.xMapper = fXMapper ? fXMapper : null;
		o.yMapper = fYMapper ? fYMapper : null;

		o.root.onDragStart	= new Function();
		o.root.onDragEnd	= new Function();
		o.root.onDrag	= new Function();
	},

	start : function(e)
	{
		var o = Drag.obj = this;
		e = Drag.fixE(e);
		var y = parseInt(o.vmode ? o.root.style.top  : o.root.style.bottom);
		var x = parseInt(o.hmode ? o.root.style.left : o.root.style.right );
		o.root.onDragStart(x, y);

		o.lastMouseX	= e.clientX;
		o.lastMouseY	= e.clientY;

		if (o.hmode) {
			if (o.minX != null)	o.minMouseX	= e.clientX - x + o.minX;
			if (o.maxX != null)	o.maxMouseX	= o.minMouseX + o.maxX - o.minX;
		} else {
			if (o.minX != null) o.maxMouseX = -o.minX + e.clientX + x;
			if (o.maxX != null) o.minMouseX = -o.maxX + e.clientX + x;
		}

		if (o.vmode) {
			if (o.minY != null)	o.minMouseY	= e.clientY - y + o.minY;
			if (o.maxY != null)	o.maxMouseY	= o.minMouseY + o.maxY - o.minY;
		} else {
			if (o.minY != null) o.maxMouseY = -o.minY + e.clientY + y;
			if (o.maxY != null) o.minMouseY = -o.maxY + e.clientY + y;
		}

		document.onmousemove	= Drag.drag;
		document.onmouseup	= Drag.end;

		return false;
	},

	drag : function(e)
	{
		e = Drag.fixE(e);
		var o = Drag.obj;

		var ey	= e.clientY;
		var ex	= e.clientX;
		var y = parseInt(o.vmode ? o.root.style.top  : o.root.style.bottom);
		var x = parseInt(o.hmode ? o.root.style.left : o.root.style.right );
		var nx, ny;

		if (o.minX != null) ex = o.hmode ? Math.max(ex, o.minMouseX) : Math.min(ex, o.maxMouseX);
		if (o.maxX != null) ex = o.hmode ? Math.min(ex, o.maxMouseX) : Math.max(ex, o.minMouseX);
		if (o.minY != null) ey = o.vmode ? Math.max(ey, o.minMouseY) : Math.min(ey, o.maxMouseY);
		if (o.maxY != null) ey = o.vmode ? Math.min(ey, o.maxMouseY) : Math.max(ey, o.minMouseY);

		nx = x + ((ex - o.lastMouseX) * (o.hmode ? 1 : -1));
		ny = y + ((ey - o.lastMouseY) * (o.vmode ? 1 : -1));

		if (o.xMapper)		nx = o.xMapper(y)
		else if (o.yMapper)	ny = o.yMapper(x)

		Drag.obj.root.style[o.hmode ? "left" : "right"] = nx + "px";
		Drag.obj.root.style[o.vmode ? "top" : "bottom"] = ny + "px";
		Drag.obj.lastMouseX	= ex;
		Drag.obj.lastMouseY	= ey;

		Drag.obj.root.onDrag(nx, ny);
		return false;
	},

	end : function()
	{
		document.onmousemove = null;
		document.onmouseup   = null;
		Drag.obj.root.onDragEnd(	parseInt(Drag.obj.root.style[Drag.obj.hmode ? "left" : "right"]), 
									parseInt(Drag.obj.root.style[Drag.obj.vmode ? "top" : "bottom"]));
		Drag.obj = null;
	},

	fixE : function(e)
	{
		if (typeof e == 'undefined') e = window.event;
		if (typeof e.layerX == 'undefined') e.layerX = e.offsetX;
		if (typeof e.layerY == 'undefined') e.layerY = e.offsetY;
		return e;
	}
};
/* =======================================================
* ypSimpleScroll
* 3/11/2001
* 
* http://www.youngpup.net/
* ======================================================= */

// Modified by Sergi Meseguer (www.zigotica.com) 04/2004
// Now it works with dragger and can use multiple instances in a page



ypSimpleScroll.prototype.scrollNorth = function(count) { this.startScroll(90, count) }
ypSimpleScroll.prototype.scrollSouth = function(count) { this.startScroll(270, count) }
ypSimpleScroll.prototype.scrollWest = function(count) { this.startScroll(180, count) }
ypSimpleScroll.prototype.scrollEast = function(count) { this.startScroll(0, count) }

ypSimpleScroll.prototype.startScroll = function(deg, count) {
	if (this.loaded){
		if (this.aniTimer) window.clearTimeout(this.aniTimer)
		this.overrideScrollAngle(deg)
		this.speed = this.origSpeed
		this.lastTime = (new Date()).getTime() - this.y.minRes
		this.aniTimer = window.setTimeout(this.gRef + ".scroll('"+deg+"','"+count+"')", this.y.minRes)
	}
}

ypSimpleScroll.prototype.endScroll = function() {
	if (this.loaded){
		window.clearTimeout(this.aniTimer)
		this.aniTimer = 0;
		this.speed = this.origSpeed
	}
}

ypSimpleScroll.prototype.overrideScrollAngle = function(deg) {
	if (this.loaded){
		deg = deg % 360
		if (deg % 90 == 0) {
			var cos = deg == 0 ? 1 : deg == 180 ? -1 : 0
			var sin = deg == 90 ? -1 : deg == 270 ? 1 : 0
		} 
		else {
			var angle = deg * Math.PI / 180
			var cos = Math.cos(angle)
			var sin = Math.sin(angle)
			sin = -sin
		}
		this.fx = cos / (Math.abs(cos) + Math.abs(sin))
		this.fy = sin / (Math.abs(cos) + Math.abs(sin))
		this.stopH = deg == 90 || deg == 270 ? this.scrollLeft : deg < 90 || deg > 270 ? this.scrollW : 0
		this.stopV = deg == 0 || deg == 180 ? this.scrollTop : deg < 180 ? 0 : this.scrollH
	}
}

ypSimpleScroll.prototype.overrideScrollSpeed = function(speed) {
	if (this.loaded) this.speed = speed
}


ypSimpleScroll.prototype.scrollTo = function(stopH, stopV, aniLen) {
	if (this.loaded){
		if (stopH != this.scrollLeft || stopV != this.scrollTop) {
			if (this.aniTimer) window.clearTimeout(this.aniTimer)
			this.lastTime = (new Date()).getTime()
			var dx = Math.abs(stopH - this.scrollLeft)
			var dy = Math.abs(stopV - this.scrollTop)
			var d = Math.sqrt(Math.pow(dx,2) + Math.pow(dy,2))
			this.fx = (stopH - this.scrollLeft) / (dx + dy)
			this.fy = (stopV - this.scrollTop) / (dx + dy)
			this.stopH = stopH
			this.stopV = stopV
			this.speed = d / aniLen * 1000
			window.setTimeout(this.gRef + ".scroll()", this.y.minRes)
		}
	}
}

ypSimpleScroll.prototype.jumpTo = function(nx, ny) { 
	if (this.loaded){
		nx = Math.min(Math.max(nx, 0), this.scrollW)
		ny = Math.min(Math.max(ny, 0), this.scrollH)
		this.scrollLeft = nx
		this.scrollTop = ny
		if (this.y.ns4)this.content.moveTo(-nx, -ny)
		else {
			this.content.style.left = -nx + "px"
			this.content.style.top = -ny + "px"
		}
	}
}

ypSimpleScroll.minRes = 10
ypSimpleScroll.ie = document.all ? 1 : 0
ypSimpleScroll.ns4 = document.layers ? 1 : 0
ypSimpleScroll.dom = document.getElementById ? 1 : 0
ypSimpleScroll.mac = navigator.platform == "MacPPC"
ypSimpleScroll.mo5 = document.getElementById && !document.all ? 1 : 0

ypSimpleScroll.prototype.scroll = function(deg,count) {
	this.aniTimer = window.setTimeout(this.gRef + ".scroll('"+deg+"','"+count+"')", this.y.minRes)
	var nt = (new Date()).getTime()
	var d = Math.round((nt - this.lastTime) / 1000 * this.speed)
	if (d > 0){
		var nx = d * this.fx + this.scrollLeft
		var ny = d * this.fy + this.scrollTop
		var xOut = (nx >= this.scrollLeft && nx >= this.stopH) || (nx <= this.scrollLeft && nx <= this.stopH)
		var yOut = (ny >= this.scrollTop && ny >= this.stopV) || (ny <= this.scrollTop && ny <= this.stopV)
		if (nt - this.lastTime != 0 && 
			((this.fx == 0 && this.fy == 0) || 
			(this.fy == 0 && xOut) || 
			(this.fx == 0 && yOut) || 
			(this.fx != 0 && this.fy != 0 && 
			xOut && yOut))) {
			this.jumpTo(this.stopH, this.stopV)
			this.endScroll()
		}
		else {
			this.jumpTo(nx, ny)
			this.lastTime = nt
		}
	// (zgtc) now we also update dragger position:
	if(deg=='270')	theThumb[count].style.top = parseInt(((theThumb[count].maxY-theThumb[count].minY)*this.scrollTop/this.stopV)+theThumb[count].minY) + "px"; //ok nomes down
	if(deg=='90')	theThumb[count].style.top = parseInt(((theThumb[count].maxY-theThumb[count].minY)*this.scrollTop/this.scrollH)+theThumb[count].minY) + "px"; //ok nomes down
	}
}

function ypSimpleScroll(id, left, top, width, height, speed) {
	var y = this.y = ypSimpleScroll
	if (document.layers && !y.ns4) history.go(0)
	if (y.ie || y.ns4 || y.dom) {
		this.loaded = false
		this.id = id
		this.origSpeed = speed
		this.aniTimer = false
		this.op = ""
		this.lastTime = 0
		this.clipH = height
		this.clipW = width
		this.scrollTop = 0
		this.scrollLeft = 0
		this.gRef = "ypSimpleScroll_"+id
		eval(this.gRef+"=this")
		var d = document
		d.write('<style type="text/css">')
		d.write('#' + this.id + 'Container { left:' + left + 'px; top:' + top + 'px; width:' + width + 'px; height:' + height + 'px; clip:rect(0 ' + width + ' ' + height + ' 0); overflow:hidden; }')
		d.write('#' + this.id + 'Container, #' + this.id + 'Content { position:absolute; }')
		d.write('#' + this.id + 'Content { left:' + (-this.scrollLeft) + 'px; top:' + (-this.scrollTop) + 'px; width:' + width + 'px; }')
		// (zgtc) fix to overwrite p/div/ul width (would be clipped if wider than scroller in css):
		d.write('#' + this.id + 'Container p, #' + this.id + 'Container div {width:' + parseInt(width-10) + 'px; }')
		d.write('</style>')
	}
}

ypSimpleScroll.prototype.load = function() {
	var d, lyrId1, lyrId2
	d = document
	lyrId1 = this.id + "Container"
	lyrId2 = this.id + "Content"
	this.container = this.y.dom ? d.getElementById(lyrId1) : this.y.ie ? d.all[lyrId1] : d.layers[lyrId1]
	this.content = obj2 = this.y.ns4 ? this.container.layers[lyrId2] : this.y.ie ? d.all[lyrId2] : d.getElementById(lyrId2)
	this.docH = Math.max(this.y.ns4 ? this.content.document.height : this.content.offsetHeight, this.clipH)
	this.docW = Math.max(this.y.ns4 ? this.content.document.width : this.content.offsetWidth, this.clipW)
	this.scrollH = this.docH - this.clipH
	this.scrollW = this.docW - this.clipW
	this.loaded = true
	this.scrollLeft = Math.max(Math.min(this.scrollLeft, this.scrollW),0)
	this.scrollTop = Math.max(Math.min(this.scrollTop, this.scrollH),0)
	this.jumpTo(this.scrollLeft, this.scrollTop)
}


// ==============================================================
// 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(document.getElementById) {
		theScroll[count] = new ypSimpleScroll(id, left, top, width, height, speed);
	}
}

function createDragger(count, handler, root, thumb, minX, maxX, minY, maxY){
/*
This is a Q and D way of making the scrollbars disappear when they are not needed. If the scrollbars are not
needed we replace them with clear images of the same size. All the code runs the same, but the scrollbars are invisible.
Chris Hilder 4/11/2008
*/
if (document.getElementById("scroll"+count+"Content"))
{

if (document.getElementById("scroll"+count+"Content").scrollHeight <= document.getElementById("root"+count).scrollHeight)
		var buttons = '<div class="up" id="up'+count+'"><a href="#" onmouseover="theScroll['+count+'].scrollNorth(\''+count+'\')" onmouseout="theScroll['+count+'].endScroll()" onclick="return false;"><img src="clear_up.gif" width="15" height="15"></a></div><div class="dn"  id="dn'+count+'""><a href="#" onmouseover="theScroll['+count+'].scrollSouth(\''+count+'\')" onmouseout="theScroll['+count+'].endScroll()" onclick="return false;"><img src="clear_dn.gif" width="15" height="15"></a></div><div class="thumb" id="'+thumb+'" style="left: 135px; top: 15px;"><img src="clear_thumb.gif" width="15" height="15"></div>';
else
		var buttons = '<div class="up" id="up'+count+'"><a href="#" onmouseover="theScroll['+count+'].scrollNorth(\''+count+'\')" onmouseout="theScroll['+count+'].endScroll()" onclick="return false;"><img src="up.gif" width="15" height="15"></a></div><div class="dn"  id="dn'+count+'""><a href="#" onmouseover="theScroll['+count+'].scrollSouth(\''+count+'\')" onmouseout="theScroll['+count+'].endScroll()" onclick="return false;"><img src="dn.gif" width="15" height="15"></a></div><div class="thumb" id="'+thumb+'" style="left: 135px; top: 15px;"><img src="thumb.gif" width="15" height="15"></div>';
//================
		document.getElementById(root).innerHTML = buttons + document.getElementById(root).innerHTML;

		theRoot[count]   = document.getElementById(root);
		theThumb[count]  = document.getElementById(thumb);
		var thisup = document.getElementById("up"+count);
		var thisdn = document.getElementById("dn"+count);
		theThumb[count].style.left = parseInt(minX+15) + "px";
		thisup.style.left = parseInt(minX+15) + "px";
		thisdn.style.left = parseInt(minX+15) + "px";
		theThumb[count].style.border =0;
		theThumb[count].style.top = parseInt(minY) + "px";
		thisup.style.top = 0 + "px";
		thisdn.style.top = parseInt(minY+maxY) + "px";
		//thisdn.style.top = 15 + "px";

		theScroll[count].load();

		//Drag.init(theHandle[count], theRoot[count]); //not draggable on screen
		Drag.init(theThumb[count], null, minX+15, maxX+15, minY, maxY);
		
		// the number of pixels the thumb can travel vertically (max - min)
		thumbTravel[count] = theThumb[count].maxY - theThumb[count].minY;

		// the ratio between scroller movement and thumbMovement
		ratio[count] = theScroll[count].scrollH / thumbTravel[count];

		theThumb[count].onDrag = function(x, y) {
			theScroll[count].jumpTo(null, Math.round((y - theThumb[count].minY) * ratio[count]));
		}
}
}	

// 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, theScroll[i].clipW, theScroll[i].clipW, 15, theScroll[i].clipH-30);
		}
	}
}) 

	instantiateScroller(1, "scroll1", 7, 0, 780, 170, 150);
	instantiateScroller(0, "scroll0", 0, 0, 374, 180, 150);


