// Director > Main (document ready)

$(document).ready(function(){
	// Hide everything while loading and rendering

	oldScripts();

	// Scan through all $("div")'s (can add more element types to selector) on the page
	$("div").each(function() {
		// Extract the text of each div and convert it to all lowercase
		var thisText = $(this).text().toLowerCase();
		// Depending on what the text of each div equals
		switch(thisText) {
			// For new products, featured products, dvds, and recently view items
			case "new products": case "featured products": case "dvds": case "recently viewed items": case "related items": case "customers who bought items in your shopping cart also bought": case "you may also like ...":
				// Eliminate spaces from text (i.e. new products > newproducts)
				var thisText = thisText.split(' ').join('');
				// Add classes: areaNumber, semantic name, and actual text > gives us multiple ways to select this
				// Product Section Label div
				$(this).attr("class", "fifteen productSectionLabel " + thisText)
					// Product Section Label  (next) Product Listing div
					.next("div").attr("class", "sixteen productListingBin " + thisText)
					// Product Section Label div (next) Product Content div (children) Columns in this tables SECOND row
					.children("table").children("tbody").children("tr:nth-child(2)").children("td:nth-child(2)").children("table").children("tbody").children(":nth-child(2)").each(function() {
						// Assign class names $(".productImage") and $(".productTitle") for the second children <tr>
						$(this).attr("class", "seventeen productItemBin " + thisText)
							// These <td> elements alternate between the product's image(even) and title/link(odd)
							.children(":even").attr("class", "eightteen productImage " + thisText)
							.parent().children(":odd").attr("class", "nineteen productTitle " + thisText);
					})
					// Product Money Bin: contains the product pricing and order button as alernating <td>, Price(:first), Button(.next())
					.parent().children(":nth-child(4)").each(function() {
						// Assign class names $(".productMoneyBin") to the fourth child <tr>
						$(this).attr("class", "twenty productMoneyRow " + thisText)
							// These <td> elements alternate between the product's price(:first) and order button(:last or .next())
							.children().attr("class", "twentyone productMoneyBin " + thisText)
							.children("table").children("tbody").children("tr").children("td:nth-child(1)").attr("class", "twentytwo productPrice " + thisText)
							.next().attr("class", "twentythree productOrderButton " + thisText);
					});
					break;
			case "top sellers":
				// Eliminate spaces from text (i.e. new products > newproducts)
				var thisText = thisText.split(' ').join('');
				// Add classes: areaNumber, semantic name, and actual text > gives us multiple ways to select this
				// Product Section Label div
				$(this).attr("class", "fifteen productSectionLabel " + thisText)
					// Product Section Label  (next) Product Listing div
					.next("div").attr("class", "sixteen productListingBin " + thisText)
					// Product Section Label div (next) Product Content div (children) Columns in this tables SECOND row
					.children("table").children("tbody").children("tr:nth-child(2)").children("td:nth-child(2)").children("table").children("tbody").children(":nth-child(5n+2)").each(function() {
						// Assign class names $(".productImage") and $(".productTitle") for the second children <tr>
						$(this).attr("class", "seventeen productItemBin " + thisText)
							// These <td> elements alternate between the product's image(even) and title/link(odd)
							.children(":even").attr("class", "eightteen productImage " + thisText)
							.parent().children(":odd").attr("class", "nineteen productTitle " + thisText);
					})
					// Product Money Bin: contains the product pricing and order button as alernating <td>, Price(:first), Button(.next())
					.parent().children(":nth-child(5n+4)").each(function() {
						// Assign class names $(".productMoneyBin") to the fourth child <tr>
						$(this).attr("class", "twenty productMoneyRow " + thisText)
							// These <td> elements alternate between the product's price(:first) and order button(:last or .next())
							.children().attr("class", "twentyone productMoneyBin " + thisText)
							.children("table").children("tbody").children("tr").children(":first").attr("class", "twentytwo productPrice " + thisText)
							.next().attr("class", "twentythree productOrderButton " + thisText);
					});

				break;
		}
	});
	
	$("body").data("browser", navigator.appName);
	
	/*Main Content Areas*/
	$("td").each(function() {
		if ($(this).attr("bgcolor") == '#FFFFFF') {
			$(this).attr("bgcolor", "#000000");
		}
	});
	
	$(".content").prepend("<a href='/'><div class='fortyfive logoButton'></div></a>");
	$("table").removeAttr("bgColor");
	
	var moreinfo = $("a:contains('more info')");
	$(moreinfo).html("").append("<img src='http://rockband.amazonwebstore.com/images/rbbuynowsmall.jpg'>").prev().remove();
	
	
	//Footer
	if ($.browser.safari) {
		$(".thirtyseven").css("marginRight", "9px");
		$(".thirtyeight").css("marginRight", "9px");
	}
	$("<div class='footerbackground'></div>").insertAfter($("body table:last"));
	//$("body").append("<div class='footerbackground'></div>");
	
	//Left content
	$(".wba_contentright").children("br").remove();
	$("#leftcol").wrap("<div class='nine leftcolWrapper'></div>");
	$("<div class='ten mainContentTop'></div>").insertBefore($(".leftcolWrapper"));
	$("<div class='eleven mainContentBottom'></div>").insertAfter($(".leftcolWrapper"));
	//$("<div style='position:relative; top:13px;'><img src='http://rockband.amazonwebstore.com/images/rbhrwide.jpg'></div>").insertAfter($("#content-5"));
	//$("<div style='position:relative; top:15px;'><img src='http://rockband.amazonwebstore.com/images/rbhrwide.jpg'></div>").insertAfter($("#content-6"));
	
	//Right Content
	//Bars
	$("#frame-2_s form").addClass("twelve rightNewsletterContent");
	$("#frame-2_s td").css({"padding":"3px", "textAlign":"left"});
	$(".rightNewsletterContent").children("table:first").css({"marginLeft":"-3px", "marginTop":"-7px"});
	$("#frame-3_s").children().addClass("twelve rightTopSeller");
	$("<div class='thirteen rightContentTop'></div>").insertBefore($(".twelve"));
	$("<div class='fourteen rightContentBottom'></div>").insertAfter($(".twelve"));	
	//Top Sellers
	$("#frame-3_s b:first").addClass("fifteen subHeader");
	
	//add image border and background
	$("#frame-3_s-3").children().children().children().children("a").children("img").parent().wrap("<div class='seventeen tsProductWrapper'></div>");
	//Resize images
	var image = $(".seventeen").children("a").children("img");
	resizeImages(image, 73, 73);
	/*$(image).each(function() {
		var w = parseInt($(this).css("width"));
        var h = parseInt($(this).css("height"));
        var changed = false;

        if ( w > 73 ) {
            var f = 1 - ((w - 73) / w);
            w = w * f;
            h = h * f;
            changed = true;
        }
        
        if ( h > 73 ) {
            var f = 1 - (( h - 73) / h);
            w = w * f;
            h = h * f;
            changed = true;
        }
        
        if ( changed = true) {
            $(this).css("width", w);
            $(this).css("height", h);
        }
	});*/
	$(".seventeen").wrap("<div class='eighteen tsProductContentWrapper'></div>");
	//Move title, Price, button and style them
	$("#frame-3_s-3").children().children().children().children("a").wrap("<div class='sixteen tsTitle'></div>");
	$(".sixteen a").css({"color":"#AAAAAA", "fontSize":"13px", "fontWeight":"normal"}).hover(
		function () {
    		$(this).css("color", "#f63");
  		},
  		function () {
    		$(this).css("color", "#aaaaaa");
  		}
	);
	
	$(".tsProductContentWrapper").wrap("<div class='nineteen productWrapper'></div>");
	
	$("#frame-3_s-3 .bold-price").parent().parent().children().css("height", "14px");
	$("#frame-3_s-3 .bold-price").parent().next().children("a").addClass("twentysix tsBuyWrapper");
	$("#frame-3_s-3 .bold-price").wrap("<div class='twentythree tsPriceWrapper'></div>");
	
	//Start moving things around
	$(".nineteen").each(function() {
		$(this).wrap("<div class='twentyfive tsWrapper'></div>");
		var parent = $(this).parent();
		$(parent).append($(this).parent().parent().next().children("div.tsTitle"));
		$(parent).append($(this).parent().parent().parent().next().next().children().children().children().children().children().children("div.tsPriceWrapper"));
		var pricewrapper = $(this).parent().children("div.tsPriceWrapper");
		$(pricewrapper).append($(this).parent().parent().parent().next().next().children().children().children().children().children().children(".tsBuyWrapper"));
		var price = $(pricewrapper).children(".bold-price");
		$("<span class='bar'>|</span>").insertAfter($(price));
		$(".rightTopSeller").append($(this).parent());
	});
	$("#frame-3_s-3").remove();
	//$("<div style='position:relative; left:15px; top:5px; height:19px;'><img src='http://rockband.amazonwebstore.com/images/rbhrnarrow.jpg'></div>").insertAfter($("#frame-3_s .fifteen:first"));
	//$(".tsWrapper:not(':last')").css("borderBottom", "1px dotted #333333");
	
	//Xbox 
	$("#frame-4_s").children("div#topsellfooter3").css("display", "none");
	$("#frame-4_s").children(".twelve").css("display", "block");
	
	//Right Promo Image

	
	//For all widgets
	$("<span>PRICE: </span>").insertBefore($(".bold-price span"));
	
	//Breadcrumb
	$(".crumbHome").parent().children().wrapAll("<div class='fiftyfive breadcrumbWrapper'></div>");
	$("<span class='fiftysix'>></span>").insertAfter($(".breadcrumbWrapper img"));
	$("[src*='orange_closed.gif']").remove();
	$(".breadcrumbWrapper").insertAfter($("#frame-1"));
	$(".breadcrumbWrapper").next().wrap("<div class='fiftyseven mainContentWrapper'></div>");
	//Remove current page/product
	$(".breadcrumbWrapper").children(".crumbPast:last").hide().prev("span.fiftysix").hide();
	//Relink portals
	$("a.crumbPast:contains('Instruments')").attr("href", "/content/Instruments.htm");
	$("a.crumbPast:contains('Accessories')").attr("href", "/content/Accessories.htm");
	$("a.crumbPast:contains('Games')").attr("href", "/content/Games.htm");
	
	pageDirector();
	
	/* Hover */
	$(".footerLinkWhite img").each(function(){
	var src = $(this).attr('src').split(".");
	$(this).hover(function () {        
	$(this).attr('src', src[0] + 'hover.png');
	    }, function () {
	       $(this).attr('src', src[0] + '.png');
	    });
	});
	$(".footerLinkGray img").each(function(){
	var src = $(this).attr('src').split(".");
	$(this).hover(function () {        
	$(this).attr('src', src[0] + 'hover.png');
	    }, function () {
	       $(this).attr('src', src[0] + '.png');
	    });
	});
	
	setTimeout(function() {
		$("body").show();
	}, 500);
	
});

