if(navigator.userAgent.match(/iPhone/i)
    || navigator.userAgent.match(/iPod/i)
    || navigator.userAgent.match(/iPad/i)
    || navigator.userAgent.match(/android/i)) {
    var redirectUrl = 'http://m.bluelans.com';
    var kcProductRegexString = /([p\-_](\d+)\.html)|(products_id=(\d+))/ig;
    var kcProductRegexResult = kcProductRegexString.exec(location.href);
    if (kcProductRegexResult && kcProductRegexResult[2] != undefined) {
        redirectUrl += '/index.php?page=item_detail&item_id=' + kcProductRegexResult[2];
        location.href = redirectUrl;
    } else if (kcProductRegexResult && kcProductRegexResult[4] != undefined) {
        redirectUrl += '/index.php?page=item_detail&item_id=' + kcProductRegexResult[4];
        location.href = redirectUrl;
    }
    
    var kcCategoryRegexString = /([c\-_](\d+))|(cPath=(\d+))/ig;
    var kcCategoryRegexResult = kcCategoryRegexString.exec(location.href);
    if (kcCategoryRegexResult && kcCategoryRegexResult[2] != undefined) {
        redirectUrl += '/index.php?page=categories&p_cid=' + kcCategoryRegexResult[2];
        location.href = redirectUrl;
    } else if (kcCategoryRegexResult && kcCategoryRegexResult[4] != undefined) {
        redirectUrl += '/index.php?page=categories&p_cid=' + kcCategoryRegexResult[4];
        location.href = redirectUrl;
    }
    location.href = redirectUrl;
}
