function soundDidFinishPlaying(){ $('.stop').attr('class', 'listen'); } function play(url, track_id){ css_class = $('#listen_track_'+track_id).attr('class'); switch (css_class){ case 'listen': $('.stop').attr('class', 'listen'); $('#listen_track_'+track_id).attr('class', 'stop'); start(url); break; case 'stop': $('#listen_track_'+track_id).attr('class', 'listen'); stop(); break; } } function start(url){ document.getElementById(instance).start(url); } function stop(){ document.getElementById(instance).stop(); } function refreshCart() { $('#sc_box').load('/cart/box'); } page_width = function() { //return window.innerWidth != null ? window.innerWidth: document.documentElement && document.documentElement.clientWidth ? document.documentElement.clientWidth:document.body != null ? document.body.clientWidth : null; return $(window).width(); } page_height = function() { //return window.innerHeight != null ? window.innerHeight: document.documentElement && document.documentElement.clientHeight ? document.documentElement.clientHeight:document.body != null ? document.body.clientHeight : null; return $(window).height(); } ajax_loader_remove = function(div) { div = '#' + div; if ($(div + '_loader')) { $(div + '_loader').remove(); $(div + '_splash').remove(); } } ajax_loader = function(div, full_screen, css_class) { u_div = div; div = '#' + div; if (full_screen == undefined) full_screen = false; if (css_class == undefined) css_class = 'ajax-loader'; switch (css_class) { case 'ajax-loader-small': l_height = 16; l_width = 16; break; case 'ajax-loader': default: l_height = 31; l_width = 31; break; } if (full_screen) { p_width = page_width(); p_height = page_height(); s_height = $(div).innerHeight() > p_height ? $(div).innerHeight().toString() : p_height.toString(); } else { p_width = $(div).innerWidth(); p_height = $(div).innerHeight(); s_height = p_height; } $(div).css('position', 'relative'); $(div + '_splash').remove(); $(div + '_loader').remove(); el = document.createElement('div'); el.id = u_div + '_splash'; $(div).append(el); splash = $('#' + el.id); splash.css({'height' : s_height + 'px'}); // splash.addClass('ajax-splash'); splash.attr('class', 'ajax-splash'); el = document.createElement('div'); el.id = u_div + '_loader'; $(div).append(el); loader = $('#' + el.id); // loader.addClass(css_class); loader.attr('class', css_class); loader.css({ 'top' : (Math.round(p_height / 2) - Math.round(l_height / 2)).toString() + 'px', 'left' : (Math.round(p_width / 2) - Math.round(l_width / 2)).toString() + 'px' }); if (full_screen) { loader.css({ 'position' : 'fixed' }) } } function addTrackToCart(track_id, el) { div_id = $(el).parent().attr('id'); ajax_loader(div_id); $.ajax({ type: "GET", url: "/cart/add", data: {'track_id':track_id, 'ajax':1 }, success: function(msg){ // button = $('#track_' + track_id + ' a.addtocart'); button = $(el).parent().find('a.addtocart'); if (msg.indexOf('