$.urlParam = function(name){
	var results = new RegExp('[\\?&]' + name + '=([^&#]*)').exec(window.location.href);
	return results[1] || 0;
}

function get_cookie ( cookie_name ) {
  var results = document.cookie.match ( '(^|;) ?' + cookie_name + '=([^;]*)(;|$)' );
  if ( results )
    return ( unescape ( results[2] ) );
  else
    return null;
}

function URLEncode(str) {
   var nstr = escape(str);

   nstr = nstr.replace(/\+/g, '%2B');
   nstr = nstr.replace(/\%20/g, '+');

   return nstr;
}

var cid = get_cookie("cid");
var psegsingle = get_cookie("psegsingle");
var psegmulti = get_cookie("psegmulti");
var reactivation = get_cookie("reactivation");
var conf = get_cookie("csession_confirm");
var sid = get_cookie("csession");
var issub = get_cookie("is_subscription");
var is_bmg = is_bmg();

// Need to set this to not defined, we should define it to 1 (to assume a user is Q)
if (! issub) issub = 1;

// This is the cookie which indicates soft-login
var softlogin = get_cookie("bemusic6pl");
var selections = new Array();
var show_queue_button;

if (! psegsingle) psegsingle = 6.99;
if (! psegmulti) psegmulti = 6.99;

function replace_prices() {
        var spans = document.getElementsByTagName("span");
        for (var i=0;i<spans.length;i++) {
                var splits = spans[i].id.split('-');
                if (splits[0] == 'pricing') {
                        if (splits[1] == 1) {
                                spans[i].innerHTML = '$'+psegsingle;
                        } else {
                                spans[i].innerHTML = '$'+(psegmulti*splits[1])
                        }
                }
        }
}

function replace_queues() {
        var spans = document.getElementsByTagName("span");
        for (var i=0;i<spans.length;i++) {
                var splits = spans[i].id.split('-');
                if (splits[0] == 'add2queue') {
						var selection = splits[1];
						var should_show_queue = show_queue_button[selection];
                        if ((conf || softlogin) && (should_show_queue == 1)) {
                                spans[i].innerHTML = '<a href="/submit/add_to_queue?selection=' + splits[1] 
                                        + '&redirect_to=' + URLEncode(document.URL)
                                        + '" title="Add To Your Music Queue">'
                                        + '<img src="/images/queue/sbtn_queue.gif" width=48 height=15 border=0></a>';
                        } else if (reactivation > 0) {
                                spans[i].innerHTML = '<a href="/reactivate/?enroll_item=' +splits[1] + '" title="Reactivate Now">'
                                        + '<img src="/images/enroll/reactivate_btn.gif" width=67 height=14 border=0 alt="Reactivate Now"></a>';
                        } else if ((conf || softlogin) && (should_show_queue != 1)) {
                        } else {
                                spans[i].innerHTML = '<a href="/enrollment/?enroll_item=' + splits[1] + '" title="Start Now">'
                                        + '<img src="/images/enroll/start_now.gif" width=74 height=14 border=0 alt="Start Now"></a>';
                        }
                }
        }
}

function replace_carts() {
        var spans = document.getElementsByTagName("span");
        for (var i=0;i<spans.length;i++) {
                var splits = spans[i].id.split('-');
                if (splits[0] == 'add2cart') {
                        if (conf || softlogin) {
                                spans[i].innerHTML = '<a href="/submit/add_to_cart?selection=' + splits[1] 
                                        + '&redirect_to=' + URLEncode(document.URL)
                                        + '" title="Add To Your Cart">'
                                        + ( issub == 1 ? 
                                            '<img src="/images/queue/sbtn_cart.gif" width=34 height=15 border=0>' :
                                            '<img src="/images/queue/addToCart_btn.gif" width=67 height=14 border=0>' ) 
                                        + '</a>';
                        } else {
                                spans[i].innerHTML = '<img src="/images/spacer.gif" width=34 height=15 border=0>';
                        }
                }
        }
        $('.add_to_cart').html('');
}

function getHTTPObject(){
	if (window.ActiveXObject) return new ActiveXObject("Microsoft.XMLHTTP");
	else if (window.XMLHttpRequest) return new XMLHttpRequest();
	else {
		alert("Your browser does not support AJAX.");
		return null;
	}
}

function showCustomerInfo(session_id) {
	return '<span id=cartAndQueueInfo name=cartAndQueueInfo></span>';
}

function loadCartAndQueueInfo(sid) {
	httpObject = getHTTPObject();
	if (httpObject != null) {
		httpObject.open("POST", '/ajax/cqinfo.html?sid='+sid, true);
		httpObject.send(null);
		httpObject.onreadystatechange = gotInfo;
	}
}

