//----------------- BASIC SLIDER FUNCTIONS ----------------------
// ***********************************************************************************
// ************************** Basic Slider Functionality ***********************************
// ***********************************************************************************
// Copyright (C) 1999 Thomas Brattli.
// This script is made by and copyrighted to Thomas Brattli at www.bratta.com
// Visit for more great scripts. This may be used freely as long as this msg is intact!
// I will also appriciate any links you could give me.
// ************************************************************************************
// ************************************************************************************
// ************************************************************************************

function checkBrowser() {
	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 checkBrowser();

function makeslider(obj,nest) {
	// NOTE: refNo (if specified) corresponds to the object's image number; eg. 2 for "button2"
	// x and y are the object's default position (within its wrapper DIV).
	nest=(!nest) ? '':'document.'+nest+'.'
	this.css=bw.dom?document.getElementById(obj).style:bw.ie4?document.all[obj].style:bw.ns4?eval(nest+'document.'+obj):0;
	this.evnt=bw.dom?document.getElementById(obj):bw.ie4?document.all[obj]:bw.ns4?this.css:0;
	this.showIt = b_showIt;
	this.hideIt = b_hideIt;
	this.moveIt = b_moveIt;
	this.slide = b_slide;
	this.slideIt = b_slideIt;
	this.setDefaultPos = b_setDefaultPos;
	this.slidTim = 0;
	this.clearTim = b_clearTim;
	this.obj = obj + "Object";
	eval(this.obj + "=this");
	return this
}

function b_showIt(){this.css.visibility="visible"}
function b_hideIt(){this.css.visibility="hidden"}

function b_moveIt(x,y) {this.x=x; this.y=y; this.css.left=this.x; this.css.top=this.y}

function b_slideIt(endx,endy,inc,speed,fn,wh) {
	if (!this.slideactive) {
	   var distx = endx - this.x;
	   var disty = endy - this.y;
	   var num = Math.sqrt(Math.pow(distx,2) + Math.pow(disty,2))/inc;
	   var dx = distx/num;
	   var dy = disty/num;
	   this.slideactive = 1;
	   this.slide(dx,dy,endx,endy,speed,fn,wh);
	}
}

function b_slide(dx,dy,endx,endy,speed,fn,wh) {
	if (!fn) fn = null; 
//	if (!wh) wh = null;
	if (this.slideactive && (Math.floor(Math.abs(dx))<Math.floor(Math.abs(endx-this.x)) || 
Math.floor(Math.abs(dy))<Math.floor(Math.abs(endy-this.y)))) {
		this.moveIt(this.x+dx,this.y+dy);
//		eval(wh);
		this.slidTim = setTimeout(this.obj+".slide("+dx+","+dy+","+endx+","+endy+","+speed+",'"+fn+"','"+wh+"')",speed)
	}
	else {
		 this.slideactive = 0;
		 this.moveIt(endx,endy);
		 eval(fn);
	}
}

//--------------- ADDITIONAL SLIDER FUNCTIONS FOR THIS IMPLEMENTATION -------------------
function b_setDefaultPos(x,y) {this.defaultX = x; this.defaultY = y}
function b_clearTim() {clearTimeout(this.slidTim)}



//------------------ SEQUENCING UTILITIES ------------------
	// start_polling: A function which allows the termination of a "setTimeout recursion" to be tested before something else starts.
	// Is useful for performing two or more sliding actions in sequence.
	// Must be called as follows:
	//     start_polling(unique_integer, 'condition', 'fn', interval);
	// where:
	// 	unique_integer :- is unique to each specific start_polling() call.
	// 	'condition' :- is a boolean expression representing the condition to be met (in string form) before fn is executed.
	// 	'fn' :- is the function to be executed (in string form)
	// 	interval :- is the polling interval in milliseconds (typically 250 minimum)
var poll_id_array = new Array(30);
function start_polling(index, condition, fn, interval) {
	if (typeof poll_id_array != "undefined") {
		if (poll_id_array[index] != null) {clearInterval(poll_id_array[index]);}
	}
	poll_id_array[index] = setInterval("poll_condition_function(" + index + ", 'poll_id_array[" + index + "]', '" + condition + "', '" + fn + "')", interval);
}

	// poll_condition_function: Called uniquely by start_polling.
function poll_condition_function(index, pollID, condition, fn, interval) {
	if (eval(condition)) {
		eval("clearInterval("+pollID+")");
		poll_id_array[index] = 0 // For poll monitoring
		eval(fn);
	}
}