function pageDirector() {
	// Run different scripts to format different pages
	var thisPage = location.href.substring((location.href.lastIndexOf("/"))+1),
		url = window.location.href.split("?")[0],
		thisURL = url.split("/"),
		thisSubPage = thisURL[3].substring(0,6);
	// Scripts to pull out content from tables
	//alert(thisSubPage);
	switch(thisSubPage) {	
		case "catego":
			//overlay("category");
			listings();
			category();
			if (thisURL[4] == '44168283421' || thisURL[4] == '44168283541') {
				$(".topNavWrapper").append("<div style='color: rgb(51, 153, 204); float: left;'>|</div><div class='eightynine topNavLink'><a href='/category/45726790161/1/Featured-RBN-CDs.htm'>Featured RBN CDs</a></div>")
			}
			
			if(url == 'http://www.rockbandstore.com/category/48940958241/1/Green-Day.htm')
{
var greenday = 'http://www.rockbandstore.com/images/rb_green_day_artwork_sweepsr_ules.pdf';	
$('.breadcrumbWrapper').append('<div style="margin-left: -87px; padding: 10px 0pt; *position:absolute; *left: 0px; *padding-top: 20px;"><a href=\"' + greenday + '\"><img src="http://www.rockbandstore.com/images/greenday.jpg" style="width:600px;"/></a></div>');
$('.leftWrapper').attr('style','top: 140px; *top:130px;');
$("#frame-6_s").css("top", "175px");
}
			//alert(thisURL[4]);
			
			break;
		case "search":
			search();
			listings();
			break;
		case "":
			//overlay("home");
			home();
			listings();
			break;
		case "cart.h":
			cartPage();
			break;
		case "myAcco":
			myAccount();
			break;
		case "orderC":
			orderConfirmation();
			break;
		case "orderS":
			orderStatus();
			break;
		case "conten":
			if (thisURL[4]) {
				var url = thisURL[4].substring(0,4);
				if (url == 'Help') 
					help();
				else 
					if (thisURL[4] == 'Accessories.htm') 
						essentials();
				else 
					if (thisURL[4] == 'Featured_Artists.htm') 
						featuredArtists();
				else 
					if (thisURL[4] == 'GDRB_XBox360_Offer.htm') 
						greenDayBundle();
				else 
					portal(thisURL[4]);  
			}
			listings();
			break;
		default: 
			//overlay("details");
			listings();
			if (thisURL[5]) {
				var asin = thisURL[5].split(".");
				details(asin[0]);
			}
			break;	
	}
	
	//First Widget 

	$(".product-widget-label:first").next().children().children().children().children("a").children("img").parent().wrap("<div class='twentyone firstWidgetImage'></div>");
	//Resize Images
	var image = $(".twentyone").children("a").children("img");
	$("[src*='no_image_m.gif']").css({
		"width": "132px",
		"height": "132px"
	});
	resizeImages(image, 132, 132);
	
	var image = $("#content-8 .twentyone").children("a").children("img");
	$("#content-8 [src*='no_image_m.gif']").css({
		"width": "125px",
		"height": "125px"
	});
	resizeImages(image, 125, 125);
	
	$(".product-widget-label:first").next().addClass("twentytwo");
	$(".twentytwo").children().children().children().children("a").wrap("<div class='twentyfour'></div>");
	$(".twentyfour").children("a").css({"color":"#aaaaaa", "fontSize":"16px", "fontWeight":"bold"}).hover(
		function () {
    		$(this).css("color", "#f63");
  		},
  		function () {
    		$(this).css("color", "#aaaaaa");
  		}
	).parent().attr("width", "50px");
	$(".twentyone").wrap("<div class='twenty'></div>");

	//Start moving things around
	$("#content-6").children().children().append($(".product-widget-label:first"));
	i = 1;
	$(".twenty").each(function(i) {
		$(this).wrap("<div class='twentyseven'></div>");
		var parent = $(this).parent();
		$(parent).append($(this).parent().parent().next().children("div.twentyfour"));
		$(this).parent().parent().parent().next().next().children().children().children().children().children().children("span.bold-price").wrap("<div class='twentyeight'></div>");
		if (i == 0 || i == 2 || i == 4 || i == 6 || i == 8) {
			var pricewrapper = $(this).parent().parent().parent().next().next().children("td:first").children().children().children().children().children("div.twentyeight");
			$(pricewrapper).append($(this).parent().parent().parent().next().next().children("td:first").children().children().children().children().children("a"));
			$(parent).append($(this).parent().parent().parent().next().next().children("td:first").children().children().children().children().children("div.twentyeight"));
		}
		else {
			var pricewrapper = $(this).parent().parent().parent().next().next().children("td:last").children().children().children().children().children("div.twentyeight");
			$(pricewrapper).append($(this).parent().parent().parent().next().next().children("td:last").children().children().children().children().children("a"));
			$(parent).append($(this).parent().parent().parent().next().next().children("td:last").children().children().children().children().children("div.twentyeight"));
		}
		var price = $(pricewrapper).children(".bold-price");
		$("<span class='bar'>|</span>").insertAfter($(price));
		$("#content-6").children().children().append($(this).parent());
		i = i + 1;
	});
	$("#content-6 table.twentytwo").remove();
	$(".twentyeight").children("a").addClass("twentysix");
	
	//Change link to go to product details
	$(".twentysix, .recommendedBuyWrapper").each(function() {
		var href = $(this).parent().prev().children("a").attr("href");
		$(this).attr("href", href);
	});
	
	$("#content-6").children().children().append($("<div style='clear:both;'></div>"));
	
	//First widget changes on portal page
	$(".leftcolWrapperNew #content-6 .twentyfour").wrap("<div style='float:left; margin-left:12px;' class='content6Right'></div>");
	$(".content6Right").append($(".leftcolWrapperNew #content-6 .twentyeight"));
	//$(".leftcolWrapperNew #content-6 .twentyseven").parent().attr("width", "370px").next().hide();
	$(".leftcolWrapperNew #content-6 .twentyseven").insertAfter($(".leftcolWrapperNew #content-6 .product-widget-label"));
	$(".leftcolWrapperNew #content-6 .twentytwo").hide();
	resizeImages($(".leftcolWrapperNew #content-6 .twentyone img"), 125);

	//Recently Viewed
	if ($.browser.msie) {
		if ($.browser.version == '7.0') {
			if ($("#frame-6_s").children().children().children("table").children("tbody").is(":empty")) {
				$("#frame-6_s").css("height", "222px");
				$("#frame-6_s").html("");
			}
		}
		else {
			if ($("#frame-6_s").children().children().children("table").is(":empty")) {
				$("#frame-6_s").css("height", "222px");
				$("#frame-6_s").html("");
			}
		}
	}
	else {
		if ($("#frame-6_s").children().children().children("table").is(":empty")) {
			$("#frame-6_s").css("height", "222px");
			$("#frame-6_s").html("");
		}
	}
	
	$("#frame-6_s").children().children().addClass("fortysix recentlyViewedWrapper");
	$("#frame-6_s div.productSectionLabel").addClass("product-widget-label");
	$("#frame-2 div.productSectionLabel").addClass("product-widget-label");
	$("<div class='fortyseven recentTop'></div>").insertBefore($(".recentlyViewedWrapper"));
	$("<div class='fortyeight recentBottom'></div>").insertAfter($(".recentlyViewedWrapper"));
	$("#frame-6_s .recentlyViewedWrapper").children("table").children().children(":first").next().children().children("a").children("img").parent().wrap("<div class='fortynine recentImgWrapper'></div>");
	$("#frame-2 .recentlyViewedWrapper").children("table").children().children(":first").next().children().children("a").children("img").parent().wrap("<div class='fortynine recentImgWrapper'></div>");
	//Resize Images
	var image = $(".fortynine").children("a").children("img");
	resizeImages(image, 73, 73);
	var image = $(".fifty").children("a").children("img");
	resizeImages(image, 73, 73);
	
	$(".recentImgWrapper").children().wrap("<div class='fifty recentImgBg'></div>");
	$(".recentImgWrapper").parent().next().children("a").wrap("<div class='fiftyone recentTitle'></div>");
	truncateText($(".fiftyone a"), 60);
	/*$("[src*='no_image_m.gif']").css({
		"width": "132px",
		"height": "132px"
	});*/
	$("[src*='no_image_s.gif'], #content-7 [src*='no_image_m.gif']").css({
		"width": "73px",
		"height": "73px"
	});
	$(".fiftyone a").css({"color":"#AAAAAA", "fontSize":"13px", "fontWeight":"normal"}).hover(
		function () {
    		$(this).css("color", "#f63");
  		},
  		function () {
    		$(this).css("color", "#aaaaaa");
  		}
	);
	$(".recentlyViewedWrapper .bold-price").parent().next().children("a").addClass("fiftytwo recentBuyWrapper");
	$(".recentlyViewedWrapper .bold-price").wrap("<div class='fiftythree recentPriceWrapper'></div>");
	$("#frame-6_s .product-widget-label").css({"position":"relative", "left":"17px", "top":"8px"});
	$("#frame-2 .product-widget-label").css({"position":"relative", "left":"17px", "top":"8px"});
	
	//Move things around
	$(".fortynine").each(function(i) {
		if (i < 4)
			j = i;
		else
			j = i-4;
		$(this).wrap("<div class='fiftyfour recentWrapper'></div>");
		var parent = $(this).parent();
		$(parent).append($(this).parent().parent().next().children("div.recentTitle"));
		$(parent).append($(this).parent().parent().parent().next().next().children("td").eq(j).children().children().children().children().children("div.recentPriceWrapper"));
		var pricewrapper = $(this).parent().children("div.recentPriceWrapper");
		$(pricewrapper).append($(this).parent().parent().parent().next().next().children("td").eq(j).children().children().children().children().children("a.recentBuyWrapper"));
		var price = $(pricewrapper).children(".bold-price");
		$("<span class='bar'>|</span>").insertAfter($(price));
		$(parent).insertAfter($("#frame-6_s .product-widget-label"));
		$(parent).insertAfter($("#frame-2 .product-widget-label"));
		i = i + 1;
	});
	//Change link to go to product details
	$(".fiftytwo").each(function() {
		var smallhref = $(this).parent().prev().children("a").attr("href");
		$(this).attr("href", smallhref);
	});
	//$("#content-7 table").remove();
	$(".fiftyfour:first").css({"marginLeft":"67px"});
	$(".fiftyfour").next("table").remove();
	$("#frame-6_s .fortysix").css("height", "200px");
	$("#frame-2 .fortysix").css("height", "200px");
	
	//Second Widget
	
	$(".leftcolWrapper #content-7").children().children().children().children().children().next().children().children("a").children("img").parent().wrap("<div class='twentynine homebtmImgWrapper'></div>");
	//Resize Images
	var image = $(".twentynine").children("a").children("img");
	resizeImages(image, 73, 73);
	$(".homebtmImgWrapper").children().wrap("<div class='thirty homebtmImgBg'></div>");
	//alert($(".homebtmImgWrapper").parent().next().html());
	$(".homebtmImgWrapper").parent().next().children("a").wrap("<div class='thirtytwo homebtmTitle'></div>");
	truncateText($(".thirtytwo a"), 60);
	$("[src*='no_image_m.gif']").attr({
		"width": "73px",
		"height": "73px"
	});
	$(".thirtytwo a").css({"color":"#AAAAAA", "fontSize":"13px", "fontWeight":"normal"}).hover(
		function () {
    		$(this).css("color", "#f63");
  		},
  		function () {
    		$(this).css("color", "#aaaaaa");
  		}
	);
	$("#content-7 .bold-price").parent().next().children("a").addClass("thirtythree homebtmBuyWrapper");
	
	$("#content-7 .bold-price").wrap("<div class='thirtyfour homebtmPriceWrapper'></div>");
	
	//Move things around
	$("#content-7 .twentynine").each(function(i) {
		if (i < 3)
			j = i;
		else
			j = i-3;
		$(this).wrap("<div class='thirtyone homebtmWrapper'></div>");
		var parent = $(this).parent();
		$(parent).append($(this).parent().parent().next().children("div.homebtmTitle"));
		//alert($(this).parent().parent().parent().next().next().children("td").eq(i).children().children().children().html());
		$(parent).append($(this).parent().parent().parent().next().next().children("td").eq(j).children().children().children().children().children("div.homebtmPriceWrapper"));
		var pricewrapper = $(this).parent().children("div.homebtmPriceWrapper");
		$(pricewrapper).append($(this).parent().parent().parent().next().next().children("td").eq(j).children().children().children().children().children("a.homebtmBuyWrapper"));
		var price = $(pricewrapper).children(".bold-price");
		$("<span class='bar'>|</span>").insertAfter($(price));
		$(".leftcolWrapper #content-7").children().children().append($(this).parent());
		i = i + 1;
	});
	$("#content-7 table").remove();
	
	//Change link to go to product details
	$(".thirtythree").each(function() {
		var smallhref = $(this).parent().prev().children("a").attr("href");
		$(this).attr("href", smallhref);
	});
	
	//Cart Page adjusting styles
	$("#cart2 .thirtyone").css({"width":"94px", "height":"115px"});
	
	if (thisSubPage == 'orderC' || thisSubPage == 'orderS') {
		$(".homebtmWrapper").css("top", "0px");
		$("#frame-2 div.productSectionLabel b").css("color", "#F7C912");
	}
	
	if (thisSubPage == 'conten' && thisURL[4] == 'Featured_Artists.htm') {
		$(".twentyseven").css({"height":"205px", "top":"6px"});
		$("#content-6 div.product-widget-label").css({"position":"relative", "left":"-5px", "top":"-5px"});
		var lastdiv = $(".twentyseven:last").next();
		$("<div style='margin:10px 0px 0px 5px;'><a href='/category/45726790161/1/Featured-RBN-CDs.htm'>SEE ALL ARTISTS >></a></div>").insertAfter($(lastdiv));
	}
	
	$(".content").prepend($(".breadcrumbWrapper"));
	$("h2#crumbProductTitle").css({"color":"#f7c912", "fontSize":"11px"});
	
	//$("#postpage-widget_s").insertAfter($(".wba_maintable"));
	//$("#postpage-widget_s").next("table").remove();
	
	//Remove header table
	$("body").prepend($("#prepage-widget_s"));
	$("#prepage-widget_s").next("a").next("table").remove();
	
	//Buy Now hover
	$("[src*='rbbuynowsmall.jpg']").hover(
		function () {
    		$(this).attr("src", "/images/rbbuynowsmallhover.jpg");
  		},
  		function () {
    		$(this).attr("src", "/images/rbbuynowsmall.jpg");
  		}
	);
	
	//Top Nav global
	$(".topNavLink a:contains('Guitars')").parent().css("display", "none").next().css("display", "none");
	$(".topNavLink a:contains('Drums')").parent().css("display", "none").prev().css("display", "none");
	
	/* Safari Fixes */
	if ($.browser.safari) {
	     if(thisSubPage == 'catego') {
		 	$(".leftcolWrapper").css("height", "560px");
			if ($(".categoryPagination").length <= 0) {
				//$(".sortpageWrapper").next("table").css("marginLeft", "-163px");
			}
			
		 }
	}
	
	//IE7 image fixes
	if ($.browser.msie) {
		if ($.browser.version == '7.0') {
			$(".eightytwo img, .twentyone img, .thirty img, .seventeen img, .fifty img").each(function() {
			var wrapper = $(this).parent().parent().css("height");
			var img = $(this).css("height");
			var wrapper = parseInt(wrapper);
			var img = parseInt(img);
			var difference = wrapper - img;
			var top = difference/2;
			$(this).css("marginTop", top + "px");
			});
		}
	}
	/*if ($.browser.msie) {
		$(".thirty img").each(function(){
			var wrapper = $(this).parent().parent().css("height");
			var img = $(this).css("height");
			var wrapper = parseInt(wrapper);
			var img = parseInt(img);
			var difference = wrapper - img;
			var top = difference / 2;
			$(this).css("marginTop", top + "px");
		});
	}*/
	
	//Green Day Bundle
	if (thisURL[4]) {
		if (thisURL[4] == 'GDRB_XBox360_Offer.htm') {
			$(".detailsTable .ten, .detailsTable .eleven").remove();
			$(".onehundred").css("top", "15px");
			$(".mainContentBottom").insertAfter($(".detailsTable"));
			$(".mainContentBottom").css("top", "23px");
		}
	}
	
	var image = $(".centercol #content-6 .twentyone").children("a").children("img");
	$(".centercol #content-6 [src*='no_image_m.gif']").css({
		"width": "125px",
		"height": "125px"
	});
	resizeImages(image, 125, 125);
}

