// ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// 
// Coded by Travis Beckham
// http://www.squidfingers.com | http://www.podlob.com
// If want to use this code, feel free to do so, but please leave this message intact.
//
// ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// --- version date: 01/24/03 ---------------------------------------------------------

//
// Minor modifications by Ryan Quigley for exhibit-E.com
//
// --- version date: 01/24/03 ---------------------------------------------------------

// ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// Cross-Browser Functions

var dom = document.getElementById;
var iex = document.all;

function addEvent(event,method){
	this[event] = method;
}
function removeEvent(event){
	this[event] = null;
}
function getElement(name,nest){
	nest = nest ? "document."+nest+"." : "";
	var el = dom ? document.getElementById(name) : iex ? document.all[name] : false;
	el.css = el.style;
	el.getTop = function(){return parseInt(el.css.top) || 0};
	el.setTop = function(y){el.css.top = y+"px"};
	el.getHeight = function(){return el.offsetHeight};
	el.getClipHeight = function(){return el.offsetHeight};
	el.hideVis = function(){el.css.visibility="hidden"};
	el.addEvent = addEvent;
	el.removeEvent = removeEvent;
	return el;
}
function getYMouse(e){
	if (!e) var e = window.event;
	if (e.PageY)
		return e.pageY;
	else if (e.clientY)
		return e.clientY + document.body.scrollTop;	
}

document.addEvent = addEvent;
document.removeEvent = removeEvent;

// ||||||||||||||||||||||||||||||||||||||||||||||||||
// Scroller Class

ScrollObj = function(speed, dragHeight, trackHeight, trackObj, upObj, downObj, dragObj, contentMaskObj, contentObj){
	this.speed = speed;
	this.dragHeight = dragHeight;
	this.trackHeight = trackHeight;
	this.trackObj = getElement(trackObj);
	this.upObj = getElement(upObj);
	this.downObj = getElement(downObj);
	this.dragObj = getElement(dragObj);
	this.contentMaskObj = getElement(contentMaskObj);
	this.contentObj = getElement(contentObj,contentMaskObj);
	this.obj = contentObj+"Object";
	eval(this.obj+"=this");
	
	this.trackTop = this.dragObj.getTop();
	this.trackLength = this.trackHeight-this.dragHeight;
	this.trackBottom = this.trackTop+this.trackLength;
	this.contentMaskHeight = this.contentMaskObj.getClipHeight();
	this.contentHeight = this.contentObj.getHeight();
	this.contentLength = this.contentHeight-this.contentMaskHeight;
	this.scrollLength = this.trackLength/this.contentLength;
	this.scrollTimer = null;
	
	if(this.contentHeight <= this.contentMaskHeight){
		this.dragObj.hideVis();
		this.upObj.hideVis();
		this.downObj.hideVis();
		this.trackObj.hideVis();
	}else{
		var self = this;
		this.trackObj.addEvent("onmousedown", function(e){self.scrollJump(e);return false});
		this.upObj.addEvent("onmousedown", function(){self.scroll(self.speed);return false});
		this.upObj.addEvent("onmouseup", function(){self.stopScroll()});
		this.upObj.addEvent("onmouseout", function(){self.stopScroll()});
		this.downObj.addEvent("onmousedown", function(){self.scroll(-self.speed);return false});
		this.downObj.addEvent("onmouseup", function(){self.stopScroll()});
		this.downObj.addEvent("onmouseout", function(){self.stopScroll()});
		this.dragObj.addEvent("onmousedown", function(e){self.startDrag(e);return false});
		if(iex) this.dragObj.addEvent("ondragstart", function(){return false});
	}
}
ScrollObj.prototype.startDrag = function(e){
	this.dragStartMouse = getYMouse(e);
	this.dragStartOffset = this.dragObj.getTop();
	var self = this;
	document.addEvent("onmousemove", function(e){self.drag(e)});
	document.addEvent("onmouseup", function(){self.stopDrag()});
}
ScrollObj.prototype.stopDrag = function(){
	document.removeEvent("onmousemove");
	document.removeEvent("onmouseup");
}
ScrollObj.prototype.drag = function(e){
	var currentMouse = getYMouse(e);
	var mouseDifference = currentMouse-this.dragStartMouse;
	var dragDistance = this.dragStartOffset+mouseDifference;
	var dragMovement = (dragDistance<this.trackTop) ? this.trackTop : (dragDistance>this.trackBottom) ? this.trackBottom : dragDistance;
	this.dragObj.setTop(dragMovement);
	var contentMovement = -(dragMovement-this.trackTop)*(1/this.scrollLength);
	this.contentObj.setTop(contentMovement);
}
ScrollObj.prototype.scroll = function(speed){
	var contentMovement = this.contentObj.getTop()+speed;
	var dragMovement = this.trackTop-Math.round(this.contentObj.getTop()*(this.trackLength/this.contentLength));
	if(contentMovement > 0){
		contentMovement = 0;
	}else if(contentMovement < -this.contentLength){
		contentMovement = -this.contentLength;
	}
	if(dragMovement < this.trackTop){
		dragMovement = this.trackTop;
	}else if(dragMovement > this.trackBottom){
		dragMovement = this.trackBottom;
	}
	this.contentObj.setTop(contentMovement);
	this.dragObj.setTop(dragMovement);
	this.scrollTimer = window.setTimeout(this.obj+".scroll("+speed+")",25);
}
ScrollObj.prototype.stopScroll = function(){
	if(this.scrollTimer){
		window.clearTimeout(this.scrollTimer);
		this.scrollTimer = null;
	}
}
ScrollObj.prototype.scrollJump = function(e){

	var currentMouse = getYMouse(e);
	var dragDistance = currentMouse - findPosY(this.trackObj);
	var dragMovement = (dragDistance<this.trackTop) ? this.trackTop : (dragDistance>this.trackBottom) ? this.trackBottom : dragDistance;
	this.dragObj.setTop(dragMovement);
	var contentMovement = -(dragMovement-this.trackTop)*(1/this.scrollLength);
	this.contentObj.setTop(contentMovement);

}
// findPosY from http://www.quirksmode.org
function findPosY(obj)
{
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}

