$(document).ready(function(){
    activateMenu('nav');
    
    if($(".ban1").length > 1)
        window.setInterval("toggle_banners(1)", 7000);
    
    if($(".ban2").length > 1)
        window.setInterval("toggle_banners(2)", 8000);
    
    if($(".ban3").length > 1)
        window.setInterval("toggle_banners(3)", 9000);
    
    /*$("#nobuttons").mouseover(
        function(){
            $("#withbuttons").fadeIn();
        }
    );
    $("#withbuttons").mouseout(
        function(){
            $(this).fadeOut();    
        }
    );*/
});

function toggle_banners(ban_index){
    var cur_index = $(".ban"+ban_index).index($(".ban"+ban_index+":visible"));
    
    if(cur_index == $(".ban"+ban_index).length - 1)
        next_banner = $(".ban"+ban_index+":eq(0)");
    else
        next_banner = $(".ban"+ban_index+":visible").next();
        
    $(".ban"+ban_index+":visible").fadeOut("slow");
    next_banner.fadeIn("slow"); 
}


activateMenu = function(nav) {

/* currentStyle restricts the Javascript to IE only */
	if (document.getElementById(nav) && document.all && document.getElementById(nav).currentStyle) {  
        var navroot = document.getElementById(nav);
        
        /* Get all the list items within the menu */

        var lis=navroot.getElementsByTagName("LI");  
        for (i=0; i<lis.length; i++) {
        
           /* If the LI has another menu level */
            if(lis[i].lastChild.tagName=="UL"){
            
                /* assign the function to the LI */
             	lis[i].onmouseover=function() {	
                
                   /* display the inner menu */
                   this.lastChild.style.display="block";
                }
                lis[i].onmouseout=function() {   
                   this.lastChild.style.display="none";
                }
            }
        }
    }
}
