/**
 * UDESC Interface do usuário
 */ 
var UDESC = {
    /**
     * Init UI functions
     */         
    init: function () {
        UDESC.homeAccordion();
        UDESC.loadPrefs();
        UDESC.homeTabs();
    },
    /**
     * Home page accordion
     */ 
    homeAccordion: function () {
        jQuery('#home-accordion').accordion({
            header: 'h2',
            autoHeight: false,
            clearStyle: true,
            changestart: function(event, ui) {
                ui.oldHeader.removeClass('current');
                ui.newHeader.addClass('current');
                ui.oldContent.slideToggle('fast');
                ui.newContent.slideToggle('fast');
            }
        });
    },
    /**
     * Main navigation
     */          
    mainNav: function () {
        jQuery("#nav > li > a").bind('click', function () {
        	jQuery("#nav > li > a").not(this).parent().removeClass('hover');
        	jQuery("#nav > li > a").not(this).removeClass('hover');
            if(jQuery(this).next() && jQuery(this).next().is('.flyout')) {
              jQuery(this).parent().toggleClass('hover');
              jQuery(this).toggleClass('hover');
              return false;
            }
            return true;
        });
    },
    loadPrefs: function() {
        //nav mouseover or hover
        UDESC.mainNav();
        
        //accordion
        if (jQuery.cookie('prefs_accordion') !== null && jQuery.cookie('prefs_accordion') != '') {
          jQuery('#home-accordion').accordion('activate', parseInt(jQuery.cookie('prefs_accordion')));
        }
    },
    /**
     *	Home page tabs 
     */
    homeTabs: function() {
    	jQuery("#tabs").tabs(
    	);
    }
}
