window.onload = function() {
  // translationLinks("machinetranslation", "/images/misc/");
	addChanges() ;
  return 1;
}

function gooogle() 
{
  var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
  document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
  var pageTracker = _gat._getTracker("UA-139779-11");
  pageTracker._initData();
  pageTracker._trackPageview();
}


function translationLinks(where, imgpath)
  {
    var here = window.location;
    var target = document.getElementById(where);
    if (target == 'undefined') return;
    target.innerHTML = '<h3><span>Other Languages</span></h3>'+
'<ul>'+
'  <li>'+
'    <a href="http://translate.google.com/translate?u='+here+'&langpair=en%7Cfr&hl=fr&ie=UTF-8&ie=UTF-8&oe=UTF-8&prev=%2Flanguage_tools"'+ 
'		title="Fran&#231;ais - Traduction par Google">'+
'		<img src="'+imgpath+'flag-france.gif" alt="Fran&#231;ais" />'+
'		<span>Fran&#231;ais</span></a>'+
'  </li>'+
'  <li>'+
'    <a href="http://translate.google.com/translate?u='+here+'&langpair=en%7Ces&hl=es&ie=UTF-8&ie=UTF-8&oe=UTF-8&prev=%2Flanguage_tools"'+ 
'		title="Espa&#241;ol - Traducci&#243;n de Google">'+
'		<img src="'+imgpath+'flag-spain.gif" alt="Espa&#241;ol" />'+
'		<span>Espa&#241;ol</span></a>'+
'  </li>'+
'  <li>'+
'    <a href="http://translate.google.com/translate?u='+here+'&langpair=en%7Cde&hl=de&ie=UTF-8&ie=UTF-8&oe=UTF-8&prev=%2Flanguage_tools"'+ 
'		title="Deutsch - &#220;bersetzung durch Google">'+
'		<img src="'+imgpath+'flag-germany.gif" alt="Deutsche" />'+
'		<span>Deutsch</span></a>'+
'  </li>'+
'  <li>'+
'    <a href="http://translate.google.com/translate?u='+here+'&langpair=en%7Cit&hl=it&ie=UTF-8&ie=UTF-8&oe=UTF-8&prev=%2Flanguage_tools"'+ 
'		title="Italiano - Traduzione da Google">'+
'		<img src="'+imgpath+'flag-italy.gif" alt="Italiano" />'+
'		<span>Italiano</span></a>'+
'  </li>'+
'  <li>'+
'    <a href="http://translate.google.com/translate?u='+here+'&langpair=en%7Cpt&hl=pt&ie=UTF-8&ie=UTF-8&oe=UTF-8&prev=%2Flanguage_tools"'+ 
'		title="Portugu&#234;s - Tradu&#231;&#227;o por Google">'+
'		<img src="'+imgpath+'flag-portugal.gif" alt="Portugu&#234;s" />'+
'		<span>Portugu&#234;s</span></a>'+
'  </li>'+
'</ul>';
  }



function AjaxObject()
{
  this.XmlHttp = this.GetHttpObject();
}

AjaxObject.prototype.GetHttpObject = function()
{ 
  var xmlhttp;
  /*@cc_on
  @if (@_jscript_version >= 5)
    try {
      xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      try {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (E) {
        xmlhttp = false;
      }
    }
  @else
  xmlhttp = false;
  @end @*/
  if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
    try {
      xmlhttp = new XMLHttpRequest();
    } catch (e) {
      try {
        xmlhttp = new ActiveXObject('Microsoft.XMLHTTP');
      } catch (e) {
        xmlhttp = false;
      }
    }
  }
  return xmlhttp;
}
 
AjaxObject.prototype.DoCallBack = function(thePage, theData, eventArgument)
{
  if( this.XmlHttp )
  {
    if( this.XmlHttp.readyState == 4 || this.XmlHttp.readyState == 0 )
    {
      var oThis = this;
      this.XmlHttp.open('POST', thePage, true);
      this.XmlHttp.onreadystatechange = function(){ oThis.ReadyStateChange(); };
      this.XmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
      this.XmlHttp.send(theData);
    }
  }
}
 
