(function(b){b.flashAudio=function(r){function i(a){a?n.attr("src","data/icons/music_on.png"):n.attr("src","data/icons/music_off.png")}function x(){h=[];var a,d;b("#autoSlideWrapper #musicList").find("ul").each(function(){a=b(this).children()[0];d=b(this).children()[1];var c,f;f=b(a).attr("title");c=b(d).attr("title");h.push({oggpath:c,mp3path:f})});c=h.length}function z(){if(o("flashmusic").initAudio!=void 0){s&&clearInterval(s);try{o("flashmusic").initAudio(h,r),k=!0}catch(a){console.log(a)}}}function p(){a++; if(A)if(l)if(a>c-1){a=d[c-1];t();if(d[0]==a){var j=d.splice(0,1);d.push(j)}a=0}else a<0&&(a=d[0],t(),d[c-1]==a&&(j=d.splice(c-1,1),d.unshift(j)),a=c-1);else a>c-1?a=0:a<0&&(a=c-1);else a>c-1?a=c-1:a<0&&(a=0);var j=h[l?d[a]:a].oggpath,y=h[l?d[a]:a].mp3path;b(v).attr("src",y);b(w).attr("src",j);try{g.load(),g.play()}catch(e){}k=!0;i(!0)}function B(){if(m&&!q)q=!0,p();else{if(k){if(m)try{g.pause()}catch(a){}else try{o("flashmusic").togglePlayback(!0)}catch(c){}k=!1;i(!1)}else{if(m)try{g.play()}catch(b){}else try{o("flashmusic").togglePlayback(!1)}catch(d){}k= !0;i(!0)}return!1}}function C(a){a.stopPropagation();p()}function D(){q&&p()}function o(a){return navigator.appName.indexOf("Microsoft")!=-1?window[a]:document[a]}function t(){if(!(c<3)){for(var a=c,b=[],g=[],f=0,e=0;f<a;f++)b[f]=f;for(e=0;e<a;e++)f=Math.round(Math.random()*(b.length-1)),g[e]=b[f],b.splice(f,1);d=g}}var u=b(document),n,h,m=!1,e=navigator.userAgent,k=!1,w,v,q=!1,s,A=!0,l,a=-1,c,d=[],g;if(u.find("#autoSlideMusic").length>0)useMusic=!0,n=b("#musicToggle"),u=b("#music"),g=b(u).get(0), x(),l=r.randomPlay,e=e.search("iPhone")==-1&&e.search("iPad")==-1&&e.search("iPod")==-1?r.autoPlay:!1,document.createElement("audio").canPlayType&&(m=!0,g.addEventListener("ended",C,!1),g.addEventListener("error",D,!1),w=b("#oggSource"),v=b("#mp3Source")),n.click(B),m?(l&&t(),e&&(q=!0,p(),i(!0))):s=setInterval(z,1E3),e||i(!1)}})(jQuery);
