/* ref: http://www.phpdevblog.net/2009/01/detecting-mobile-devices.html*/

function Client() {}
Client.prototype.mobileClients = [
    "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",
    "Windows Phone"
];

Client.prototype.isMobileClient = function(userAgent)
{
    userAgent=userAgent.toLowerCase();
    for (var i in this.mobileClients) {
        if (userAgent.indexOf(this.mobileClients[i]) != -1) {
            return true;
        }
    }
    return false;
}

var client = new Client();

if(window.location.hostname=="m.invendium.dk")
{
    // stylesheet for mobile devices
    var cssNode = document.createElement('link');
    cssNode.type = 'text/css';
    cssNode.rel = 'stylesheet';
    cssNode.href = 'mobile.css';
    cssNode.media = 'screen';
    document.getElementsByTagName('head')[0].appendChild(cssNode);
}
else if (client.isMobileClient(navigator.userAgent))
{
    window.location = "http://m.invendium.dk"+window.location.pathname+window.location.search;;
}


function printProps(obj, objName) {
  var output = "" ;
  for (var prop in obj) {
    output += objName + "." + prop + " = " + obj[prop] + "\n" ;
  }
  alert( output );
}


