var mobileIndicators = [
  "Smartphone",
  "WindowsCE",
  "Palm",
  "hiptop",
  "amoi",
  "AvantGo",
  "Alcatel-",
  "AnexTek",
  "AU-MIC",
  "AUDIOVOX-",
  "BlackBerry",
  "Blazer",
  "CDM-",
  "Dopod-",
  "Ericsson",
  "Hitachi-",
  "HPiPAQ-",
  "HTC-",
  "Droid",
  "Android",
  "iPhone",
  "iPod",
  "KDDI",
  "LG",
  "MM-",
  "MO01",
  "MOT-",
  "Motorola",
  "N515i",
  "N525i",
  "NEC-",
  "Nokia",
  "NOKIA",
  "OpenWeb",
  "Operamini",
  "Opera mini",
  "OPWV",
  "Panasonic",
  "Pantec",
  "PG-",
  "PLS",
  "PM-",
  "PN-",
  "portalmmm",
  "QCI-",
  "RL-",
  "SAGEM",
  "Samsung",
  "SAMSUNG",
  "SCH",
  "SCP-",
  "SEC-",
  "Sendo",
  "SGH-",
  "SHARP-",
  "SIE-",
  "SonyEricsson",
  "SPH",
  "SPV",
  "UP.Browser",
  "UP.Link",
  "V60t",
  "VI600",
  "VK530",
  "VM4050",
  "Vodafone",
  "ZTE",
  "802SH"
 ];

function mobileQueryString(ji) {
    hu = window.location.search.substring(1);
    gy = hu.split("&");
    for (i = 0; i < gy.length; i++) {
        ft = gy[i].split("=");
        if (ft[0] == ji) {
            return ft[1];
        }
    }
    return (false);
}

var fromMobile = mobileQueryString("fromMobileSite");
if (fromMobile == 'false' || fromMobile == '') {
    fromMobile = false;
}
else
    fromMobile = true;

if (!fromMobile) {
    var isMobile = false;
    var agent = navigator.userAgent.toLowerCase();
	for (var i = 0; i < mobileIndicators.length; i++){ 
        var indicator = mobileIndicators[i].toLowerCase();
        if (agent.indexOf(indicator) > -1) {
            isMobile = true;
        }
    } 
    if (isMobile) {
        if (location.host.indexOf("trainparty.com") != -1) {
            var host = "http://m.trainparty.com" + location.pathname;
            location.replace(host);
        }
    }
}

