$(document).ready(function() {	

    // The following button rollover (setupButton) is for the Home Theater Speaker guide.
	$(".setupButton").hover(function() {
		$(this).attr("src", $(this).attr("src").split(".").join("-hover."));
	}, function() {
		$(this).attr("src", $(this).attr("src").split("-hover.").join("."));
	});
	
	$(".imgRollover").hover(
		function(){			
			if($(this).attr("src").indexOf("_on") == -1 && $(this).attr("src").indexOf("_click") == -1) {				
				var newSrc = $(this).attr("src").replace(".gif","_on.gif#hover");				
				$(this).attr("src",newSrc);				
			}
		},
		function(){
			if($(this).attr("src").indexOf("_on.gif#hover") != -1) {
				var oldSrc = $(this).attr("src").replace("_on.gif#hover",".gif");				
				$(this).attr("src",oldSrc);
			}
		}
	);
	//The following code is for the left nav. It sets the "last" class on the <ul> if it is the last subsection open. This class adds the rounded corner. 
	if ($("div.navLinks>ul:last").next("div").attr('class') == null){
		$("div.navLinks>ul:last").addClass("last");
	}
	//The following code is to give the last subhead in the left nav a bottom rounded corner if it does not have children.
	if($("div.navLinks>div.subHeader").length){
	    if($("div.navLinks>div.subHeader:last").attr('class').indexOf('childOn') == -1 && $("div.navLinks>div.subHeader:last").next('ul').html() == null){
		    $("div.navLinks>div.subHeader:last").addClass('last').append('<div></div>');
		    $("div.navLinks>div.subHeader:last").find('div').css('top',$("div.navLinks>div.subHeader:last").outerHeight() + 'px');
	    }
	}
	//The following code sets the mouseover functionality for the Consumer Landing pages and the Broadcast Landing Pages
	$("#altContent>div.productMod").mouseover(function(){
		$(this).addClass("overProductMod");		
	});	
	$("#altContent>div.productMod").mouseout(function(){
		$(this).removeClass("overProductMod");		
	});		
	// The following code fixes the box navigation on all the landing pages
	if( ($('body').attr("class")) && $('body').attr("class").indexOf('subLandingPage') != -1){				
		if($('div#mainContent').outerHeight() < $('div#headImage').outerHeight()){					
			$('div#mainContent').css("paddingBottom", $('div#headImage').outerHeight() - $('div#mainContent').outerHeight() - 40);
		}
	}	
});  
function hideSelectBoxes(menuLeft,menuTop,menuWidth,menuHeight){	
	for(var selectLoop=0; selectLoop < $("select").length; selectLoop++){
		var tempOffset = $("select").eq(selectLoop).offset();
		var tempSelectY = tempOffset.top;
		var tempSelectX = tempOffset.left;
		var tempSelectWidth = $("select").eq(selectLoop).width();
		var tempSelectHeight = $("select").eq(selectLoop).height();
		if((tempSelectY <= menuTop + menuHeight && tempSelectY + tempSelectHeight >= menuTop ) && ((tempSelectX <= menuLeft && menuLeft <= (tempSelectWidth + tempSelectX)) || ((menuLeft <= tempSelectX) && (menuLeft + menuWidth > tempSelectX)))){
			$("select").eq(selectLoop).css("visibility","hidden");
		}else{
			$("select").eq(selectLoop).css("visibility","visible");
		}
	}
};		
function showAllSelectBoxes(){	
	for(var selectLoop=0; selectLoop < $("select").length; selectLoop++){		
		$("select").eq(selectLoop).css("visibility","visible");		
	}
};	
$(function(){   
    $('input').not($('input.searchbox,input[type=submit]')).keydown(function(e){           
        if (e.which == 13 || e.keyCode == 13) {                 
            return false;
        }
    });
    $('input.searchbox').keydown(function(e){               
        if (e.which == 13 || e.keyCode == 13) {                 
            document.location = $('a.searchButton').attr('href');                   
            return false;
        }
    });
}); 

//legacy support for popups (Game Demos)
a = 'toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=no,scrollbars=';
var popwscr = a+'yes,';
var popwnoscr = a+'no,';