var TN_mobile = function () {

    function CheckCancelledCookie() {
        return ('; ' + document.cookie + ';').indexOf("; tn_mcan=") > -1;
    }

    function SetCancelledCookie() {
        document.cookie = "tn_mcan=true; path=/";
    }

    function CheckCancelledQParam() {
        return window.location.search.replace('?', '&').indexOf("&tn_mcan=") > -1;
    }

    function CheckDroid() {
        return navigator.userAgent.toLowerCase().indexOf("android") > -1;
    }

    function CheckIphone() {
        return navigator.userAgent.toLowerCase().indexOf("iphone") > -1;
    }

    function CheckBlackBerry() {
        return navigator.userAgent.toLowerCase().indexOf("blackberry") > -1;
    }

    return {
        "DroidUrl": "",
        "IphoneUrl": "",
        "BlackBerryUrl": "",
        "Redirect":
  function () {

      if (CheckCancelledCookie())
          return;
      if (CheckCancelledQParam()) {
          SetCancelledCookie();
          return;
      }

      var firstMUrl = this.DroidUrl;
      if (firstMUrl == "")
          firstMUrl = this.IphoneUrl;
      if (firstMUrl == "")
          firstMUrl = this.BlackBerryUrl;
      if (firstMUrl == "")
          firstMUrl = "?tn_mcan=true";


      if (CheckDroid())
          document.location = this.DroidUrl == "" ? firstMUrl : this.DroidUrl;

      if (CheckIphone())
          document.location = this.IphoneUrl == "" ? firstMUrl : this.IphoneUrl;

      if (CheckBlackBerry())
          document.location = this.BlackBerryUrl == "" ? firstMUrl : this.BlackBerryUrl;

  }
    };
} ();

if (typeof TN_mobileUrlOverride == 'function')
    TN_mobileUrlOverride();
TN_mobile.Redirect();
