/*
' **************************************************
' © VWA Software Development 2006
' Release: 1.01.0002
' Changed: Nov 30, 2006
' Author : Berco Wassink
' **************************************************
*/

buttonforw = new Image();
buttonforw.src = "../buttons/forwardoff.gif";
buttonforwon = new Image();
buttonforwon.src = "../buttons/forwardon.gif";
buttonback = new Image();
buttonback.src = "../buttons/backoff.gif";
buttonbackon = new Image();
buttonbackon.src = "../buttons/backon.gif";
buttontop = new Image();
buttontop.src = "../buttons/topoff.gif";
buttontopon = new Image();
buttontopon.src = "../buttons/topon.gif";
buttondown = new Image();
buttondown.src = "../buttons/backoff.gif";
buttondownon = new Image();
buttondownon.src = "../buttons/backon.gif";

function buttonrollon(name) {
	document[name].src = eval(name + 'on.src');
}
function buttonrolloff(name) {
	document[name].src = eval(name + '.src');
}

function buttonon(name) {
	buttonrollon(name);
}
function buttonoff(name) {
	buttonrolloff(name);
}

function OpenButton(sURL) {
	// Open de opgegeven knop
	var bOK = false;
	
	// Zoek knoppenframe op
	var oFrame = FindFrame('topframe');
	if (oFrame) {
		if (oFrame.frames['button']) {
			oFrame = oFrame.frames['button'];
			
			var iPos = sURL.indexOf('ButtonID=');
			if (iPos >= 0) {
				var iButtonID = sURL.substring(iPos + 9, sURL.length);
				iPos = iButtonID.indexOf('&');
				if (iPos < 0)
					iPos = iButtonID.indexOf('?');
				if (iPos < 0)
					iPos = iButtonID.indexOf('#');
				if (iPos >= 0)
					iButtonID = iButtonID.substring(0, iPos);
				bOK = oFrame.FindButton(iButtonID);
			}
		}
	}
	
	// Controleren of knop gevonden is (zo niet hele menu openen)
	if (bOK) {
		var oFrame = FindFrame('content');
		if (oFrame)
			oFrame.location.href = '../idx/content.asp?SiteID=' + iSiteID + '&' + sURL;
	} else
		OpenMenu(sURL);
}
function OpenMenu(sURL) {
	// Ga naar opgegeven menu
	var oFrame = FindFrame('topframe');
	if (oFrame)
		oFrame.location.href = '../main.asp?SiteID=' + iSiteID + '&' + sURL;
}
function GotoA(sURL) {
	// Spring naar juiste plek
	location.href = '#' + sURL;
}
function FindA() {
	var oFrame = this;
	var sURL = '', sPrefFrame = '';
	
	// Controleren of deze pagina al interne link heeft
	sURL = oFrame.location.href;
	if (sURL.indexOf('#') >= 0)
		return;
	
	// Alle hogere frames doorlopen op zoek naar interne link
	while (oFrame.parent.frames.length > 0) {
		// Frame instellen
		oFrame = oFrame.parent;
		
		// Frame naam controleren (hoogste frames zijn topframe of mainframe)
		if ((sPrefFrame == 'topframe') || (sPrefFrame == 'mainframe'))
			if ((oFrame.name != 'topframe') && (oFrame.name != 'mainframe'))
				return;
		
		// Controleren of interne link in URL staat (en daarbij deze knop bedoeld is) (kan foutmelding oplevereren indien ander domein)
		try{
		sURL = oFrame.location.href;
		}
		catch(err){}
		
		if ((sURL.indexOf('#') >= 0) && ((sURL.indexOf('?ButtonID=' + iButtonID) >= 0) || (sURL.indexOf('&ButtonID=' + iButtonID) >= 0))) {
			sURL = sURL.substr(sURL.indexOf('#'));
			GotoA(sURL);
			return;
		}
		
		// Controleren of hoofdframe bereikt is
		if (oFrame == top)
			return;
		
		// Frame naam onthouden
		sPrefFrame = oFrame.name;
	}
}
function OpenURL(sURL, bOpenInContent) {
	if (!bOpenInContent) {
		// Open de pagina in dit frame
		self.location.href = sURL;
	} else {
		// Open de pagina in content-frame
		var oFrame = FindFrame('content');
		if (oFrame)
			oFrame.location.href = sURL;
	}
}
function OpenDoc(sURL, iPopupWidth, iPopupHeight, iPopupType) {
	// Naar content dir verwijzen
	var sDir = '';
	if (!(typeof(sContentDir) == 'undefined') || (sContentDir == null))
		sDir = sContentDir;
	if (sDir.length == 0)
		sDir = '../content/';
	OpenExtern(sDir + sURL, iPopupWidth, iPopupHeight, iPopupType);
}
function OpenExtern(sURL, iPopupWidth, iPopupHeight, iPopupType) {
	// Open de pagina in popup venster
	if (!iPopupWidth)
		iPopupWidth = screen.availWidth * (2/3);
	if (!iPopupHeight)
		iPopupHeight = screen.availHeight * (2/3);
	if (!iPopupType)
		iPopupType = 0;
	
	// Juiste venstertype openen
	switch (iPopupType) {
	case -1: // Zelfde scherm
		document.location.href = sURL;
		break;
	case 1: // Normaal popup venster
		oWin = window.open(sURL, 'Popup', 'width=' + iPopupWidth + ',height=' + iPopupHeight + ',left=' + (screen.availWidth - iPopupWidth) / 2 + ',top=' + (screen.availHeight - iPopupHeight) / 2 + ',status=no,toolbar=no,menubar=no,location=no,resizable=no,scrollbars=yes');
		if (oWin)
			oWin.focus();
		break;
	case 2: // Modaal popup venster
		if (window.showModalDialog)
			oWin = window.showModalDialog(sURL, 'Popup', 'dialogWidth:' + iPopupWidth + 'px;dialogHeight:' + iPopupHeight + 'px;font-family:Verdana;font-size:12;status:no;scroll:no;center:yes;edge:raised;resizable:no;help:no;unadorned:yes;');
		else
			window.open(sURL, 'Popup', 'width=' + iPopupWidth + ',height=' + iPopupHeight + ',left=' + (screen.availWidth - iPopupWidth) / 2 + ',top=' + (screen.availHeight - iPopupHeight) / 2 + ',status=no,toolbar=no,menubar=no,location=no,resizable=no,scrollbars=no,modal=yes');
		break;
	default: // Normaal venster
		oWin = window.open(sURL, 'Popup', 'width=' + iPopupWidth + ',height=' + iPopupHeight + ',left=' + (screen.availWidth - iPopupWidth) / 2 + ',top=' + (screen.availHeight - iPopupHeight - 140) / 2 + ',status=yes,toolbar=yes,menubar=yes,location=yes,resizable=yes,scrollbars=yes');
		if (oWin)
			oWin.focus();
		break;
	}
}

function FindFrame(sFrame) {
	// Hoogste frame opzoeken (in MKO topframe / mainframe)
	var oFrame = FindParentFrame(this, sFrame);
	if ((oFrame) && ((oFrame.name == sFrame) || ((sFrame == 'topframe') && (oFrame.name == 'mainframe'))))
		return oFrame;
	else
		return false;
}
function FindParentFrame(oFrame, sFrame) {
	if ((oFrame.name == sFrame) || ((sFrame == 'topframe') && (oFrame.name == 'mainframe')))
		return oFrame;
	else if (oFrame == top)
		return oFrame;
	else if (oFrame.parent.frames.length > 0)
		return FindParentFrame(oFrame.parent, sFrame);
	return oFrame;
}