//Manual Scroller- © Dynamic Drive 2001
//For full source code, visit http://www.dynamicdrive.com

var vert_obj;
var vert_contentheight;
var horiz_obj;
var horiz_contentwidth;
var speed;
var iens6;
var ns4;

function initscrolling(){
	//specify speed of scroll (greater=faster)
	speed = 5

	iens6 = document.all || document.getElementById
	ns4 = document.layers

	if (iens6){
		vert_obj = document.getElementById? document.getElementById("vert_content") : document.all.vert_content
		vert_contentheight = vert_obj.offsetHeight

		horiz_obj = document.getElementById? document.getElementById("horiz_content") : document.all.horiz_content
		horiz_contentwidth = horiz_obj.offsetWidth
	}
	else if (ns4){
		vert_obj = document.nsvertcontainer.document.nsvertcontent
		vert_contentheight = vert_obj.clip.height

		horiz_obj = document.nshorizcontainer.document.nshorizcontent
		horiz_contentwidth = horiz_obj.clip.width
	}

	//set the pos
	var searchdata = window.location.search.substr(1);
	var searcharray = searchdata.split(/[&;]/g);
	for(var i = 0; i < searcharray.length; i ++){
		var searchpair = searcharray[i].split('=');
		if(searchpair[0] == "hpos"){
			if (iens6)
				horiz_obj.style.left = searchpair[1];
			else
				horiz_obj.left += searchpair[1];
		}
	}

}
	
function imagelinker(link){
	if (iens6){
		var sURL = unescape(link + "?hpos=" + horiz_obj.style.left);
		window.open(sURL,'_self');
		//window.open(link + "?hpos=" + horiz_obj.style.left, "_top");
		//alert("sup!!!!!!@");
		//window.open(link + "?hpos=" + horiz_obj.style.left, "_self");
	}else if (ns4){
		window.open(link + "?hpos=" + horiz_obj.left, "_self");
	}
}

function movedown(){
	if (window.moveupvar) clearTimeout(moveupvar)
	if (iens6 && parseInt(vert_obj.style.top) >= (vert_contentheight * (-1) + 230))
		vert_obj.style.top = parseInt(vert_obj.style.top) - speed + "px"
	else if (ns4 && vert_obj.top >= (vert_contentheight * (-1) + 230))
		vert_obj.top -= speed
	movedownvar = setTimeout("movedown()", 20)
}

function moveup(){
	if (window.movedownvar) clearTimeout(movedownvar)
	if (iens6 && parseInt(vert_obj.style.top) <= 0)
		vert_obj.style.top = parseInt(vert_obj.style.top) + speed + "px"
	else if (ns4 && vert_obj.top <= 0)
		vert_obj.top += speed
	moveupvar=setTimeout("moveup()", 20)
}

/***
dan stanfield
stops all scrolling
8/2/07 - added left & right stops
***/
function stopscroll(){
	if (window.moveupvar) clearTimeout(moveupvar)
	if (window.movedownvar) clearTimeout(movedownvar)
	if (window.moveleftvar) clearTimeout(moveleftvar)
	if (window.moverightvar) clearTimeout(moverightvar)
}


function movetop(){
	stopscroll()
	if (iens6)
		crossobj.style.top = 0 + "px"
	else if (ns4)
		crossobj.top = 0
}

function getcontent_height(){
	if (iens6)
		vert_contentheight = crossobj.offsetHeight
	else if (ns4)
		document.nscontainer.document.nscontent.visibility = "show"
}

function getcontent_width(){
	if (iens6)
		horiz_contentwidth = crossobj.offsetWidth
	else if (ns4)
		document.nscontainer.document.nscontent.visibility = "show"
}


function setscrollhorizpos(pos){
	if (iens6 && parseInt(horiz_obj.style.left) < 0)
		horiz_obj.style.left = pos;
	else if (ns4 && horiz_obj.left <= 0)
		horiz_obj.left += pos;
}

/***
dan stanfield
scrolling to the left
***/
function moveleft(){
	var browser = window.navigator.userAgent;
	


//	iens6 = window.ActiveXObject;
	//Image Stop logic
	var endOfScroll = (horiz_contentwidth * (-1));
	if (parseInt(horiz_obj.style.left) == (endOfScroll-148)){
		return false;
	}
	if (window.moveleftvar){
		clearTimeout(moveleftvar);
	}
	
	if (typeof document.body.style.maxHeight != "undefined") {
    // IE 7, mozilla, safari, opera 9
  		if (browser.indexOf('Safari') > -1){
			horiz_obj = document.getElementById? document.getElementById("horiz_content") : document.all.horiz_content;
			horiz_contentwidth = horiz_obj.offsetWidth;
			if (horiz_obj.scrollWidth < 410 ){}
			else if (parseInt(horiz_obj.style.left) >= (horiz_contentwidth * (-1) + 535)){
				horiz_obj.style.left = parseInt(horiz_obj.style.left) - speed + "px";
			}
		}else {
			horiz_obj = document.getElementById? document.getElementById("horiz_content") : document.all.horiz_content;
			horiz_contentwidth = horiz_obj.offsetWidth;
			if (horiz_obj.scrollWidth < 410 ){}
			else if (parseInt(horiz_obj.style.left) >= (horiz_contentwidth * (-1) + 535)){
				horiz_obj.style.left = parseInt(horiz_obj.style.left) - speed + "px";
			}
		}
	} else {
	// IE6, older browsers
		if (parseInt(horiz_obj.style.left) >= (horiz_contentwidth * (-1) + 535)){
				horiz_obj.style.left = parseInt(horiz_obj.style.left) - speed + "px";
			}else if (ns4)
				if(horiz_obj.left >= (horiz_contentwidth * (-1) + 310)){
					horiz_obj.right -= speed;
				}
	}
	
	moveleftvar=setTimeout("moveleft()", 10);
	
}

/***
dan stanfield
scrolling to the right
***/
function moveright(){
	
	if (iens6 && parseInt(horiz_obj.style.left) < 0){
		horiz_obj.style.left = parseInt(horiz_obj.style.left) + speed + "px";
	}else if (ns4 && horiz_obj.left <= 0){
		horiz_obj.left += speed;
	}else if (vert_obj.top >= (horiz_contentwidth * (-1) + 310)){
		vert_obj.top -= speed;

	}else{
		//horiz_obj.style.right = parseInt(horiz_obj.style.left) - speed + "px";

	}
	moverightvar = setTimeout("moveright()", 10);
	
	


}
