﻿Sbi = {};

Sbi.Event = {};

Sbi.Event.cookieRedirect = function() {
    var origin = $j.cookie("countryOfOrigin");
    if (origin) {
        if ((origin != "US") && (origin != "CA")) {
            $j.getJSON("/MrHandyman/scripts/supported_countries.json", function(json) {
                var theOriginUrl = null;
                $j.each(json.countries, function(key, value) {
                    if (key.toString() == origin) {
                        location.replace(value);
                    }
                });
            });
        }
    }
    else {
        if (google.loader.ClientLocation) {
            var countryCode = google.loader.ClientLocation.address.country_code;
            if ((countryCode != "US") && (countryCode != "CA")) {
                location.replace("/country-select.aspx");
            }
        }
        else {
            location.replace("/country-select.aspx");
        }
    }
}