DC = window.DC || {};
if (window.jQuery) {
jQuery(function() {
    var host = window.location.host;
    var trhost = 'tradutor.dicoruna.es';

    DC.lang = (host == trhost) ? 'es' : 'gl';

    if (location.search.indexOf('custom-theme') != -1) {
        $('head')
           .append($('<link href="/css/themes/v0/css" rel="stylesheet" type="text/css">'))
           .append($('<script type="text/javascript" src="/css/themes/v0/js"></script>'));
    }

    $('#lang-selector').click(function(event) {
        var klass = $(event.target).attr('class');        

        if (klass == 'lang-gl') {
            if (host == trhost) {
                window.location.href = /inurl=([^&#]*)/.exec(window.location.search)[1];
            }
        } else if (klass == 'lang-es') {
            if (host != trhost) {
                window.location = 'http://tradutor.dicoruna.es/fron-trad/urlTranslate.php?direccion3=gl-es&inurl=' + window.location.href;
            }
        }
        event.preventDefault();
    });
});
}
