// Customize the "redirects" array below.
// Copy this file named "mobileredirects.js" to the root of your web site.
// Include the script tag on line 5 below in web pages where you wish to activate mobile redirects.
//
// <script type="text/javascript" src="/mobileredirects.js"></script>
//
// After implementation, test with mobile and non-mobile browsers.

(function () {
    var redirects = [{
        urlcontains: "boston-ames-special-offers",
        mobileurl: "http://m.ameshotel.com/mobile.aspx?pg=morgans_special_offers"
	},{
        urlcontains: "london-sanderson-special-offers",
        mobileurl: "http://m.sandersonlondon.com/mobile.aspx?pg=morgans_special_offers"
    },{
        urlcontains: "london-st-martins-lane-special-offers",
        mobileurl: "http://m.stmartinslane.com/mobile.aspx?pg=morgans_special_offers"
    },{
        urlcontains: "los-angeles-mondrian-special-offers",
        mobileurl: "http://m.mondrianhotel.com/mobile.aspx?pg=morgans_special_offers"
    },{
        urlcontains: "new-york-hudson-special-offers",
        mobileurl: "http://m.hudsonhotel.com/mobile.aspx?pg=morgans_special_offers"
    },{
        urlcontains: "new-york-mondrian-special-offers",
        mobileurl: "http://m.mondriansoho.com/mobile.aspx?pg=morgans_special_offers"
    },{
        urlcontains: "new-york-morgans-special-offers",
        mobileurl: "http://m.morganshotel.com/mobile.aspx?pg=morgans_special_offers"
    },{
        urlcontains: "new-york-royalton-special-offers",
        mobileurl: "http://m.royaltonhotel.com/mobile.aspx?pg=morgans_special_offers"
    },{
        urlcontains: "san-francisco-clift-special-offers",
        mobileurl: "http://m.clifthotel.com/mobile.aspx?pg=morgans_special_offers"
    },{
        urlcontains: "south-beach-delano-special-offers",
        mobileurl: "http://m.delano-hotel.com/mobile.aspx?pg=morgans_special_offers"
    },{
        urlcontains: "south-beach-mondrian-special-offers",
        mobileurl: "http://m.mondrian-miami.com/mobile.aspx?pg=morgans_special_offers"
    },{
        urlcontains: "south-beach-shore-club-special-offers",
        mobileurl: "http://m.shoreclub.com/mobile.aspx?pg=morgans_special_offers"
    },{
        urlcontains: "morganshotelgroup.com",
        mobileurl: "http://m.morganshotelgroup.com/"
    }];

    var mobileUserAgents = ["midp", "240x320", "blackberry", "netfront", "nokia", "panasonic", "portalmmm", "sharp", "sie-", "sonyericsson", "symbian", "windows ce", "benq", "mda", "mot-", "opera mini", "philips", "pocket pc", "sagem", "samsung", "sda", "sgh-", "vodafone", "xda", "iphone", "android", "ipad"];
    var myUserAgent = navigator.userAgent.toLowerCase();
    var currentURL = window.location.href.toLowerCase();

    for (var i = 0; i < mobileUserAgents.length; i++) {
        if (myUserAgent.indexOf(mobileUserAgents[i]) !== -1) {
			if (/\/email-special-offers\//.test(window.location) || /\/the-list\//.test(window.location)|| /\/meetings-events\//.test(window.location)) {
				break;
			}
			else
			{
				for (var ii = 0; ii < redirects.length; ii++) {
					if (currentURL.indexOf(redirects[ii].urlcontains) !== -1) {
						window.location.assign(redirects[ii].mobileurl);
						break;
					}
				}
			
			}

            break;
        }
    }
}());
