<!--
// General.js - versie 29072002
// ----------------------------
// -- Algemeen ----------------
// getObj(name); object bepalen (los van welke browser); return objectpointer
// getParam(name); URL parameters opvragen; return parameterstring
// getDocumentName(); Documentnaam zonder extensie opvragen; return naamstring
// checkBrowser(); huidige browser opvragen; return browserstring
// findPosX(obj); X positie van object bepalen in pixels; return position 
// findPosY(obj); Y positie van object bepalen in pixels; return position
// -- Popup -------------------
// openWindow(winName,popupURL,features);
// closeWindow(winName);
// -- Button (image) ----------
// butOver(imgobj); rolloverplaatje activeren
// butOverOn(imgobj); rolloverplaatje activeren bij enabled button
// butOut(imgobj); rolloverplaatje deactiveren
// butOutOn(imgobj); rolloverplaatje deactiveren bij enabled button
// butOn(imgobj); button enabled activeren
// preLoadImg(imgobjs); voorladen niet meteen zichtbare plaatjes
// -- Navigatie-engine --------
// loadFrame(frame,ID); voor laden document in frame
// determineNavObj(ID, optNavMenu); Vertalen navigatie Item ID naar arrayobject; return objectpointer
// determineParentObj(ID); Vertalen navigatie Item ID naar parent-arrayobject; return objectpointer
// -- Servlet-engine --------
// callServlet(frame,servlet,param);
// closeApplication();
// ----------------------------

