var flag_folder_url = "http://www.ledset.com/templates/translator/"; // <-- MUST CHANGE
var flag_alignment = "h";
var to_translaton_heading = "";

// 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")); 

	// http://translate.google.com/translate?u=http://www.ledset.com&langpair=en|es&hl=en&ie=UTF-8&oe=UTF-8
	translation_url = "http://translate.google.com/translate?u=";
	translation_url+= orig_url;
	translation_url+= "&hl=";
	translation_url+= hl_equals;
	translation_url+= "&langpair=";
	translation_url+= langpair;
	translation_url+= "&ie=UTF-8&oe=UTF-8";

	full_link = "<a href='" + translation_url + "' title='" + title + "'>" + "<img src='" + flag_folder_url + flag_file + "' width='40' height='30' 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 == "www.ledset.com" || document.location.hostname == "ledset.com" || document.location.hostname == "69.10.148.115")
{
	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 
  {
    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 + "english_flag.gif'" + " width='40' height='30' border='0'>"
                      + "</a>";
    document.write(original_link); 
  }; 

// Bust out of Google's frame if we're not looking at a translated page.
if (document.location.hostname == "www.ledset.com" || document.location.hostname == "ledset.com" || document.location.hostname == "69.10.148.115")
	if (top != self)
		top.location.replace(unescape(window.location.pathname));