// DATALISTAS ******************************************************************

var oBody;


var DataListas = 
{
	
	
	init: function ()
	{
		oBody = $$('body').getProperty('id').toString();
		
		Features.start();
	}
	
};


// FEATURES ********************************************************************

var Features = 
{
	
	start: function ()
	{
		Features.logoTips();
		Features.subNavigation();
		
		switch ( oBody )
		{
		    case "home":
			    // mediatypes
			    new Accordion (	$$('dl#mediatypes dt') , $$('dl#mediatypes dd') , {	onActive: function(toggler, element){ toggler.addClass('active'); }, onBackground: function(toggler, element) { toggler.removeClass('active'); }, alwaysHide: true, start:'all-closed'});
			    Features.mySmoothScroll ();
			    break
			case "inner-content":   
    			break
			default:			
	    		break
		}
	},
	
	logoTips: function ()
	{
		var oLogo = $$('h1 a')[0];
		var oSlogan = $$('h2.slogan')[0];
		var oBody = $$('body').getProperty('id').toString();
		var styleProperty = 'background-position';
		var styleValueDefault = '0 0';
		var styleValueHome = '0 -64px';
		var styleValueOthers = '0 -128px';
		
		oLogo.addEvent('mouseover', function () {( oBody == 'home' ) ? oSlogan.setStyle(styleProperty, styleValueHome) : oSlogan.setStyle(styleProperty, styleValueOthers);});		
		oLogo.addEvent('mouseout', function () {oSlogan.setStyle(styleProperty, styleValueDefault);});	
	},
	
	// used to make horizontal smoothscroll
	mySmoothScroll: function()
	{
	    var scroll = new Fx.Scroll('contentmask', {
	        wait: false,
	        duration: 700,
	        transition: Fx.Transitions.Quad.easeInOut
        });
        
        
        $('aseta_esquerda1').addEvent('click', function(event) {
	        event = new Event(event).stop();
	        scroll.toElement('posicao1');
	        mudaSeta(1);
        });
        $('aseta_esquerda2').addEvent('click', function(event) {
	        event = new Event(event).stop();
	        scroll.toElement('posicao2');
	        mudaSeta(2);
        });
        $('aseta_direita1').addEvent('click', function(event) {
	        event = new Event(event).stop();
	        scroll.toElement('posicao2');
	        mudaSeta(3);
        });
        $('aseta_direita2').addEvent('click', function(event) {
	        event = new Event(event).stop();
	        scroll.toElement('posicao3');
	        mudaSeta(4);
        });
        /*$('nav-materias').addEvent('click', function(event) {
	        event = new Event(event).stop();
	        scroll.toElement('home-materias');
        });
        $('nav-colunistas').addEvent('click', function(event) {
	        event = new Event(event).stop();
	        scroll.toElement('home-colunistas');
        });
        $('nav-noticias').addEvent('click', function(event) {
	        event = new Event(event).stop();
	        scroll.toElement('home-noticias');
        });
        $('nav-meus-sonhos').addEvent('click', function(event) {
	        event = new Event(event).stop();
	        scroll.toElement('home-meus-sonhos');
        });
        $('nav-videos').addEvent('click', function(event) {
	        event = new Event(event).stop();
	        scroll.toElement('home-videos');
        });
        $('nav-frases').addEvent('click', function(event) {
	        event = new Event(event).stop();
	        scroll.toElement('home-frases');
        });
        $('nav-fale-conosco').addEvent('click', function(event) {
	        event = new Event(event).stop();
	        scroll.toElement('home-fale-conosco');
        });*/
        
	},
	
	
	subNavigation: function ()
	{
		if (window.ie6) {
			navRoot = document.getElementById("main-nav");
            for (i=0; i<navRoot.childNodes.length; i++) {
                node = navRoot.childNodes[i];
                if (node.nodeName=="LI") {
                    node.onmouseover=function() {
                        this.className+=" over";
                    }
                    node.onmouseout=function() {
                        this.className=this.className.replace(" over", "");
                    }
                }
            }
        }	
	}
	
}


// LISTENERS *******************************************************************

window.addEvent('load', DataListas.init);
