jQuery(document).ready(function(){
    var $ = jQuery;
    
    var currentLocation = window.location.pathname;
    
    
    $(".menu a").each(function(){
        if ($(this).attr("href") == currentLocation) {
            $(this).addClass("current");
            $("#" + $(this).attr("rel")).addClass("current");
        }
    });
    
    $(".sub-menu").not(".current").hide();
    
    var closeTimer;
    $(".main-menu a").hover(
        function(){
            clearTimeout(closeTimer);
            $(".main-menu a").removeClass("selected");
            $(this).addClass("selected");
            var subId = $(this).attr("rel");
            $(".sub-menu").not("#" + subId).hide();
            
            $("#" + subId).fadeIn("fast");
        },
        function(){
            closeTimer = setTimeout(function(){
                $(".sub-menu").not(".current").fadeOut("slow", function(){
                    $(".main-menu a").removeClass("selected");
                });
            }, 500);
            if (!$(".sub-menu.current").is(":visible")) {
                $(".sub-menu.current").fadeIn("fast");
            }
        }
        );
    
    
    
    $(".sub-menu").hover(
        function(){
            clearTimeout(closeTimer);
        }, 
        function() {
            closeTimer = setTimeout(function(){
                $(".sub-menu").not(".current").fadeOut("slow", function(){
                    $(".main-menu a").removeClass("selected");
                });
                
            }, 500);
        }
        );
    
    
    $(".slider").cycle({
        delay:-3000,
        timeout:7000,
        speed:3000
    });
	$(".slideracc").cycle({
        delay:-3000,
        timeout:7000,
        speed:3000
    });
});

