<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
<title>Translate Site</title>
<!--
   Authored by Deepak Kumar Vasudevan
     deepak@cssolutionsinc.com
     http://www.cssolutionsinc.com
 -->
<script language="JavaScript" type="text/javascript">
<!--

  //Global Configuration Settings
  var thiswebsitelang = "English";  //Specify the language of your website.
    var WWW="http://dinki.mine.nu/word/"; //Specify the URL of your website. Leave it blank to translate current page.

    //Do not modify these settings...
    var tranurl = "http://fets3.freetranslation.com/?Sequence=core&Language=";
  var langarray = new Array("Spanish","French","German","Italian","Portuguese","English","Norwegian");

  //After translating, we should ensure change the thiswebsitelang suitably.
  var purl = "";
  purl = self.location.href;

    //Enter test only on genuine translation page.
    if (purl.indexOf("retarget") > -1)
    {
      var thestring = purl.substring(purl.indexOf("retarget")+1,purl.length);
    thestring = thestring.substring(thestring.indexOf("=")+1,thestring.length);
    thiswebsitelang = thestring;

      if (WWW == "")
          {
                  //If this variable is blank, then self.location.href will be taken. In this case, the script is likely to go mad.

        //Get the value of Url in the querystring...
                        var startposition = purl.indexOf("Url=")+4;
                        var stopposition = startposition;

                        for (var cnt=startposition;cnt<purl.length;cnt++)
                        {
                           //This version, we will restrict only to simple URLs after translation process. Is that okay?
                           if (purl.charAt(cnt) == "&")
                                         {
                                                          stopposition = cnt;
                                                                break;
                                                        }
                        }
                        WWW = purl.substring(startposition,stopposition);
                }

    }


  function translate(x,y)
    {
    /*
          x: form element that contains the language selection of the user;
      y: window in which the url has to be opened. (normally it is _top,_blank,_parent,_self.  For any custom pop window, use a javascript function to open the pop window and then pass the window name or handle as argument to this function. That should work, but I have not used that anyway. :-) :-)

     What does not work in this version:

            (*) Passing _self in an attempt to open results in the same window does not work properly in Netscape, whilst the nice Explorer automatically manages things for you. Netscape horrendously resizes itself. Take care of not to pass _self or try a work around. I am also working on to fix this bug. If you get a solution, please do share it with me too.
        */

        if (self.name == "tranwin")
        {
          alert ("This is a translated window. Please close this window and go the parent frame and select a new language.");
      return;
        }

      var theurl = "";
      var winwidth = "";
       var winheight = "";

        with (x)
        {
           //the following assignments are provided in peacemeal fashion for better reading and understanding purposes.
       if (WWW == "")
                       WWW = self.location.href;

                    if (winwidth == "")
                       winwidth = screen.availWidth;

                    if (winheight = "")
                       winheight = screen.availHeight;


                    theurl = tranurl+thiswebsitelang;
           theurl += "%2F";
       theurl += x.transelect.options[x.transelect.selectedIndex].value;
                 theurl += "&Url=";
                 theurl += WWW;
                    theurl += "&retarget=" + x.transelect.options[x.transelect.selectedIndex].value;
        }

        var tranwin = window.open(theurl,"tranwin","width="+winwidth+",height="+winheight+",toolbars=no,statusbar=yes,scrollbars=yes");
    }


    function doPopulate(x)
    {
      var d=0,startcount=1,option;
      for (d=0;d<langarray.length-1;d++)
        {
          /* if (langarray[d] == thiswebsitelang) continue; */
      option = new Option(langarray[d],langarray[d]);
          x.options[startcount] = option;
             startcount++;
        }

        //Now comes the daunting question of which language to show preselected.
    var randomnumber=Math.floor(Math.random()*x.options.length);
        x.selectedIndex = randomnumber;
    }
//-->
</script>

</head>
<body onLoad="doPopulate(document.transform.transelect)">
<h3>Free Translation</h3>
<h5>(Supports <script language="JavaScript" type="text/javascript">
<!--
  document.write (langarray.length-1);
//-->
</script> languages)</h5>
<Form name="transform">
Translate <script language="JavaScript" type="text/javascript">
<!--
   document.write (WWW);
//-->
</script>
 into
  <select name="transelect" onChange="translate(this.form)">
      <option value="">Select A Language</option>
    </select>
    &nbsp;
    </Form>
    <h5 align="center">
      <a href="javascript:void(0)" onClick='document.location.href="view-source:"+self.location.href;'>View Source</a> | <a href="http://deepak.portland.co.uk/">Translation (JavaScript) Concept by Deepak Kumar Vasudevan</a> | <A href="http://www.freetranslation.com">Translation Powered By Freetranslation</a>
    </h5>
</body>
</html>