// JavaScript Document
/*****************************************************************************
sIFR 
*****************************************************************************/
var gotham_book = {
  src: 'gotham_book.swf'
};
sIFR.activate(gotham_book);

sIFR.replace(gotham_book, {
  selector: 'h2',
  wmode: 'transparent'
  ,css: [
	'.sIFR-root { text-align: left; color:#7D937D; letter-spacing: -0.5; font-size: 18; margin-top: 0;}'
	,'a { text-decoration: none; }'
	,'a:link { color: #617F51; }'
	,'a:hover { color: #617F51; }'
  ]
});

window.addEvent('domready', function(){
//detect IE6
	if(Browser.Engine.trident4)window.ie6=true;
							 
//scroll to top
	new SmoothScroll({ duration: 300 });

if(!window.ie6){
//detección y remplazo de tipografía
    d = new Detector();
	if(d.test('Corbel')){
		$$('p','ul','ol','input','textarea','select').setStyles({'font-family':'corbel','font-size':'15px'});
	}	

	//muestra flechitas scroll si el contenido horizontal es mayor al espacio de visualización
		contenedorX = $('contenedor').getStyle("width").toInt();
		windowX = window.getSize().x;
		if(contenedorX-windowX>0){
			$('nav_izq').setStyle('visibility','visible');
			$('nav_der').setStyle('visibility','visible');
		}
    
    //define si se muestra o no la flechita hacia el top
	window.addEvent('scroll',function() {
		if($(window).getScroll().x>0){ //muestra
			$('nav_top').setStyle('background-position','3px 167px');
		}else{ //oculta
			$('nav_top').setStyle('background-position','-20px 167px');	
		}
	});
	
	document.addEvent('keydown', function(event){
    //The passed event parameter is already an instance of the Event class.
    //alert(event.key);   //Returns the lowercase letter pressed.
	if(event.key=='"')window.scrollBy(windowX-325,0);;
	if(event.key=='!')window.scrollBy(-windowX+325,0);;
});

	
	//flechitas scroll (originalmente hice con mouseover y mouseout)
		$('nav_der').addEvent('mousedown', function(e){
			this.dx=setInterval('window.scrollBy(50,0)',50);
	   });
		$('nav_der').addEvent('dblclick', function(e){window.scrollBy(50,0)}); //para que IE no deje de avanzar si haces dos clicks seguidos
		$('nav_der').addEvent('mouseup', function(e){
			clearInterval(this.dx);
		});
		
	//flechitas scroll
		$('nav_izq').addEvent('mousedown', function(e){
			this.dx=setInterval('window.scrollBy(-50,0)',50);
	   });
		$('nav_izq').addEvent('dblclick', function(e){window.scrollBy(-50,0)}); //para que IE no deje de avanzar si haces dos clicks seguidos
		$('nav_izq').addEvent('mouseup', function(e){
			clearInterval(this.dx);
		});
}
//mousewheel scroll
	$(document).addEvent('mousewheel', function(e){ //opciones que no funcionaron bien fueron document.body o window
		e.stop(); // prevent the mousewheel from scrolling the page.
		var mover; 
		(e.wheel < 0 ? moverpag=+100 : moverpag=-100)
		window.scrollBy(moverpag,0);
	});
});