function gotInfo() {
	if (httpObject.readyState == 4) {
		var caq = document.getElementById('cartAndQueueInfo');
		if (caq) {
			caq.innerHTML = httpObject.responseText;
		}
	}
}

function memberHeader(session) {
	var header = '<div class="blue_text" style="width: 770px; text-align: right;">'
		+ '  <a href="/cart/" class="blue_nav">Checkout</a> |'
		+ '  <a href="/account/" class="blue_nav">Your Account</a> |'
		+ '  <a href="/account/preferences/" class="blue_nav">';
		if (issub && issub == 1) header += 'Subscription '
		header += 'Preferences</a> |'
		+ '  <a href="/login/?logout=1" class="blue_nav">Log Out</a>'
		+ '<img src="/images/spacer.gif" width="1" height="5"><br>'
		+ '<table cellpadding=0 cellspacing=0 width=778 border=0>'
		+ '  <tr>'
		+ '    <td width="369">'
		+ '       <a href="/"><img src="/images/main_logo.gif" width="354" height="69" alt="yourmusic.com" border="0"></a>'
		+ '    </td>'
		+ '    <td valign=top width="409">';
	header += showCustomerInfo(session);
	header += '    </td>'
		+ '  </tr>'
		+ '</table>'
		+ '<img src="/images/spacer.gif" width="1" height="5"><br>'
		+ '<form action="/search/index.html" method="GET">'
		+ '<table width="776" cellspacing="0" cellpadding="0" border="0">'
		+ '  <tr>'
		+ '    <td width="422"><div style="border: 1px solid #B5DFF7; background-color: #E9E9E9;"><table width="420" cellspacing="0" cellpadding="0" border="0">'
		+ '      <tr>'
		+ '        <td width="59" height="33"><img src="/images/search.gif" width="43" height="13" alt="Search" vspace="10" style="margin-left: 16px;"></td>'
		+ '        <td width="137" align="center" valign="middle"><div style="width: 135px;"><select class="search_sel" style="width: 130px;" name="search_type">'
		+ '	<option value="artists"  selected="selected">Artist Name'
		+ '	<option value="albums" >Album Title'
		+ '	<option value="tracks" >Song Title'
		+ '	<option value="composers" >Composer'
		+ '	<option value="selections" >Selection Number'
		+ '        </select></div> </td>'
		+ '        <td width="25"><img src="/images/for.gif" width="25" height="13" alt="For" vspace="10"></td>'
		+ '        <td width="159" align="center" valign="middle"><input type="text" class="cart_txt_0" style="width: 150px;" name="search_text"><input type="hidden" name="do_search" value="1"></td>'
		+ '        <td width="40"><input type=image src="/images/go.gif" width="24" height="14" alt="Go" border=0 style="margin-right: 16px;" valign="middle"></td>'
		+ '      </tr>'
		+ '    </table></div></td>'
		+ '    <td width="354">';
		
	if ( issub && issub == 1 ) {
	    header += '<a href="/tellafriend/">'
	        + '<img src="/images/taf/bnr_searchbar_taf-incentive.gif" width="354" height="35" border="0" alt="Tell A Friend About This Great Deal!">'
	        + '</a>';
	}
	else {
	    header += '<img src="/images/header/699_free_shipping_354x35.jpg" width="354" height="35" border="0" alt="$6.99 CDs, Free Shipping"/>';
	}
	
	header += '</td>'
		+ '  </tr>'
		+ '</table>'
		+ '</form>';
	return header;
}

function relURL(url) {
	if (! url) url = document.location.href;

	var pos1 = url.indexOf('/');
	var start = url.indexOf('/', pos1+2);
	return URLEncode(url.substring(start));
}

