
/* Techgua */

/* menuEffects()- Control the display of the the menu effects */
function mainMenuEffects()
{
    var szNormal = 92, szSmall  = 75, szFull   = 144;
     
        var menus = $$("#menu .mitem");
        var fx = new Fx.Elements(menus, {wait: false, duration: 300, transition: Fx.Transitions.Cubic.easeInOut});
        menus.each(function(menu, i) {
            menu.addEvent("mouseenter", function(event) {
                var o = {};
                o[i] = {'width': [menu.getStyle("width").toInt(), szFull]};
                menus.each(function(other, j) {
	                if(i != j) {
		                var w = other.getStyle("width").toInt();
		                if(w != szSmall) o[j] = {'width': [w, szSmall]};
	                }
                });
                fx.start(o);
            });
        });
         
        $("menu").addEvent("mouseleave", function(event) 
        {
            var o = {};
            menus.each(function(menu, i) 
            {
                o[i] = {'width': [menu.getStyle("width").toInt(), szNormal]}
            });
            fx.start(o);
        });
};

function subMenuEffects()
{
    // Sub-Menu Effects
    // Creates the change effect of color and extended of the menu
    window.addEvent('load', function()
    {
		    var list = $$('#sub_menu li');
		    list.each(function(element) 
		    {
    			
			    var fx = new Fx.Styles(element, {duration:200, wait:false});
    			
			    element.addEvent('mouseenter', function()
			    {
				    fx.start(
				    {
					    'margin-left': 8,
					    'background-color': '#426b83',
					    'color': '#ff8'
				    });
			    });
    			
			    element.addEvent('mouseleave', function()
			    {
				    fx.start(
				    {
					    'margin-left': 0,
					    'background-color': '#8AD7FF',
					    'color': '#888'
				    });
			    });
    			
		    });
    }); 
    	
    //This script uses mootools: http://mootools.net
    // Creates the accordion effect on the page.

    var stretchers = $$('div.accordion');
    var togglers = $$('li.toggler');

    stretchers.setStyles({'height': '0', 'overflow': 'hidden'});

    window.addEvent('load', function(){
    	
        //Initialization of effects
        togglers.each(function(toggler, i){
	        toggler.color = toggler.getStyle('background-color');
	        toggler.$tmp.first = toggler.getFirst();
	        toggler.$tmp.fx = new Fx.Style(toggler, 'background-color', {'wait': false, 'transition': Fx.Transitions.Quart.easeOut});
        });
    	
	    //Create accordian effect.
        var myAccordion = new Accordion(togglers, stretchers, {
    		
	        'opacity': false,
    		
	        'start': false,
    		
	        'transition': Fx.Transitions.Quad.easeOut,
    		
	        onActive: function(toggler){
		        toggler.$tmp.fx.start('#8AD7FF');
		        toggler.$tmp.first.setStyle('color', '#ffffff');
    	
	        },
    	
	        onBackground: function(toggler){
		        toggler.$tmp.fx.stop();
		        toggler.setStyle('background-color', toggler.color).$tmp.first.setStyle('color', '#222');
	        }
        });
    	
        //Open that is called by the URL
        var found = 0;
        $$('h3.toggler a').each(function(link, i){
	        if (window.location.hash.test(link.hash)) found = i;
        });
        myAccordion.display(found); 		
    });


};