var BROWSER_SAFARI=1;
var BROWSER_FIREFOX=2;
var BROWSER_INTERNET_EXPLORER=3;
var BROWSER_OTHER=4;
var ITUNES_INSTALLED_COOKIE_NAME="iTunesPresent";
function iTunesDetected(){
if("true"==getCookie(ITUNES_INSTALLED_COOKIE_NAME)){
return true;
}
if(-1!=navigator.userAgent.indexOf("Macintosh")){
return true;
}
if(BROWSER_INTERNET_EXPLORER==detectedBrowser()){
return iTunesActiveXComponentInstalled();
}
return iTunesMozillaPluginDetected();
}
function detectedBrowser(){
if(-1!=navigator.userAgent.indexOf("AppleWebKit")){
return BROWSER_SAFARI;
}
if(-1!=navigator.userAgent.indexOf("Firefox")){
return BROWSER_FIREFOX;
}
if(-1!=navigator.userAgent.indexOf("MSIE ")){
return BROWSER_INTERNET_EXPLORER;
}else{
return BROWSER_OTHER;
}
}
function iTunesActiveXComponentInstalled(){
var _1=document.getElementById("iTunesDetectorIE");
var _2=false;
if((_1!=null)&&(typeof (_1)!="undefined")){
if(typeof (_1.IsITMSHandlerAvailable)!="undefined"){
_2=_1.IsITMSHandlerAvailable;
dbg(typeof (_1.IsITMSHandlerAvailable));
}
if((_2==null)||(typeof (_2)=="undefined")){
_2=false;
}
}
dbg("ActiveX Control result: "+_2);
return _2;
}
function iTunesMozillaPluginDetected(){
var _3=false;
if(navigator.plugins&&navigator.plugins.length>0){
for(var i=0;i<navigator.plugins.length;i++){
var _5=navigator.plugins[i];
var _6=_5.name;
if(_6.indexOf("iTunes Application Detector")>-1){
_3=true;
}
}
}
info("FF plugin detected: "+_3);
return _3;
}
function itmsOpen(_7,_8,_9,_a){
if(null!=getCookie("recentlyRedirected")){
_a=true;
}
setCookie("recentlyRedirected",true,4000);
if(iTunesDetected()){
setCookie(ITUNES_INSTALLED_COOKIE_NAME,true,9999999999);
if(_a){
setTimeout("window.location.href = \""+_7+"\"",1);
return true;
}else{
return replaceCurrentPageWithUrl(_7);
}
}else{
if(BROWSER_INTERNET_EXPLORER==detectedBrowser()){
window.location.replace(_8);
}else{
document.getElementById(_9).style.display="block";
}
}
return true;
}
function replaceCurrentPageWithUrl(_b){
window.location.href=_b;
info("Window History Length: "+window.history.length);
if(window.history.length<2){
setTimeout("window.close()",100);
}else{
setTimeout("window.history.back()",100);
}
return true;
}
function setCookie(_c,_d,_e){
var _f=new Date();
_f.setTime(_f.getTime()+_e);
var _10=_c+"="+escape(_d)+"; expires="+_f.toGMTString();
info("setCookie(): "+_10);
document.cookie=_10;
}
function getCookie(_11){
if(null==document.cookie||null==_11){
return null;
}
var _12=document.cookie.split(";");
var _13=null;
for(var i=0;i<_12.length;i++){
var c=_12[i];
var _16=c.split("=");
if(-1<_16[0].indexOf(_11)){
_13=unescape(_16[1]);
break;
}
}
info("getCookie("+_11+"): "+_13);
return _13;
}
function dbg(str){
}
function info(str){
}


