// JavaScript Document

function scriptInit() {
    if (!document.getElementById) return;
}

function checkActive() {
    var loc = window.location.href;
    if (loc.substr(loc.length - 1) == '/') {
        loc += 'index.html';
    }

    $$('a').each(function(el) {
        if (el.href == loc) {
            el.addClass('active');
        }
    });
}

function convertLinks() {
    if (location.href.match('www.gem.ac.uk')) {
        $$('a').each(function(el) {
            if (el.href.match('sites.uk-plc.net\/gem\/')) {
                el.href = 'http://www.gem.ac.uk/' + el.href.substr(28);
            }
        });
    } else {
        $$('a').each(function(el) {
            if (el.href.match('www.gem.ac.uk')) {
                el.href = 'http://sites.uk-plc.net/gem/' + el.href.substr(21);
            }
        });
    }
}

window.addEvent('domready', convertLinks);
window.addEvent('domready', checkActive);

