var songName_AC,artistName_AC,albumName_AC,lastFocused,retries=0,lastSong,lastAlbum,lastArtist,scrollToBottom=false;function onChosen(G,A,F){var D,C,B,E;if(G.name.indexOf("album")!=-1){if(A){$("songName").focus()}B=lastAlbum;lastAlbum=G.value;if(lastAlbum==B){return }}else{if(G.name.indexOf("artist")!=-1){if(A){$("albumName").focus()}B=lastArtist;lastArtist=G.value;if(lastArtist==B){return }}else{if(G.name.indexOf("song")!=-1){B=lastSong;lastSong=G.value;if(lastSong==B){return }}}}D=new Object();C=$("selectedActionLink").href;D.asynchronous=true;D.onComplete=onComplete;E=C.toLowerCase().lastIndexOf(";jsessionid");if(E==-1){C+="/"+G.name}else{C=C.substring(0,E)+"/"+G.name+C.substring(E)}D.parameters="value="+encodeURIComponent(G.value);new Ajax.Request(C,D)}function makeClickable(E){if((document.all)&&(navigator.userAgent.indexOf("Opera")==-1)){var D=E.getElementsByTagName("tr"),B,C,A;A=function(F){this.style.background="#FFD4A7"};C=function(){this.style.background=""};if(D){for(B=1;B<D.length;B++){D[B].onmouseover=A;D[B].onmouseout=C}}}}function getComponent(B,C){var A=new Object();A.asynchronous=false;A.onError=function(D){finalizeSearch(D)};A.onSuccess=function(D){var E=D.responseText;if(retries>6||E.indexOf("Sorry, no prices found!")!=-1||E.indexOf("finished!!!!!!!!!!")!=-1){C.innerHTML=E;if(window.event){makeClickable(C)}resetIcon();if(setupplay){setupplay()}}else{if(E.charAt(0)=="<"){C.innerHTML=E;makeClickable(C);setTimeout("pollForPrices()",8000)}else{resetIcon()}}if(scrollToBottom){window.scroll(0,150)}};new Ajax.Request(B,A)}function pollForPrices(){var A;A=$("morePrices").href;getComponent(A,$("priceContainer"));retries++}function onComplete(A){}function finalizeSearch(A){window.location.href="/buymusic"}function onCompleteSearch(A){if(A.responseText=="t"){pollForPrices()}else{finalizeSearch(A)}}function resetIcon(){retries=0;$("progress").style.display="none";$("icon").style.display="";$("message").style.color="#8BFEFA";$("go").disabled="";$("albumName").disabled="";$("artistName").disabled="";$("songName").disabled=""}function forceAC(C,B){var A=function(){C.focus();C.value="%";B.activate();C.value=""};A()}function onFo(A){lastFocused=A;if(songName_AC.element!=A){songName_AC.hasFocus=false}if(artistName_AC.element!=A){artistName_AC.hasFocus=false}if(albumName_AC.element!=A){albumName_AC.hasFocus=false}}function showSearching(D){var C,B,F,E,A,G;E=!D.artistName.value.strip();A=!D.songName.value.strip();G=!D.albumName.value.strip();if(!E&&(!A||!G)){}else{if(A&&D.songName==lastFocused){forceAC(D.songName,songName_AC);return }if(G&&D.albumName==lastFocused){forceAC(D.albumName,albumName_AC);return }if(E){forceAC(D.artistName,artistName_AC);return }forceAC(D.albumName,albumName_AC);return }retries=0;$("go").focus();$("progress").style.display="";$("icon").style.display="none";$("message").style.color="";$("go").disabled="true";$("albumName").disabled="true";$("artistName").disabled="true";$("songName").disabled="true";C=new Object();B=$("searchActionLink").href;C.asynchronous=false;C.onSuccess=onCompleteSearch;C.onFailure=finalizeSearch;C.parameters="artist="+encodeURIComponent(D.artistName.value)+"&album="+encodeURIComponent(D.albumName.value)+"&song="+encodeURIComponent(D.songName.value);albumName_AC.stopIndicator();artistName_AC.stopIndicator();songName_AC.stopIndicator();new Ajax.Request(B,C)};