function myAccount () {
	//Hide widgets
	$("#frame-2_s").css("display", "none");
	$("#frame-3_s").css("display", "none");
	$("#frame-4_s").css("display", "none");
	$("#frame-5_s").css("display", "none");
	$(".breadcrumbWrapper").css("display", "none");
	
	//Reposition
	$("#frame-6_s").css({"top":"40px", "left":"0px"});
	
	//Widen Content area
	$("#wba_main-table5").children().wrap("<div class='leftcolWrapper fortysix'></div>");
	$("<div class='fortyseven accountTop'></div>").insertBefore($(".leftcolWrapper"));
	$("<div class='fortyeight accountBottom'></div>").insertAfter($(".leftcolWrapper"));
	$(".accountTop").css("top", "27px");
	$(".accountBottom").css("top", "27px");
	$(".leftcolWrapper").css({"top":"25px", "paddingBottom":"120px"});
	$(".leftcolWrapper").children("table:first").css({"marginLeft":"20px", "width":"880px"});
	$("#leftcol").css("width", "900px");
	
	//Styling
	$("h1").css("marginBottom","20px");
	$("h3").css({"fontWeight":"bold", "marginTop":"15px"});
	$("[src*='rbgobtn.jpg']").addClass("onehundredone accountButton");
	if ($.browser.msie) {
		if ($.browser.version == '7.0') {
			$(".accountButton").css("top", "0px");
		}
	}
	$("a:contains('Privacy Policy')").attr("href", "http://www.rockband.com/privacy");
	$("a:contains('Shipping Policy')").attr("href", "/content/Help.htm");
	$("a:contains('Return Policy')").attr("href", "/content/Help.htm");
}

function orderConfirmation () {
	//Hide widgets
	$("#frame-2_s").css("display", "none");
	$("#frame-3_s").css("display", "none");
	$("#frame-4_s").css("display", "none");
	$("#frame-5_s").css("display", "none");
	$("#frame-6_s").css("display", "none");
	$(".breadcrumbWrapper").css("display", "none");
	
	//Bottom Widget
	$("#frame-2").children().children().wrapAll("<div class='fortysix recentlyViewedWrapper'></div>");
	$("#frame-2").css({"top":"50px", "position":"relative"});
	$("#frame-2 div.productSectionLabel").addClass("product-widget-label");
	
	//Widen Content area
	$("#wba_main-table5").children().wrap("<div class='leftcolWrapper fortysix'></div>");
	$("<div class='fortyseven confirmTop'></div>").insertBefore($(".leftcolWrapper"));
	$("<div class='fortyeight confirmBottom'></div>").insertAfter($(".leftcolWrapper"));
	$(".confirmTop").css("top", "27px");
	$(".confirmBottom").css("top", "27px");
	$(".leftcolWrapper").css({"top":"25px", "paddingBottom":"120px"});
	$(".leftcolWrapper").children("table:first").css({"marginLeft":"20px", "width":"880px"});
	$("#leftcol").css("width", "900px");
	
	//Styling
	$("h1").css("marginBottom","20px");
	$("h3").css({"fontWeight":"bold", "marginTop":"15px"});
	$("[src*='btn_go.gif']").addClass("onehundredone accountButton");
	if ($.browser.msie) {
		if ($.browser.version == '7.0') {
			$(".accountButton").css("top", "0px");
		}
	}
	$("strong").css("color","#aaaaaa");
	$("b").css("color","#aaaaaa");
	$("#totalValue").css("color","#aaaaaa");
	$("h1:last").parent().parent().parent().parent().wrap("<div class='onehundredtwo confirmWrapper'></div>");
	$(".confirmWrapper").next("table").wrap("<div class='onehundredthree confirmContent'></div>");
	$(".confirmContent").children().children().children("tr:first").next().children().children("b").css({
		"color": "#f7c912",
		"paddingBottom":"15px"
	});
	$(".confirmContent").children().children().children().children().children("img").wrap("<div class='thirty'></div>");
	$(".confirmContent").children().children().children().children("td").css({
		"verticalAlign": "top",
		"paddingBottom":"20px"
	});
	
	$(".thirty").wrap("<div class='twentynine' style='height:77px;'></div>");
	$(".twentynine").parent().removeClass("thirtyone");
}

function orderStatus () {
	//Hide widgets
	$("#frame-2_s").css("display", "none");
	$("#frame-3_s").css("display", "none");
	$("#frame-4_s").css("display", "none");
	$("#frame-5_s").css("display", "none");
	$(".breadcrumbWrapper").css("display", "none");
	
	//Reposition
	$("#frame-6_s").css({"top":"40px", "left":"0px"});
	
	//Widen Content area
	$("#wba_main-table5").children().wrap("<div class='leftcolWrapper fortysix'></div>");
	$("<div class='fortyseven confirmTop'></div>").insertBefore($(".leftcolWrapper"));
	$("<div class='fortyeight confirmBottom'></div>").insertAfter($(".leftcolWrapper"));
	$(".confirmTop").css("top", "27px");
	$(".confirmBottom").css("top", "27px");
	$(".leftcolWrapper").css({"top":"25px", "paddingBottom":"120px"});
	$(".leftcolWrapper").children("table:first").css({"marginLeft":"20px", "width":"880px"});
	$("#leftcol").css("width", "900px");
	
	//Styling
	$("h1").css("marginBottom","20px");
	$("h3").css({"fontWeight":"bold", "marginTop":"15px"});
	$("[src*='rbgobtn.jpg']").addClass("onehundredone accountButton");
	if ($.browser.msie) {
		if ($.browser.version == '7.0') {
			$(".accountButton").css("top", "0px");
		}
	}
	$("strong").css("color","#aaaaaa");
	$("b").css("color","#aaaaaa");
	$(".our").css("color","#aaaaaa");
	$("h1").eq(2).parent().parent().parent().parent().wrap("<div class='onehundredtwo confirmWrapper'></div>");
	$(".confirmWrapper").children().children().children("tr:nth-child(4)").children().children().wrap("<div class='onehundredthree confirmContent'></div>");
	$(".confirmContent").children().children().children("tr:first").children().children("b").css("color", "#f7c912");
	$(".confirmContent").children().children().children().children().children("img").wrap("<div class='thirty'></div>");
	$(".thirty").wrap("<div class='twentynine' style='height:77px;'></div>");
	$(".twentynine").parent().removeClass("thirtyone");
}

function cartPage() {
	//Hide widgets
	$("#frame-2_s").css("display", "none");
	$("#frame-3_s").css("display", "none");
	$("#frame-4_s").css("display", "none");
	$("#frame-5_s").css("display", "none");
	$("#frame-6_s").remove();
	$(".breadcrumbWrapper").css("display", "none");
	
	//Widen Content area
	$("#wba_main-table5").children().wrap("<div class='leftcolWrapper fortysix'></div>");
	$("<div class='fortyseven cartTop'></div>").insertBefore($(".leftcolWrapper"));
	$("<div class='fortyeight cartBottom'></div>").insertAfter($(".leftcolWrapper"));
	$(".cartTop").css("top", "27px");
	$(".cartBottom").css("top", "27px");
	$(".leftcolWrapper").css({"top":"29px", "paddingBottom":"120px"});
	$("#leftcol").css("width", "900px");
	
	//Styling
	
	//Header
	$(".leftcolWrapper").prepend($("h1:first"));
	$("h1").wrap("<div class='seventytwo cartHeader'></div>");
	$("h1").css("fontSize", "23px");
	//Top
	$("#topSubTotal").css("display", "none");
	$(".seventytwo").next("table").wrap("<div class='ninetytwo cartTableWrapper'></div>");
	$("#cart2").children().children("tr:first").children().children().wrapAll("<div class='ninetythree cartTopButtons'></div>");
	$(".cartTableWrapper").prepend($(".cartTopButtons"));
	//Bottom
	
	var bottombtn = $("#safeandsecure").parent();
	$("#continueShopping").parent().clone().prependTo($(bottombtn));
	$(bottombtn).children().wrapAll("<div class='ninetyeight cartBottomButtons'></div>")
	
	//Table
	$("#cart2").wrap("<div class='ninetyfour cartTable'></div>");
	$(".cartTable").insertAfter($(".cartTopButtons"));
	//Table Styling
	$("#itemHeaders").children("td").css({"color":"#F7C912"});
	$(".itemImage").children("a").wrap("<div class='thirty'></div>");
	$(".thirty").css({"width":"75px", "height":"75px"});
	$(".thirty").wrap("<div class='twentynine' style='width:75px; height:75px;'></div>");
	$(".line").css("display", "none");
	$(".itemPrice span").css({"color":"#aaaaaa", "fontWeight":"normal", "fontSize":"13px"});
	$(".itemName a").css({
		"fontSize": "13px",
		"fontWeight":"normal"
	});
	$("#cartTotalLabel").parent().parent().parent().wrap("<div class='ninetysix cartTotalWrapper'></div>");
	$("[src*='rbcontinueshoppingbtn.jpg']:last").attr("src", "http://rockband.amazonwebstore.com/images/rbcartcancelbtn.png");
	$("[src*='img_safeandsecure.gif']").attr("src", "http://rockband.amazonwebstore.com/images/rbcartwebstore.png");
	$(".cartBottomButtons #continueShopping:last").css({"position":"relative", "bottom":"2px"});
	//Permission Script
	$("#content-6").attr("id", "permissionScript");
	$("#permissionScript").next().remove();
	$(".eighty").next().wrap("<div class='ninetynine permissionScript'></div>");
	
	//updating
	$("[src*='bt_update_sm.gif']").attr("src", "http://rockband.amazonwebstore.com/images/rbcartupdatebtn.jpg");
	$("[src*='bt_remove.gif']").attr("src", "http://rockband.amazonwebstore.com/images/rbcartremovebtn.jpg");
	$("<span style='color:#3399CC;position:relative;top:-2px;'> | </span>").insertAfter($(".updateItem"));
	$(".itemRemove").prev("br").remove();
	$("input.cart").next().css("marginBottom", "5px");
	$(".itemQuantity").each(function() {
		$(this).children(":first").next().addClass("box");
	});
	
	//remove last column
	$("#cart2").children().children().children(":nth-child(5)").css("display", "none");
	$(".itemTotalPrice").css("display", "none");
	$("#permissionScript").css({"top":"40px", "position":"relative"});

	$("<hr class='eighty' style='position:absolute; clear:both; top:57px;'>").insertAfter($(".cartTopButtons"));
	if ($.browser.msie) {
		if ($.browser.version <= '7.0') {
			$(".eighty").css({"top":"77px", "display":"block", "left":"-40px", "width":"855px"});
		}
		if ($.browser.version >= '8.0') {
			$("#cart2").css({"left":"0px"});
			$(".eighty").css("top", "64px");
		}
	}
	
	if ($("#cart2").length > 0) {
		$("<div class='ninetyseven cartBarWide'></div>").insertBefore($(".cartTotalWrapper"));
	}
	else {
		$("#continueShopping").attr("src", "http://rockband.amazonwebstore.com/images/rbcontinueshoppingbtn.jpg");
		$("#permissionScript").hide();
		$(".cartTableWrapper").css("left", "0px");
	}
	
	//Bottom Widget
	$("#frame-2").children().children().wrapAll("<div class='fortysix recentlyViewedWrapper'></div>");
	$("#frame-2").css({"position":"relative", "top":"50px"});
	
	$(".leftcolWrapper").insertBefore($("#frame-2"));
	$(".cartTop").insertBefore($(".leftcolWrapper"));
	$(".cartBottom").insertAfter($(".leftcolWrapper"));
	
	//Check for bundle - if so, apply discount
	var discount = 'false';
	$(".itemName").each(function() {
		var link = $(this).children().children().attr("href");
		var splitlink = link.split("/");
		var asinlink = splitlink[3].split(".");
		var asin = asinlink[0];
		
		if (asin == 'B003P6JVO2' || asin == 'B003P6GP4Q' || asin == 'B003P6GP5K' || asin == 'B003P6LWZS') {
			var price = $(this).parent().parent().next().children(".our");
			$("<span class='discount'><br>*Your discount will<br>appear at checkout</span>").insertAfter($(price));
			discount = 'true';
		}
	});
	if (discount == 'true') {
		var shipping = $("#cartTotalLabel").parent();
		$("<tr><td colspan='2' align='right'><span class='discount'><b>*Your discount will appear at checkout</b></span></td></tr>").insertAfter($(shipping));
	}
	
}

function home() {
	$("#frame-4_s").css("display", "none");
	$("#frame-5_s").css("display", "none");
	$("#frame-6_s").css("display", "none");
	$("#frame-4_s").children(".twelve").css("display", "none");
}