AjaxObject.prototype.AbortCallBack = function()
{
  if( this.XmlHttp )
    this.XmlHttp.abort();
}
 
AjaxObject.prototype.OnLoading = function()
{
  // Loading
  var working = document.getElementById('working');
  if (working)
  {
    working.innerHTML = '<img src="busy_spinner_medium.gif" height="20px" alt="working..." /> Loading...';
    working.style.visibility = 'visible';
  }
}
 
AjaxObject.prototype.OnLoaded = function()
{
  // Loaded
  var working = document.getElementById('working');
  if (working)
  {
    working.innerHTML = '<img src="busy_spinner_medium.gif" height="20px" alt="working..." /> Loaded...';
    working.style.visibility = 'visible';
  }
}
 
AjaxObject.prototype.OnInteractive = function()
{
  // Interactive 
  // this is normal mode when doing nothing
  var working = document.getElementById('working');
  if (working)
  {
    working.innerHTML = '<img src="busy_spinner_medium.gif" height="20px" alt="working..." /> Interactive...';
    working.style.visibility = 'hidden';
    //working.innerHTML = ''; 
  }
}
 
AjaxObject.prototype.OnComplete = function(responseText, responseXml)
{
  // Complete
  var working = document.getElementById('working');
  if (working)
  {
    working.innerHTML = '<img src="busy_spinner_medium.gif" height="20px" alt="working..." /> Done...';
    working.style.visibility = 'visible';
  }
}
 
AjaxObject.prototype.OnAbort = function()
{
  // Abort
  var working = document.getElementById('working');
  if (working)
  {
    working.innerHTML = '<img src="busy_spinner_medium.gif" height="20px" alt="working..." /> Aborted...';
  }
}
 
AjaxObject.prototype.OnError = function(status, statusText)
{
  // Error
  var working = document.getElementById('working');
  if (working)
  {
    working.innerHTML = '<img src="busy_spinner_medium.gif" height="20px" alt="working..." /> Error...';
  }
}
 
AjaxObject.prototype.ReadyStateChange = function()
{
  if( this.XmlHttp.readyState == 1 )
  {
    this.OnLoading();
  }
  else if( this.XmlHttp.readyState == 2 )
  {
    this.OnLoaded();
  }
  else if( this.XmlHttp.readyState == 3 )
  {
    this.OnInteractive();
  }
  else if( this.XmlHttp.readyState == 4 )
  {
    //alert ('state: ' + this.XmlHttp.readyState + 'Status: ' + this.XmlHttp.status + 'Text: ' + this.XmlHttp.statusText);
    if( this.XmlHttp.status == 0 )
      this.OnAbort();
    else if( this.XmlHttp.status == 200) //&& this.XmlHttp.statusText == "OK" ) // Opera currently buggers this
      this.OnComplete(this.XmlHttp.responseText, this.XmlHttp.responseXML);
    else
      this.OnError(this.XmlHttp.status, this.XmlHttp.statusText, this.XmlHttp.responseText);   
  }
}

var changes = new AjaxObject();
changes.OnComplete = changes_Complete;

function addChanges() 
{
  var uri = 'changes.vsp';
  changes.DoCallBack(uri, '', '');
}

function changes_Complete(responseText, responseXML) 
{
	var elm = document.createElement("span");
	var css = '<br/><a name="docrecentchanges"><span></span></a><style>#changeshead {font-weight: bolder; font-size: 1.3em;} #recentchanges ul {margin-left:0px; list-style-type: none; padding: 0px;}</style>';
	elm.innerHTML = css + responseText;
	document.body.appendChild(elm);
	
	var elm2 = document.createElement("div");
	var elm2content = '<br /><a href="#docrecentchanges">Recent Changes</a>';
	elm2.innerHTML = elm2content;
	var contents = document.getElementById('currenttoc');
	contents.appendChild(elm);
	
}

