
function detectMobile() {
	if (document.cookie.indexOf("mobile_redirect=false") < 0) {
		if (!navigator.userAgent.match(/Opera/i)) {
			if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i))) {
				if (confirm("This site has an specific template foro iPhone uses. Click OK to view.")) {            
					document.cookie = "mobile_redirect=false"; 
					window.location = "./mobile.php?lofi=1";
				} else {
					setMobileCookies();
				}
			} else if(navigator.userAgent.match(/android/i)) {
				if (confirm("This site has an specific template for Android users. Click OK to view.")) {            
					document.cookie = "mobile_redirect=false"; 
					window.location = "./mobile.php?lofi=1";
				} else {
					setMobileCookies();
				}
			} else if((navigator.userAgent.match(/Symbian/i)) || (navigator.userAgent.match(/Nokia/i))) {
				if (confirm("This site has an specific templare foro Nokia uses. Click OK to view.")) {            
					document.cookie = "mobile_redirect=false"; 
					window.location = "./mobile.php?lofi=1";
				} else {
					setMobileCookies();
				}
			}
			
		}
	}
}

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

detectMobile();
