$(document).ready(function(){if(typeof do_resize_window!="undefined"&&do_resize_window==1){set_window()}$("#also_bought_div").show();if(parseInt(navigator.appVersion)>3){if(navigator.appName=="Netscape"||navigator.appName=="Opera"){window_width=window.innerWidth;window_height=window.innerHeight}if(navigator.appName.indexOf("Microsoft")!=-1){window_width=document.body.offsetWidth;window_height=document.body.offsetHeight;window_width=document.body.offsetWidth<365?365:document.body.offsetWidth}}else{if(jQuery.browser.safari){window_width=window.innerWidth<356?365:window.innerWidth;window_height=window.innerHeight<400?400:window.innerHeight}}$(".content_loading").hide();var a=10;if(typeof(window.also_bought_products_per_page)==="undefined"){var c=Math.floor((window_width-200)/160)}else{if(also_bought_products_per_page>1){var c=also_bought_products_per_page}else{var c=Math.floor((window_width-200)/160)}}var f=Math.ceil(a/c);$(".also_bought_page_count").text(f);var e=$(".also_bought_section").length;page_numbers=new Array();if(e!=0){for(var h=0;h<e;h++){for(var b=1;b<=c;b++){$("#also_bought_subtable_"+h+"_"+b).show()}page_numbers[h]=1}}var d=window_width-100;var g=window_width-360;$("a.also_bought_arrow_left").click(function(j){var i=$(this).parents("div").find("input.strip_number").val();var k=$(this).parents("div").find("input.xml_url").val();if(page_numbers[i]>1){page_numbers[i]--;display_strip(page_numbers[i],c,i,k,false)}j.preventDefault()});$("a.also_bought_arrow_right").click(function(j){var i=$(this).parents("div").find("input.strip_number").val();var l=$(this).parents("div").find("input.xml_url").val();var k=$("#also_bought_page_count_"+i).text();if(page_numbers[i]<k){page_numbers[i]++;display_strip(page_numbers[i],c,i,l,false)}j.preventDefault()});var e=0;$("#also_bought_div .xml_url").each(function(){var i=$(this).val();display_strip(page_numbers[e],c,e,i,false);e++});$(".merchandise_feedback_link").click(function(k){var j=$(this).find("[name=class_id]").val();var i=$(this).parents("div").find("input.strip_number").val();var l=$(this).parents("div").find("input.xml_url").val();merchandise_feedback(j,c,i,l);k.preventDefault()})});function display_strip(b,d,a,h,g){$(".also_bought_title").show();$("#also_bought_subtable_"+a).find("td.separator").hide();var f=$("#strip_type_"+a).val();var c=(b-1)*d;var e=c+d;$("#also_bought_subtable_"+a).hide();$("#content_loading_"+a).show();$.ajax({url:h,type:"GET",dataType:"xml",timeout:50000,error:function(){$("#content_loading_"+a).hide();$("#error_loading_"+a).show()},success:function(p){$("#content_loading_"+a).hide();$("#also_bought_subtable_"+a).show();$("#separator_"+a+"_"+j).show();var j=1;var m=$(p).find("item").slice(c,e).length;var l=$(p).find("item").length;if(b==1){var s=Math.ceil(l/d);$("#also_bought_page_count_"+a).text(s)}if(l==0){this.error()}$(p).find("item").slice(c,e).each(function(){var L=$(this).find("title_cut").text();var v=$(this).find("artist_cut").text();var z=$(this).find("label_cut").text();var K=$(this).find("cover_image").text();var C=$(this).find("class_id").text();var y=$(this).find("currency_symbol").text();var F=$(this).find("currency_symbol").text()+$(this).find("price_with_vat").text();var G=$(this).find("listen_link").text();var n=$(this).find("merchandise_class").text();var E=$(this).find("label_encoded").text();var B=$(this).find("artist_encoded").text();var A=$(this).find("popup_url").text();var x=$(this).find("url").text();var i=$(this).find("nonpps_img_lnk").text();var w=$(this).find("title_id").text();var D=$(this).find("product_id").text();var u=$(this).find("mix_title_cut").text();var J=$(this).find("display_format").text();if(f=="merchandise"){$("#also_bought_label_"+a+"_"+j).hide();$("#also_bought_artist_"+a+"_"+j).hide();var n=$(this).find("merchandise_class").text();$("#merchandise_feedback_link_"+a+"_"+j+"_item").text(n);$("#merchandise_feedback_class_"+a+"_"+j).attr("value",C);$("#merchandise_feedback_link_"+a+"_"+j).attr("href",x);$("#merchandise_feedback_link_single_"+a+"_link").attr("href",C);$("#merchandise_feedback_link_single_"+a+"_item").text(n);$("#merchandise_feedback_single_"+a).show();$("#also_bought_single_title_"+a).text(n);$("#also_bought_title_"+a+"_"+j).text(L);$("#also_bought_title_"+a+"_"+j).css({height:400})}else{$("#listen_link_"+a+"_"+j).attr("href",G);$("#listen_link_"+a+"_"+j).attr("class","ultraplayer_play");var H=$(this).find("title_id").text()+"-"+$(this).find("product_id").text()+"-"+$(this).find("track_number").text()+"-";$("#also_bought_artist_"+a+"_"+j).text(v);$("#also_bought_title_"+a+"_"+j).text(L);if(u!=""&z!=""){$("#also_bought_mix_title_"+a+"_"+j).text(u);$("#also_bought_label_"+a+"_"+j).text("("+z+")")}else{if(u==""&z!=""){if(f=="tracks"){$("#also_bought_mix_title_"+a+"_"+j).html("&nbsp;");$("#also_bought_label_"+a+"_"+j).text("("+z+")")}else{$("#also_bought_label_"+a+"_"+j).text("("+z+")")}}else{$("#also_bought_mix_title_"+a+"_"+j).html("&nbsp;");$("#also_bought_label_"+a+"_"+j).text("(no label)")}}$("#also_bought_display_format_"+a+"_"+j).text("("+J+")");var t="";$(this).find("digital_price").each(function(){var O=$(this).parents("item").find("currency_symbol").text()+$(this).find("price").text()+" - "+$(this).find("name").text();var M=H+$(this).attr("format_key");var Q=$(this).attr("format_key");var P=$(this).parents("item").find("sale_format").text();var N="";if(Q==P){N="selected"}else{N=""}t+='<option value="'+M+'" '+N+">"+O+"</option>"});$("#also_bought_digital_prices_"+a+"_"+j).html(t)}$("#also_bought_physical_price_"+a+"_"+j).html(F);var I="new_product";if(website()=="junodownload"){I="normal"}add_product_click_handler("#also_bought_label_"+a+"_"+j,"labels/"+E,I,f);add_product_click_handler("#also_bought_artist_"+a+"_"+j,"artists/"+B,I,f);add_product_click_handler("#also_bought_title_"+a+"_"+j,A,I,f);add_product_click_handler("#also_bought_image_link_"+a+"_"+j,A,I,f);add_product_click_handler("#buy_link_"+a+"_"+j,"cart/add/"+w+"/"+D+"/?popup=1","adding_to_cart",f);$("#also_bought_image_"+a+"_"+j).attr("src",K);$("#also_bought_image_"+a+"_"+j).attr("alt",v+" - "+L);$("#also_bought_page_number_"+a).text(b);$("#also_bought_"+a+"_"+j).show();if(j<m){$("#separator_"+a+"_"+j).show()}j++});var r=j-1;if(r<d&&b==1){$("#also_bought_page_count_"+a).text(1)}if(r<d){for(var o=j;o<(d+1);o++){$("#also_bought_"+a+"_"+o).hide()}}if(g){var s=Math.ceil(j/d);$("#also_bought_page_count_"+a).text(s)}if(/safari/.test(navigator.userAgent.toLowerCase())){$(".also_bought_title").show();var q=$(".also_bought_section").length;for(var k=0;k<q;k++){for(var o=1;o<=d;o++){$("#also_bought_subtable_"+k+"_"+o).show()}}}if(typeof process_playlist_or_mp3_links=="function"){process_playlist_or_mp3_links()}}})}function merchandise_feedback(c,b,a,d){$.ajax({url:"/merchandise_feedback.php?class_id="+c,processData:false,success:function(){display_strip(1,b,a,d,true);return false},error:function(){display_strip(1,b,a,d,true);return false}})}function digital_release_add_from_pwbt(b,a,c){$("#also_bought_digital_prices_"+a+"_"+c+" option:selected").each(function(){var d=$(this).val();var e=b+"?popup=1&item["+d+"]=1";addToCartWindow(e,4)})}function add_product_click_handler(d,a,c,b){$(d).attr("href",url_nonsecure+"/"+a);$(d).click(function(e){if(c=="adding_to_cart"){if(b=="merchandise"){media_id=2}else{media_id=1}addToCartWindow(a,media_id)}else{if(c=="opener"){opener.document.location.href=url_nonsecure+"/"+a;window.opener.focus()}else{if(c=="new_product"){close_and_go_to(a,false)}else{window.document.location.href=url_nonsecure+"/"+a}}}e.preventDefault()})};