function portal(page) {	
	//var page = "Games.htm";
	var pagename = page.split(".");
	//Reposition Widgets
	$("#frame-2_s").css("top", "199px");
	$("#frame-3_s").css("top", "720px");
	$("#frame-4_s").css("top", "410px");
	$("#frame-5_s").css("top", "467px");
	$("#frame-6_s").css("top", "66px");
	$(".breadcrumbWrapper").css({"top":"185px", "marginLeft":"87px"});
	$(".breadcrumbWrapper").children(".crumbPast:last").show().text(pagename[0]).prev("span.fiftysix").show();
	$("#wba_main-table5").css("height", "955px");
	$("#frame-2_s, #frame-3_s, #frame-4_s, #frame-5_s").css("marginLeft", "624px");
	
	//Apply widget properties
	$("#content-2").attr("id", "content-6");
	$("#content-3").attr("id", "content-8");

	//Additions
	$("#content-6").parent().children().wrapAll("<div class='onehundredeleven leftcolWrapperNew'></div>");
	$(".leftcolWrapperNew").wrap("<div class='centercol'></div>");
	//$(".leftcolWrapper").css({"top":"44px", "left":"-7px"});
	$(".centercol").prepend($("<div class='onehundrednine mainContentNewTop'></div>"));
	$(".centercol").append($("<div class='onehundredten mainContentNewBottom'></div>"));
	//$(".mainContentNewTop").css({"top":"44px", "left":"-7px"});
	//$(".mainContentBottom").css({"top":"44px", "left":"-7px"});
	$(".leftcolWrapperNew").children().css("left", "20px");
	$("#content-6").css("top", "5px");
	$("#content-8").css("top", "15px");
	//$("<div style='position:relative; top:7px; left:20px;'><img src='http://rockband.amazonwebstore.com/images/rbhrwide.jpg'></div>").insertAfter($("#content-6"));
	$(".product-widget-label:contains('Best Sellers')").css("height", "41px");
	$(".thirtyone").css("height", "137px");
	$("h1").css("display", "none");
	//$(".leftcolWrapper").css("height", "594px");
	$("#wba_main-table5").css("height", "955px");
	$("#frame-3 .product-widget-label").addClass("fifteen productSectionLabel").removeClass("product-widget-label");
	
	//Top Nav
	
	$("body").css("backgroundImage", "url('http://www.rockbandstore.com/images/rbbgheadercategory.jpg')");
	$(".content").prepend($(".topNavWrapper"));
	
	if (page == 'Games.htm')
		$(".headerNavCat").children().children("a:contains('Games')").css("color", "#f7c912");
	else if (page == 'Instruments.htm')
		$(".headerNavCat").children().children("a:contains('Instruments')").css("color", "#f7c912");
	
	//Breadcrumb
	$(".breadcrumbWrapper a:last").attr("href", "/content/" + page);
	
	//Left Column
	$("#frame-2").addClass("leftnavigation");
	$("#frame-2").wrap($("<div class='leftcolnarrow'></div>"));
	$(".leftcolnarrow").insertBefore($(".centercol"));
	$(".leftcolnarrow").append($("#frame-3"));
	
	//Navigation
	var maincat = page.split(".");
	$(".topNavWrapper").clone().appendTo($("#frame-2 .onehundredeight"));
	$("#frame-2 .topNavWrapper").addClass("onehundredtwelve leftNav").removeClass("topNavWrapper").removeClass("ninety");
	$("#frame-2 .leftNav").children("div:contains('|')").remove();
	$("#frame-2 .leftNav").children("div.eightynine").removeClass("eightynine").addClass("subcategory").removeClass("topNavLink");
	//Add Main Cat
	$("#frame-2 .leftNav").prepend("<div class='maincategory'>" + maincat[0] + "</div>");
	
	//Recommended
	$("#frame-3").children("div").wrap("<div class='onehundredeight'></div>");
	$("#frame-3").prepend("<div class='onehundredsix'></div>");
	$("#frame-3").append("<div class='onehundredseven'></div>");
	
	//Second Widget
	
	$("#content-8").children().children().children().children().children().next().children().children("a").children("img").parent().wrap("<div class='twentynine homebtmImgWrapper'></div>");
	//Resize Images
	var image = $(".twentynine").children("a").children("img");
	resizeImages(image, 110, 110);
	$(".homebtmImgWrapper").children().wrap("<div class='thirty homebtmImgBg'></div>");
	//alert($(".homebtmImgWrapper").parent().next().html());
	$(".homebtmImgWrapper").parent().next().children("a").wrap("<div class='thirtytwo homebtmTitle'></div>");
	truncateText($(".thirtytwo a"), 60);
	$("[src*='no_image_m.gif']").attr({
		"width": "110px",
		"height": "110px"
	});
	$(".thirtytwo a").css({"color":"#AAAAAA", "fontSize":"13px", "fontWeight":"normal"}).hover(
		function () {
    		$(this).css("color", "#f63");
  		},
  		function () {
    		$(this).css("color", "#aaaaaa");
  		}
	);
	$("#content-8 .bold-price").parent().next().children("a").addClass("thirtythree homebtmBuyWrapper");
	
	$("#content-8 .bold-price").wrap("<div class='thirtyfour homebtmPriceWrapper'></div>");
	
	//Move things around
	$("#content-8 .twentynine").each(function(i) {
		if (i < 2)
			j = i;
		else if (i < 4 && i > 2)
			j = i-2;
		else	
			j = i - 4;
		$(this).wrap("<div class='thirtyone homebtmWrapper'></div>");
		var parent = $(this).parent();
		$(parent).append($(this).parent().parent().next().children("div.homebtmTitle"));
		//alert($(this).parent().parent().parent().next().next().children("td").eq(i).children().children().children().html());
		$(parent).append($(this).parent().parent().parent().next().next().children("td").eq(j).children().children().children().children().children("div.homebtmPriceWrapper"));
		var pricewrapper = $(this).parent().children("div.homebtmPriceWrapper");
		$(pricewrapper).append($(this).parent().parent().parent().next().next().children("td").eq(j).children().children().children().children().children("a.homebtmBuyWrapper"));
		var price = $(pricewrapper).children(".bold-price");
		$("<span class='bar'>|</span>").insertAfter($(price));
		$("#content-8").children().children().append($(this).parent());
		i = i + 1;
	});
	$("#content-8 table").remove();
	
	/* Recommended Widget */
	
	$("#frame-3").children().children().children().children().children().children().children().children("a").children("img").parent().wrap("<div class='twentynine recommendedImgWrapper'></div>");
	//Resize Images
	var image = $(".recommendedImgWrapper").children("a").children("img");
	resizeImages(image, 73, 73);
	$(".recommendedImgWrapper").children().wrap("<div class='thirty recommendedImgBg'></div>");
	//alert($(".homebtmImgWrapper").parent().next().html());
	$(".recommendedImgWrapper").parent().parent().prev().prev().children().children("a").wrap("<div class='onehundredfourteen recommendedTitle'></div>");
	truncateText($(".recommendedTitle a"), 60);
	$("[src*='no_image_m.gif']").attr({
		"width": "110px",
		"height": "110px"
	});
	$(".recommendedTitle a").css({"color":"#AAAAAA", "fontSize":"13px", "fontWeight":"normal"}).hover(
		function () {
    		$(this).css("color", "#f63");
  		},
  		function () {
    		$(this).css("color", "#aaaaaa");
  		}
	);
	$("#frame-3 .bold-price").parent().next().children("a").addClass("recommendedBuyWrapper");
	
	$("#frame-3 .bold-price").wrap("<div class='recommendedPriceWrapper'></div>");
	
	//Move things around
	$("#frame-3 .recommendedImgWrapper").each(function(i) {
		$(this).wrap("<div class='onehundredfifteen recommededbtmWrapper'></div>");
		var parent = $(this).parent();
		$(parent).append($(this).parent().parent().parent().prev().prev().children().children("div.recommendedTitle"));
		//alert($(this).parent().parent().parent().next().next().children("td").eq(i).children().children().children().html());
		$(parent).append($(this).parent().parent().parent().next().next().children().children().children().children().children().children("div.recommendedPriceWrapper"));
		var pricewrapper = $(this).parent().children("div.recommendedPriceWrapper");
		$(pricewrapper).append($(this).parent().parent().parent().next().next().children().children().children().children().children().children("a.recommendedBuyWrapper"));
		var price = $(pricewrapper).children(".bold-price");
		$("<span class='bar'>|</span>").insertAfter($(price));
		$("#frame-3").children().children().append($(this).parent());
	});
	$("#frame-3 table").remove();
	$("#frame-3 span.bold-price span:contains('PRICE: ')").remove();
	$("#frame-3 .productSectionLabel").css("fontSize", "20px");
	
	//Best Sellers updates
	$("#frame-3_s .twentyfive:last").hide();
	$("#frame-3_s .tsTitle").each(function(i) {
		j = i + 1;
		$(this).children().prepend(j + '. ');
		i = i + 1;
	});
}

function featuredArtists() {
	//Move widgets
	$("#frame-3_s").css("top", "776px");
	$("#frame-4_s").css("top", "657px");
	$("#frame-5_s").css("top", "396px");
	$("#frame-6_s").css({"top":"40px", "left":"0px"});
	$(".breadcrumbWrapper").css({"top":"158px", "marginLeft":"87px"});
	
	//Apply widget properties
	$("#content-1").attr("id", "content-6");

	//Additions
	$("#content-6").parent().children().wrapAll("<div class='nine leftcolWrapper'></div>");	
	$(".leftcolWrapper")
	$("<div class='ten mainContentTop'></div>").insertBefore($(".leftcolWrapper"));
	$("<div class='eleven mainContentBottom'></div>").insertAfter($(".leftcolWrapper"));
	$(".mainContentTop").css("top", "25px");
	$(".leftcolWrapper").css({"top":"25px", "height":"1160px"});
	$(".mainContentBottom").css("top", "25px");
	$(".leftcolWrapper").children().css("left", "20px");
	$("h1").css("display", "none");
	$("#wba_main-table4").css("display", "none");
}