function notLoggedInHeader(session) {
	var header = '<div class="blue_text" style="width: 770px; text-align: right;">'
		+ '  <a href="/cart/" class="blue_nav">Checkout</a> |'
		+ '  <a href="/account/" class="blue_nav">Your Account</a> |'
		+ '  <a href="/account/preferences/" class="blue_nav">';
		if (issub && issub == 1) header += 'Subscription '
		header += 'Preferences</a> |'
		+ '  <a href="/login/?success='+ relURL() + '" class="blue_nav">Log In</a>'
		+ '<img src="/images/spacer.gif" width="1" height="5"><br>'
		+ '<table cellpadding=0 cellspacing=0 width=778 border=0>'
		+ '  <tr>'
		+ '    <td width="369">'
		+ '       <a href="/"><img src="/images/main_logo.gif" width="354" height="69" alt="yourmusic.com" border="0"></a>'
		+ '    </td>'
		+ '    <td valign=top width="409">';
	header += showCustomerInfo(session);
	header += '    </td>'
		+ '  </tr>'
		+ '</table>'
		+ '<img src="/images/spacer.gif" width="1" height="5"><br>'
		+ '<form action="/search/index.html" method="GET">'
		+ '<table width="776" cellspacing="0" cellpadding="0" border="0">'
		+ '  <tr>'
		+ '    <td width="422"><div style="border: 1px solid #B5DFF7; background-color: #E9E9E9;"><table width="420" cellspacing="0" cellpadding="0" border="0">'
		+ '      <tr>'
		+ '        <td width="59" height="33"><img src="/images/search.gif" width="43" height="13" alt="Search" vspace="10" style="margin-left: 16px;"></td>'
		+ '        <td width="137" align="center" valign="middle"><div style="width: 135px;"><select class="search_sel" style="width: 130px;" name="search_type">'
		+ '	<option value="artists"  selected="selected">Artist Name'
		+ '	<option value="albums" >Album Title'
		+ '	<option value="tracks" >Song Title'
		+ '	<option value="composers" >Composer'
		+ '	<option value="selections" >Selection Number'
		+ '        </select></div> </td>'
		+ '        <td width="25"><img src="/images/for.gif" width="25" height="13" alt="For" vspace="10"></td>'
		+ '        <td width="159" align="center" valign="middle"><input type="text" class="cart_txt_0" style="width: 150px;" name="search_text"><input type="hidden" name="do_search" value="1"></td>'
		+ '        <td width="40"><input type=image src="/images/go.gif" width="24" height="14" alt="Go" border=0 style="margin-right: 16px;" valign="middle"></td>'
		+ '      </tr>'
		+ '    </table></div></td>'
		+ '    <td width="354">';
		
	if ( issub && issub == 1 ) {
	    header += '<a href="/tellafriend/">'
	        + '<img src="/images/taf/bnr_searchbar_taf-incentive.gif" width="354" height="35" border="0" alt="Tell A Friend About This Great Deal!">'
	        + '</a>';
	}
	else {
	    header += '<img src="/images/header/699_free_shipping_354x35.jpg" width="354" height="35" border="0" alt="$6.99 CDs, Free Shipping"/>';
	}
	
	header += '</td>'
		+ '  </tr>'
		+ '</table>'
		+ '</form>';
	return header;
}

function enrollHeader() {
	var header = '<table cellpadding="0" cellspacing="0" width="778" border="0">'
		+ '  <tr>'
		+ '    <td rowspan="3" width="370"><table cellpadding="0" cellspacing="0" border="0"><tr><td><a href="/"><img src="/images/main_logo.gif" width="354" height="69" alt="yourmusic.com" border="0"></a></td></tr></tr></table>'
		+ '</td>'
		+ '    <td valign="top">'
		+ '<div style="text-align: right; margin: 0 8px 0 0" class="gray_text">Already a ';
		if (issub) header += 'subscriber'; else header += 'member';
		header += '? <a href="/login/?success='+ relURL() +'" class="blue_nav">Log In</a></div>'
		+ '    </td>'
		+ '  </tr>'
		+ '  <tr>'
		+ '          <td><img src="/images/enroll/spacer.gif" width="1" height="5"></td>'
		+ '  </tr>'
		+ '  <tr>'
		+ '    <td valign=top>'
		+ '<table cellpadding="0" cellspacing="0" width="100%" border="0">'
		+ '  <tr>'
		+ '    <td><img src="/images/banners/YM_enrollbanner_699.gif" border="0"></td>'
		+ '  </tr>'
		+ '</table>'
		+ '    </td>'
		+ '  </tr>'
		+ '  <tr> <td><img src="/images/enroll/spacer.gif" width="1" height="5"></td> </tr>'
		+ '</table>';
	header += '<form action="/search/index.html" method="GET">'
		+ '<table width="776" cellspacing="0" cellpadding="0" border="0">'
		+ '  <tr>'
		+ '    <td width="619"><div style="border: 1px solid #B5DFF7; background-color: #E9E9E9;"><table width="619" cellspacing="0" cellpadding="0" border="0">'
		+ '      <tr>'
		+ '        <td width="59" height="33"><img src="/images/search.gif" width="43" height="13" alt="Search" vspace="10" style="margin-left: 16px;"></td>'
		+ '        <td width="137" align="center">';
	header += '<div style="width: 135px;"><select class="search_sel" style="width: 130px;" name="search_type">'
		+ '	<option value="artists"  selected="selected">Artist Name'
		+ '	<option value="albums" >Album Title'
		+ '	<option value="tracks" >Song Title'
		+ '	<option value="composers" >Composer'
		+ '	<option value="selections" >Selection Number'
		+ '</select></div>'
		+ '</td>'
		+ '        <td width="25"><img src="/images/for.gif" width="25" height="13" alt="For" vspace="10"></td>'
		+ '        <td width="159" align="center"><input type="text" class="cart_txt_0" style="width: 150px;" name="search_text"><input type="hidden" name="do_search" value="1"></td>'
		+ '        <td width="37"><input type=image src="/images/go.gif" width="24" height="14" alt="Go" border=0 style="margin-right: 13px;"></td>'
		+ '        <td width="103" style="padding: 2px 10px 0 0;"><a href="/enroll/browse/" title="Browse"><img src="/images/enroll/browse_btn.gif" width="103" height="28" border="0" alt="Browse"></a></td>'
		+ '        <td width="83" style="padding: 2px 6px 0 0;"><a href="/enrollment/howitworks/" title="Learn More"><img src="/images/enroll/learn_btn.gif" width="83" height="28" border="0" alt="Learn More"></a></td>'
		+ '      </tr>'
		+ '    </table></div></td>'
		+ '    <td width="149" style="padding: 0 0 0 8px; height: 40px;"><a href="/enrollment/" title="Subscribe Now"><img src="/images/enroll/subscribe_btn.gif" width="149" height="40" border="0" alt="Subscribe Now"></a></td>'
		+ '  </tr>'
		+ '</table>'
		+ '</form>';
	return header;
}


