/**
 * faceeditor.js			2005/11/22
 */
function onUpload() {
  if (document.forms[0].faceFile.value == "") {
    alert("You need to choose a file first");
    return false;
  }
  document.forms[0].elements["faceUpload"].value = "true";
  //document.forms[0].elements["faceFile"].disabled = true;
  document.forms[0].elements["faceUploadButton"].disabled = true;
  _div = document.createElement("div");
  _div.id = "uploadInProgress";
  _div.style.backgroundImage = "url(./img/uploading.gif)";
  document.body.appendChild(_div);
  setInterval('blinkUploading()', 1000);
  return true;
}

function blinkUploading() {
  _div = document.getElementById("uploadInProgress");
  if (_div) {
    current = _div.style.backgroundImage;
    if (current != "none") {
      _div.style.backgroundImage = "none";
    } else {
      _div.style.backgroundImage = "url(./img/uploading.gif)";
    }
  }
}

function showFace(nick) {
  _img = document.getElementById("question");
  _img.src = "/pictures/faces/" + nick + "_face.gif";
}

function hideExampleFace() {
  _img = document.getElementById("question");
  _img.src = "./img/question.gif";
}

function hideError() {
  _error = document.getElementById("error");
  _error.parentNode.removeChild(_error);
}
function showFaceEditor(_nick, _uid) {
  if (window.faceEditorWindow != null && !window.faceEditorWindow.closed) {
    window.faceEditorWindow.focus();
    return;
  }

  winWidth = (window.ActiveXObject) ? 622 : 620;  
  //winWidth = 622;
  winHeight = 567;
  
  params = "width=" + winWidth + ",height=" + winHeight + ",resizable=yes,status=no," +
    "left=" + Math.ceil(screen.availWidth/2 - winWidth/2) + "," +
    "top=" + Math.ceil(screen.availHeight/2 - winHeight/2);

  editorUrl = "/fdfaces/faceeditor.php?nick=" + _nick + "&uid=" + _uid;
  
  window.faceEditorWindow = window.open(editorUrl, "FdFaces", params);
}
