
/*
** controls switching between English and Spanish
*/

function switchlanguage(lang)
{
var sPath = location.href;
var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);
var newpage = "../" + lang + "/" + sPage;
location.href = newpage;
}

/*********************************************************/

/*
** this is for displaying localized modification date
*/

var spMonths = new Array("enero", "febrero", "marzo", "abril", "mayo", "junio", "julio", "agosto", "septiembre", "octubre", "noviembre", "diciembre");
var enMonths = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");

function writeModificationDate(lang)
{
  var d = new Date(document.lastModified);
 
  if (lang == 'en')
     document.write(enMonths[d.getMonth()] + ' ' + d.getDate() + ', ' + d.getFullYear() + ' @ ' + d.getHours() + ':' + d.getMinutes() + ':' + d.getSeconds());
  else if (lang == 'sp')
     document.write(d.getDate() + ' ' + spMonths[d.getMonth()] + ' ' + d.getFullYear() + ' @ ' + d.getHours() + ':' + d.getMinutes() + ':' + d.getSeconds());
}


/*********************************************************/

/*
** these functions are for extracting values from the QUERYSTRING
*/

function PageQuery(q) {
if(q.length > 1) this.q = q.substring(1, q.length);
else this.q = null;
this.keyValuePairs = new Array();
if(q) {
for(var i=0; i < this.q.split("&").length; i++) {
this.keyValuePairs[i] = this.q.split("&")[i];
}
}
this.getKeyValuePairs = function() { return this.keyValuePairs; }
this.getValue = function(s) {
for(var j=0; j < this.keyValuePairs.length; j++) {
if(this.keyValuePairs[j].split("=")[0] == s)
return this.keyValuePairs[j].split("=")[1];
}
return false;
}
this.getParameters = function() {
var a = new Array(this.getLength());
for(var j=0; j < this.keyValuePairs.length; j++) {
a[j] = this.keyValuePairs[j].split("=")[0];
}
return a;
}
this.getLength = function() { return this.keyValuePairs.length; }
}

/* -------------------------- */

function queryString(key)
{
var page = new PageQuery(window.location.search);
return unescape(page.getValue(key));
}

/* ------------------------- */

function displayItem(key)
{
if(queryString(key)=='false')
{
document.write("no ?name=value for ", key);
}
else
{
document.write(queryString(key));
}
}

/**********************************************************/

/*
** handles translation
*/
function dotranslation()
{
  var num = document.translation.theAction.selectedIndex;
  
  document.translation.action = document.translation.theAction.options[num].value;
  document.translation.spen.value = document.translation.tranword.value;
  document.translation.enit.value = document.translation.tranword.value;
  document.translation.iten.value = document.translation.tranword.value;
  document.translation.enfr.value = document.translation.tranword.value;
  document.translation.fren.value = document.translation.tranword.value;
  
  return true;
} /* dotranslation */