﻿var urlParams = {};
(function() {
    var e,
        d = function(s) { return decodeURIComponent(s.replace(/\+/g, " ")); },
        q = window.location.search.substring(1),
        r = /([^&=]+)=?([^&]*)/g;

    while (e = r.exec(q))
        urlParams[d(e[1])] = d(e[2]);
})();

// Check for any of the following user agents: blackberry,iphone,ipod,mobile,opera mini,windows ce,palm
if (!("Mobile" in urlParams)) {
    if (/blackberry/i.test(navigator.userAgent)
        || /iphone/i.test(navigator.userAgent)
        || /ipod/i.test(navigator.userAgent)
        || /mobile/i.test(navigator.userAgent)
        || /opera mini/i.test(navigator.userAgent)
        || /windows ce/i.test(navigator.userAgent)
        || /palm/i.test(navigator.userAgent)) {
        var result = confirm("Would you like to view the mobile version of our site?");
        if (result) {
            location.replace("/Mobile");
        }
        else {
            location.replace(window.location + "?Mobile=0");
        }
    }
}