function essentials () {
	/*//Reposition Widgets
	$("#frame-3_s").css("top", "776px");
	$("#frame-4_s").css("top", "657px");
	$("#frame-5_s").css("top", "396px");
	$(".content").prepend($(".breadcrumbWrapper"));
	$(".breadcrumbWrapper").css({"top":"176px", "marginLeft":"87px"});
	
	//Hide Things
	$("h1:first").hide();
	
	//Apply widget properties
	$("#content-2").attr("id", "content-6");
	$("#content-3").attr("id", "content-7");
	
	//Additions
	$("#content-6").parent().children().wrapAll("<div class='nine leftcolWrapper'></div>");
	$(".leftcolWrapper").css({"top":"44px", "left":"-7px"});
	$(".leftcolWrapper").css("height", "622px");
	$("<div class='ten mainContentTop'></div>").insertBefore($(".leftcolWrapper"));
	$("<div class='eleven mainContentBottom'></div>").insertAfter($(".leftcolWrapper"));
	$(".mainContentTop").css({"top":"44px", "left":"-7px"});
	$(".mainContentBottom").css({"top":"33px", "left":"-7px"});
	$(".leftcolWrapper").children().css("left", "20px");
	$("#content-6").css("top", "5px");
	$("#content-7").css("top", "15px");
	$("<div style='position:relative; top:7px; left:20px;'><img src='http://rockband.amazonwebstore.com/images/rbhrwide.jpg'></div>").insertAfter($("#content-6"));
	$(".product-widget-label:contains('Best Sellers')").css("height", "41px");
	$(".thirtyone").css("height", "137px");
	$("h1").css("display", "none");
	$("#content-1").insertBefore($(".mainContentTop"));
	$("#content-1").css({"position":"relative", "top":"26px", "left":"-7px"});
	$(".headerNavCat a:contains('Accessories')").css("color", "#f7c912");
	
	//Wrap Main Left Content to set Min Height
	$(".mainContentTop").wrap("<div class='seventyone leftWrapper'></div>");
	$(".leftWrapper").append($(".leftcolWrapper"));
	$(".leftWrapper").append($(".mainContentBottom"));
	$(".leftWrapper").css("min-height", "1220px");
	
	//Top Nav
	$(".content").prepend($(".topNavWrapper"));
	$(".topNavWrapper").css("marginLeft", "338px");
	$("body").css("backgroundImage", "url('http://www.rockbandstore.com/images/rbbgheadercategory.jpg')");*/
	
	//var page = "Games.htm";
	//Reposition Widgets
	$("#frame-2_s").css("top", "199px");
	$("#frame-3_s").css("top", "720px");
	$("#frame-4_s").css("top", "410px");
	$("#frame-5_s").css("top", "467px");
	$("#frame-6_s").css("top", "66px");
	$(".breadcrumbWrapper").css({"top":"185px", "marginLeft":"87px"});
	$(".breadcrumbWrapper").children(".crumbPast:last").show().text('Accessories').prev("span.fiftysix").show();
	$("#wba_main-table5").css("height", "955px");
	$("#frame-2_s, #frame-3_s, #frame-4_s, #frame-5_s").css("marginLeft", "624px");
	
	//Apply widget properties
	$("#content-2").attr("id", "content-6");
	$("#content-3").attr("id", "content-8");

	//Additions
	$("#content-6").parent().children().wrapAll("<div class='onehundredeleven leftcolWrapperNew'></div>");
	$(".leftcolWrapperNew").wrap("<div class='centercol'></div>");
	//$(".leftcolWrapper").css({"top":"44px", "left":"-7px"});
	$(".centercol").prepend($("<div class='onehundrednine mainContentNewTop'></div>"));
	$(".centercol").append($("<div class='onehundredten mainContentNewBottom'></div>"));
	//$(".mainContentNewTop").css({"top":"44px", "left":"-7px"});
	//$(".mainContentBottom").css({"top":"44px", "left":"-7px"});
	$(".leftcolWrapperNew").children().css("left", "20px");
	$("#content-6").css("top", "5px");
	$("#content-8").css("top", "15px");
	//$("<div style='position:relative; top:7px; left:20px;'><img src='http://rockband.amazonwebstore.com/images/rbhrwide.jpg'></div>").insertAfter($("#content-6"));
	$(".product-widget-label:contains('Best Sellers')").css("height", "41px");
	//$(".thirtyone").css("height", "137px");
	$("h1").css("display", "none");
	//$(".leftcolWrapper").css("height", "594px");
	$("#wba_main-table5").css("height", "955px");
	$("#frame-3 .product-widget-label").addClass("fifteen productSectionLabel").removeClass("product-widget-label");
	
	//Top Nav
	$("body").css("backgroundImage", "url('http://www.rockbandstore.com/images/rbbgheadercategory.jpg')");
	$(".content").prepend($(".topNavWrapper"));
	
	$(".headerNavCat").children().children("a:contains('Accessories')").css("color", "#f7c912");
	
	//Breadcrumb
	$(".breadcrumbWrapper a:last").attr("href", "/content/Accessories.htm");
	
	//Left Column
	$("#frame-2").addClass("leftnavigation");
	$("#frame-2").wrap($("<div class='leftcolnarrow'></div>"));
	$(".leftcolnarrow").insertBefore($(".centercol"));
	$(".leftcolnarrow").append($("#frame-3"));
	
	//Navigation
	var maincat = 'Accessories';
	$(".topNavWrapper").clone().appendTo($("#frame-2 .onehundredeight"));
	$("#frame-2 .topNavWrapper").addClass("onehundredtwelve leftNav").removeClass("topNavWrapper").removeClass("ninety");
	$("#frame-2 .leftNav").children("div:contains('|')").remove();
	$("#frame-2 .leftNav").children("div.eightynine").removeClass("eightynine").addClass("subcategory").removeClass("topNavLink");
	//Add Main Cat
	$("#frame-2 .leftNav").prepend("<div class='maincategory'>" + maincat + "</div>");
	
	//Recommended
	$("#frame-3").children("div").wrap("<div class='onehundredeight'></div>");
	$("#frame-3").prepend("<div class='onehundredsix'></div>");
	$("#frame-3").append("<div class='onehundredseven'></div>");
	
	//Second Widget
	
	$("#content-8").children().children().children().children().children().next().children().children("a").children("img").parent().wrap("<div class='twentynine homebtmImgWrapper'></div>");
	//Resize Images
	var image = $(".twentynine").children("a").children("img");
	resizeImages(image, 110, 110);
	$(".homebtmImgWrapper").children().wrap("<div class='thirty homebtmImgBg'></div>");
	//alert($(".homebtmImgWrapper").parent().next().html());
	$(".homebtmImgWrapper").parent().next().children("a").wrap("<div class='thirtytwo homebtmTitle'></div>");
	truncateText($(".thirtytwo a"), 60);
	$("[src*='no_image_m.gif']").attr({
		"width": "110px",
		"height": "110px"
	});
	$(".thirtytwo a").css({"color":"#AAAAAA", "fontSize":"13px", "fontWeight":"normal"}).hover(
		function () {
    		$(this).css("color", "#f63");
  		},
  		function () {
    		$(this).css("color", "#aaaaaa");
  		}
	);
	$("#content-8 .bold-price").parent().next().children("a").addClass("thirtythree homebtmBuyWrapper");
	
	$("#content-8 .bold-price").wrap("<div class='thirtyfour homebtmPriceWrapper'></div>");
	
	//Move things around
	$("#content-8 .twentynine").each(function(i) {
		if (i < 2)
			j = i;
		else if (i < 4 && i > 2)
			j = i-2;
		else	
			j = i - 4;
		$(this).wrap("<div class='thirtyone homebtmWrapper'></div>");
		var parent = $(this).parent();
		$(parent).append($(this).parent().parent().next().children("div.homebtmTitle"));
		//alert($(this).parent().parent().parent().next().next().children("td").eq(i).children().children().children().html());
		$(parent).append($(this).parent().parent().parent().next().next().children("td").eq(j).children().children().children().children().children("div.homebtmPriceWrapper"));
		var pricewrapper = $(this).parent().children("div.homebtmPriceWrapper");
		$(pricewrapper).append($(this).parent().parent().parent().next().next().children("td").eq(j).children().children().children().children().children("a.homebtmBuyWrapper"));
		var price = $(pricewrapper).children(".bold-price");
		$("<span class='bar'>|</span>").insertAfter($(price));
		$("#content-8").children().children().append($(this).parent());
		i = i + 1;
	});
	$("#content-8 table").remove();
	
	/* Recommended Widget */
	
	$("#frame-3").children().children().children().children().children().children().children().children("a").children("img").parent().wrap("<div class='twentynine recommendedImgWrapper'></div>");
	//Resize Images
	var image = $(".recommendedImgWrapper").children("a").children("img");
	resizeImages(image, 73, 73);
	$(".recommendedImgWrapper").children().wrap("<div class='thirty recommendedImgBg'></div>");
	//alert($(".homebtmImgWrapper").parent().next().html());
	$(".recommendedImgWrapper").parent().parent().prev().prev().children().children("a").wrap("<div class='onehundredfourteen recommendedTitle'></div>");
	truncateText($(".recommendedTitle a"), 60);
	$("[src*='no_image_m.gif']").attr({
		"width": "110px",
		"height": "110px"
	});
	$(".recommendedTitle a").css({"color":"#AAAAAA", "fontSize":"13px", "fontWeight":"normal"}).hover(
		function () {
    		$(this).css("color", "#f63");
  		},
  		function () {
    		$(this).css("color", "#aaaaaa");
  		}
	);
	$("#frame-3 .bold-price").parent().next().children("a").addClass("recommendedBuyWrapper");
	
	$("#frame-3 .bold-price").wrap("<div class='recommendedPriceWrapper'></div>");
	
	//Move things around
	$("#frame-3 .recommendedImgWrapper").each(function(i) {
		$(this).wrap("<div class='onehundredfifteen recommededbtmWrapper'></div>");
		var parent = $(this).parent();
		$(parent).append($(this).parent().parent().parent().prev().prev().children().children("div.recommendedTitle"));
		//alert($(this).parent().parent().parent().next().next().children("td").eq(i).children().children().children().html());
		$(parent).append($(this).parent().parent().parent().next().next().children().children().children().children().children().children("div.recommendedPriceWrapper"));
		var pricewrapper = $(this).parent().children("div.recommendedPriceWrapper");
		$(pricewrapper).append($(this).parent().parent().parent().next().next().children().children().children().children().children().children("a.recommendedBuyWrapper"));
		var price = $(pricewrapper).children(".bold-price");
		$("<span class='bar'>|</span>").insertAfter($(price));
		$("#frame-3").children().children().append($(this).parent());
	});
	$("#frame-3 table").remove();
	$("#frame-3 span.bold-price span:contains('PRICE: ')").remove();
	$("#frame-3 .productSectionLabel").css("fontSize", "20px");
	
	//Best Sellers updates
	$("#frame-3_s .twentyfive:last").hide();
	$("#frame-3_s .tsTitle").each(function(i) {
		j = i + 1;
		$(this).children().prepend(j + '. ');
		i = i + 1;
	});
	
}

function greenDayBundle() {
	$("h1:first, .breadcrumbWrapper").remove();
	$(".mainContentTop").css("top", "26px");
	
	//Hide things
	$("#frame-7").css("display", "none");
	
	//Move widgets
	$("#frame-3_s").css("top", "776px");
	$("#frame-4_s").css("top", "657px");
	$("#frame-5_s").css("top", "396px");
	$("#frame-6_s").css({"left":"6px", "top":"48px"});
	
	$(".sixtyfour").css("zIndex", "0");
	$(".seventynine").css("left", "177px");
}

function search(){
	//Hide widgets
	$("#frame-2_s").css("display", "none");
	$("#frame-3_s").css("display", "none");
	$("#frame-4_s").css("display", "none");
	$("#frame-5_s").css("display", "none");
	$("#frame-6_s").css("display", "none");
	$(".breadcrumbWrapper").css("display", "none");
	
	//Widen Content area
	$(".mainContentTop").removeClass("ten").addClass("fortyseven").css("top", "27px");
	$(".leftcolWrapper").removeClass("nine").addClass("fortysix").css("top", "27px");
	$(".mainContentBottom").removeClass("eleven").addClass("fortyeight").css("top", "27px");
	$(".leftcolWrapper").css("height", "990px");
	$("#leftcol").css({"width":"900px", "display":"none"});
	
	//Header
	var keyword = $("h1").text().split(": ");
	var search = '"' + keyword[1] + '"';
	$("<div class='seventytwo searchHeader'><h1>Search Results for " + search + "</h1></div>").insertBefore($("#leftcol"));
	$("h1:last").remove();
	
	//Resize image and put background
	$("a.r").wrap("<div class='sixtyone searchImageWrapper'></div>");
	
	//Styling
	$(".product-title").css({
		"color": "#3399cc",
		"width": "162px"
	}).hover(
		function () {
    		$(this).css("color", "#f63");
  		},
  		function () {
    		$(this).css("color", "#3399cc");
  		}
	);
	$(".k").wrap("<div class='seventythree searchPrice'></div>");
	$("#sortBy").next("table").wrap("<div class='seventyfour searchProductListWrapper'></div>");
	$(".searchImageWrapper").css({
		"position": "relative"
	});
	$(".searchImageWrapper").each(function(i){
		$(this).parent().children().wrapAll("<div class='seventyfive searchProductWrapper'></div>");
		var parent = $(this).parent();
		$(".searchProductListWrapper").append($(parent));
		
		if (i == 3 || i == 7) {
			$("<hr class='eighty searchHr'>").insertAfter(parent);
		}
		i = i + 1;
	});
	$(".searchImageWrapper").wrap("<div class='sixtyonewrapper'></div>");
	$("#leftcol").css("top", "7px");
	$(".searchProductListWrapper").children("table").remove();
	
	//Pagination
	$("[src*='page_next.gif']").parent().css({
		"textDecoration": "none",
		"textTransform": "uppercase",
		"marginLeft":"15px"
	}).html("next >>");
	$("[src*='page_prev.gif']").parent().css({
		"textDecoration": "none",
		"textTransform": "uppercase",
		"marginRight":"20px"
	}).html("<< prev");
	$(".breadcrumbWrapper").parent().next().children().wrapAll("<div class='seventysix searchPagination'></div>");
	$("a:contains('<< prev'):last").parent().children().wrapAll("<div class='seventyeight searchPaginationBottom'></div>");
	$("b:contains('1'):last").parent().children().wrapAll("<div class='seventyeight searchPaginationBottom'></div>");
	$("<span>Page:</span>").insertBefore($(".searchPagination").children(":contains('1')"));
	$("<span>Page:</span>").insertBefore($(".searchPaginationBottom").children(":contains('1')"));
	var atop = $(".searchPagination").children("a").not(":contains('1')");
	var abottom = $(".searchPaginationBottom").children("a").not(":contains('1')");
	var btop = $(".searchPagination").children("b").not(":contains('1')");
	var bbottom = $(".searchPaginationBottom").children("b").not(":contains('1')");
	$("<span style='color:#3399CC'>|</span>").insertBefore($(atop));
	$("<span style='color:#3399CC'>|</span>").insertBefore($(abottom));
	$("<span style='color:#3399CC'>|</span>").insertBefore($(btop));
	$("<span style='color:#3399CC'>|</span>").insertBefore($(bbottom));
	if ($(".searchPagination").children(":first").html() == '|') 
		$(".searchPagination").children(":first").remove();
	if ($(".searchPaginationBottom").children(":first").html() == '|') 
		$(".searchPaginationBottom").children(":first").remove();
	$(".searchPagination").insertAfter($(".searchHeader"));
	$("a:contains('next >>')").prev("span").remove();
	
	//Sorting
	$("#sortBy").addClass("seventyseven searchSortby");
	$("#sortBy label").html("Sort By:");
	$(".searchSortby").insertAfter($(".searchPagination"));
	
	$(".searchProductListWrapper").insertAfter($(".searchSortby"));
	$(".searchPaginationBottom").insertAfter($(".searchProductListWrapper"));
	
	//No Results
	if ($("#emptysearch-widget").length) {
		$(".noResultsTitle").css({
			"color": "#aaaaaa",
			"paddingLeft": "0px"
		});
		$(".noResultsTitleKeyword").css("color", "#aaaaaa");
		$(".leftcolWrapper").css("height", "570px");
	}
}

function help() {
	//Hide widgets
	$("#frame-2_s").css("display", "none");
	$("#frame-3_s").css("display", "none");
	$("#frame-4_s").css("display", "none");
	$("#frame-5_s").css("display", "none");
	$("#frame-6_s").css("display", "none");
	$(".breadcrumbWrapper").css("display", "none");
	
	$(".fortysix").prepend($("h1:first"));
	$(".breadcrumbWrapper").css("display", "none");
	$("h1").wrap("<div class='seventytwo cartHeader'></div>");
	$("h1").css("fontSize", "23px");
	$("h2").css({"fontSize":"16px", "color":"#aaaaaa"});
	$("h3").css({"fontSize":"14px", "fontWeight":"bold"});
	$(".fortyseven").css("top", "27px");
	$(".fortysix").css("top", "27px");
	$(".fortyeight").css("top", "27px");
	$("p").css("marginTop", "15px");
	$("ul").css({"marginTop":"15px", "marginLeft":"20px"});
	$("ol").css({"marginTop":"15px", "marginLeft":"20px"});
	$("ul li").css({"listStyle":"disc"});
	$("ol li").css({"listStyle":"decimal"});
	$("h3").css("marginTop", "15px");
	$("table.help td").css({
		"padding": "3px",
		"borderRight":"1px solid #1D6CB9"
	});
	$("table.availability td:first").css({
		"paddingRight": "40px"
	});
}

