///////////////////////////////////////////////////////////////////////////////
//                   JS.Translator.Front-End (en-to-all v1.1)
//          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.
///////////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////////
// README.txt INCLUDED HERE:
//                   JS.Translator.Front-End (en-to-all v1.1)
//                              by Shawn Brown
///////////////////////////////////////////////////////////////////////////////
//
//JS.TRANSLATOR.FRONT-END and the accompanying FLAG IMAGES are 
//Copyright 2004 Shawn Brown (http://www.shawnbrown.com). 
//
//JS.Translator.Front-End is a JavaScript that manages the translation of English language
// web pages into German, Spanish, French, Italian and Portuguese via Google's translation 
//services. The JavaScript writes several flags onto a web page. Each flag is a link to 
//Google's translation service. Clicking on a flag prompts Google to machine-translate the 
//current page into a corresponding target language. 
//
//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).
//
//FLAG IMAGES: I created the flags used with this script. You can use them with the script or 
//separately (for other purposes) as long as you adhere to the LICENSE. If you want to 
//distribute the flags yourself (e.g., with a script *you* wrote), you need to email me 
//(inform@shawnbrown.com) and get permission. 
//
//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.
//
//REDISTRIBUTION: You may redistribute this JavaScript and the flag images for free. You may not 
//charge money for these files and you must keep the included readme.txt with the files you're 
//distributing.
//
///////////////////////////////////////////////////////////////////////////////
//
//ABOUT THIS SCRIPT: The quality of machine-translated text extends from clumsy to 
// unintelligible--and anywhere in between the two. That being said, it *is* useful for 
//conveying the gist of a website and for site navigation. If your website's ability to cater 
//to non-English speakers is a key feature, you should have each page properly translated 
//(by a human). But if you've never really thought about such things before, and you like the 
//idea of providing a translated version of your site, you can add this script to any web 
//page for little effort and no cost. 
//
//This is the "en-to-all" (English-to-All) version of this JavaScript. It's probably the least 
//useful of all of the versions. Most non-English speakers are likely to already have a 
//translation tool they're comfortable with. But many people rely on Google's translation 
//services and this script provides an extremely easy way to access this feature--which *does* 
//provide a useful service. 
///////////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////////
// 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 = "/gj/"; // <-- MUST CHANGE
var        flag_alignment = "h";
var to_translaton_heading = "";
var   to_original_heading = "Original<br>";


///////////////////////////////////////////////////////////////////////////////
//             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)
{
    var orig_url = document.location.href;
    orig_url = orig_url.slice(7, orig_url.length);
    escape(orig_url);
    if (orig_url.search("%3F") > -1)
      orig_url = orig_url.slice(0, orig_url.search("%3F")); 

  translation_url = "http://translate.google.com/translate?hl=" 
                  + hl_equals 
                  + "&ie=UTF-8&oe=UTF-8&langpair=" 
                  + langpair 
                  + "&u=" 
                  + orig_url
                  + "&prev=%2Flanguage_tools";

  full_link = "<a href='" + translation_url + "' title='" + title + "'>"
            + "<img src='" + flag_folder_url + flag_file + "' width='16' height='11' border='0' hspace='2' vspace='2'>"
            + "</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("es","en|es","es.gif","Español")
                + translation_link("fr","en|fr","fr.gif","Françai")
                + translation_link("pt","en|pt","pt.gif","Português")
                + translation_link("nl","en|nl","nl.gif","Nederlands")
	            + translation_link("de","en|de","de.gif","Deutsch")
                + translation_link("it","en|it","it.gif","Italiano")
                + translation_link("el","en|el","el.gif","Ελληνικά")
                + translation_link("ru","en|ru","ru.gif","Русско")
                + translation_link("ar","en|ar","ar.gif","[أربيك]")
                + translation_link("zh-CN","en|zh-CN","cn.gif","简体中文")
                + translation_link("zh-TW","en|zh-TW","hk.gif","繁體中文")
                + translation_link("ko","en|ko","kr.gif","한국어")
                + translation_link("ja","en|ja","jp.gif","日本語");
    document.write(to_translaton_heading + trans_links);
  }

// Else, the page has been translated. Write the back-to-English link flag. 
else 
  {
    var 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 + "en.gif'" + " width='40' height='30' 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 
///////////////////////////////////////////////////////////////////////////////