// -- Algemene functies -------
// Cross browser detect object
function getObj(name) {
	if (document.getElementById) return document.getElementById(name);
	else if (document.all) return document.all[name];
	else if (document.layers) return document.layers[name];
}
// Parameters van URL opvragen
function getParam(name) {
	var param = null;
	var tmpStr = new String(location.search);
	tmpStr = tmpStr.substring(1,tmpStr.length);		// ? weghalen
	var tmpArray = tmpStr.split('&');							// opsplitsen
	for (var i=0; i<tmpArray.length; i++) {
		tmpStr = tmpArray[i];
		if (tmpStr.search(name)!=-1)  param = tmpStr.slice(tmpStr.lastIndexOf('=')+1, tmpStr.length);
	}
	return param;
}
// Documentnaam zonder extensie opvragen
function getDocName(ins) {
	var tmpStr = new String(document.location.href);	
	var docName = tmpStr.slice(tmpStr.lastIndexOf('/')+1,tmpStr.lastIndexOf('.'));
	return docName;
}
// Check Browser routines
var browser='';
function checkBrowser() {
	if (browser=='') {
		var detect = navigator.userAgent.toLowerCase();
		var OS,browserversion,total,thestring;
		if (checkIt('konqueror'))
		{
			browser = "Konqueror";
			OS = "Linux";
		}
		else if (checkIt('omniweb')) browser = "OmniWeb"
		else if (checkIt('opera')) browser = "Opera"
		else if (checkIt('webtv')) browser = "WebTV";
		else if (checkIt('icab')) browser = "iCab"
		else if (checkIt('msie')) browser = "Internet Explorer"
		else if (!checkIt('compatible'))
		{
			browser = "Netscape Navigator"
			browserversion = detect.charAt(8);
		}
		else browser = "An unknown browser";
		if (!browserversion) browserversion = detect.charAt(place + thestring.length);
		if (!OS)
		{
			if (checkIt('linux')) OS = "Linux";
			else if (checkIt('x11')) OS = "Unix";
			else if (checkIt('mac')) OS = "Mac"
			else if (checkIt('win')) OS = "Windows"
			else OS = "an unknown operating system";
		}
	}
	return browser
}
function checkIt(string)
{
	place = detect.indexOf(string) + 1;
	thestring = string;
	return place;
}
// X positie van object bepalen
function findPosX(obj) {
	var curleft = 0;
	if (document.getElementById || document.all)	{
		while (obj.offsetParent) {
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (document.layers)
		curleft += obj.x;
	return curleft;
}
// Y positie van object bepalen
function findPosY(obj) {
	var curtop = 0;
	if (document.getElementById || document.all) {
		while (obj.offsetParent) {
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (document.layers)
		curtop += obj.y;
	return curtop;
}
// -------------------------------

// -- Popupwindow functies -------
// Open popupwindows
function openWindow(winName,popupURL,features) { 
  var posx=null;
  var posy=null;
	var theURL=null;
	var features=null;
	
	switch (winName) {
		case 'toets':
			if (top.gTestWin&&!top.gTestWin.closed) alert('Testwindow is already open... please use the taskbar to switch to the testwindow.');
		  else {
				var resx=792, resy=570;
				var posx=(screen.width-resx)/2;
				var posy=(screen.height-resy)/2;
				var winURL=window.location.hostname;
			  features  = 'status=yes,scrollbars=yes,resizable=yes,width='+resx+',height='+resy+',left='+posx+',top='+posy;
				top.gTestWin = window.open(popupURL+'/starttvisa'+top.gExt,'testvisiontest',features);
			}
			break;
		case 'presentatie':
		  closeWindow('child');
			var resx=800, resy=600;
			var posx=(screen.width-resx)/2;
			var posy=(screen.height-resy)/2;
			var winURL=window.location.hostname;
		  features  = 'status=no,scrollbars=no,resizable=no,width='+resx+',height='+resy+',left='+posx+',top='+posy;
			top.gChild = window.open(popupURL+'/teelenpresentation'+top.gExt,'teelenpresentation',features);
			break;			
		case 'afdrukken':
		  closeWindow('child');
			var resx=792, resy=570;
			var posx=(screen.width-resx)/2;
			var posy=(screen.height-resy)/2;
		  popupURL = popupURL+top.gExt;
		  features = features + 'status=yes,scrollbars=yes,resizable=yes,width='+resx+',height='+resy+',left='+posx+',top='+posy;
		  top.gChild = open(popupURL,winName,features);
			break;
		case 'zoeken':
		  closeWindow('child');
			var resx=792, resy=570;
			var posx=(screen.width-resx)/2;
			var posy=(screen.height-resy)/2;
		  features = features + 'status=yes,scrollbars=yes,resizable=yes,width='+resx+',height='+resy+',left='+posx+',top='+posy;
		  top.gChild = open(popupURL,winName,features);
			break;			
	}
}
// Voor sluiten popup window(s)
function closeChildWindow() {
  if (top.gChild != null)
    if (top.closed) top.gChild = null;
    else top.gChild.close();
}
function closeTestWindow() {
  if (top.gTestWin != null)
    if (top.gTestWin.closed) top.gTestWin = null;
    else top.gTestWin.close();
}
function closeWindow(winName) {
	switch (name) {
		case 'test' :
			closeTestWindow(); break;
		case 'child' :
			closeChildWindow(); break;
		default :
			closeChildWindow();
			closeTestWindow();			
	}
}
// -------------------------------

// Button (image) functions
function butOver(img) {
	var strTemp = new String(img.src);
  if (strTemp.search('_ghost')==-1 && strTemp.search('_on')==-1) img.src = strTemp.replace('.gif','_over.gif');
}
function butOverOn(img) {
	var strTemp = new String(img.src);
  if (strTemp.search('_ghost')==-1 && strTemp.search('_on')==-1) img.src = strTemp.replace('.gif','_over.gif');
  if (strTemp.search('_on')!=-1) img.src = strTemp.replace('_on.gif','_onover.gif');	
}
function butOut(img) {
	var strTemp = new String(img.src);
  if (strTemp.search('_ghost')==-1) { 
		if (strTemp.search('_over')!=-1) img.src = strTemp.replace('_over','');
		else img.src = strTemp.replace('_onover','_on');		
	}
}
function butOutOn(img) {
	var strTemp = new String(img.src);
  if (strTemp.search('_ghost')==-1 && strTemp.search('_on')==-1) img.src = strTemp.replace('_over','');
  else if (strTemp.search('_ghost')==-1) img.src = strTemp.replace('_on','');
}
function butOn(img) {
	var strTemp = new String(img.src);
  if (strTemp.search('_ghost')==-1) img.src = strTemp.replace('.gif','_on.gif');
}
// Voorladen van rollovers
function preloadImg() { 
	if (document.images) {
		if(!document.preArr) document.preArr = new Array();
		
    var i,j = document.preArr.length, a = preloadImg.arguments;
		for(i=0; i<a.length; i++) {
			if (a[i].indexOf("#")!=0) {
				document.preArr[j] = new Image;
				document.preArr[j++].src= a[i];
			}
		}
	}
}
// -------------------------------

// Navigatie-engine ondersteunende functies
// Laden van het contentframe
function loadFrame(frame,ID,param) {
		var newURL;
		var x = determineNavObj(ID);
		if (x) x.visited = true;			// Waar geweest bijwerken, als van toepassing

		if (param) newURL = ID+top.gExt+'?'+param;
		else newURL = ID+top.gExt;
		eval('parent.'+frame+'.location.href=newURL');
}
// Vertalen navigatie Item ID naar arrayobject
function determineNavObj(ID, optNavMenu) {
	var navMenu;

	if (optNavMenu) navMenu = optNavMenu;
	else navMenu = parent.leftfr.navMenu;				// standaardverwijzing in geval van 1 menu
	for (i=0; i<navMenu.length; i++) {
		if (navMenu[i].id==ID) return navMenu[i];
		for (j=0; j<navMenu[i].childs.length; j++) {
			if (navMenu[i].childs[j].id==ID) return navMenu[i].childs[j];
			for (k=0; k<navMenu[i].childs[j].childs.length; k++) {
				if (navMenu[i].childs[j].childs[k].id==ID) return navMenu[i].childs[j].childs[k];
			}
		}
	}
}
// Opsnorren parent object van navigatie-item
function determineParentObj(ID) {
	var navMenu = parent.leftfr.navMenu;
	var x=null;
	var y=null;
	for (i=0; i<navMenu.length; i++) {
		x=navMenu[i];
		for (j=0; j<navMenu[i].childs.length; j++) {
			if (navMenu[i].childs[j].id==pID) return x;
			y=x.childs[j];
			for (k=0; k<navMenu[i].childs[j].childs.length; k++) {
				if (navMenu[i].childs[j].childs[k].id==pID) return y;
			}
		}
	}
}
// -------------------------------

// Servlet-engine functies
// Voor het aanroepen van een servletCall
function callServlet(frame,servlet,param) {
	var newURL = top.servletPath+servlet;
	if (param) newURL = newURL+'?'+param;
	if (frame=='_blank') {
	  var closeChild = null;
		features = 'scrollbars=no,resizable=no,width=400,height=200';
	  closeChild = open(newURL,'blank',features);
	}
	else eval('parent.'+frame+'.location.href=newURL');
}
// Voor sluiten van de applicatie (waar men ook is)
// Het aanroepen closeWindows (voor evt. childwindows) is gekoppeld aan de window.onunload
function closeApplication()	{
	top.resetOnunload();
	closeWindow();
	if (top.server) {
		var tmpStr = new String(top.botfr.location.href);	// Pak een willekeurige URL van een willekeurig frame (niet top!)
		var newURL = tmpStr.slice(0,tmpStr.lastIndexOf('/')+1)+'servlet_logout'+top.gExt;	
		callServlet('_blank','servlet_logout','Redirect='+newURL);
// de loadFrame call werkt niet zo maar, vanwege de verkeerde context aanroep
// loadFrame('top','default');
// Er nu voor gekozen om het venster te sluiten. Eventueel kan dus ook teruggesprongen worden naar een loginpagina. Beide kan niet.
		top.close();
	}
	else top.close();
}
// -------------------------------
//-->

