 $(document).ready(function(){
 
	function detectMobile() {
		if (DetectIphoneOrIpod()) {
			isMobile("iOS");
		}else if (DetectAndroid()){
			isMobile("android");
		} 
	}


	//check if there is a cookie set identifying this browser as mobile
	if($.cookie("isMobile") == "true") {
		//redirect or do something
		if($.cookie("switchMobile") == "true") {
			window.location = "/club/scripts/section/section.asp?NS=MOB_HP";
		}
	}else{
		//no cookie set, so run the mobile detection
		detectMobile();

	}




	function isMobile(type) {
		//this is a mobile device
		
			var switchMobile = confirm("Do you wish to switch to the Mobile site?");
			if (switchMobile) {
				$.cookie("switchMobile", "true", { expires: 30, path: '/' });
				$.cookie("isMobile", "true", { expires: 30, path: '/' });
				window.location = "/club/scripts/section/section.asp?NS=MOB_HP";
				
			} else{
			
				
				$.cookie("switchMobile", "false", { expires: 30, path: '/' });
				$.cookie("isMobile", "true", { expires: 30, path: '/' });
			}
		
	 }




	 $('a#switchtoMobile').live('click', function() {
		var switchMobile = confirm("Do you wish to switch to the Mobile site?");
			if (switchMobile) {
				$.cookie("switchMobile", "true", { expires: 30, path: '/' });
				$.cookie("isMobile", "true", { expires: 30, path: '/' });
				window.location = "/club/scripts/section/section.asp?NS=MOB_HP";
				
			} else{
			
				
				$.cookie("switchMobile", "false", { expires: 30, path: '/' });
				$.cookie("isMobile", "true", { expires: 30, path: '/' });
			}
		return false;
	});


});






