$(document).ready(function(){
	
	$('.main-menu > ul > li.page_item')
	.filter(function(){
		return $(this).find('ul.children').size();
	})
	.each(function(){		
		
		var ancho 	= parseFloat($(this).width())+2;	
		var clon 	= $(this).children('a').clone().addClass('fake-btn').prependTo($(this)).css({ width: ancho+'px' });	
			
		$(this).bind('mouseover mouseout', function(e){
			$(this).find('a').toggleClass('main-menu-hover');
			if ( e.type == 'mouseover' ){
				clon.show();
			} else {
				clon.hide();
			}
		});
	});
	
	/*
	$("ul#menu > li").each(function(){
		
		// var submenu = $(this).find('ul.sub_menu');
		
		if ( $(this).find('ul.sub_menu').size()==1 )
		{
			// var text 	= $(this).find('a').first().text();
			// var width	= parseFloat($(this).width());
			// 
			// if ( !$.browser.safari )
			// width = width+2;
			// 
			// var fake 	= $('#fake-option').clone().attr('id', '').css({ width: width +'px' }).html(text).prependTo( $(this) );
			
			$(this).bind('mouseover', function(e){
				// fake.show();				
				$(this).addClass("hover");
			});
			$(this).bind('mouseout', function(e){
				// fake.hide();
				$(this).removeClass("hover");
			});
		}
		
		// $(this).hover(function(){
		// 	$(this).addClass("hover");
		// }, function(){
		// 	$(this).removeClass("hover");
		// });		
	});
	*/
	
    // $("ul#menu li").hover(function(){
    // 
    //     $(this).addClass("hover");
    //     $('ul:first',this).css('visibility', 'visible');
    // 
    // }, function(){
    // 
    //     $(this).removeClass("hover");
    //     $('ul:first',this).css('visibility', 'hidden');
    // 
    // });	
});
