﻿// global.js
function ddlNav(ddl) {
    if (ddl.options[ddl.options.selectedIndex].value !== '') {
        var slash = String.fromCharCode(47);
        var url = ddl.options[ddl.options.selectedIndex].value;
        if (url.substring(0, 7) == "http:" + slash + slash) {
            window.location = url;
        }
        else {
            // encoding the slash is required so reverse proxy does not insert the path incorrectly.
            var path = window.location.pathname;
            var pathArray = path.split(slash);
            var startPath = window.location.protocol + slash + slash + window.location.host;
            var endPath = '';

            if (pathArray[1] == "us" || pathArray[1] == "canada") {
                endPath = slash + pathArray[1] + ddl.options[ddl.options.selectedIndex].value;
            }
            else {
                endPath = ddl.options[ddl.options.selectedIndex].value;
            }

            endPath = endPath.replace(slash + slash, slash);
            window.location = startPath + endPath;
        }
    }
}
