/////////////////////////
// Idiomas
/////////////////////////

function country(lang) {
  if (lang != parent.ugc_lang) {
    parent.ugc_lang = lang
    parent.frames.main.location = "../" + lang + "/" + getPageFromURL(parent.frames.main.location)
    parent.frames.bottom.location = "../" + lang + "/bottom.html"
  }
}

function country_logo(lang) {
  parent.frames.main.location = "../" + parent.ugc_lang + "/main.html"
  parent.frames.bottom.location = "../" + parent.ugc_lang + "/bottom.html"
}

function getPageFromURL(url) {
  url = url.toString()
  var result = "index.html"
  var beg = url.lastIndexOf('/')
  var sea = url.lastIndexOf('?')
  var end = url.length
  if ((beg > -1) && (beg != (end -1))) {
    if (sea > -1) end = sea
    result = url.substring(beg +1, end)
  }
  return result
}

/////////////////////////
// links
/////////////////////////

function common_onload() {
  for (var x = 0; x < document.links.length; x++) {
    document.links[x].onmouseover = onmouse_over
    document.links[x].onmouseout = onmouse_out
  }
}

function onmouse_over() {
  // esto es para NS6
  var t = this.innerHTML.split('<br>')
  var r = ""
  for (var x=0; x < t.length; x++) {
    var k = t[x].trim() + " "
    if (k.charAt(0) != '<') r+= k
  }
  // para IE, con this.innerText hay suficiente.
  window.defaultStatus = this.innerText || r || "Gavicas"
  return true
}

function onmouse_out() {
  window.defaultStatus = "Gavicas"
  return true
}

window.onload = common_onload

String.prototype.trim = function() {
  return this.replace(/(^\s*)|(\s*$)/g, "")
}
