/* 

	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 = ["<img src='images/uparrow.png' style='cursor:pointer;' border='0' />", "<img src='images/downarrow.png' style='cursor:pointer;' border='0' />"];
	
	//	id for each navigation button (OPTIONAL)
	var navId = ["btnUp", "btnDown"];

	// movement speed
	var speed = 5;
	
	// desired height of the container element (in pixels)
	var height = 130;
	var width = 207;
	//
	// END CONFIG
	// do not edit below this line (unless you want to of course :) )
	//

	var obj = document.getElementById(id);
	
	obj.up = false;
	obj.down = false;
	obj.fast = false;

	var div_up = document.getElementById('div_up');
	var container = document.createElement("div");
	var div_down = document.getElementById('div_down');
	var parent = obj.parentNode;
	container.id="easyscroll";
	parent.insertBefore(container,obj);
	parent.removeChild(obj);		
	
	container.align = "center"
	container.style.position = "relative";
	container.style.height = height + "px";
	//container.style.width = width + "px";
	container.style.overflow = "hidden";
	//container.style.paddingLeft = "3px";
	container.style.paddingTop = "2px";
	container.style.marginRight = "0px";
	container.style.marginLeft = "0px";
	//container.style.paddingRight = "3px";
	container.style.paddingBottom = "2px";
	obj.style.position = "absolute";
	obj.style.top = "0";
	obj.style.left = "0";
	obj.style.right = "0";
	container.appendChild(obj);
	
	div_up.innerHTML = nav[0];
	div_down.innerHTML = nav[1];
	
	var btns = new Array();
	btns.push(div_up);
	btns.push(div_down);
	/*var ul = document.createElement("ul");
	ul.id="easyscrollnav";
	for (var i=0;i<nav.length;i++){
		var li = document.createElement("li");
		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);		
		
};

this.easyscroll_col = function(){
	
	// id of the container element 
	var id_col = "myContent_col";
	
	// navigation buttons text
	var nav_col = ["<img src='images/uparrow.png' style='cursor:pointer;' border='0' />", "<img src='images/downarrow.png' style='cursor:pointer;' border='0' />"];
	
	//	id for each navigation button (OPTIONAL)
	var navId_col = ["btnUp", "btnDown"];

	// movement speed
	var speed_col = 5;
	
	// desired height of the container element (in pixels)
	var height_col = 130;
	var width_col = 207;
	//
	// END CONFIG
	// do not edit below this line (unless you want to of course :) )
	//

	var obj_col = document.getElementById(id_col);
	
	obj_col.up = false;
	obj_col.down = false;
	obj_col.fast = false;

	var div_up_col = document.getElementById('div_up_col');
	var container_col = document.createElement("div");
	var div_down_col = document.getElementById('div_down_col');
	var parent_col = obj_col.parentNode;
	container_col.id = "easyscroll_col";
	parent_col.insertBefore(container_col,obj_col);
	parent_col.removeChild(obj_col);		
	
	container_col.style.position = "relative";
	container_col.style.height = height_col + "px";
	//container_col.style.width = "100%";
	container_col.style.overflow = "hidden";
	//container_col.style.paddingLeft = "3px";
	container_col.style.paddingTop = "2px";
	container_col.style.marginRight = "0px";
	container_col.style.marginLeft = "0px";
	//container_col.style.paddingRight = "3px";
	container_col.style.paddingBottom = "2px";
	obj_col.style.position = "absolute";
	obj_col.style.top = "0";
	obj_col.style.left = "0";
	obj_col.style.right = "0";
	container_col.appendChild(obj_col);
	
	div_up_col.innerHTML = nav_col[0];
	div_down_col.innerHTML = nav_col[1];
	
	var btns_col = new Array();
	btns_col.push(div_up_col);
	btns_col.push(div_down_col);
	/*var ul = document.createElement("ul");
	ul.id="easyscrollnav";
	for (var i=0;i<nav.length;i++){
		var li = document.createElement("li");
		li.innerHTML = nav[i];
		li.id = navId[i];
		//btns.push(li);
		ul.appendChild(li);
	}; */
	//parent.insertBefore(ul,container);
	
	btns_col[0].onmouseover = function(){
		obj_col.up = true;
		this.className = "over";
	};
	btns_col[0].onmouseout = function(){
		obj_col.up = false;
		this.className = "";
	};		
	btns_col[1].onmouseover = function(){
		obj_col.down = true;
		this.className = "over";		
	};
	btns_col[1].onmouseout = function(){
		obj_col.down = false;
		this.className = "";
	};		
	btns_col[0].onmousedown = btns_col[1].onmousedown = function(){
		obj_col.fast = true;
	};	
	btns_col[0].onmouseup = btns_col[1].onmouseup = function(){
		obj_col.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_col = function(){				
		var newTop_col;
		var objHeight_col = obj_col.offsetHeight;
		var top_col = obj_col.offsetTop;
		var fast_col = (obj_col.fast) ? 2 : 1;
		if(obj_col.down){		 
			newTop_col = ((objHeight_col+top_col) > height_col) ? top_col-(speed_col*fast_col) : top_col;	
			obj_col.style.top = newTop_col + "px";
		};	
		if(obj_col.up){		 
			newTop_col = (top_col < 0) ? top_col+(speed_col*fast_col) : top_col;
			obj_col.style.top = newTop_col + "px";
		};
	};	
	obj_col.interval = setInterval("start_col()",50);		
		
};