function category() {
	//Reposition Widgets
	$("#frame-2_s").css("top", "203px");
	$("#frame-3_s").css("top", "735px");
	$("#frame-4_s").css("top", "415px");
	$("#frame-5_s").css("top", "475px");
	$("#frame-6_s").css("top", "135px");
	$(".breadcrumbWrapper").css({"top":"182px", "marginLeft":"87px"});
	$(".breadcrumbWrapper").children(".crumbPast:last").show().prev("span.fiftysix").show();
	$("#postpage-widget_s").css("marginTop", "188px");
	$("#frame-2_s, #frame-4_s, #frame-5_s, #frame-3_s").css("marginLeft", "618px");
	
	//Styling
	$("#sortBy").next("table").wrap("<div class='eightysix categoryTable'></div>");
	$(".categoryTable img").parent().wrap("<div class='eightyone categoryImgWrapper'></div>");
	var image = $(".eightyone").children("a").children("img");
	resizeImages(image, 73, 73);
	$(".categoryImgWrapper").children().wrap("<div class='eightytwo categoryImgBg'></div>");
	
	$(".eightyone").each(function(i) {
		//alert(i);
		//alert(j);
		if (i < 2)
			j = i;
		else if (i < 4)
			j = i-2;
		else if (i < 6)
			j = i-4;
		else 
			j = i-8;
		$(this).wrap("<div class='eightythree categoryWrapper'></div>");
		var parent = $(this).parent();
		$(this).parent().parent().parent().next().children("td").eq(j).children("h3").wrap("<div class='eightyfour categoryTitle'></div>");
		$(parent).append($(this).parent().parent().parent().next().children().children("div.categoryTitle"));
		$(this).parent().parent().parent().next().next().children("td").eq(j).children("span").wrap("<div class='eightyfive categoryPriceWrapper'></div>");
		$(parent).append($(this).parent().parent().parent().next().next().children().children("div.categoryPriceWrapper"));
		$(".categoryTable").append($(this).parent());
		var href = $(this).children().children("a").attr("href");
		$(this).next().next(".categoryPriceWrapper").append("<span class='bar'>|</span><a href='" + href + "' class='thirtythree homebtmBuyWrapper'><img title='Add to Cart' src='/images/rbbuynowsmall.jpg' class='wba_add_to_cart_btn' alt='Add to Cart'></a>");
		i = i + 1;
	});
	$(".categoryTitle a").css({"fontSize":"13px", "color":"#aaaaaa"}).hover(
		function () {
    		$(this).css("color", "#f63");
  		},
  		function () {
    		$(this).css("color", "#aaaaaa");
  		}
	);
	truncateText($(".categoryTitle a"), 60);
	$(".categoryTable").children("table").remove();
	$(".product-price").css({"color":"#AAAAAA", "fontWeight":"normal"});
	$(".product-price").children("br").remove();
	$(".categoryPriceWrapper").prepend($("<span>PRICE: </span>"));
	$(".leftcolWrapper").prepend($("h1"));
	$("h1").addClass("seventytwo categoryHeader");
	//$(".categoryHeader").css({"left":"26px", "top":"5px", "float":"left"});
	
	//Pagination
	$("[src*='page_next.gif']").parent().css({"textDecoration":"none", "textTransform":"uppercase"}).html("next >>");
	$("[src*='page_prev.gif']").parent().css({"textDecoration":"none", "textTransform":"uppercase"}).html("<< prev");
	$(".breadcrumbWrapper").parent().next().children().wrapAll("<div class='seventysix categoryPagination'></div>");
	$("#leftcol-col-1").children().children().children().children(":last").children().wrapAll("<div class='seventysix categoryPagination'></div>");
	$("a:contains('<< prev'):last").parent().children().wrapAll("<div class='seventyeight categoryPaginationBottom'></div>");
	$("b:contains('1'):last").parent().children().wrapAll("<div class='seventyeight categoryPaginationBottom'></div>");
	$(".seventyeight").css({"top":"630px", "right":"20px"});
	$("<span>Page:</span>").insertBefore($(".categoryPagination").children(":contains('1')"));
	$("<span>Page:</span>").insertBefore($(".categoryPaginationBottom").children(":contains('1')"));
	var atop = $(".categoryPagination").children("a").not(":contains('1')");
	var abottom = $(".categoryPaginationBottom").children("a").not(":contains('1')");
	var btop = $(".categoryPagination").children("b").not(":contains('1')");
	var bbottom = $(".categoryPaginationBottom").children("b").not(":contains('1')");
	$("<span style='color:#3399CC'>|</span>").insertBefore($(atop));
	$("<span style='color:#3399CC'>|</span>").insertBefore($(abottom));
	$("<span style='color:#3399CC'>|</span>").insertBefore($(btop));
	$("<span style='color:#3399CC'>|</span>").insertBefore($(bbottom));
	if ($(".categoryPagination").children(":first").html() == '|')
		$(".categoryPagination").children(":first").remove();
	if ($(".categoryPaginationBottom").children(":first").html() == '|')
		$(".categoryPaginationBottom").children(":first").remove();
	$(".categoryPagination").insertAfter($(".categoryHeader"));
	$(".categoryPagination").css({"right":"20px", "top":"13px", "position":"relative"});
	
	$(".categoryTable").insertAfter($(".sortpageWrapper"));
	$(".categoryPaginationBottom").insertAfter($(".categoryTable"));
	//$("#leftcol").remove();
	
	//Sorting
	$("#sortBy").addClass("seventyseven categorySortby");
	$("#sortBy label").html("Sort By:");
	if ($(".categoryPagination").length)
		$(".categorySortby").insertAfter($(".categoryPagination"));
	else 
		$(".categorySortby").insertAfter($(".categoryHeader"));
	$(".categorySortby").wrap("<div class='eightyseven sortpageWrapper'></div>");
	$(".categorySortby").css({"right":"0px", "top":"0px"});
	
	//Wrap Main Content
	$(".mainContentTop").wrap("<div class='seventyone leftWrapper'></div>");
	$(".leftWrapper").append($(".leftcolWrapper"));
	$(".leftWrapper").append($(".mainContentBottom"));
	$(".leftWrapper").css("top", "34px");
	
	//Top Nav
	$("body").css("backgroundImage", "url('http://www.rockbandstore.com/images/rbbgheadercategory.jpg')");
	$("table#leftnav-sibling:first").parent().children().children().children().children("td#button").children("h2").children("a").wrap("<div class='eightynine topNavLink'></div>");
	$(".content").prepend($("<div class='ninety topNavWrapper'></div>"));
	$(".topNavWrapper").append($(".topNavLink"));
	//$(".topNavWrapper").prepend("<div class='ninetyone topNavArrow'><img src='http://rockband.amazonwebstore.com/images/rbtopnavarrow.gif'></div>");
	$("<div style='color:#3399CC; float:left;'>|</span>").insertBefore($(".topNavLink:not(':first')"));
	var category = $(".leftnav-head").children().children(":first").children().children("a").text();
	if (category == 'Games')
		$(".topNavArrow").css("marginLeft", "156px");
	else
		$(".topNavArrow").css("marginLeft", "75px");
	var title = $(".categoryHeader").text();
	$(".topNavWrapper .topNavLink:contains(" + title + ")").children("a").css("color", "black");
	var navhead = $(".leftnav-head").children().children("tr:first").children().children("a").text();
	
	$(".headerNavCat a:contains('" + navhead + "')").css("color", "#f7c912");
	//Change header to include main category refernce
	var categoryHeader = $(".categoryHeader").text();
	if ($(".categoryHeader").text() == 'Featured RBN CDs') {
		$(".headerNavCat a").css("color", "#ffffff");
		$(".headerNavCat a:contains('Accessories')").css("color", "#f7c912");
		if ($.browser.msie) {
			$(".topNavWrapper").css("marginLeft", "338px").children("div:first").remove();
			$(".topNavWrapper").children("div:first").remove();
			$(".topNavWrapper").children("div:first").next().html("<a href='/category/44168283541/1/Instruments.htm'>Instruments</a>");
			$(".topNavWrapper").children("div:first").next().next().next().html("<a href='/category/44168283421/1/Stage-Gear.htm'>Stage Gear</a>");
		}
		else {
			$(".topNavWrapper").css("marginLeft", "338px").children("div:first").html("<a href='/category/44168283541/1/Instruments.htm'>Instruments</a>");
			$(".topNavWrapper").children("div:first").next().next().html("<a href='/category/44168283421/1/Stage-Gear.htm'>Stage Gear</a>");
			$(".topNavWrapper").children("div:first").next().next().next().next().css("display", "none").next().css("display", "none");
		}
	}
	else 
		$(".categoryHeader").text(navhead + " for " + categoryHeader);
	if (navhead == 'Accessories')
		$(".topNavWrapper").css("marginLeft", "338px");
		
	if ($(".topNavWrapper").children("div:first").text() == '|')
		$(".topNavWrapper").children("div:first").remove();
		
	/* Refresh Changes */
	
	$("#leftcol").css("width", "415px");
	$(".mainContentTop").removeClass("ten").removeClass("mainContentTop").addClass("onehundrednine mainContentNewTop");
	$(".leftcolWrapper").removeClass("nine").removeClass("leftcolWrapper").addClass("onehundredeleven leftcolWrapperNew");
	$(".mainContentBottom").removeClass("eleven").removeClass("mainContentBottom").addClass("onehundredten mainContentNewBottom");
	$(".mainContentNewTop").wrap("<div class='centercol'></div>");
	$(".centercol").append($(".leftcolWrapperNew")).append($(".mainContentNewBottom"));
	$(".centercol").css("marginTop", "-17px");
	$(".leftcolWrapperNew").css("height", "685px");
	$(".leftWrapper").css("height", "890px");
	$("#leftcol").css("left", "0px");
	$("#leftcol").css("left", "0px");
	$(".categoryPaginationBottom").css({"top":"675px"});
	
	//Left Column
	$("#leftnav-6").attr("id", "frame-2");
	$("#leftnav-7").attr("id", "frame-3");
	$("#frame-3").wrap($("<div class='leftcolnarrow'></div>"));
	$(".leftcolnarrow").prepend($("#frame-2"));
	$(".leftcolnarrow").insertBefore($(".centercol"));
	$("#frame-2").addClass("leftnavigation");
	$(".leftcolnarrow").css("marginTop", "30px");
	
	/* Recommended Widget */
	$("#frame-3").children("div").wrap("<div class='onehundredeight'></div>");
	$("#frame-3").prepend("<div class='onehundredsix'></div>");
	$("#frame-3").append("<div class='onehundredseven'></div>");
	$("#frame-3 .productSectionLabel").css({"padding":"0px", "color":"#F7C912",  "fontSize":"20px", "paddingTop":"10px"});
	
	$("#frame-3").children().children().children().children().children().children().children().children("a").children("img").parent().wrap("<div class='twentynine recommendedImgWrapper'></div>");
	//Resize Images
	var image = $(".recommendedImgWrapper").children("a").children("img");
	resizeImages(image, 73, 73);
	$(".recommendedImgWrapper").children().wrap("<div class='thirty recommendedImgBg'></div>");
	//alert($(".homebtmImgWrapper").parent().next().html());
	$(".recommendedImgWrapper").parent().parent().prev().prev().children().children("a").wrap("<div class='onehundredfourteen recommendedTitle'></div>");
	truncateText($(".recommendedTitle a"), 60);
	$("[src*='no_image_m.gif']").attr({
		"width": "110px",
		"height": "110px"
	});
	$(".recommendedTitle a").css({"color":"#AAAAAA", "fontSize":"13px", "fontWeight":"normal"}).hover(
		function () {
    		$(this).css("color", "#f63");
  		},
  		function () {
    		$(this).css("color", "#aaaaaa");
  		}
	);
	$("#frame-3 .bold-price").parent().next().children("a").addClass("recommendedBuyWrapper");
	
	$("#frame-3 .bold-price").wrap("<div class='recommendedPriceWrapper'></div>");
	
	//Move things around
	$("#frame-3 .recommendedImgWrapper").each(function(i) {
		$(this).wrap("<div class='onehundredfifteen recommededbtmWrapper'></div>");
		var parent = $(this).parent();
		$(parent).append($(this).parent().parent().parent().prev().prev().children().children("div.recommendedTitle"));
		//alert($(this).parent().parent().parent().next().next().children("td").eq(i).children().children().children().html());
		$(parent).append($(this).parent().parent().parent().next().next().children().children().children().children().children().children("div.recommendedPriceWrapper"));
		var pricewrapper = $(this).parent().children("div.recommendedPriceWrapper");
		$(pricewrapper).append($(this).parent().parent().parent().next().next().children().children().children().children().children().children("a.recommendedBuyWrapper"));
		var price = $(pricewrapper).children(".bold-price");
		$("<span class='bar'>|</span>").insertAfter($(price));
		$("#frame-3").children().children().append($(this).parent());
	});
	$("#frame-3 table").remove();
	$("#frame-3 span.bold-price span:contains('PRICE: ')").remove();
	
	//Best Sellers updates
	$("#frame-3_s .twentyfive:last").hide();
	$("#frame-3_s .tsTitle").each(function(i) {
		j = i + 1;
		$(this).children().prepend(j + '. ');
		i = i + 1;
	});
	
	//Navigation
	var maincat = $(".leftnav-head").children().children("tr:first").children().children("a");
	$(".topNavWrapper").clone().appendTo($("#frame-2 .onehundredeight"));
	$("#frame-2 .topNavWrapper").addClass("onehundredtwelve leftNav").removeClass("topNavWrapper").removeClass("ninety");
	$("#frame-2 .leftNav").children("div:contains('|')").remove();
	$("#frame-2 .leftNav").children("div.eightynine").removeClass("eightynine").addClass("subcategory").removeClass("topNavLink");
	//Add Main Cat
	$("#frame-2 .leftNav").prepend("<div class='maincategory'></div>");
	$("#frame-2 .maincategory").append($(maincat));
	$("#frame-2 .subcategory").children("a").css("color", "#F7C912");
	
	if ($(".categoryPagination").length > 1)
		$(".categoryPagination:first").remove();
	if ($(".sortpageWrapper").length > 1)
		$(".sortpageWrapper:first").remove();
	$("#frame-2 .leftNav").css("marginLeft", "0px")
}
	
