

	///////////////////////////////////////////////////////////////////
	//
	// Project: hager-ag
	// Module: image bar slider functions
	//
	// Patrick Sibenaler info@sibenaler.com
	// Jan 2005
	//
	// V 1.0
	//
	// Description: Init, update and scroll the image bar
	//
	///////////////////////////////////////////////////////////////////


	// init
	var intervall = 40;			// ms update recall
	var velocity = 0;			// start velocity of the bar
	var leftedge = 0;			// start position of the bar
	var bar_init_ok = 0;		// make sure the bar is set up, before scrolling it (events)
	var maxspeed = 10;			// maximum speed of bar scrolling



	///////////////////////////////////////////////////////////////////
	// setup event handlers
	if (document.layers){							// ns4

		window.captureEvents(Event.RESIZE) ;		//window resize
		window.onresize = bar_init;

		document.captureEvents(Event.MOUSEMOVE);	// mouse move within the doc
		document.onmousemove = bar_update;

	}else if (document.all){						// ie

		window.onresize = bar_init;					// window resize

		document.onmousemove = bar_update;			// mouse move within doc

	}else if (window.addEventListener){

		window.addEventListener("resize" , bar_init , false) ;	// window resize

		document.onmousemove = bar_update;			// mouse move within doc

	};


	///////////////////////////////////////////////////////////////////
	// set doc size
	function bar_init(){

		if (document.all) {

			doc_x = document.body.offsetWidth;
			doc_y = document.body.offsetHeight;

		}else if (document.layers || document.getElementById){

			doc_x = window.innerWidth;
			doc_y = window.innerHeight;

		}
		bar_init_ok = 1;

	}

	///////////////////////////////////////////////////////////////////
	// update velocity (called on mousemove)
	function bar_update(myEventObject){

		if (bar_init_ok == 1){

			if(document.getElementById || document.all) {			//ie & mozilla

				if(document.all){
					var myEventObject = window.event;
				}
				mouse_x = myEventObject.clientX;

			}

			if(document.layers){									//ns4

				mouse_x = myEventObject.pageX;

			}

			mousemax = doc_x/2;		// max mouse offset
			velocity = -(mouse_x - mousemax) / mousemax * maxspeed;

		}
	}


	///////////////////////////////////////////////////////////////////
	// slide the bar
	function bar_slide(divID) {

		velocity = velocity - (velocity / 40);	// slow down when not active

		if (document.layers){					// ns4

			leftedge = leftedge + velocity;
			if (leftedge + document.layers['myId'].document.width < doc_x){ leftedge = doc_x - document.layers['myId'].document.width; }
			if (leftedge > 0) { leftedge=0; }
			document.layers[divID].left = leftedge;

		}else if (document.all){				// ie

			leftedge = leftedge + velocity;
			if (leftedge + document.all(divID).offsetWidth < doc_x ){ leftedge = doc_x - document.all(divID).offsetWidth; }
			if (leftedge > 0) { leftedge=0; }
			document.all(divID).style.left = leftedge;

		}else if (document.getElementById){		// ns6

			// divwidth in moz is recalculated on the fly and matches the 'visible' portion at first!!
			// will get bigger when 'scrolling into the window' - so we can't compare to the orig value, but 
			// let it 'scroll in' a little bit... best solution so far.
			// also, it needs the style attribute width: auto !!
			rightslip = 20;  // number of pixels we let the div slip into the window
			leftedge = leftedge + velocity;
			if (leftedge + document.getElementById(divID).offsetWidth < doc_x - rightslip ){ leftedge = doc_x - document.getElementById(divID).offsetWidth - rightslip; }
			if (leftedge > 0) { leftedge=0; }
			document.getElementById(divID).style.left = leftedge;


		}
	}



	///////////////////////////////////////////////////////////////////
	// set bar label
	function bar_label(setText) {

		finaltxt = "<font class=text>" + setText + "</font>";

		if (document.layers){					// ns4

			document.layers['bar_label'].innerHTML = finaltxt;

		}else if (document.all){				// ie

			document.all('bar_label').innerHTML = finaltxt;

		}else if (document.getElementById){		// ns6

			document.getElementById('bar_label').innerHTML = finaltxt;

		}

	}