this.easyscroll_tem = function(){
	
	// id of the container element 
	var id_tem = "myContent_tem";
	
	// navigation buttons text
	var nav_tem = ["<img src='images/uparrow.png' style='cursor:pointer;' border='0' />", "<img src='images/downarrow.png' style='cursor:pointer;' border='0' />"];
	
	//	id for each navigation button (OPTIONAL)
	var navId_tem = ["btnUp", "btnDown"];

	// movement speed
	var speed_tem = 5;
	
	// desired height of the container element (in pixels)
	var height_tem = 130;
	var width_tem = 207;
	//
	// END CONFIG
	// do not edit below this line (unless you want to of course :) )
	//

	var obj_tem = document.getElementById(id_tem);
	
	obj_tem.up = false;
	obj_tem.down = false;
	obj_tem.fast = false;

	var div_up_tem = document.getElementById('div_up_tem');
	var container_tem = document.createElement("div");
	var div_down_tem = document.getElementById('div_down_tem');
	var parent_tem = obj_tem.parentNode;
	container_tem.id = "easyscroll_tem";
	parent_tem.insertBefore(container_tem,obj_tem);
	parent_tem.removeChild(obj_tem);		
	
	container_tem.style.position = "relative";
	container_tem.style.height = height_tem + "px";
	//container_tem.style.width = width_tem + "px";
	container_tem.style.overflow = "hidden";
	//container_tem.style.paddingLeft = "3px";
	container_tem.style.paddingTop = "2px";
	container_tem.style.marginRight = "0px";
	container_tem.style.marginLeft = "0px";
	//container_tem.style.paddingRight = "3px";
	container_tem.style.paddingBottom = "2px";
	obj_tem.style.position = "absolute";
	obj_tem.style.top = "0";
	obj_tem.style.left = "0";
	obj_tem.style.right = "0";
	container_tem.appendChild(obj_tem);
	
	div_up_tem.innerHTML = nav_tem[0];
	div_down_tem.innerHTML = nav_tem[1];
	
	var btns_tem = new Array();
	btns_tem.push(div_up_tem);
	btns_tem.push(div_down_tem);
	/*var ul = document.createElement("ul");
	ul.id="easyscrollnav";
	for (var i=0;i<nav.length;i++){
		var li = document.createElement("li");
		li.innerHTML = nav[i];
		li.id = navId[i];
		//btns.push(li);
		ul.appendChild(li);
	}; */
	//parent.insertBefore(ul,container);
	
	btns_tem[0].onmouseover = function(){
		obj_tem.up = true;
		this.className = "over";
	};
	btns_tem[0].onmouseout = function(){
		obj_tem.up = false;
		this.className = "";
	};		
	btns_tem[1].onmouseover = function(){
		obj_tem.down = true;
		this.className = "over";		
	};
	btns_tem[1].onmouseout = function(){
		obj_tem.down = false;
		this.className = "";
	};		
	btns_tem[0].onmousedown = btns_tem[1].onmousedown = function(){
		obj_tem.fast = true;
	};	
	btns_tem[0].onmouseup = btns_tem[1].onmouseup = function(){
		obj_tem.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_tem = function(){				
		var newTop_tem;
		var objHeight_tem = obj_tem.offsetHeight;
		var top_tem = obj_tem.offsetTop;
		var fast_tem = (obj_tem.fast) ? 2 : 1;
		if(obj_tem.down){		 
			newTop_tem = ((objHeight_tem+top_tem) > height_tem) ? top_tem-(speed_tem*fast_tem) : top_tem;	
			obj_tem.style.top = newTop_tem + "px";
		};	
		if(obj_tem.up){		 
			newTop_tem = (top_tem < 0) ? top_tem+(speed_tem*fast_tem) : top_tem;
			obj_tem.style.top = newTop_tem + "px";
		};
	};	
	obj_tem.interval = setInterval("start_tem()",50);		
		
};

this.easyscroll_prod = function(){
	
	// id of the container element 
	var id_prod = "myContent_prod";
	
	// navigation buttons text
	var nav_prod = ["<img src='images/uparrow.png' style='cursor:pointer;' border='0' />", "<img src='images/downarrow.png' style='cursor:pointer;' border='0' />"];
	
	//	id for each navigation button (OPTIONAL)
	var navId_prod = ["btnUp", "btnDown"];

	// movement speed
	var speed_prod = 5;
	
	// desired height of the container element (in pixels)
	var height_prod = 130;
	var width_prod = 207;
	//
	// END CONFIG
	// do not edit below this line (unless you want to of course :) )
	//

	var obj_prod = document.getElementById(id_prod);
	
	obj_prod.up = false;
	obj_prod.down = false;
	obj_prod.fast = false;

	var div_up_prod = document.getElementById('div_up_prod');
	var container_prod = document.createElement("div");
	var div_down_prod = document.getElementById('div_down_prod');
	var parent_prod = obj_prod.parentNode;
	container_prod.id = "easyscroll_prod";
	parent_prod.insertBefore(container_prod,obj_prod);
	parent_prod.removeChild(obj_prod);		
	
	container_prod.style.position = "relative";
	container_prod.style.height = height_prod + "px";
	//container_prod.style.width = width_prod + "px";
	container_prod.style.overflow = "hidden";
	//container_prod.style.paddingLeft = "3px";
	container_prod.style.paddingTop = "2px";
	container_prod.style.marginRight = "0px";
	container_prod.style.marginLeft = "0px";
	//container_prod.style.paddingRight = "3px";
	container_prod.style.paddingBottom = "2px";
	obj_prod.style.position = "absolute";
	obj_prod.style.top = "0";
	obj_prod.style.left = "0";
	obj_prod.style.right = "0";
	container_prod.appendChild(obj_prod);
	
	div_up_prod.innerHTML = nav_prod[0];
	div_down_prod.innerHTML = nav_prod[1];
	
	var btns_prod = new Array();
	btns_prod.push(div_up_prod);
	btns_prod.push(div_down_prod);
	/*var ul = document.createElement("ul");
	ul.id="easyscrollnav";
	for (var i=0;i<nav.length;i++){
		var li = document.createElement("li");
		li.innerHTML = nav[i];
		li.id = navId[i];
		//btns.push(li);
		ul.appendChild(li);
	}; */
	//parent.insertBefore(ul,container);
	
	btns_prod[0].onmouseover = function(){
		obj_prod.up = true;
		this.className = "over";
	};
	btns_prod[0].onmouseout = function(){
		obj_prod.up = false;
		this.className = "";
	};		
	btns_prod[1].onmouseover = function(){
		obj_prod.down = true;
		this.className = "over";		
	};
	btns_prod[1].onmouseout = function(){
		obj_prod.down = false;
		this.className = "";
	};		
	btns_prod[0].onmousedown = btns_prod[1].onmousedown = function(){
		obj_prod.fast = true;
	};	
	btns_prod[0].onmouseup = btns_prod[1].onmouseup = function(){
		obj_prod.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_prod = function(){				
		var newTop_prod;
		var objHeight_prod = obj_prod.offsetHeight;
		var top_prod = obj_prod.offsetTop;
		var fast_prod = (obj_prod.fast) ? 2 : 1;
		if(obj_prod.down){		 
			newTop_prod = ((objHeight_prod+top_prod) > height_prod) ? top_prod-(speed_prod*fast_prod) : top_prod;	
			obj_prod.style.top = newTop_prod + "px";
		};	
		if(obj_prod.up){		 
			newTop_prod = (top_prod < 0) ? top_prod+(speed_prod*fast_prod) : top_prod;
			obj_prod.style.top = newTop_prod + "px";
		};
	};	
	obj_prod.interval = setInterval("start_prod()",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);
	};
};

this.addEvent_col = 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);
	};
};

this.addEvent_tem = 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);
	};
};

this.addEvent_prod = 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);
addEvent_col(window,"load",easyscroll_col);
addEvent_tem(window,"load",easyscroll_tem);
addEvent_prod(window,"load",easyscroll_prod);