function details(product) {
	//var product = 'B0016HLABO';
	//Hide things
	$("#frame-7").css("display", "none");
	$("a:contains('Email')").hide().siblings().hide();
	$("a:contains('Zoom')").hide().siblings().hide();
	$("b:contains('SKU:')").css("display", "none");
	
	//Move widgets
	$("#frame-2_s").css("top", "172px");
	$("#frame-3_s").css("top", "699px");
	$("#frame-4_s").css("top", "649px");
	$("#frame-5_s").css("top", "384px");
	$(".mainContentTop").css("top", "25px");
	$(".leftcolWrapper").css("top", "25px");
	$(".mainContentBottom").css("top", "25px");
	$(".breadcrumbWrapper").css({"top":"158px", "marginLeft":"87px"});
	$("#frame-2_s, #frame-4_s, #frame-5_s, #frame-3_s").css("marginLeft", "618px");
	$("#frame-6_s").css("clear", "both");
	
	//Styling
	
	
	//Title
	$("h1:first").wrap("<div class='fiftynine detailsTitleWrapper'></div>");
	$(".leftcolWrapper").prepend($(".detailsTitleWrapper"));
	$(".detailsTitleWrapper").wrap("<div class='sixty productDetailsWrapper'></div>");
	//$("<div style='position:relative; top:8px;'><img src='http://rockband.amazonwebstore.com/images/rbhrwide.jpg'></div>").insertAfter($(".detailsTitleWrapper"));
	
	//Product Image Column
	$("#leftcol-col-251").children().wrapAll("<div class='fiftyeight detailsImageColumnWrapper'></div>");
	$("#productImage").parent().wrap("<div class='sixtyone detailsImageWrapper'></div>");
	$(".sixtyone").wrap("<div class='sixtyonewrapper'></div>");
	$(".detailsImageColumnWrapper").children("table").wrap("<div class='sixtytwo detailsImageSectionWrapper'></div>");
	$(".detailsImageSectionWrapper").children("table").attr("width", "162px");
	$(".productDetailsWrapper").append($(".detailsImageColumnWrapper"));
	//Resize Images
	//alert($(".detailsImageWrapper img").attr("width"));
	var image = $(".detailsImageWrapper").children("a").children("img");
	
	if ($.browser.msie) {
		if ($.browser.version == '8.0') {
			//$(image).css("width", "162px");
			$(".detailsImageWrapper").css({"display":"inline-block"});
		}
		else {
			$(".detailsImageWrapper").css({"maxWidth":"162px", "maxHeight":"162px"});
		}
	}
	else
		$(".detailsImageWrapper").css({"maxWidth":"162px", "maxHeight":"162px"});
	
	/*if ($.browser.msie) {
		if ($.browser.version == '7.0') {
			$(".sixtyone").css("height", "auto");
		}
	}*/
	//Thumbnails
	$(".detailsImageSectionWrapper").children().children().children("tr:first").next().children().children("table").children().children().children().children("img").addClass("onehundredfive detailsThumbWrapper");
	$(".detailsThumbWrapper").css("border", "1px solid #12baba").hover(
		function () {
    		$(this).css("border", "1px solid #f63");
  		},
  		function () {
    		$(this).css("border", "1px solid #12baba");
  		}
	);
	
	//Product Details Column
	$(".detailsImageColumnWrapper").wrap("<div style='margin-bottom:0px;position:relative;'></div>");
	$(".detailsInfoWrapper").insertAfter($(".detailsImageColumnWrapper"));
	$("#leftcol").wrap("<div class='onehundred detailsTable'></div>");
	//$("#leftcol").css("top", "70px");
	$("#leftcol-col-252").children("table").wrap("<div class='sixtyfour detailsInfoWrapper'></div>");
	$(".detailsInfoWrapper").prepend($(".wbaProductRatingWidget"));
	$(".list-label").parent().parent().parent().wrap("<div class='sixtyfive detailsPriceWrapper'></div>");
	$(".sixtyfive .our-label").css("paddingRight", "10px");
	if ($(".wbaProductRatingWidget").length) 
		$(".detailsPriceWrapper").insertAfter($(".wbaProductRatingWidget"));
	else {
		$(".detailsInfoWrapper").prepend($(".detailsPriceWrapper"));
		
	}
	//Remove empty line
	
	//Move Shipping
	var checkshipping = $("td:contains('Shipping: ')").next("td:last").html();
	if (checkshipping != null) {
		var shipping = "<div class='sixtysix detailsShipping'><span class='shipping'>Shipping:</span>" + $("td:contains('Shipping: ')").next("td:last").html() + "</div>";	
	}
	else
		var shipping = "<div class='sixtysix detailsShipping'></div>";	
	$(shipping).insertAfter($(".detailsPriceWrapper"));
	$(".save-label").parent().next().children("td").html("");
	$("#savingsAmountLabel").parent().parent().next().children().css("display", "none");
	
	//In Stock
	$("#inStock").wrap("<div class='sixtyeight detailsInstock'></div>");
	$(".detailsInstock").insertAfter($(".detailsShipping"));
	$("#inStock").css({"fontWeight":"normal", "fontSize":"13px", "color":"#AAAAAA"});
	//Availability
	$("#parentAvailability").parent().wrap("<div class='sixtyseven detailsAvailability'></div>");
	if ($(".detailsInstock").length) 
		$(".detailsAvailability").insertAfter($(".detailsInstock"));
	else {
		$(".detailsAvailability").insertAfter($(".detailsShipping"));
		$("span:contains('Out of stock')").css("display", "none");
		$(".detailsAvailability span:contains('Out of stock')").css("display", "block");
	}
	$(".detailsAvailability").children().children("b").hide();
	$(".detailsAvailability span").css("fontSize", "13px");
	//Size if available
	
	//Button
	$(".detailsInfoWrapper [src*='btn_addtocart_lg.gif']").attr("src", "http://rockband.amazonwebstore.com/images/rb_details_addtocart.jpg");
	$(".detailsInfoWrapper .preorder_btn").attr("src", "http://rockband.amazonwebstore.com/images/rb_details_addtocart.jpg");
	
	$(".detailsInfoWrapper").insertAfter($(".detailsImageColumnWrapper"));
	$("#frame-6_s").css("top", "45px");
	$(".detailsAvailability").next("table").wrap("<div class='seventynine addToCartDetails'></div>");
	//Take out line breaks from product availability forms
	$(".addToCartDetails").children().children().children("tr").eq(2).children().html("");
	if ($(".addToCartDetails").children().children().children("tr").eq(4).children().html() == '&nbsp;')
		$(".addToCartDetails").children().children().children("tr").eq(4).children().html("");
	if ($(".addToCartDetails").children().children().children("tr").eq(6).children().html() == '&nbsp;')
		$(".addToCartDetails").children().children().children("tr").eq(6).children().html("");
	if ($(".addToCartDetails").children().children().children("tr").eq(9).children().html() == '&nbsp;')
		$(".addToCartDetails").children().children().children("tr").eq(9).children().html("");
	if (!$(".wbaProductRatingWidget").length)
		$(".addToCartDetails").css("top", "111px");
	if ($("#listPrice").html() == '')
		$(".addToCartDetails").css("top", "125px");
	//Move button form
	if ($.browser.msie) {
		if ($.browser.version > '7.0') {
			$(".addToCartDetails").css("top", "172px");
		}
		else {
			$(".addToCartDetails").css("top", "172px");
			if ($("#limitedQuantity").length) {
				$(".addToCartDetails").css("top", "170px")
			}	
		}
	}
	$("#limitedQuantity").parent().css("paddingTop", "10px");
	if ($.browser.msie) {
		if ($.browser.version == '7.0') {
			$(".addToCartDetails").css("left", "0px");
		}
	}
	$("#sku").css("display", "none");
	$(".thirdPartyWarning").parent().parent().prev().remove();
	
	//Ratings
	$("<div class='sixtythree detailsRating'></div>").insertAfter($(".addToCartDetails"));
	switch(product) {	
		case "B0016HLABO": case "B000TSZADA": case "B000TSX3TS": case "B000TT2D0M": 
			$(".detailsRating").html("<img src='http://rockband.amazonwebstore.com/images/lyrics-mildsuggestivethemes.gif'>")
			break;
		case "B001BXACDA": case "B001BX4U5G": case "B001BXACIA": case "B001BXA9CE": case "B001BXA9AG": case "B001BX6JUA": case "B001BX6JY6": case "B001920EMM": case "B001920ELI": case "B001F03N62": case "B001F03MRW": case "B001F04T8I": case "B001F03MY0": case "B0026IZU68":
			$(".detailsRating").html("<img src='http://rockband.amazonwebstore.com/images/lyrics_suggestivethemes.gif'>")
			break;
		case "B001LJPAAO": case "B001KAMZ8E": case "B001KAN1VO": case "B001LVXEC8": 
			$(".detailsRating").html("<img src='http://rockband.amazonwebstore.com/images/lyrics.gif'>")
			break;
		case "B001ZE3G74": case "B001ZE3G7E": case "B001ZE3G7O": case "B001ZE3G7Y": case "B002M2N9O8": case "B002M2N9NY": case "B002M2N9OI": case "B002M2N9NO": 
			$(".detailsRating").html("<img src='http://rockband.amazonwebstore.com/images/mildlyrics.gif'>")
			break;
		case "B002AO7DHW": case "B002AO7DTK": case "B002AO7DAY": case "B002ARW2CA": 
			$(".detailsRating").html("<img src='http://rockband.amazonwebstore.com/images/lyrics_e10plus.gif'>")
			break;
		case "B001TOMQYO": case "B001TOMR0M": case "B001TOMR5C": case "B001TOQ8VQ": 
			$(".detailsRating").html("<img src='http://rockband.amazonwebstore.com/images/e10.gif'>")
			break;
		case "B001TOQ8LG": case "B001TOMQRG": case "B001TOQ8JS": case "B001TOMQXA": case "B001TORSHY": case "B001TOMQUS": case "B002I7A832": case "B002I7A82I": case "B002I7A82S": 
			$(".detailsRating").html("<img src='http://rockband.amazonwebstore.com/images/esrb_mildlyrics_tobacco.gif'>")
			break;
		case "B0039R62SK": case "B0039R62GW": case "B0039RFIQM": case "B003E4B792": case "B003E4CZDY":
			$(".detailsRating").html("<img src='http://rockband.amazonwebstore.com/images/esrb_t_drug_lyric_blood.gif'>")
			break;
	}
	
	//Features, Description, Etc
	$("#leftcol h2").css({"color":"#AAAAAA", "fontSize":"13px","fontWeight":"normal"});
	$("#leftcol strong").css({"color":"#f7c912", "fontSize":"17px","fontWeight":"bold"});
	$("#leftcol strong").wrap("<div class='sixtynine detailsInfoHeaders'></div>");
	$(".detailsInfoHeaders:not(':first')").css("borderTop", "1px dotted #333333");
	$("#toyWarnings .sixtynine").css("border", "none");
	$("#features h2").css({"color":"#AAAAAA", "fontSize":"13px"});
	$(".productDetails").children().children().children("td").css("width", "200px");
	
	//Wrap Main Left Content to set Min Height
	$(".mainContentTop").wrap("<div class='seventyone leftWrapper'></div>");
	$(".leftWrapper").append($(".leftcolWrapper"));
	$(".leftWrapper").append($(".mainContentBottom"));
	$(".leftWrapper").css("min-height", "1180px");
	$(".leftcolWrapper").css("paddingBottom", "80px");
	
	//Hide dimensions if 0 
	$(".productDetails td:contains('0.0 inches')").each(function() {
		$(this).parent().hide();
	});
	//Ships in 1 business days
	if ($("#parentAvailability").text() == 'Usually ships in 1 business days') {
		$("#parentAvailability").text("Usually ships in 1 business day");
	}
	
	//Deal with odd characters 
	$(".detailsTable h2").each(function() {
		var text = $(this).text();
		text.replace("’", "'");
		text.replace("�", "-");
	});
	
	/* Refresh Changes */
	
	$("#leftcol").css("width", "375px");
	$(".mainContentTop").removeClass("ten").removeClass("mainContentTop").addClass("onehundrednine mainContentNewTop");
	$(".leftcolWrapper").removeClass("nine").removeClass("leftcolWrapper").addClass("onehundredeleven leftcolWrapperNew");
	$(".mainContentBottom").removeClass("eleven").removeClass("mainContentBottom").addClass("onehundredten mainContentNewBottom");
	$(".mainContentNewTop").wrap("<div class='centercol'></div>");
	$(".centercol").append($(".leftcolWrapperNew")).append($(".mainContentNewBottom"));
	$(".centercol").css("marginTop", "5px");
	$("#frame-3_s .productSectionLabel b").text("Top Sellers");
	
	//Left Column
	$("#leftnav-6").attr("id", "frame-2");
	$("#leftnav-7").attr("id", "frame-3");
	$("#frame-3").wrap($("<div class='leftcolnarrow'></div>"));
	$(".leftcolnarrow").prepend($("#frame-2"));
	$(".leftcolnarrow").insertBefore($(".centercol"));
	$("#frame-2").addClass("leftnavigation");
	$(".leftcolnarrow").css("marginTop", "26px");
	
	/* Recommended Widget */
	$("#frame-3").children("div").wrap("<div class='onehundredeight'></div>");
	$("#frame-3").prepend("<div class='onehundredsix'></div>");
	$("#frame-3").append("<div class='onehundredseven'></div>");
	$("#frame-3 .productSectionLabel").css({"padding":"0px", "color":"#F7C912",  "fontSize":"20px", "paddingTop":"10px"});
	
	$("#frame-3").children().children().children().children().children().children().children("a").children("img").parent().wrap("<div class='twentynine recommendedImgWrapper'></div>");
	//Resize Images
	var image = $(".recommendedImgWrapper").children("a").children("img");
	resizeImages(image, 73, 73);
	$(".recommendedImgWrapper").children().wrap("<div class='thirty recommendedImgBg'></div>");
	//alert($(".homebtmImgWrapper").parent().next().html());
	$(".recommendedImgWrapper").parent().parent().prev().prev().children().children("a").wrap("<div class='onehundredfourteen recommendedTitle'></div>");
	truncateText($(".recommendedTitle a"), 60);
	$("[src*='no_image_m.gif']").attr({
		"width": "110px",
		"height": "110px"
	});
	$(".recommendedTitle a").css({"color":"#AAAAAA", "fontSize":"13px", "fontWeight":"normal"}).hover(
		function () {
    		$(this).css("color", "#f63");
  		},
  		function () {
    		$(this).css("color", "#aaaaaa");
  		}
	);
	$("#frame-3 .bold-price").parent().next().children("a").addClass("recommendedBuyWrapper");
	
	$("#frame-3 .bold-price").wrap("<div class='recommendedPriceWrapper'></div>");
	
	//Move things around
	$("#frame-3 .recommendedImgWrapper").each(function(i) {
		$(this).wrap("<div class='onehundredfifteen recommededbtmWrapper'></div>");
		var parent = $(this).parent();
		$(parent).append($(this).parent().parent().parent().prev().prev().children().children("div.recommendedTitle"));
		//alert($(this).parent().parent().parent().next().next().children("td").eq(i).children().children().children().html());
		$(parent).append($(this).parent().parent().parent().next().next().children().children().children().children().children().children("div.recommendedPriceWrapper"));
		var pricewrapper = $(this).parent().children("div.recommendedPriceWrapper");
		$(pricewrapper).append($(this).parent().parent().parent().next().next().children().children().children().children().children().children("a.recommendedBuyWrapper"));
		var price = $(pricewrapper).children(".bold-price");
		$("<span class='bar'>|</span>").insertAfter($(price));
		$("#frame-3").children().children().append($(this).parent());
	});
	$("#frame-3 table").remove();
	$("#frame-3 span.bold-price span:contains('PRICE: ')").remove();
	
	//Best Sellers updates
	$("#frame-3_s .tsTitle").each(function(i) {
		j = i + 1;
		$(this).children().prepend(j + '. ');
		i = i + 1;
	});
	
	//Left Navigation
	var maincattext = $(".leftnav-head").children().children(":first").children(":first").next().text()
	$("#frame-2 .onehundredeight").append("<div class='onehundredtwelve leftNav'><div class='maincategory'>" + maincattext + "</div></div>");
	$(".leftnav #button h2, .leftnav-sibling #button h2").children().wrap("<div class='subcategory'></div>");
	$(".leftNav").append($(".subcategory"));
}


