
function openImageWindow(imageSrc,imageTitle)
{
    var l = Math.floor((screen.width)/2);
    var t = Math.floor((screen.height)/2);

_CONTENT="";
_CONTENT += "<HTML>\n";
_CONTENT += "<head>\n";
_CONTENT += "<title>"+imageTitle+"</title>\n";
_CONTENT += "<SCRIPT>\n";
_CONTENT += "var NS = (navigator.appName=='Netscape')?true:false;\n";
_CONTENT += "function fitPic() {\n";
_CONTENT += " iWidth = (NS)?window.innerWidth:document.body.clientWidth;\n";
_CONTENT += " iHeight = (NS)?window.innerHeight:document.body.clientHeight;\n";
_CONTENT += " iWidth = document.images[0].width - iWidth;\n";
_CONTENT += " iHeight = (document.images[0].height - iHeight)-12;\n";
_CONTENT += " window.resizeBy(iWidth, iHeight);\n";
_CONTENT += " self.focus(); }\n";

_CONTENT += "function replaceWindow() { \n"
_CONTENT += "w=document.images[0].width+25;\n";
_CONTENT += "h=document.images[0].height+25;\n";
_CONTENT += "window.moveTo( (screen.width - w) / 2, (screen.height - h) / 2); \n";
_CONTENT += "}\n"

_CONTENT+="</"+"SCRIPT>\n";
_CONTENT += "</head>\n";

//_CONTENT += "<BODY onLoad='setTimeout(\"fitPic();\", 250);' style='margin:0px;'>\n";
_CONTENT += "<BODY onLoad='fitPic();' style='margin:0px;'>\n";
_CONTENT += "<IMG SRC='" + imageSrc + "' border='0' style='cursor:hand;cursor:pointer;' onClick='window.close();' onLoad='replaceWindow();'> \n";
_CONTENT += "<SCRIPT>\n";
//_CONTENT += "setTimeout(\"replaceWindow()\", 500);\n";
_CONTENT += "</SCRIPT>\n";
_CONTENT += "</BODY>\n";
_CONTENT += "</HTML>\n";

  var _parms = 'directories=no,location=no,menubar=no,scrollbars=yes,status=no,toolbar=no,resizable=no,height=100,width=100'; //,top=' + t + ',left=' + l
  var _windowName = "PicViewer";
  
  myWindowHandle=window.open("",_windowName,_parms);
  myWindowHandle.document.open();
  myWindowHandle.document.write(_CONTENT);
  myWindowHandle.document.close();
  myWindowHandle.focus();
}

var timeoutID = false;

function setError(error)
{
	if (error != '')
	{
		if (timeoutID != false)
			clearTimeout(timeoutID);

		document.getElementById("error").innerHTML = "De volgende fouten zijn opgetreden:<br>\n " + error;
		document.getElementById("error").style.visibility= '';
		timeoutID = setTimeout("resetHTML('error')", 5000);
		return false;
	}
}

function resetHTML(obj_name) 
{
	document.getElementById(obj_name).innerHTML = "";
	document.getElementById(obj_name).style.visibility= 'hidden';
}

var firstEnterUname = true;
var firstEnterPasswd = true;

function beforeSubmit() {
  if (window.location.href.indexOf("?logOff=1") != -1)
    document.forms[0].action = "/index.php";
  
	if (isEmpty(document.getElementById('loginUsername')) || isEmpty(document.getElementById('loginPassword'))) {
		alert("Vul zowel gebruikersnaam als wachtwoord in.");
	  return false;
	}
  
  return true;
}

function isEmpty(aTextField) {
  if ((aTextField.value.length == 0) || (aTextField.value==null))
    return true;
  else 
    return false;
}	

function printLogOff(reloc) {
	window.location = reloc + '?logOff=1';
}

function onEnterUname(fieldObj) {
	if (firstEnterUname) {
		fieldObj.value = "";
		firstEnterUname = false;
	}
}

function onEnterPasswd(fieldObj) {
	if (firstEnterPasswd) {
		fieldObj.value = "";
		fieldObj.type = "password";
		firstEnterPasswd = false;
	}
}