function detectTapatalk() {
	if (document.cookie.indexOf("tapatalk_redirect2=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("This forum has an app for iPhone! Click OK to learn more about Motorcycle.com app."))
					window.location = "http://itunes.apple.com/us/app/motorcycle.com/id423565588?mt=8";
			} else if(navigator.userAgent.match(/iPad/i)) {
				setTapatalkCookies();
				if (confirm("This forum has an app for iPad! Click OK to learn more about Motorcycle.com app."))
					window.location = "http://itunes.apple.com/us/app/motorcycle.com/id423565588?mt=8";
			} else if(navigator.userAgent.match(/Android/i)) {
				setTapatalkCookies();
				if (confirm("This forum has an app for Android! Click OK to download Motorcycle.com App for free."))
					window.location = "market://details?id=com.quoord.tapatalkmotorcyclefree.activity";
			}
		}
	}
}

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_redirect2=false" + expires; 
}

detectTapatalk();

