var vmuk = {
    enable: function (controlId) {
        $(controlId).removeAttr('disabled');
        $(controlId).css({ opacity: 1 });
    },
    disable: function (controlId) {
        $(controlId).attr('disabled', 'disabled');
        $(controlId).css({ opacity: 0.5 });
    }
};

$(document).ready(function () {
    var stagingUrl = document.domain == 'localhost' || document.domain == '192.168.1.230' || document.domain == '192.168.1.70';
    var wwwVectone = 'http://www.vectonemobile.co.uk/';
    var myVectone = 'https://my.vectonemobile.co.uk/';
    var wwwPatt = /https?\:\/\/((www|my).)?vectonemobile.co.uk\/?/gi;
    if (stagingUrl) {
        wwwVectone = 'http://192.168.1.230:4401/';
        myVectone = 'http://192.168.1.70/vectonemobileuk_vNET/';
        wwwPatt = /(http\:\/\/[^\/\r\n\b]*.?)?vectonemobileuk_(v5|vNET)\/?/gi;
    }

    var payg = /pay-as-you-go\/(bundles\/activate|add-ons\/mobile-internet\/activate|offers\/free-mobile-internet|vm-rates\/standard\/mobile-internet\/activate-payg|top-up\/step|top-up)[\w\/\-\_\.\?\=]*\b/g;
    var pm = /pay-monthly\/(order-pay-monthly|add-ons\/mobile-internet\/activate)[\w\/\-\_\.\?\=]*\b/g;
    var myaccount = /myvectone[\w\/\-\_\.\?\=]*\b/g;
    var others = /vm-quickaccess[\w\/\-\_\.\?\=]*\b/g;

    $('a').each(function () {
        var href = $(this).attr('href');
        if (href) {
            // PAYG
            if (href.search(payg) != -1) {
                href = myVectone + href.match(payg);
                $(this).attr('href', href);
            }
            // PM
            else if (href.search(pm) != -1) {
                href = myVectone + href.match(pm);
                $(this).attr('href', href);
            }
            // My Vectone
            else if (href.search(myaccount) != -1) {
                href = myVectone + href.match(myaccount);
                $(this).attr('href', href);
            }
            // Others
            else if (href.search(others) != -1) {
                href = myVectone + href.match(others);
                $(this).attr('href', href);
            }
            else {
                href = href.replace(wwwPatt, wwwVectone);
                $(this).attr('href', href);
            }
        }
    });
});