function replace_header() {
	var hdr = document.getElementById("staticheader1");
	if (conf) { // Member
		hdr.innerHTML = memberHeader(conf);
	} else if (softlogin) { // Member but not logged in
		hdr.innerHTML = notLoggedInHeader(sid);
	} else { // Not a member
		// htdocs-disco/lib/header/enroll.mas
        hdr.innerHTML = enrollHeader();
        
	}
}

// We have some custom /home messaging needs which has to come in via AJAX
function replace_messaging() {
    $.post(
        '/ajax/home_messaging.html',
        {},
        function ( html ) {
            $('#replace_welcome_message').replaceWith( html );
        },
        'html'
    );
}

function replace_footer() {
    $.post(
        '/ajax/footer.html',
        {},
        function ( html ) {
            $('#footer').replaceWith( html );
        },
        'html'
    );
}

function replace_comingsoon(cid) {
 	var spans = document.getElementsByTagName("span");
 	for (var i=0;i<spans.length;i++) {
 		var splits = spans[i].id.split('-');
 		if (splits[0] == 'comingsoon') {
 			var party_code = splits[1];
			var where = spans[i];
			$.post(
				'/ajax/check_comingsoon.html',
				{ party: splits[1], cid: cid },
				function ( html ) {
					where.innerHTML = html;
				},
				'html'
			);
 		}
 	}

	return 0;
}

// THE FOLLOWING FUNCTIONS ARE FOR TAF
// BEGIN
function find_taf_product_code() {
 	var spans = document.getElementsByTagName("span");
 	for (var i=0;i<spans.length;i++) {
 		var splits = spans[i].id.split('-');
 		if (splits[0] == 'album_taf') {
 			return splits[1];
 		}
 	}
	
	return 0;
}

function find_taf_party_code() {
 	var spans = document.getElementsByTagName("span");
 	for (var i=0;i<spans.length;i++) {
 		var splits = spans[i].id.split('-');
 		if (splits[0] == 'bio_taf') {
 			return splits[1];
 		}
 	}
	
	return 0;
}

function replace_album_taf() {
	var product_code = find_taf_product_code();
	if (product_code != 0) $('#album_taf').html('<a href="/tellafriend/?product_code=' + product_code + '" class="new_taf_link">Tell a Friend about this album</a><br>');
}

function replace_bio_taf() {
	var party_code = find_taf_party_code();
	if (party_code != 0) $('#bio_taf').html('<a href="/tellafriend/?party_code=' + party_code + '" class="new_taf_link">Tell a Friend about this artist</a><br>');
}

function replace_gift_center() {
	var html;
	if (is_bmg == 0) {
		//<!-- Q -->
		//<!-- Gift Center -->
		html = '<a href="/browse/features/200810_holidaymusic/favorite.html"><img src="/images/features/gift_center/bnr_holidaymusic_220x150.gif" alt="Holiday Music" width="220" height="150" border="0"></a> <a href="/gift_subscriptions/"><img src="/images/features/gift_center/bnr_gs_holiday.jpg" alt="Gift Subscriptions" width="395" height="150" border="0"></a>';
		$('#gift_center2').html(html);
	} 
	else {
		//<!-- NQ -->
		//<!-- Gift Center -->
		html = '<a href="/browse/features/200810_holidaymusic/favorite.html"><img src="/images/features/gift_center/bnr_holidaymusic_220x150.gif" alt="Holiday Music" width="220" height="150" border="0"></a> <a href="/browse/features/buyers_guide/"><img src="/images/features/gift_center/bnr_buyersguides_392x150.gif" alt="YM Giudes" width="392" height="150" border="0"></a>';
		$('#gift_center2').html(html);
	}
}

