///////////////////////////////////////////////////////////////////////////////
//                   JS.Translator.Front-End (en-to-all v1.0)
//          Copyright 2004 Shawn Brown (http://www.shawnbrown.com)
//
// LICENSE: This script and the accompanying flag images are free for personal 
// use (no obligations--but keep the readme.txt together with the files 
// you're using). The JavaScript and flag files are also free for business, non-
// profit organization and commercial sites but, in these cases, you must send 
// email to me and tell me your site's URL (obligations: no money--however, send 
// email to inform@shawnbrown.com and keep the readme.txt together with the 
// files you're using).
// 
// WARRANTY: Absolutely none. But if you find a problem with this JavaScript, 
// inform me and I'll fix it if I have time. Also, if you would like a different 
// flag (e.g. a Brazilian flag for your Portuguese link) let me know--I can 
// create it and send it to you via email.
///////////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////////
// CUSTOMIZATION VARIABLES -- YOU MUST ENTER URL FOR THE FOLDER CONTAINING FLAG
// FILES. The other variables can also be changed to customize this script for a 
// particular site. Explanation of variables...
//        flag_folder_url : folder location where the flag files are stored
//         flag_alignment : "v" for vertical, "h" for horizontal
// to_translation_heading : text/HTML that appears before the to-translation flags
//    to_original_heading : text/HTML that appears before the to-original flag
///////////////////////////////////////////////////////////////////////////////
var       flag_folder_url = "http://www.seaweedireland.com/translate/"; // <-- MUST CHANGE
var        flag_alignment = "h";
var to_translaton_heading = "";
var   to_original_heading = "";


///////////////////////////////////////////////////////////////////////////////
//             SCRIPT BEGINS -- DO NOT CHANGE AFTER THIS POINT
///////////////////////////////////////////////////////////////////////////////

// Function returns a single HTML-formatted hyperlink using a flag graphic.
function translation_link(hl_equals,langpair,flag_file,title)
{
  translation_url = "http://translate.google.com/translate?hl=" 
                  + hl_equals 
                  + "&ie=UTF-8&oe=UTF-8&langpair=" 
                  + langpair 
                  + "&u=" 
                  + document.location
                  + "&prev=%2Flanguage_tools";

  full_link = "<a href='" + translation_url + "' title='" + title + "'>"
            + "<img src='" + flag_folder_url + flag_file + "' width='25' height='20' border='0'>"
            + "</a>";

  if (flag_alignment == "v") 
    full_link = full_link + "<br>"; 

  return (full_link)
}

// If the page has not been loaded by Google's translator, then write the link flags.
if (document.location.hostname != "216.239.39.104" &&
    document.location.hostname != "216.239.37.104" &&
    document.location.hostname != "translate.google.com")
  {
    trans_links = translation_link("de","en|de","german_flag.gif","Deutsch")
                + translation_link("es","en|es","spanish_flag.gif","Espa&ntilde;ol")
                + translation_link("fr","en|fr","french_flag.gif","Fran&ccedil;ais")
                + translation_link("it","en|it","italian_flag.gif","Italiano")
                + translation_link("pt","en|pt","portuguese_flag.gif","Portuguese");
    document.write(to_translaton_heading + trans_links);
  }

// Else, the page has been translated. Write the back-to-English link flag. 
else 
  {
    orig_url = document.location.href;
    orig_url = orig_url.slice(7, orig_url.length);
    orig_url = orig_url.slice(orig_url.search("http"), orig_url.length);
    if (orig_url.search("&") > -1)
      orig_url = orig_url.slice(0, orig_url.search("&")); 

    var original_link = "<a href='" + orig_url + "' title='English'>"
                      + "<img src='" + flag_folder_url + "english_flag.gif'" + " width='25' height='20' border='0'>"
                      + "</a>";
    document.write(to_original_heading + original_link); 
  }; 

// Bust out of Google's frame if we're not looking at a translated page.
if (top != self &&
    document.location.hostname != "216.239.39.104" &&
    document.location.hostname != "216.239.37.104" &&
    document.location.hostname != "translate.google.com")

  top.location.replace(unescape(window.location.pathname));

///////////////////////////////////////////////////////////////////////////////
//                              SCRIPT ENDS 
///////////////////////////////////////////////////////////////////////////////