
// -- 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];
}

// -------------------------------

// Button (image) functions
function isButOn(img) {
	var strTemp = new String(img.src);
	if (strTemp.search('_ghost')== -1 && strTemp.search('_on') != -1) return true;
	else return false;
}

function butToggle(img) {
  if ( isButOn(img) ) {butOutOn(img);}
	else { butOutOn(img); butOn(img);}
}

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');
}


// voor het plaatsen van popup-tekst in een overlibpopup
var activePopup = '';
function getPopup(popupName) {	//  voor overlib popup
	var strTemp = new String(popupName);
	//alert('popup= '+popupName);
	activePopup = strTemp.substring(1, strTemp.length);
	var x=getObj(popupName);
	return x.innerHTML;
}
function getPopupWidth(popupName) {	//  voor overlib popup
	var x=getObj(popupName);
	return x.style.width;
}
function getPopupCaption(popupName) {	//  voor overlib popup
	var x=getObj(popupName);
	return x.innerHTML;
}
function getPopupX(obj) {	//  voor het bepalen of een popup links of rechts van het i-knopje moet komen
	var posx;
	if (findPosX(obj) < document.body.clientWidth/2) posx = findPosX(obj);
	else posx = findPosX(obj)-parseInt(getPopupWidth('c'+obj.id))+27;
	return posx;
}
function refreshOverlibPos() {	// voor overlib popup
	var x = getObj('overDiv');
	var y = getObj(activePopup);
	if (x&&y) {
		if (activePopup.substring(0,1)!='i')	{	// niet bij i-popup, maar bij vb popup
			x.style.left = findPosX(y)-parseInt(getPopupWidth('c'+activePopup))+30;
			x.style.top =  findPosY(y)-10;
		}
		else {
			x.style.left = getPopupX(y);
			x.style.top =  findPosY(y)-9;
		}
	}
}

// -------------------------------
// Idem voor IFrame
function loadConIFrame(pFrame,pID,pParam) {
	// Waar geweest bijwerken
	var x = determineNavObj(pID);
	if (x) x.visited = true;

	var pURL = top.getPublicPathVar()+gContent+pID;
	if (pParam) pURL = pURL+gExt+'?'+pParam;
	else pURL = pURL+gExt;
	
	if (top.getServerVar()) eval('parent.parent.'+pFrame+'.location.href=top.getServletPathVar()+"RONVisitSubject?Subject='+pID+'&Redirect='+pURL+'&Module='+top.getModuleVar()+'"');
	else eval('parent.parent.'+pFrame+'.location.href=pURL');
}

//

var lastOverActive;
var lastOverVisited;
var lastID;

function showPopup(pCel)
{
	var y;
	var c;
	
	if ( lastID ) {
		if ( lastID != pCel.id ) {
			y = getObj(lastID)
			if ( y ) y.className = 'celselect';
		}
		else {
			y = getObj('divinhoud');
			y.innerHTML = "&nbsp;";
			lastID = null;
			lastOverActive = null;
			lastOverVisited = null;
			pCel.className = 'celselect';
			celOver(pCel);
			return;
		}
	}
	y = getObj('divinhoud');
	c = getObj('c' + pCel.id);
	if ( y && c) {
		y.innerHTML = c.innerHTML;
	}
	else if (y) y.innerHTML = "&nbsp;";
	pCel.className = 'celactive';
	lastOverActive = pCel;
	lastOverVisited = null;
	lastID = pCel.id;
}

function celOver(pCel)
{
	if (pCel.className == 'celactive') {
			lastOverActive = pCel;
			lastOverVisited = null;
	}
	else {
			pCel.className="celover";
	}
}