function replace_buyers_guide() {
	var html;
	if (is_bmg == 0) {
		html = 'Whether you\'re filling up your music queue or adding to your collection, get great suggestions and discover new music with these yourmusic guides.';
		$('#buyers_guide').html(html);
	} 
	else {
		html = 'Get great suggestions and discover new music with these yourmusic guides.';
		$('#buyers_guide').html(html);
	}
}

function replace_feature() {
	var feature_html;
	
	if (is_bmg == 0) {
		//<!-- Q -->
		//<!-- FLP -->
		feature_html = '<style type="text/css" media="all">'
+'li#feature_1 	{'
+'  left: 0px;'
+'  top: 0px;'
+'  width: 392px;'
+'  height: 150px;'
+'  background-image: url(/images/promos/features/topartists_feat_392x150.gif);'
+'}'
+'li#feature_1, li#feature_1 a {'
+'  width: 392px;'
+'  height: 150px;'
+'}'
+'li#feature_2 	{'
+'  left: 406px;'
+'  top: 0px;'
+'  width: 220px;'
+'  height: 150px;'
+'  background-image: url(/images/promos/features/bnr_aod_owlcity_220x150.gif);'
+'}'
+'li#feature_2, li#feature_2 a {'
+'  width: 220px;'
+'  height: 150px;'
+'}'
+'li#feature_3 	{'
+'  left: 0px;'
+'  top: 172px;'
+'  width: 190px;'
+'  height: 190px;'
+'  background-image: url(/images/promos/features/hp_GiftCenter_190x190.jpg);'
+'}'
+'li#feature_3, li#feature_3 a {'
+'  width: 190px;'
+'  height: 190px;'
+'}'
+'li#feature_4 	{'
+'  left: 0px;'
+'  top: 382px;'
+'  width: 190px;'
+'  height: 85px;'
+'  background-image: url(/images/promos/features/bnr_boxed_sets_190x85.jpg);'
+'}'
+'li#feature_4, li#feature_4 a {'
+'  width: 190px;'
+'  height: 85px;'
+'}'
+'li#feature_5 	{'
+'  left: 202px;'
+'  top: 172px;'
+'  width: 192px;'
+'  height: 85px;'
+'  background-image: url(/images/promos/features/select_hp_192x85.jpg);'
+'}'
+'li#feature_5, li#feature_5 a {'
+'  width: 190px;'
+'  height: 85px;'
+'}'
+'li#feature_6 	{'
+'  left: 0px;'
+'  top: 487px;'
+'  width: 190px;'
+'  height: 85px;'
+'  background-image: url(/images/promos/features/bnr_giftsubs_190x85.gif);'
+'}'
+'li#feature_6, li#feature_6 a {'
+'  width: 190px;'
+'  height: 85px;'
+'}'
+'li#feature_7 	{'
+'  left: 202px;'
+'  top: 277px;'
+'  width: 190px;'
+'  height: 85px;'
+'  background-image: url(/images/promos/features/bnr_rockofages_190x85.gif);'
+'}'
+'li#feature_7, li#feature_7 a {'
+'  width: 190px;'
+'  height: 84px;'
+'}'
+'li#feature_8 	{'
+'  left: 202px;'
+'  top: 382px;'
+'  width: 190px;'
+'  height: 190px;'
+'  background-image: url(/images/promos/features/bnr_similarsounds.gif);'
+'}'
+'li#feature_8, li#feature_8 a {'
+'  width: 190px;'
+'  height: 190px;'
+'}'
+''
+'</style>'
+'<h1 id="header">Now Featuring</h1>'
+'<h2 id="subheader">Browse our most popular features to find your favorite music</h2>'
+'<div id="wrapper">'
+'  <ul id="features">'
+'    <li id="feature_1"><a href="/browse/features/200905_topartists/" title="Top Artists 2009">Top Artists 2009</a></li>'
+'    <li id="feature_2"><a href="/browse/features/artists_on_deck/owlcity.html" title="Artists On Deck">Artists On Deck</a></li>'
+'    <li id="feature_3"><a href="/browse/features/200511_gift_center/" title="Gift Center">Gift Center</a></li>'
+'    <li id="feature_4"><a href="/browse/features/200910_boxed_sets/1.html" title="25 Favorite Boxed Sets">25 Favorite Boxed Sets</a></li>'
+'    <li id="feature_5"><a href="/browse/features/200907_selects/" title="Your Music Selects">American Idol</a></li>'
+''
+'    <li id="feature_6"><a href="/gift_subscriptions/" title="Give Music! Gift subscriptions are now available.">Give Music! Gift subscriptions are now available.</a></li>'
+'    <li id="feature_7"><a href="/browse/features/200909_rock_of_ages/1.html" title="Rock of Ages">Rock of Ages</a></li>'
+'    <li id="feature_8"><a href="/browse/features/200505_similar_sounds/" title="Similar Sounds, Similar Styles:  Recommendations Based On Your Favorite Artists!">Similar Sounds, Similar Styles:  Recommendations Based On Your Favorite Artists!</a></li>'
+'  </ul>'
+'  <div id="more_stuff">'
+'  <dl id="more_features">'
+'    <dt class="small_gray_bold_text">More features...</dt>'
+'    <dd>'
+'	<ul>'
//+'	<li><a href="/browse/features/200511_gift_center/">Gift Center</a></li>'
+'	<li><a href="/browse/features/200810_holidaymusic/favorite.html">Holiday Music</a></li>'
+'	<li><a href="/browse/features/200901_grammys/top.html">2009 Grammy Awards</a></li>'
+'	<li><a href="/browse/features/200502_100great/">100 Great Albums</a></li>'
+'	<li><a href="/browse/features/editors_picks/">Editor\'s Picks</a></li>'
+'	<li><a href="/browse/features/decades/">Shop By Decade</a></li>'
+'	<li><a href="/browse/features/200503_classic_rock/">Classic Rock</a></li>'
+'	<li><a href="/browse/features/200905_collections/">Prime Collections</a></li>'
+'	<li><a href="/browse/features/200906_ultimate/landing.html">Ultimate Artists</a></li>'
+'  <li><a href="/browse/features/american_idol/current.html">American Idol</a></li>'
+'	<li><a href="/browse/features/200905_soundtracks/">Soundtrack Favorites &#150; <span style="color: #ff0000; font-weight: bold;">NEW!</span></a></li>'
+'	<li><a href="/browse/features/200906_country/">Legends of Country &#150; <span style="color: #ff0000; font-weight: bold;">NEW!</span></a></li>'
+'	<li><a href="/browse/features/200906_classicJazz/">Classic Jazz &#150; <span style="color: #ff0000; font-weight: bold;">NEW!</span></a></li>'
+'  <li><a href="/browse/features/200906_classical_essentials/">Classical Essentials &#150; <span style="color: #ff0000; font-weight: bold;">NEW!</span></a></li>'
+'  <li><a href="/browse/features/200906_christian/">Best of Christian &amp; Gospel &#150; <span style="color: #ff0000; font-weight: bold;">NEW!</span></a></li>'
+'  <li><a href="/browse/features/200906_deluxe/">Deluxe Editions &#150; <span style="color: #ff0000; font-weight: bold;">NEW!</span></a></li>'
+'	<li><a href="/browse/features/200906_michaeljackson/">Remembering Michael Jackson</a></li>'
+'	<li><a href="/browse/features/200903_motown/">Motown 50</a></li>'
//+'	<li><a href="/browse/features/200809_london_calling/">London Calling</a></li>'
//+'	<li><a href="/browse/features/200601_lovesongs/">50 Great Love Songs</a></li>'
+'	<li><a href="/browse/features/200610_crooners/">Crooners</a></li>'
+'	<li><a href="/browse/features/200505_albums_never_heard/">Best Albums You\'ve Never Heard</a></li>'
+'	<li><a href="/browse/features/buyers_guide/">yourmusic Guides</a></li>'
+'	<li><a href="/browse/popularqueue.html">Popular Queue Items</a></li>'
+'	<li><a href="/browse/features/coming_soon/">Coming Soon</a></li>'
+'	</ul>'
+'    </dd>'
+'  </dl>'
+'  </div>'
+'</div>';
	}
	else {
		//<!-- NQ -->
		//<!-- FLP -->
		feature_html = '<style type="text/css" media="all">'
+''
+'li#feature_1 	{'
+'  left: 0px;'
+'  top: 0px;'
+'  width: 392px;'
+'  height: 150px;'
+'  background-image: url(/images/promos/features/topartists_feat_392x150.gif);'
+'}'
+'li#feature_1, li#feature_1 a {'
+'  width: 392px;'
+'  height: 150px;'
+'}'
+'li#feature_2 	{'
+'  left: 406px;'
+'  top: 0px;'
+'  width: 220px;'
+'  height: 150px;'
+'  background-image: url(/images/promos/features/bnr_aod_owlcity_220x150.gif);'
+'}'
+'li#feature_2, li#feature_2 a {'
+'  width: 220px;'
+'  height: 150px;'
+'}'
+'li#feature_3 	{'
+'  left: 0px;'
+'  top: 172px;'
+'  width: 190px;'
+'  height: 190px;'
+'  background-image: url(/images/promos/features/hp_GiftCenter_190x190.jpg);'
+'}'
+'li#feature_3, li#feature_3 a {'
+'  width: 190px;'
+'  height: 190px;'
+'}'
+'li#feature_4 	{'
+'  left: 0px;'
+'  top: 382px;'
+'  width: 190px;'
+'  height: 85px;'
+'  background-image: url(/images/promos/features/bnr_boxed_sets_190x85.jpg);'
+'}'
+'li#feature_4, li#feature_4 a {'
+'  width: 190px;'
+'  height: 85px;'
+'}'
+'li#feature_5 	{'
+'  left: 202px;'
+'  top: 172px;'
+'  width: 190px;'
+'  height: 85px;'
+'  background-image: url(/images/promos/features/select_hp_192x85.jpg);'
+'}'
+'li#feature_5, li#feature_5 a {'
+'  width: 190px;'
+'  height: 85px;'
+'}'
+'li#feature_6 	{'
+'  left: 0px;'
+'  top: 487px;'
+'  width: 190px;'
+'  height: 85px;'
+'  background-image: url(/images/promos/features/primeCollect_hp_192x85.jpg);'
+'}'
+'li#feature_6, li#feature_6 a {'
+'  width: 190px;'
+'  height: 85px;'
+'}'
+'li#feature_7 	{'
+'  left: 202px;'
+'  top: 277px;'
+'  width: 190px;'
+'  height: 85px;'
+'  background-image: url(/images/promos/features/bnr_rockofages_190x85.gif);'
+'}'
+'li#feature_7, li#feature_7 a {'
+'  width: 190px;'
+'  height: 84px;'
+'}'
+'li#feature_8 	{'
+'  left: 202px;'
+'  top: 382px;'
+'  width: 190px;'
+'  height: 190px;'
+'  background-image: url(/images/promos/features/bnr_similarsounds.gif);'
+'}'
+'li#feature_8, li#feature_8 a {'
+'  width: 190px;'
+'  height: 190px;'
+'}'
+''
+'</style>'
+'<h1 id="header">Now Featuring</h1>'
+'<h2 id="subheader">Browse our most popular features to find your favorite music</h2>'
+'<div id="wrapper">'
+'  <ul id="features">'
+'    <li id="feature_1"><a href="/browse/features/200905_topartists/" title="Top Artists 2009">Top Artists 2009</a></li>'
+'    <li id="feature_2"><a href="/browse/features/artists_on_deck/owlcity.html" title="Artists On Deck">Artists On Deck</a></li>'
+''
+'    <li id="feature_3"><a href="/browse/features/200511_gift_center/" title="Gift Center">Gift Center</a></li>'
+'    <li id="feature_4"><a href="/browse/features/200910_boxed_sets/1.html" title="25 Favorite Boxed Sets">25 Favorite Boxed Sets</a></li>'
+'    <li id="feature_5"><a href="/browse/features/200907_selects/" title="Your Music Selects">American Idol</a></li>'
+'    <li id="feature_6"><a href="/browse/features/200905_collections/" title="Prime Collections">Prime Collections</a></li>'
+'    <li id="feature_7"><a href="/browse/features/200909_rock_of_ages/1.html" title="Rock of Ages">Rock of Ages</a></li>'
+'    <li id="feature_8"><a href="/browse/features/200505_similar_sounds/" title="Similar Sounds, Similar Styles:  Recommendations Based On Your Favorite Artists!">Similar Sounds, Similar Styles:  Recommendations Based On Your Favorite Artists!</a></li>'
+''
+'  </ul>'
+'  <div id="more_stuff">'
+'  <dl id="more_features">'
+'    <dt class="small_gray_bold_text">More features...</dt>'
+'    <dd>'
+'      <ul>'
//+'	<li><a href="/browse/features/200511_gift_center/">Gift Center</a></li>'
+'	<li><a href="/browse/features/200810_holidaymusic/favorite.html">Holiday Music</a></li>'
+'	<li><a href="/browse/features/200901_grammys/top.html">2009 Grammy Awards</a></li>'
+'	<li><a href="/browse/features/200502_100great/">100 Great Albums</a></li>'
+'	<li><a href="/browse/features/editors_picks/">Editor\'s Picks</a></li>'
+'	<li><a href="/browse/features/decades/">Shop By Decade</a></li>'
+'	<li><a href="/browse/features/200503_classic_rock/">Classic Rock</a></li>'
//+'	<li><a href="/browse/features/200905_collections/">Prime Collections</a></li>'
+'	<li><a href="/browse/features/200906_ultimate/landing.html">Ultimate Artists</a></li>'
+'  <li><a href="/browse/features/american_idol/current.html">American Idol</a></li>'
+'	<li><a href="/browse/features/200905_soundtracks/">Soundtrack Favorites &#150; <span style="color: #ff0000; font-weight: bold;">NEW!</span></a></li>'
+'	<li><a href="/browse/features/200906_country/">Legends of Country &#150; <span style="color: #ff0000; font-weight: bold;">NEW!</span></a></li>'
+'  <li><a href="/browse/features/200906_classicJazz/">Classic Jazz &#150; <span style="color: #ff0000; font-weight: bold;">NEW!</span></a></li>'
+'  <li><a href="/browse/features/200906_classical_essentials/">Classical Essentials &#150; <span style="color: #ff0000; font-weight: bold;">NEW!</span></a></li>'
+'  <li><a href="/browse/features/200906_christian/">Best of Christian &amp; Gospel &#150; <span style="color: #ff0000; font-weight: bold;">NEW!</span></a></li>'
+'  <li><a href="/browse/features/200906_deluxe/">Deluxe Editions &#150; <span style="color: #ff0000; font-weight: bold;">NEW!</span></a></li>'
+'  <li><a href="/browse/features/200906_michaeljackson/">Remembering Michael Jackson</a></li>'
+'  <li><a href="/browse/features/200903_motown/">Motown 50</a></li>'
//+'	<li><a href="/browse/features/200809_london_calling/">London Calling</a></li>'
//+'	<li><a href="/browse/features/200601_lovesongs/">50 Great Love Songs</a></li>'
+'	<li><a href="/browse/features/200610_crooners/">Crooners</a></li>'
+'	<li><a href="/browse/features/200505_albums_never_heard/">Best Albums You\'ve Never Heard</a></li>'
+'	<li><a href="/browse/features/buyers_guide/">yourmusic Guides</a></li>'
+'	<li><a href="/browse/features/coming_soon/">Coming Soon</a></li>'
+'	</ul>'
+'    </dd>'
+'  </dl>'
+'  </div>'
+'</div>';
	}
	
	$('#features_x').replaceWith(feature_html);
}

