jQuery(function () {
    var cancel = jQuery('div.formControls input#cancel');
    if (cancel) {
        cancel.click( function () {
            window.location = '..'
        });
    }
    var save = jQuery('dl.contentViews a#save-form');
    if (save) {
        save.click( function () {
            jQuery('form div.formControls input#save').click();
        });
    }
    var cancel_to_url = jQuery('div.formControls input#cancel_to_url');
    if (cancel_to_url) {
        cancel_to_url.click( function () {
            window.location = jQuery(this).attr('name');
        });
    }
    var sel_lang = jQuery('form select#id_target');
    if (sel_lang) {
        sel_lang.change( function () {
            var fromlang = jQuery('form input#id_from_lang')[0].value;
            var tolang = jQuery('form input#id_to_lang')[0].value;
            window.location = '?current=' + tolang + '&target=' + fromlang;
        });
    }
});

