//
// function translate()
//
// Ensure the original text is stored in the en_cache
// If the text exists in the target_language_cache then use that text
// Translate
// Store in the target_language_cache
// Display
//

$(document).ready(function() {
    // Add a set of flags before each 'translate' div
    $(".node").before('<div class="flag"><span class="flagtext"><img class="imgflag" src="/themes/garland/images/flags/gif/it.gif" alt="it"/>&nbsp;<img class="imgflag" src="/themes/garland/images/flags/gif/fr.gif" alt="fr"/>&nbsp;<img class="imgflag" src="/themes/garland/images/flags/gif/es.gif" alt="es"/>&nbsp;<img class="imgflag" src="/themes/garland/images/flags/gif/de.gif" alt="de"/>&nbsp;<img class="imgflag" src="/themes/garland/images/flags/gif/gb.gif" alt="english"/></span></div>');

    // If an imgflag is clicked call translate on the required element
    $(".imgflag").click(function() {
        var language=$(this).attr('alt');
        $(this).parent().parent().next().translate('english', language, {fromOriginal:true });
    });
});

