﻿/* 

	Easy Scroll v1.0
	written by Alen Grakalic, provided by Css Globe (cssglobe.com)
	please visit http://cssglobe.com/post/1495/easy-scroll-accessible-content-scroller
	
*/

this.easyscroll = function() {

	// id of the container element 
	var id = "myContent";

	// navigation buttons text
	var nav = [" ", " ", " "];

	//	id for each navigation button (OPTIONAL)
	var navId = ["btnUp", "btnDown", "btnReset"];

	// movement speed
	var speed = 5;

	// desired height of the container element (in pixels)
	var height = 200;

	//
	// END CONFIG
	// do not edit below this line (unless you want to of course :) )
	//
	
	/*
	javascript: alert($get('easyscroll').innerHTML);
	---------------------------
Microsoft Internet Explorer
---------------------------
<DIV id=myContent style="LEFT: 0px; POSITION: absolute; TOP: 0px" up="false" down="false" fast="false" interval="57346463">
<P>The most versatile air charter option for small numbers of passengers over a short distance, Air Taxi aircraft are perfect for that last minute business meeting or beating a lengthy commute. As well as the large international airports, typical Air Taxi aircraft are able to operate into the many hundreds of small airstrips not serviced by the airlines, getting you closer to your destination.<BR><BR>If you are looking to get away from the harsh environment and long waiting times associated with the airport terminal and want to try the simplicity of air charter, then Air Taxi is for you. An Air Taxi is a great way to get to sporting events, special family occasions or shuttle potential clients to your latest marketing event.<BR><BR>Fast and affordable, flexible and responsive, Air Taxi charter makes perfect business sense. Contact our dedicated team of charter specialists who are on hand to guide you through the aircraft available for your particular requirements.</P></DIV>
---------------------------
OK   
---------------------------

	*/
	var obj = document.getElementById(id);

	if (!obj) return; /* james */
	
	obj.up = false;
	obj.down = false;
	obj.fast = false;

	var container = document.createElement("div");
	var parent = obj.parentNode;
	container.id = "easyscroll";
	parent.insertBefore(container, obj);
	parent.removeChild(obj);

	container.style.position = "absolute";
	container.style.height = height + "px";
	container.style.overflow = "hidden";
	container.style.position = "absolute";
	container.style.marginLeft = "0px";
	container.style.paddingLeft = "0px";
	container.style.left = "0px";
	obj.style.position = "relative";
	obj.style.top = "0px";
	obj.style.left = "0px";
	container.appendChild(obj);

	var btns = new Array();
	var ul = document.createElement("ul");
	ul.id = "easyscrollnav";
	ul.style.position = "relative";
	ul.style.zIndex = "100";
	for (var i = 0; i < nav.length; i++) {
		var li = document.createElement("li");
		li.style.textAlign = "left";
		li.style.position = "absolute";
		ul.style.zIndex = "100";
		li.style.right = "0px";
		if (i == 1) li.style.top = "30px";
		if (i == 1) li.style.zIndex = "50";
		if (i == 2) li.style.top = "60px";
		if (i == 2) li.style.zIndex = "10";
		li.innerHTML = nav[i];
		li.id = navId[i];
		btns.push(li);
		ul.appendChild(li);
	};
	parent.insertBefore(ul, container);

	btns[0].onmouseover = function() {
		obj.up = true;
		this.className = "over";
	};
	btns[0].onmouseout = function() {
		obj.up = false;
		this.className = "";
	};
	btns[1].onmouseover = function() {
		obj.down = true;
		this.className = "over";
	};
	btns[1].onmouseout = function() {
		obj.down = false;
		this.className = "";
	};
	btns[0].onmousedown = btns[1].onmousedown = function() {
		obj.fast = true;
	};
	btns[0].onmouseup = btns[1].onmouseup = function() {
		obj.fast = false;
	};
	btns[2].onmouseover = function() {
		this.className = "over";
	};
	btns[2].onmouseout = function() {
		this.className = "";
	};
	btns[2].onclick = function() {
		obj.style.top = "0px";
	};

	this.start = function() {
		var newTop;
		var objHeight = obj.offsetHeight;
		var top = obj.offsetTop;
		var fast = (obj.fast) ? 2 : 1;
		if (obj.down) {
			newTop = ((objHeight + top) > height) ? top - (speed * fast) : top;
			obj.style.top = newTop + "px";
		};
		if (obj.up) {
			newTop = (top < 0) ? top + (speed * fast) : top;
			obj.style.top = newTop + "px";
		};
	};
	obj.interval = setInterval("start()", 50);

};


//
// script initiates on page load. 
//

this.addEvent = function(obj,type,fn){
	if(obj.attachEvent){
		obj['e'+type+fn] = fn;
		obj[type+fn] = function(){obj['e'+type+fn](window.event );}
		obj.attachEvent('on'+type, obj[type+fn]);
	} else {
		obj.addEventListener(type,fn,false);
	};
};
addEvent(window,"load",easyscroll)