// Formats these listing types > New Products, Featured Products, DVDs, Recently Viewed Items
function listings() {
	/*$("body").data("itemCount", 0);
	$(".sixteen .productItemBin").children("td").children("div").each(function() {	
		var lastClass = $(this).attr("class").split(" "),
			lastClassLength = lastClass.length-1,
			thisParent = $(this).closest(".sixteen"),
			thisLabel = $(this).parent().attr("class").split(" ");
		
		$("body").data("itemName", thisLabel[thisLabel.length-1]);
		
		switch(lastClass[lastClassLength]) {
			case "imageWrapper":
				$("body").data("itemCount", $("body").data("itemCount")+1);
				
				$(thisParent).append("<div class='thirtyseven itemBin "+ $('body').data('itemName')+"Item"+$("body").data("itemCount")+"'></div>");		
				$("."+$('body').data('itemName')+"Item"+$("body").data("itemCount")).append($(this));			
				break;
			case $('body').data('itemName')+"Title":
				$("."+$('body').data('itemName')+"Item"+$("body").data("itemCount")).append($(this));	
				break;
		}
	});
	
	$("body").data("moneyCount", 0);
	$(".sixteen .productMoneyRow").children("td").children("div").each(function() {
		var thisMoney = $(this).children("table").children().children(),
		thisLabel = $(this).parent().attr("class").split(" ");
		
		$("body").data("itemName", thisLabel[thisLabel.length-1]);
		$("body").data("moneyCount", $("body").data("moneyCount")+1);
		
		$("."+$('body').data('itemName')+"Item"+$("body").data("moneyCount")).append($(thisMoney).children().children());
	});
	$(".sixteen").css("padding", "0px");
	$(".sixteen table").remove();
	$(".sixteen itemBin").append("<div style='clear:both'></div>");
	
	
	//Resize images for listings
	$(".imageWrapper img").each(function() {
		var w = parseInt($(this).css("width"));
        var h = parseInt($(this).css("height"));
        var changed = false;

        if ( w > 76 ) {
            var f = 1 - ((w - 76) / w);
            w = w * f;
            h = h * f;
            changed = true;
        }
        
        if ( h > 100 ) {
            var f = 1 - (( h - 100) / h);
            w = w * f;
            h = h * f;
            changed = true;
        }
        
        if ( changed = true) {
            $(this).css("width", w);
            $(this).css("height", h);
        }
	});
	
	//Truncate Title to two lines
	//$('.twentysix a').truncatable({limit: 50, more: '...', less: false});
	
	$(".twentysix a").each(function() {
		var str = $(this).text();
		var limit = 50;
		var bits, i;
		
		bits = str.split('');
		if (bits.length > limit) {
			for (i = bits.length - 1; i > -1; --i) {
			if (i > limit) {
			bits.length = i;
			}
			else if (' ' === bits[i]) {
			bits.length = i;
			break;
			}
			}
			bits.push('...');
		}
		var truncate = bits.join('');
		$(this).text(truncate);
	});
	 
	
	
	$("#frame-4_s-col-3").addClass("thirtyeight");*/
}



// Return the last class for $(thisObject)
function lastClass(thisObject) {
	var thisClasses = $(thisObject).attr("class").split(" ");
	return thisClasses[thisClasses.length-1]; 
}

function measure(thisObject, attr) {
	if (attr=="width") {
		if ($("body").data("browser")=="Microsoft Internet Explorer") {
			var thisSize = $(thisObject).width();
			return thisSize*1;
		} else {
			var thisSize = $(thisObject).css(attr).split("px");
			return thisSize[0]*1;
		}
	} else {
		var thisSize = $(thisObject).css(attr).split("px");
		return thisSize[0]*1;
	}
}

/* Resize Images */
// element = element enclosing images
function resizeImages (element, width, height) {
	$(element).each(function() {
		if ($(this).attr("src") == '/shared/images/no_image_s.gif' || $(this).attr("src") == '/shared/images/no_image_m.gif' || $(this).attr("src") == '/shared/images/no_image_l.gif') {
			$(this).attr("width", width);
			$(this).attr("height", height);
		}
		else {
			var w = parseInt($(this).css("width"));
			var h = parseInt($(this).css("height"));
			var changed = false;
			
			if (w > width) {
				var f = 1 - ((w - width) / w);
				w = w * f;
				h = h * f;
				changed = true;
			}
			
			if (h > height) {
				var f = 1 - ((h - height) / h);
				w = w * f;
				h = h * f;
				changed = true;
			}
			
			if (changed = true) {
				$(this).css("width", w);
				$(this).css("height", h);
			}
		}
	});
}

/* Truncate Text */
function truncateText (element, length) {
	$(element).each(function() {
		var str = $(this).text();
		var limit = length;
		var bits, i;
		
		bits = str.split('');
		if (bits.length > limit) {
			for (i = bits.length - 1; i > -1; --i) {
			if (i > limit) {
			bits.length = i;
			}
			else if (' ' === bits[i]) {
			bits.length = i;
			break;
			}
			}
			bits.push('...');
		}
		var truncate = bits.join('');
		$(this).text(truncate);
	});
}

function oldScripts() {
	$('.wba_contentright table:eq(0)').attr('id','leftcol');
	$('.wba_maintable td:eq(10)').attr('id','tohide');
	
	
	$("img").each(function(i){
			try{			
				if($(this).attr("src").indexOf("/themes/sport/variations/blue/images/dots_leftnav_foot.gif")!=-1) {
					$(this).hide();
				}  
	
	
	}catch(e){}
	    });
	
	$("img").each(function(i){
			try{			
				if($(this).attr("src").indexOf("corner_topleft.gif")!=-1) {
					$(this).hide();
				}  
	if($(this).attr("src").indexOf("corner_topright.gif")!=-1) {
					$(this).hide();
				}  
	if($(this).attr("src").indexOf("corner_botleft.gif")!=-1) {
					$(this).hide();
				}  
	if($(this).attr("src").indexOf("corner_botright.gif")!=-1) {
					$(this).hide();
				}  
	if($(this).attr("src").indexOf("img_footer_left.jpg")!=-1) {
					$(this).hide();
				}  
	if($(this).attr("src").indexOf("img_footer_right.jpg")!=-1) {
					$(this).hide();
				}  
	
	if($(this).attr("src").indexOf("1_pixel.gif")!=-1) {
					$(this).hide();
				}  
	
	
			}catch(e){}
	    });
	
	$("td").each(function(i){
			try{			
				if($(this).attr("background").indexOf("/themes/sport/variations/blue/images/bg_leftnav_foot.gif")!=-1) {
					$(this).attr('background', 'none');
				} 
	
	
			}catch(e){}
	    });
	$("td").each(function(i){
			try{			
				if($(this).attr("bgcolor").indexOf("#ffffff")!=-1) {
					$(this).attr('bgcolor', 'transparent');
				} 
	
	
			}catch(e){}
	    });
	
	

	
	$("td").each(function(i){
					$(this).css('padding', '0px');
	    });

	
	
	
	
	
	$("td").each(function(i){
			try{			
			
	if($(this).attr("background").indexOf("/themes/sport/variations/blue/images/bg_leftnav.jpg")!=-1) {
					$(this).attr('background', 'none');
				} 
	
			}catch(e){}
	    });
	
	
	
	
	$("table").each(function(i){
			try{			
				if($(this).attr("background").indexOf("bg_footer.gif")!=-1) {
					$(this).hide();
				}  
	
			}catch(e){}
	    });
	
	$("table").each(function(i){
			try{			
				if($(this).attr("bgcolor").indexOf("#ffffff")!=-1) {
					$(this).attr('bgcolor', 'transparent');
				} 
	
			}catch(e){}
	    });
	$("table").each(function(i){
			try{			
				
	if($(this).attr("cellspacing").indexOf("10")!=-1) {
					$(this).attr('cellspacing', '0');
				} 
	
			}catch(e){}
	    });
	
	
	$("table").each(function(i){
			try{			
				
	if($(this).attr("cellspacing").indexOf("5")!=-1) {
					$(this).attr('cellspacing', '0');
				} 
	
			}catch(e){}
	    });
	
	$("a").each(function(i){
			try{			
				
	if($(this).attr("style").indexOf("font-size: 14px;")!=-1) {
					$(this).attr('style', 'font-size: 12px;');
				} 
	
			}catch(e){}
	    });
	
	$("a").each(function(i){
			try{			
				
	if($(this).attr("style").indexOf("font-size: 14px; font-weight: bold; padding-top: 10px;")!=-1) {
					$(this).attr('style', 'font-size: 12px;');
				} 
	
			}catch(e){}
	    });
	
	
	
	
	$("table").each(function(i){
			try{			
				
	if($(this).attr("cellspacing").indexOf("5")!=-1) {
					$(this).attr('cellspacing', '0');
				} 
	
			}catch(e){}
	    });
	
	
	
	
	$("tr").each(function(i){
			try{			
	if($(this).attr("bgcolor").indexOf("#ffffff")!=-1) {
					$(this).attr('bgcolor', 'transparent');
				} 
			}catch(e){}
	    });
	
	
	
	
	
	$("div").each(function(i){
			try{			
				if($(this).attr("style").indexOf("padding: 3px; font-size: 16px;")!=-1) {
	$(this).attr('style', 'padding: 3px; font-size: 18px;');
					
				}  
			}catch(e){}
	    });
	
	$("a").each(function(i){
			try{			
				if($(this).attr("style").indexOf("font-size: 12px;")!=-1) {
	$(this).attr('style', 'font-size: 14px; font-weight:bold;');
					
				}  
	
			}catch(e){}
	    });
	
	$("#leftcol table").each(function(i){
			try{			
				if($(this).attr("bgcolor").indexOf("#ffffff")!=-1) {
	$(this).attr('bgcolor', 'transparent');
					
				}  
	
			}catch(e){}
	    });
	
/*
	$("td").each(function(i){
			try{			
				if($(this).attr("style").indexOf("padding: 5px;")!=-1) {
	$(this).attr('style', 'padding: 0px;');
					
				}  
	
			}catch(e){}
	    });
*/
	
	
	
	i=1;
		$('#frame-3_s').children().children().children().each( function(){
			$(this).attr('id','frame-3_s-' + i);
			i++;
		});
	
	i=1;
		$('#leftcol').children().children().children().each( function(){
			$(this).attr('id','leftcol-col-' + i);
			//if ($(this).text() == "" || $(this).text().match(/^\s$/)) $(this).remove();
			i++;
		});
	
	i=1;
		$('#content-18').children().children().children().each( function(){
			$(this).attr('id','content-18-col-' + i);
			
			i++;
		});
	
	i=1;
		$('#content-15').children().children().children().each( function(){
			$(this).attr('id','content-15-col-' + i);
			
			i++;
		});
	
	
	
	i=1;
		$('#content-16').children().children().children().each( function(){
			$(this).attr('id','content-16-col-' + i);
			
			i++;
		});
	
	i=1;
		$('#frame-4_s').children().children().children().each( function(){
			$(this).attr('id','frame-4_s-col-' + i);
			
			i++;
		});
	
	
	$('#frame-4_s').children().attr('id','topsellfooter' + i);;
	
	
	j=1;
		$('#content-18-col-3').children().children().children().children().each( function(){
			$(this).attr('id','content-18-col-3-' + j);
			
			j++;
		});
	
	
	k=1;
		$('#wba_main').children().children().children().each( function(){
			$(this).attr('id','wba_main-table' + k);
			
			k++;
		});
	
	k=1;
		$('#leftnav-6').children().children().each( function(){
			$(this).attr('id','leftnav-6-table' + k);
			
			k++;
		});
	
	
	k=1;
		$('#leftnav-6-table1').children().each( function(){
			$(this).attr('id','leftnav-6-table1' + k);
			
			k++;
		});
	k=1;
		$('#leftnav-6-table13').children().children().children().children().each( function(){
			$(this).attr('id','leftnav-6-table13' + k);
			
			k++;
		});
	
	k=1;
		$('#leftcol-col-2').children().each( function(){
			$(this).attr('id','leftcol-col-2' + k);
			
			k++;
		});
	
	
	
	k=1;
		$('#leftcol-col-21').children().children().children().each( function(){
			$(this).attr('id','leftcol-col-2' + k);
			
			k++;
		});
	k=1;
		$('#leftcol-col-25').children().children().children().children().children().children().children().children().each( function(){
			$(this).attr('id','leftcol-col-25' + k);
			
			k++;
		});
}