function is_bmg() {
	var result = $.ajax({
		type: 'GET',
		cache: false,
		url: '/ajax/is_bmg.html', 
		async: false,
		dataType: 'json'
	}).responseText;

	var res1 = eval('(' + result + ')');

	return res1;
}

// END

// Find all the products on the page, submit a JSON request to check multi-cd-ness
function find_products() {
	var spans = document.getElementsByTagName("span");
	for (var i=0;i<spans.length;i++) {
		var splits = spans[i].id.split('-');
		if (splits[0] == 'add2queue') {
			var selection = splits[1];
			selections.push(selection);
		}
	}
	
	// Short circuit if we got none to look up.
	if (selections.length < 1) {
		return;
	}
	
	var jsonified = $.toJSON(selections);

	var result = $.ajax({
		type: 'GET',
		cache: false,
		url: '/ajax/ismulti.html', 
		data: "selection=" + jsonified,
		async: false,
		dataType: 'json'
	}).responseText;

	show_queue_button = eval('(' + result + ')');
}

function fixupBrowse() {
	// We need to set cookies for the BMG landing page
	if (document.URL.match('enroll_bmg')) {
		var tc = URLEncode($.urlParam('tc'));
		var bmg_email = URLEncode($.urlParam('bmg_email'));
		var result = $.ajax({
			type: 'GET',
			cache: false,
			url: '/ajax/bmg_cookies.html', 
			async: false,
			data: 'tc=' + tc + '&bmg_email=' + bmg_email,
			dataType: 'json'
		}).responseText;
	}
	else {
		find_products();
		replace_header();
		if (sid) loadCartAndQueueInfo(sid);
		replace_prices();
		replace_carts();
		if (issub == 1) replace_queues();
		replace_messaging();
		replace_comingsoon(cid);
		replace_footer();
	
		// Only replace these items if they are a Q customer	
		if (is_bmg == 0) {
			replace_album_taf();
			replace_bio_taf();
		}

		replace_gift_center();
		replace_buyers_guide();
		replace_feature();
	}
}
