// ==UserScript==
// @name	  		I Have iTunes
// @author			Mark Husson <mhusson atte gmail dought com>
// @description		Auto-Initialization of iTunes when clicking links to lauch a song. Only install this script if you have iTunes. See notes for the auto-back feature.
// @namespace		http://michaelhusson.com/mark/greasemonkey/
// @include		 	http://phobos.apple.com/WebObjects/MZStore.woa/wa/lastChanceRedirect?*

// Note: If you want to bypass clicking the "back" link/button every time, change autoBackButton to true.

// ==/UserScript=

(function() {
	var autoBackButton = false;
	if(document.title == "Got iTunes?"){
		hasITMS();
		if(autoBackButton){
			setTimeout("goBack()", 2000);
			document.body.innerHTML = "<p>Launching iTunes, please wait...</p>"
		}else{
			document.getElementsByTagName("div")[0].innerHTML = "<p>Loading item in iTunes, Please wait...</p><p>If you came from a webpage, <a href='javascript:history.back();'>click here</a> to go back to whatever you were reading</p>";
		}
	}
	
	goBack = function(){
		history.back();
	}
})();