// window.XMLHttpRequest is a feature IE6 does not have, so these scripts are testing for IE6 or not.

$(document).ready(function(){
// Banner functionality
	// Sets five image names in an array
	var bannerArray = ["nose", "rejuv", "recon", "breast", "contour"];
	// Selects one image randomly and replaces the website banner with that image
	var bannerRandom = Math.floor(Math.random()*bannerArray.length);
if(window.XMLHttpRequest) {
// Serves this to all browsers except IE6
	$("#banner > h3 > img").attr({
		src: "/ebusiness4/images/banner/banner-" + bannerArray[bannerRandom] + "-trans.png"
	});
} else {
// Serves this to IE6
			$("#banner > h3 > img").attr({
		src: "/ebusiness4/images/banner/banner-" + bannerArray[bannerRandom] + ".jpg"
	});
}

// Adds the accordion styling to the navigation
$("#subNavigation ul.main").css("margin-left","0");
$("#subNavigation ul.main").treeview({
	collapsed: true,
	persist: "location"
});

// Removes an unnecessary border from the .clearFix first element
$("h2.blueRounded + div.clearFix dl dt:first-child").addClass("top");

// Opens a link into a new window if it has a 'rel=external' tag applied
$("a[rel='external']").click(function(){
	window.open(this.href);
	return false;
});

if(window.XMLHttpRequest) {
	if($.browser.safari) {
	$("#container").css("padding-right","3px");
	} else {
	// Rounds the corners on all the content boxes
	$(".blueRounded").corner("top 10px");
	$(".grayRounded").corner("top 10px");
	$("#contentNoColumns #subContent h4").corner("10px");
	
	// Defines the container corners and border
	$("#containerBorder").css("width","780px").css("padding","2px").css("background","#ccc").css("margin","0 auto");
	$("#container").corner("round 8px").parent().corner("round 10px");
	}
}

if(!window.XMLHttpRequest) {

// Fix the Navigation Hover issue for IE6
$('#container #mainNavigation li, #contentFull .eventBrochure .gallery #photos div div').hover(function() {
	$(this).addClass('hover');
}, function() {
	$(this).removeClass('hover');
});

// Fix the CSS2 Selectors for IE6 by adding an advancedCSS class
$("#mainContent h1 + h2, #contentFull .altLanding ul + p, .sectionDetail dl + p, .medicalNews dl + p, .sectionDetail ol + dl, .sectionDetail dl + h2, .sectionDetail fieldset + dl, .sectionDetail dl + fieldset, .sectionDetail dl.bravoPatient + p, #contentFull .pressKit .grayRounded + .clearFix p, #contentFull .pressKit .grayRounded + .clearFix ul, #contentFull .pressKit .grayRounded + .clearFix p img, #content .magazine h1 + h2, #contentFull .eventBrochure .description #travel dl + p, #contentFull .eventBrochure .description #travel p + dl dt, #contentFull .eventBrochure .description #program dl dt + dd, #contentFull .eventBrochure .description #program dl dt.subItem + dd, #contentFull .episode h3 + h1, #content #subContent h3 + dl dt:first-child").addClass("advancedCSS");

$("#mainContent h1 + h2.blueRounded").removeClass("advancedCSS");
}
});