
$(document).ready(function()
{
	$('body').addClass('javascript-enabled');

	var dropDownMenuJQueryObject = $('div#topSlots div.menu > ul');

	// Initialize the drop-down menus
	dropDownMenuJQueryObject.superfish({
		delay: 300,
		autoArrows: false,
		dropShadows: false,
		disableHI: true
	});

	var tierOneListItemsJQueryObject = dropDownMenuJQueryObject.find('> li');

	//	Vertically center the Tier 1 top-nav items
	tierOneListItemsJQueryObject.find('> a > span > span').each(function() {
		// disabled for -154
		//$(this).css('padding-top', parseInt(( $(this).parent().height() - $(this).height()) / 2) + 'px');
	});


	/* This applies the PNG-fix for IE6 and also creates the iframe-shims
		to allow the drop-down bits to appear over select elements (if needed) in IE6 */
	tierOneListItemsJQueryObject
		.find('ul').ifixpng()
		.end()
		.find('div.afterLevelTwoList').ifixpng()
		.end()
		.find('div.levelTwoContainer').bgiframe();

	$('div.puff').each(addPuffAnimation);

	// Clear the search box when it has focus
	$('div.searchNav input[type=text], form.emailSignup input[type=text]')
		.focus(function()
		{
			if (!this.title.length) this.title = this.value;
			this.value = "";
		})
		.blur(function()
		{
			if (!this.value.length) this.value = this.title;
		});	
    
});

function changeRollover(src, hoverOn){
	/*
		This regex is designed to work with filenames in either format:

			go_button.gif <--> go_button_hover.gif

				-or-

			go_button._V257564918_.gif <--> go_button_hover._V257564918_.gif
	*/
    return hoverOn ? src.replace ("_hover", "") : src.replace(/((\._\w\d+_)?\.\w{3,4})?$/, "_hover$1");
}



// plugin dependency: jquery.easing.1.3
function addPuffAnimation() {
    var $this = $(this);
    var slidingPanel = $this.children('.widgetText:first');
    // assumes the concealed text is a p
    
    this.myHeight = $this.outerHeight(); 
    // mouseout/mouseover
    // NOTE: Please refrain from adding offsets here. Tweak the CSS if changing the positioning
    this.inPos = $this.children('img:first').outerHeight();
    this.outPos = this.myHeight - slidingPanel.outerHeight();
    
    // reposition link text elements at bottom (part overflowing)
    slidingPanel.css({ 'top' : this.inPos + 'px' });			
    
    $(this).hover(function() {
    	var $outPos = this.outPos;
    	slidingPanel.stop()
    		.animate({ 'top' : $outPos + 'px' }, 260, 'easeOutQuad'); 
    }, 
    function() {
    	var $inPos = this.inPos;
    	slidingPanel.stop()
    		.animate({ 'top' : $inPos + 'px' }, 260, 'easeOutQuad'); 
    })

        // if a link exists, make the entire widget 'hot'
    var pointerLink = $this.find('a[href]:first');
    if (pointerLink.length > 0) {
      $this.click(function(){
        var target = pointerLink.attr('target');
        if(target){
            window.open(pointerLink.attr('href'), target);
        } else {
            window.location = pointerLink.attr('href');
        }        
      });
      $this.addClass('clickable');
    }
}

