window.onload = function() {
    if (typeof(interfaceLoad)=='function') { 
        interfaceLoad();
    }
}

function showPhoto(el) {
    var id = el.getAttribute('photo_id');
    var w = el.getAttribute('width')*1+20;
    var h = el.getAttribute('height')*1+20;
    var x = Math.floor((screen.width - w - 10)/2);
    var y = Math.floor((screen.height - h - 60)/2);
    var win = window.open('/picture/?id='+id, 'IMAGE_WINDOW', 'dependent=yes, disrectories=no, width='+w+', height='+h+', innerWidth='+w+', innerHeight='+h+', location=no, menubar=no, resizable=no, screenX='+x+', screenY='+y+', scrollbars=no, titlebar=no, toolbar=no');
    win.focus();
}

function changeState(el) {
  var parent = el.parentNode;
  var done = false;
  var divs = parent.getElementsByTagName('div');
  var i = 0;
  while ((i < divs.length) && !done) {
    if (divs[i].className == 'hidden') {
      divs[i].className = 'display';
      el.id = 'active';
      done = true;
    } else {
      if (divs[i].className == 'display') {
        divs[i].className = 'hidden';
        el.id = '';
        done = true;
      }
    }
    i ++;
  }
}

function showVideo(el) {
  var w = 560;
  var h = 400;
  var id = el.getAttribute('id');
  var x = Math.floor((screen.width - w - 50)/2);
  var y = Math.floor((screen.height - h - 60)/2);
  var win = window.open('/video/?id='+id, 'IMAGE_WINDOW', 'dependent=yes, disrectories=no, width='+w+', height='+h+', innerWidth='+w+', innerHeight='+h+', location=no, menubar=no, resizable=no, screenX='+x+', screenY='+y+', scrollbars=yes, titlebar=no, toolbar=no');
  win.focus();
}
