function searchy(param) {
  if (param == "hide") {
    if (document.getElementById("search").value == "Search...") { document.getElementById("search").value = ""; }
  }
  else if (param == "show") {
    if (document.getElementById("search").value == "") { document.getElementById("search").value = "Search..."; }
  }  
}
function highlight(way, album) {
  var title = document.getElementById('random-image').title;
  var low = '../gallery/Albums/'+album+'/Thumbs/'+title;
  var high = '../gallery/Albums/'+album+'/Highlights/'+title;
  if (way == "yes") { document.getElementById('random-image').src = high; }
  else if (way == "no") { document.getElementById('random-image').src = low; }  
}
function show(where, how) {
  if (how == 'show') {
    document.getElementById(where+'1').style.display='none';
    document.getElementById(where+'2').style.display='';
  }
  else if (how == 'hide') {
    document.getElementById(where+'1').style.display='';
    document.getElementById(where+'2').style.display='none';
  }
}
function last() {
  window.open("date.php", "visitors", 'left=150,top=150,width=500,height=400,toolbar=1,resizable=0,scrollbars=1');
}
function letornum (evt, whose) {
  var charCode = (evt.which) ? evt.keyCode : window.event.charCode;
  if ((whose == "username") || (whose == "password")) {
    if ((charCode >= 48 && charCode <= 57) || (charCode >= 97 && charCode <= 122) || (charCode >= 65 && charCode <= 90) || (charCode == 8)) { return true; }
    else {
      return false;
    }
  }
  else {
    if ((charCode >= 48 && charCode <= 57) || (charCode == 8)) { return true; }
    else { return false; }
  }
}

var dopustimi = new Array();
dopustimi["username"] = 0;
dopustimi["password"] = 0;
dopustimi["code"] = 0;
function stateChanged() {
  if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {
    var rezultat = xmlHttp.responseText;
    var pomestata = rezultat.split(":");
    if (pomestata[1] == 0) {
      document.getElementById(pomestata[0]+'2').style.visibility = '';
      document.getElementById(pomestata[0]+'2').src= 'img/ok-not.jpg';
      dopustimi[pomestata[0]] = 0;
    }
    else {
      document.getElementById(pomestata[0]+'2').style.visibility = '';
      document.getElementById(pomestata[0]+'2').src= 'img/ok.jpg';
      dopustimi[pomestata[0]] = 1;
    }
    if ((dopustimi["code"] + dopustimi["username"] + dopustimi["password"]) == 3) {
      document.getElementById("submit1").style.display = 'none';
      document.getElementById("submit2").style.display = '';
    }
    else {
      document.getElementById("submit2").style.display = 'none';
      document.getElementById("submit1").style.display = '';
    }
  }
}
function GetXmlHttpObject() {
  var xmlHttp=null;
  try { xmlHttp=new XMLHttpRequest(); }
  catch (e) {
    try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); }
    catch (e) { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); }
  }
  return xmlHttp;
} 

function letornum2 (whose) {
  xmlHttp = GetXmlHttpObject();
  if (xmlHttp==null) {
    alert ("Browser does not support HTTP Request");
    return;
  }
  var url = "check.php?manner="+whose+"&value="+document.getElementById(whose).value;
  xmlHttp.onreadystatechange=stateChanged;
  xmlHttp.open("GET",url,true);
  xmlHttp.send(null);
}