/** 
	jquery mega drop down 
**/
jQuery(document).ready(function() {
            
	function megaHoverOver(){
		jQuery(this).find(".sub").stop().fadeTo('fast', 1).show();
                
		//Calculate width of all ul's
		(function($) { 
			jQuery.fn.calcSubWidth = function() {
				rowWidth = 0;
				//Calculate row
				$(this).find("ul").each(function() {					
					rowWidth += $(this).width(); 
				});	
			};
		})(jQuery); 
            
		if ( jQuery(this).find(".row").length > 0 ) { //If row exists...
			var biggestRow = 0;	
			//Calculate each row
			jQuery(this).find(".row").each(function() {							   
				jQuery(this).calcSubWidth();
				//Find biggest row
				if(rowWidth > biggestRow) {
					biggestRow = rowWidth;
				}
			});
			
			//Set width
			jQuery(this).find(".sub").css({'width' :biggestRow});
			jQuery(this).find(".row:last").css({'margin':'0'});
                
		} else { //If row does not exist...
                
			jQuery(this).calcSubWidth();
			//Set Width
			jQuery(this).find(".sub").css({'width' : rowWidth});
                
		}
		
		//adjust position
		var sub = jQuery(this).find(".sub");
	    if(sub.length > 0 && sub.outerWidth() + sub.parent().position().left > 980)
	        sub.css('left', (sub.parent().width() - sub.outerWidth()) + 'px');
	}
        
	function megaHoverOut(){ 
		jQuery(this).find(".sub").stop().fadeTo('fast', 0, function() {
			jQuery(this).hide(); 
		});
	}
        
	var config = {    
		sensitivity: 1, 		// number = sensitivity threshold (must be 1 or higher)    
		interval: 0, 			// number = milliseconds for onMouseOver polling interval    
		over: megaHoverOver, 	// function = onMouseOver callback (REQUIRED)    
		timeout: 10, 			// number = milliseconds delay before onMouseOut    
		out: megaHoverOut 		// function = onMouseOut callback (REQUIRED)    
	};
    
	jQuery("ul#topnav li .sub").css({'opacity':'0'});
	jQuery("ul#topnav li").hoverIntent(config);
            
    /*utility*/
    jQuery('div#utility ul li').mouseover(function(){
        jQuery(this).find('.sub').show();
        jQuery(this).find('a.utility_link').addClass('active');
    })
    .mouseout(function(){
        jQuery(this).find('.sub').hide();
        jQuery(this).find('a.utility_link').removeClass('active');
    });
});


/**
	toggle callouts on special packages 
**/
var currSpecialCallout = 'specialCallout1';
function showCallout(id)
{
	if(id == currSpecialCallout)
	return;
					
	jQuery('#'+currSpecialCallout+'').hide();		
	jQuery('#'+currSpecialCallout+'_Btn'+'').removeClass('selected');
			
	jQuery('#'+id+'').fadeIn('slow');			
	jQuery('#'+id+'_Btn'+'').addClass('selected');
			
	currSpecialCallout = id;
}

/* close callout on category pages */
function close_callout(id) { 
	var callout = jQuery('#'+id+'');
	var curr_link = jQuery('ul#call_tabs a');
	
	if (callout.is(':visible')) { 
		callout.slideUp('slow');
	}
	if (curr_link.hasClass('selected')) {
		curr_link.removeClass('selected');
	}
}


/* toggle callouts on category pages */
function toggle_callout(id) {
	var selected_callout = jQuery('#'+id+'');			
	var curr_callout = jQuery('div#callouts div.callout');	
	var selected_link = jQuery('#lnk_'+id+'');
	var curr_link = jQuery('ul#call_tabs a');

	if (selected_callout.is(':visible')) {
		selected_callout.slideUp('slow');
		curr_link.removeClass('selected');		
	} else if (curr_callout.is(':visible')) {
		curr_callout.hide();
		selected_callout.slideDown('slow');
		curr_link.removeClass('selected');
		selected_link.addClass('selected');
	} else {
		selected_callout.slideDown('slow');
		curr_link.removeClass('selected');
		selected_link.addClass('selected');
	}

}


/* corporate footer */
function toggleOtherBrands(id, isShow)
{
	var ele = document.getElementById(id);
	if(isShow)
		ele.style.display = 'block';
	else
		ele.style.display = 'none';
}  



