Object.extend(Event, {
	wheel:function (event){
		var delta = 0;
		if (!event) event = window.event;
		if (event.wheelDelta) {
			delta = event.wheelDelta/120; 
			if (window.opera) delta = -delta;
		} else if (event.detail) { delta = -event.detail/3;	}
		return Math.round(delta); //Safari Round
	}
});

function setMenus(Urlo){

	var Url = Urlo.replace(/.*\?(.*?)/,"$1");
	var Variables = Url.split("&");
	for (i = 0; i < Variables.length; i++) {
	       Separ = Variables[i].split("=");
	       //eval ('var '+Separ[0]+'="'+Separ[1]+'"');
	}
	
	var url = Urlo.split("&")[0].replace("http://", "");
	var index =	url.indexOf("/");
	var menu = url.substring(index, url.indexOf("/", index + 4));
	var elem = $A($('espacio_menu').getElementsByTagName('a')).detect(function(item,index){
		return item.href.indexOf(menu) != -1;
	});
	//if (console) console.debug(elem)
	if (elem){
		if (document.all)
			elem.className = "selected";
		else
	 		elem.addClassName("selected");
	}else{
		
		$('espacio_menu').getElementsByTagName('a')[0].className = "selected";

	}
	
	
	elem = $A($('submenu').getElementsByTagName('a')).detect(function(item,index){ 
		return (item.href == Urlo);
	});
	if (elem){ 
		if (document.all)
			elem.className = "selected";
		else
	 		elem.addClassName("selected");
	}
}

function mouseWheel(e){
	//var ele = Event.element(e);
	document.getElementById('barra_txt').scrollTop = document.getElementById('barra_txt').scrollTop - (20 * Event.wheel(e));
	Event.stop(e);
}

myspeed=0;
thespeed=3;
function scrollwindow(){
	document.getElementById('barra_txt').scrollTop = document.getElementById('barra_txt').scrollTop + myspeed;
}

function initializeIT(){
	if (myspeed!=0){
		scrollwindow()
	}
}

var Scrollable = Class.create();
Scrollable.prototype = {
	initialize : function(e){
		this.element = $(e);
		
		
		
		Event.observe(this.element, "mousewheel", this.mouseWheel.bindAsEventListener(this), false);
		Event.observe(this.element, "DOMMouseScroll", this.mouseWheel.bindAsEventListener(this), false); // Firefox
		
		/*
		this.element.style.cursor = "move";
		this.element.onmousedown = this.mouseDown.bindAsEventListener(this);
		this.element.onmouseup = this.mouseUp.bindAsEventListener(this);
		this.element.onmousemove = this.mouseMove.bindAsEventListener(this);
		this.element.onmouseout = this.mouseOut.bindAsEventListener(this);*/
		
	},
	
	mouseWheel : function(e){
		//var ele = Event.element(e);
		this.element.scrollTop = this.element.scrollTop - (20 * Event.wheel(e));
		Event.stop(e);
	},
	
	mouseDown : function(e){
		this.scrolling = true;
		this.clientX = e.clientX;
		this.clientY = e.clientY;
		Event.stop(e);
	},
	
	mouseUp : function(e){
		this.scrolling = false;	
	},

	// si nos salimos del area dejar de arrastrar
	mouseOut : function(e){
		this.scrolling = false;	
	},
	

	mouseMove : function(e){
		if (!this.scrolling) return;
		
		this.element.scrollTop = this.element.scrollTop - (this.clientY - e.clientY);

		//console.debug(this.clientY - e.clientY);
	}

}

function toggleScroll(){
	Event.observe(window, "load", function(){
		

		if (document.all||document.getElementById||document.layers) setInterval("initializeIT()",20);

		//var effect = !document.all;
		var effect = false;
		
		//sIFR.replaceElement(named({sSelector:".Titular_Bold", sFlashSrc:"/flash/din_medium.swf", sColor:"#e65320", sWmode:"transparent"}));
		
		// si hay padding es que corresponde con la ficha de designers...
		if ($('barra_txt_content') && $('barra_txt_content').style.paddingTop == "250px"){
			$('staticbuttons-container').style.top = "360px";
		}
		
		if (effect){
			
			//$('barra_txt').style.display = "none";
			
	
			$('barra_txt_content').style.display = "none";
			
			setTimeout(function(){
				//$('barra_txt_content').style.display = "";
				
				try{
					new Effect.Appear('barra_txt_content');
					new Effect.BlindDown('barra_txt_content',{ duration: 2.0, afterFinish : function(){
							//console.debug(Element.getDimensions('barra_txt_content').height)
							//console.debug(Element.getDimensions('barra_txt').height)
	
							if (Element.getDimensions('barra_txt_content').height > Element.getDimensions('barra_txt').height){
								$('staticbuttons').style.display = "";
								new Scrollable('barra_txt');
							}
						} 
					});
					
					
				}catch(e){alert(e);}
				//
			},500);
		}else{
			if ($('barra_txt_content') && (Element.getDimensions('barra_txt_content').height > Element.getDimensions('barra_txt').height)){
				$('staticbuttons').style.display = "";
				new Scrollable('barra_txt');
			}

		}
	});
}