var menuNow = null;

function menuOn(el){
  if(menuNow !== null) menuNow.className = "menuelement";
  el.className = "menuelement active";
  menuNow = el;
  if(el.getAttribute("href")){
    window.status = el.getAttribute("href");
    el.onclick = function(){location.href = this.getAttribute("href")};
  }
  el.onmouseout =function(){window.status = ''};
}

var last = window.onload;
if(typeof(last) !== 'function')
  window.onload = allPrepare;
else
  window.onload = function(){last();allPrepare()};

function allPrepare(){
  var ar = document.getElementsByTagName('a');
  for(var i=0; i<ar.length;i++) ar[i].onclick = function(){this.blur();};
  
  ar = document.getElementsByTagName('span');
  for(i=0; i<ar.length;i++){
    if(ar[i].className.indexOf('menuelement') !== -1){
      if(ar[i].className.match(/active/i)) menuNow = ar[i];
      ar[i].onmouseover = function(e){menuOn(this)};
    }
  }
  
  ar = document.getElementsByTagName('div');
  for(i=0; i<ar.length;i++){
    if(ar[i].className.match(/submenu/i)){
      ar[i].onclick = function(e){
        if(!e) e = window.event;
        e.cancelBubble = true;
        if(e.stopPropagation) e.stopPropagation();
        this.parentNode.blur();
      }
    }
  }
  
  if(document.getElementById('photominis')) document.getElementById('photominis').onmouseover = function(e){OnPhotoMini(e,this);};
  
  var j;
  for(i=0;i<document.forms.length;i++)
    for(j=0;j<document.forms[i].elements.length;j++)
      if(document.forms[i].elements[j].tagName.toLowerCase() !== 'textarea')
        document.forms[i].elements[j].onkeypress = function(e){
          var keynum;
          if(window.event)
            keynum = window.event.keyCode;
          else if(e.which)
            keynum = e.which;
          if(keynum == 13) this.form.submit();
          return true;
        }
}
