function detectTapatalk() {
	if (document.cookie.indexOf("tapatalk_redirect=false") < 0) {
		if (!navigator.userAgent.match(/Opera/i) && !navigator.userAgent.match(/Dolphin/i)) {
			if ((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i))) {
				setTapatalkCookies();
				if (confirm("Want to grab the HowardForums App for iPhone and iPod?"))
					window.location = "http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=418102517&mt=8";
			} else if(navigator.userAgent.match(/iPad/i)) {
				setTapatalkCookies();
				if (confirm("Want to grab the HowardForums App for your iPad?"))
					window.location = "http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=418102517&mt=8";
			} else if(navigator.userAgent.match(/android/i)) {
				setTapatalkCookies();
				if (confirm("Want to grab the HowardForums App for Android?"))
					window.location = "market://details?id=com.quoord.tapatalkhowardforum.activity";
			} else if((navigator.userAgent.match(/Windows Phone/i)) || (navigator.userAgent.match(/ZuneWP7/i))) {
				setTapatalkCookies();
				if (confirm("Want to grab the HowardForums App for Windows Phone 7?"))      
					window.location = "zune://navigate/?phoneAppID=cbc4faad-6054-e011-854c-00237de2db9e";
			} else if(navigator.userAgent.match(/webOS/i)) {
				setTapatalkCookies();
				if (confirm("This forum has an app for webOS phone! Click OK to learn more about Tapatalk."))      
					window.location = "http://developer.palm.com/appredirect/?packageid=com.newnessdevelopments.forums";
			}
		}
	}
}

function setTapatalkCookies() {
	var date = new Date();
	var days = 90;
	date.setTime(date.getTime()+(days*24*60*60*1000));
	var expires = "; expires="+ date.toGMTString();
	document.cookie = "tapatalk_redirect=false" + expires; 
}

detectTapatalk();
