function detectMobile() {
	var newUrl = "";
	if (document.URL.indexOf("styleid=") < 0) {
		if (document.URL.indexOf("?") >= 0) {
			newUrl = document.URL + "&styleid=12";
		} else {
			newUrl = document.URL + "?styleid=12";
		}
	}
	
	if (document.cookie.indexOf("mobile_redirect=false") < 0) {
		if((navigator.userAgent.match(/opera/i)) && ( (navigator.userAgent.match(/mini/i) || (navigator.userAgent.match(/mobi/i) ) {
			if (confirm("Dieses Forum ist in einer Mobilversion verfügbar. Möchten Sie zur Mobilversion wechseln?")) {
				document.cookie = "mobile_redirect=false";
				window.location = newUrl;
			} else {
				setmobileCookies();
			}
		} else if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i))) {
			if (confirm("Dieses Forum ist in einer Mobilversion verfügbar. Möchten Sie zur Mobilversion wechseln?")) {
				document.cookie = "mobile_redirect=false";
				window.location = newUrl;
			} else {
				setmobileCookies();
			}
		} else if(navigator.userAgent.match(/android/i)) {
			if (confirm("Dieses Forum ist in einer Mobilversion verfügbar. Möchten Sie zur Mobilversion wechseln?")) {
				document.cookie = "mobile_redirect=false";
				window.location = newUrl;
			} else {
				setmobileCookies();
			}
		} else if((navigator.userAgent.match(/Symbian/i)) || (navigator.userAgent.match(/Nokia/i))) {
			if (confirm("Dieses Forum ist in einer Mobilversion verfügbar. Möchten Sie zur Mobilversion wechseln?")) {
				document.cookie = "mobile_redirect=false";
				window.location = newUrl;
			} else {
				setmobileCookies();
			}
		}
	}
}

function setmobileCookies() {
	var date = new Date();
	var days = 1;
	date.setTime(date.getTime()+(days*24*60*60*1000));
	var expires = "; expires="+ date.toGMTString();
	document.cookie = "mobile_redirect=false" + expires;
}

detectMobile();

