function attachLanguages() {
  if (document.getElementById('navlanguage')) {
    lang = document.getElementById('navlanguage');
    langs = lang.getElementsByTagName('li');
    langbox = document.createElement('ul');
    langbox.setAttribute('id','langbox');
    for (var i=0;i<langs.length;i++) {
      if (langs[i].className.indexOf('selected')<0) {
        langbox.appendChild(langs[i].cloneNode(true));
        langs[i].style.display = 'none';
      } else {
        langs[i].childNodes[0].className = 'show';
        langs[i].childNodes[0].onclick = function() {
          if (document.getElementById('langbox')) {
            document.getElementById('language').removeChild(langbox);
          } else {
            document.getElementById('language').appendChild(langbox);
          }
          return false;
        }
      }
    }
  }
}

function attachShadows() {
  if (document.getElementsByTagName('div')) {
    divs = document.getElementsByTagName('div');
    for (var i=0;i<divs.length;i++) {
      if ((divs[i].className.indexOf('shadowbox')>=0)&&(divs[i].className.indexOf('done')<0)) {
        shadowt = document.createElement('div');
        shadowt.className = 'shadow-t';
        shadowr = document.createElement('div');
        shadowr.className = 'shadow-r';
        shadowb = document.createElement('div');
        shadowb.className = 'shadow-b';
        shadowl = document.createElement('div');
        shadowl.className = 'shadow-l';
        shadowlt = document.createElement('div');
        shadowlt.className = 'shadow-lt';
        shadowrt = document.createElement('div');
        shadowrt.className = 'shadow-rt';
        shadowrb = document.createElement('div');
        shadowrb.className = 'shadow-rb';
        shadowlb = document.createElement('div');
        shadowlb.className = 'shadow-lb';
        shadowbox = divs[i].cloneNode(true);
        shadowbox.className = 'shadowbox done';
        shadowlb.appendChild(shadowbox);
        shadowrb.appendChild(shadowlb);
        shadowrt.appendChild(shadowrb);
        shadowlt.appendChild(shadowrt);
        shadowl.appendChild(shadowlt);
        shadowb.appendChild(shadowl);
        shadowr.appendChild(shadowb);
        shadowt.appendChild(shadowr);
        divs[i].parentNode.appendChild(shadowt);
        divs[i].parentNode.removeChild(divs[i]);
      }
    }
  }
}

function flexFlash(width,height) {
  if (document.getElementById('flash')) {
    document.getElementById('flash').style.visibility='hidden';
    var z = Math.round(document.getElementById('flash').offsetWidth*(height/width));
    document.getElementById('flash').style.height=z+'px';
    try {
      var x = document.getElementById('movieobject');
      x.style.height=z+'px';
      x.style.width='100%';
    } catch(error) {
    } try {
      var x = document.getElementById('movieembed');
      x.style.height=z+'px';
      x.style.width='100%';
    } catch(error) {}
    document.getElementById('flash').style.visibility='visible';
  }
}

function init() {
  attachLanguages();
  attachShadows();
  flexFlash(779,210);
}

window.onresize = init;
