function mouse_pos(e) {
	if(!e) e = window.event;
	var body = (window.document.compatMode && window.document.compatMode == "CSS1Compat") ? 
	window.document.documentElement : window.document.body;
	mouseLeft = (e.pageX) ? e.pageX : e.clientX + body.scrollLeft - body.clientLeft;
	return mouseLeft;
}

function stop_scrolling(){
    window.document.onmousemove = null;
}
	
document.onmouseup = stop_scrolling;

function scroll_it(e){
	my_mouse_x = mouse_pos(e);
	if ( my_mouse_x > (conLeft+10) && my_mouse_x < (conLeft+857) ) {
    	document.getElementById("scrollbar").firstChild.style.left = (my_mouse_x -conLeft) + "px";
    	document.getElementById("image_conainer").firstChild.style.left = (my_mouse_x -conLeft) *scrollfact + "px";
   } else {
   	if ( my_mouse_x < conLeft ) {
   		document.getElementById("scrollbar").firstChild.style.left = "10px";
   		document.getElementById("image_conainer").firstChild.style.left = "0px";
   	} else if (my_mouse_x > (conLeft+857) ) {
   		document.getElementById("scrollbar").firstChild.style.left = "857px";
   		document.getElementById("image_conainer").firstChild.style.left = (877-conWidth)+"px";
   	}
   }
}

function start_scrolling() {
	mouseDistance = 0;
	window.document.onmousemove = scroll_it;
}


function init() {
	conWidth = document.getElementById("image_conainer").firstChild.offsetWidth;
	if (!conWidth) window.setTimeout("init()",500);
	if ( conWidth > 820 ) {
		document.getElementById("scrollbar").style.visibility = "visible";
		conLeft = window.innerWidth/2-440;
		if (isNaN(conLeft)) {
			conLeft = document.body.clientWidth/2-440;
		}
		scrollfact = (conWidth -877)/857 *-1;
	}
}