function RunFoo()
{
   document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="158" height="482">\n');
   document.write('<param name="movie" value="images/mapLrg.swf">\n');
   document.write('<param name="quality" value="high">\n');
   document.write('<param name="bgcolor" value="#363636">\n');
   document.write('<embed src="images/mapLrg.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" bgcolor="#363636" width="158" height="482"></embed>\n');
   document.write('</object>\n');
}

function RunFooSm()
{
   document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="84" height="320">\n');
   document.write('<param name="movie" value="images/mapSm.swf">\n');
   document.write('<param name="quality" value="high">\n');
   document.write('<param name="bgcolor" value="#363636">\n');
   document.write('<embed src="images/mapSm.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" bgcolor="#363636" width="84" height="320"></embed>\n');
   document.write('</object>\n');
}

function spec()
{
   document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="800" height="455">\n');
   document.write('<param name="movie" value="images/spec.swf">\n');
   document.write('<param name="quality" value="high">\n');
   document.write('<param name="wmode" value="transparent">\n');
   document.write('<param name="bgcolor" value="#4D251E">\n');
   document.write('<embed src="images/spec.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" bgcolor="#4D251E" width="800" height="455" wmode="transparent"></embed>\n');
   document.write('</object>\n');
}

function specSm()
{
   document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="600" height="320">\n');
   document.write('<param name="movie" value="images/specSm.swf">\n');
   document.write('<param name="quality" value="high">\n');
   document.write('<param name="wmode" value="transparent">\n');
   document.write('<param name="bgcolor" value="#4D251E">\n');
   document.write('<embed src="images/specSm.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" bgcolor="#4D251E" width="600" height="320" wmode="transparent"></embed>\n');
   document.write('</object>\n');
}

function remodEx()
{
document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="1440" height="445">\n');
	document.write('<param name="movie" value="improve4.swf">\n');
	document.write('<param name="quality" value="high">\n');
	document.write('<param name="wmode" value="transparent">\n');
	document.write('<embed src="improve4.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="1440" height="445" wmode="transparent"></embed>\n');
	document.write('</object>\n');
}

function remodMn()
{
document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="1440" height="445">\n');
	document.write('<param name="movie" value="improve5.swf">\n');
	document.write('<param name="quality" value="high">\n');
	document.write('<param name="wmode" value="transparent">\n');
	document.write('<embed src="improve5.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="1440" height="445" wmode="transparent"></embed>\n');
	document.write('</object>\n');
}

function movieMN()
{
document.write('<OBJECT classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" width="320" height="255" codebase="http://www.apple.com/qtactivex/qtplugin.cab">\n');
document.write('<param name="src" value="http://www.636molinoave.com/molinoSeg1.mp4">\n');
document.write('<param name="autoplay" value="false">\n');
document.write('<param name="controller" value="true">\n');
document.write('<param name="loop" value="false">\n');
document.write('<EMBED src="http://www.636molinoave.com/molinoSeg1.mp4" width="320" height="255" autoplay="false" controller="true" loop="false" pluginspage="http://www.apple.com/quicktime/download/">\n');
document.write('</EMBED>\n');
document.write('</OBJECT>\n');
}