/* 
Scroll Noticias
*/

this.ScrollNoticias = function(){
	
	// Id del Contenido
	var id = "Contenido";
	
	// velocidad
	var speed = 5;
	
	// altura del Contenido en pixels
	var height = 520;
	
	// Código de accción

	var obj = document.getElementById(id);
	
	obj.up = false;
	obj.down = false;
	obj.reset = false;
	
	var Contenido = document.createElement("div");
	var parent = obj.parentNode;
	Contenido.id="Contenido";
	parent.insertBefore(Contenido,obj);
	parent.removeChild(obj);	
	
	Contenido.style.position = "relative";
	Contenido.style.float = "left";
	
	Contenido.style.height = (height) + "px";
	Contenido.style.overflow = "hidden";
	obj.style.position = "absolute";
	obj.style.top = "0";
	obj.style.left = "0";
	obj.style.border = "0px";
	obj.style.padding = "1px";
	obj.style.width = "190px";
	Contenido.appendChild(obj);
	
	 //boton up	
	BotonFuncionSubir.onmouseover = function(){
		obj.up = true;
		this.className = "over";
	};
	BotonFuncionSubir.onmouseout = function(){
		obj.up = false;
		this.className = "";
	};
	//boton down	
	BotonFuncionBajar.onmouseover = function(){ 		
		obj.down = true;
		this.className = "over";
	};	
	BotonFuncionBajar.onmouseout = function(){ 		
		obj.down = false;
		this.className = "";
	};
	//boton top		
	BotonFuncionSubirTodo.onmouseover = function(){ 		
		obj.style.top = "0px";
	};		
	BotonFuncionSubirTodo.onmouseout = function(){ 		
		obj.style.top = "0px";
	};	
	this.start = function(){				
		var newTop;
		var objHeight = obj.offsetHeight;
		var top = obj.offsetTop;
		var fast = 2;
		if(obj.down){		 
			newTop = ((objHeight+top) > height) ? top-(speed) : top;	
			obj.style.top = newTop + "px";
		};		
		if(obj.up){		 
			newTop = (top < 0) ? top+(speed) : 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",ScrollNoticias);
