jQuery.fn.fadeIn = function(speed, callback) { 
    return this.animate({opacity: 'show'}, speed, function() { 
        if (jQuery.browser.msie)  
            this.style.removeAttribute('filter');  
        if (jQuery.isFunction(callback)) 
            callback();  
    }); 
}; 
 
jQuery.fn.fadeOut = function(speed, callback) { 
    return this.animate({opacity: 'hide'}, speed, function() { 
        if (jQuery.browser.msie)  
            this.style.removeAttribute('filter');  
        if (jQuery.isFunction(callback)) 
            callback();  
    }); 
}; 
 
jQuery.fn.fadeTo = function(speed,to,callback) { 
    return this.animate({opacity: to}, speed, function() { 
        if (to == 1 && jQuery.browser.msie)  
            this.style.removeAttribute('filter');  
        if (jQuery.isFunction(callback)) 
            callback();  
    }); 
}; 

$j(document).ready(function() {
	$j('a.extend').click(function() {
		if ($j(this).hasClass("extended")) {
			// cierra el menu
			if (jQuery.browser.msie && (jQuery.browser.version < 7)) {
				$j(this).next().hide();
			}
			else {
				$j(this).next().animate({
					height: "hide",
					opacity: "0"
				}, { queue:false, duration:200 });
				$j(this).removeClass("extended");
			}
			
		}
		else {
			// abre el menu
			
			var thisUl = $j(this).next();
			var otros = $j(this).parent().parent().parent().parent().children().children().children().children("ul").not(thisUl);
			if (jQuery.browser.msie && (jQuery.browser.version < 7)) {
				otros.hide();
				thisUl.show();
			}
			else {
				$j(this).addClass("extended");
				otros.animate({
					height: "hide",
					opacity: "0"
				}, { queue:false, duration:200 });
				otros.prev().removeClass("extended");
				thisUl.animate({
					height: "show",
					opacity: "1"
				}, { queue:false, duration:200 });
			}
		}
	});
	return false;
});