//Set cookie for mobile
function get_cookie(Name) {
    var search = Name + "="
    var returnvalue = "";
    
    if (document.cookie.length > 0) {
        offset = document.cookie.indexOf(search)
        if (offset != -1) {
            offset += search.length
            end = document.cookie.indexOf(";", offset);
            if (end == -1) end = document.cookie.length;
            returnvalue = unescape(document.cookie.substring(offset, end))
        }
    }
    return returnvalue;
}
//Redirect iPhone, iPod Touch, Android, and Blackberry users to mobile version of website if JS is enabled
var query = window.location.search.substring(3);
if ((query == "true") || (get_cookie("mobile")=="true")) {
    document.cookie="mobile=true";
    return;
} else {
    if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/ipad/i)) || (navigator.userAgent.match(/iPod/i)) || (navigator.userAgent.match(/android/i))) {
        window.location = "http://mobile.annapolismarriott.com/";
    }
    else if((navigator.userAgent.match(/blackberry/i)) || (navigator.userAgent.match(/BlackBerry/i)) || (navigator.userAgent.match(/opera mini/i))){
        if (navigator.userAgent.indexOf("WebKit") >= 0) {
            window.location = "http://mobile.annapolismarriott.com/";
        } else {
        window.location = "http://m.annapolismarriott.com/";
        }
    }
}
