var DOM = (document.getElementById) ? true : false;
var IE  = (document.all) ? true : false;
var NS4 = (document.layers) ? true : false;

var helpwindow;     var childwindow;    var calendarwindow; var tmpPopup;				
var bDontCloseChildren = 0;
var bCloseOnFocus = 0;
var sWindowOnUnload = '';
var sWindowOnResize = '';

function getValueFromParamList(sParamList, sParamName, sSeparator)
{
	if (sSeparator == null) sSeparator = ',';
	iPos_Start = sParamList.indexOf(sParamName + '=');
	if (iPos_Start != -1) {
		iPos_End = sParamList.indexOf(sSeparator, iPos_Start);
		if (iPos_End == -1) iPos_End = sParamList.length;
		return sParamList.substring(iPos_Start + sParamName.length + 1, iPos_End);
	} else {
		return -1;
	}
}
function windowOpen(sUrl, sName, sOptions, bDontAutoClose, bDontFocus)
{
	iRequestedWidth =  parseInt(getValueFromParamList(sOptions, 'width'));
	iRequestedHeight = parseInt(getValueFromParamList(sOptions, 'height'));
	iRequestedLeft =   parseInt(getValueFromParamList(sOptions, 'left'));
	iRequestedTop =    parseInt(getValueFromParamList(sOptions, 'top'));

	if (!isNaN(iRequestedWidth))  iPopupWidth =  Math.min(iRequestedWidth, screen.availWidth);
	if (!isNaN(iRequestedHeight)) iPopupHeight = Math.min(iRequestedHeight, screen.availHeight);
	if (!isNaN(iRequestedLeft))   iPopupLeft =   Math.min(iRequestedLeft, screen.availWidth - iPopupWidth);
	if (!isNaN(iRequestedTop))    iPopupTop =    Math.min(iRequestedTop, screen.availHeight - iPopupHeight);

	if (!isNaN(iRequestedWidth) && iRequestedWidth != iPopupWidth)
		sOptions = setValueInParamList(sOptions, 'width', iPopupWidth);
	if (!isNaN(iRequestedHeight) && iRequestedHeight != iPopupHeight)
		sOptions = setValueInParamList(sOptions, 'height', iPopupHeight);
	if (!isNaN(iRequestedLeft) && iRequestedLeft != iPopupLeft)
		sOptions = setValueInParamList(sOptions, 'left', iPopupLeft);
	if (!isNaN(iRequestedTop) && iRequestedTop != iPopupTop)
		sOptions = setValueInParamList(sOptions, 'top', iPopupTop);

  tmpPopup = window.open(sUrl, sName, sOptions);
  if (!bDontFocus)
    setTimeout("try{tmpPopup.focus();} catch(e) {}", 10);
  else
    setTimeout("try{this.focus();} catch(e) {}", 10);
  if(!bDontAutoClose) {
		try {
	    if(typeof(sName) != 'undefined' && sName != '' && window.name != tmpPopup.name) 	      childwindow = tmpPopup;
    } catch (e) {
			childwindow = tmpPopup;
		}
  }
  return tmpPopup;
}
function parentFocus()
{
    try {
      window.opener.focus();
    } catch(e) {}
}
function windowClose()
{
  parentFocus();
  window.close();
}
function eventWindowOnUnload()
{
	if(!bDontCloseChildren)
	{
		if (typeof childwindow != 'undefined') {
			try { childwindow.close();		} catch(e) {}
		}
	  if (typeof calendarwindow != 'undefined') {
			try { calendarwindow.close();	} catch(e) {}
		}
	}
  eval(sWindowOnUnload);
}
function eventWindowOnFocus()
{
  if(bCloseOnFocus)
    window.close();
}
function eventWindowOnResize()
{
  eval(sWindowOnResize);
}
function windowPrint()
{
  window.print();
}
function eventWindowOnBeforePrint()
{
  try {
    document.getElementById('divPreviewHeader').style.display = 'none';
  } catch(e) {}
  try {
    document.getElementById('tableDebugPV').style.display = 'none';
  } catch(e) {}
}
function eventWindowOnAfterPrint()
{
  try {
    document.getElementById('divPreviewHeader').style.display = 'inline';
  } catch(e) {}
  try {
    document.getElementById('tableDebugPV').style.display = 'inline';
  } catch(e) {}
}
function openFlashPopUp(sFile, iWidth, iHeight) {
	windowOpen("/documentviewer.html?sDocName=pageFlash&variant=3&file=" + sFile, 'flash', "top=50,left=50,toolbar=0,height="+iHeight+",width="+iWidth+",resizable=1,scrollbars=0");
}

function EscapeQuote(sText)
{
	re = /'/g;
	return sText.replace(re, "\\'");
}
function AddSlashes(sText)
{
	re = /(['\\])/g;
	return sText.replace(re, "\\$1");
}
function Html2Asc(sText)
{
	re = /&nbsp;/gi;
	sText = sText.replace(re, " ");
	re = /&amp;/gi;
	sText = sText.replace(re, "\&");
	re = /&euro;/gi;
	sText = sText.replace(re, "€");
	return sText;
}
var sWindowOnLoad = '';

function openPopUp(sUrl, iWidth, iHeight, sTarget)
{
	if (typeof(sTarget)=="undefined")
		sTarget = "content";
	windowOpen(sUrl, sTarget, "top=50,left=50,toolbar=0,height="+ iHeight +",width="+iWidth+",resizable=1,scrollbars=1",false);
}
function setValueInParamList(sParamList, sParamName, sParamValue, sSeparator) {
	if (sSeparator == null) sSeparator = ',';
	iPos_Start = sParamList.indexOf(sParamName + '=');
	if (iPos_Start != -1) {
		iPos_End = sParamList.indexOf(sSeparator, iPos_Start);
		if (iPos_End == -1) iPos_End = sParamList.length;
		return sParamList.substring(0, iPos_Start) + sParamName + '=' + sParamValue + sParamList.substr(iPos_End);
	} else {
		return sParamList + ',' + sParamName + '=' + sParamValue;
	}
}
function windowOpenPrintPreview(sUrl)
{
  return(windowOpen(sUrl, 'PrintPreview','left=100,top=100,height=550,width=700,resizable=1,scrollbars=1'));
}
function windowOpenExportPreview(sUrl)
{
  return(windowOpen(sUrl, 'ExportPreview','top=20,left=20,height=200,width=300,resizable=1,menubar=1'));
}
function showProduct(ID) {
	windowOpen("/documentviewer.html?sDocName=pageProduct&cleanVersion=popup&uPopUp=1&ProdID="+ID, 'product', 'top=50,left=50,toolbar=0,height=410,width=700,resizable=1,scrollbars=1');
}

function windowRefresh(_bDontCloseChildren)
{
	bDontCloseChildren = _bDontCloseChildren;
	try {	window.document.location.reload(true);	}   // Javascript 1.3
	catch(e) { window.document.location.replace(window.document.location.href); }
}
function windowReplace(sUrl)
{
  window.document.location.replace(sUrl);
}
function eventWindowOnLoad()
{
	setTimeout("eventWindowOnLoad_();" ,0);
}
function eventWindowOnLoad_()
{
	if(typeof(dRenderStart) != "undefined")
  	sRenderDiff = DateDiffString(dRenderStart, new Date());

	if(typeof(bDebugMode) != "undefined" && bDebugMode)
		DebugPrint();

	oSpan = document.getElementById('debugOnloadTime');
	if(oSpan != null)
	{
		oSpan.innerHTML = TimeEval(sWindowOnLoad, '<i>Onload event</i>');
		setTimeout("DisplayTimingReport();", 5);
	}
	else
		eval(sWindowOnLoad);

	oSpan = document.getElementById('debugRenderTime');
	if(oSpan != null)
		oSpan.innerHTML = sRenderDiff;
}
function windowOnLoad(sJavascript)
{
  if (navigator.appName == "Netscape" && false) {
        if (document.body.attributes.onload)
      document.body.attributes.onload.value += ";" + sJavascript;
    else
      document.body.setAttribute("onload", sJavascript);
  } else {
        window.onload = function() { eventWindowOnLoad(); };
		if(typeof(bDebugMode) != "undefined" && bDebugMode)
  	  sWindowOnLoad += 'TimeEval("' + sJavascript + '", "' + sJavascript + '");';
		else
  	  sWindowOnLoad += 'eval("' + sJavascript + '");';
  }
}
function windowOnUnload(sJavascript)
{
  sWindowOnUnload += sJavascript;
}

function windowOnResize(sJavascript)
{
  sWindowOnResize += sJavascript;
}
function parentRefresh()
{
  try {
    window.opener.windowRefresh();
  } catch(e) {
	  try {
	    window.opener.location.reload(true);
	  } catch(e) {}
	}
}
function parentCall(sCmd)
{
    try {
      eval('window.opener.' + sCmd +';');
    } catch(e) {}
}
function Collapse(sID, bCollapse)
{
	var oCaption = document.getElementById(sID + "_caption");
	var oBody    = document.getElementById(sID + "_body");
	var bDoCollapse = (bCollapse || (bCollapse == null && oCaption.parentNode.parentNode.className == 'stUncollCaption'));
	if(bDoCollapse) {
		oCaption.parentNode.parentNode.className = 'stCollCaption';
		oBody.className    = 'stCollBody';
		eval("oCaption.innerHTML = " + sID + "_CollCaption;");
		eval("try {" + sID + "_OnCollapse();} catch(e) {};");
	} else {
		oCaption.parentNode.parentNode.className = 'stUncollCaption';
		oBody.className    = 'stUncollBody';
		eval("oCaption.innerHTML = " + sID + "_UncollCaption;");
		eval("try {" + sID + "_OnUncollapse();} catch(e) {};");
	}
}
function Collapse2(ID)
{
	var oDiv = document.getElementById(ID+"_body");
	oDiv.className = ((oDiv.className=="stUncollBody") ? "stCollBody" : "stUncollBody");
}
var sHilite_OldColor;
function Hilite(oObj, sColor)
{
  sHilite_OldColor = oObj.style.backgroundColor;
  if(sColor == null || sColor == '')
  {
    sColor = '#E1E4F0';
  }
  oObj.style.backgroundColor = sColor;
}

function Unhilite(oObj)
{
  oObj.style.backgroundColor = sHilite_OldColor;
}
function ClassHilite(oObj, sClass)
{
  sHilite_OldClass = oObj.className;
  if(sClass == null || sClass == '')
    sClass = 'stHighLight';
	if(oObj.className.indexOf(sClass) == -1)
  oObj.className += ' ' + sClass;
}
function ClassUnhilite(oObj, sClass)
{
  if(sClass == null || sClass == '')
    sClass = 'stHighLight';
  oObj.className = ltrim(rtrim(oObj.className.replace(sClass, '')));
}
function hideElements() {
 if (document.all) {
 	aObj = document.all.tags('SELECT');
  for (i = 0; i < aObj.length; i++){
   obj = aObj[i];
   if (!obj || !obj.offsetParent)
    continue;
   obj.style.visibility = 'hidden';
  }
 	aObj = document.all.tags('IFRAME');
  for (i = 0; i < aObj.length; i++){
   obj = aObj[i];
   if (!obj || !obj.offsetParent || (obj.id).substr(0, 3) == 'if_')
    continue;
   obj.style.visibility = 'hidden';
  }
 	aObj = document.all.tags('OBJECT');
  for (i = 0; i < aObj.length; i++){
   obj = aObj[i];
   if (!obj || !obj.offsetParent)
    continue;
   obj.style.visibility = 'hidden';
  }
 }
}
function showElements() {
 if (document.all) {
 	aObj = document.all.tags('SELECT');
  for (i = 0; i < aObj.length; i++) {
   obj = aObj[i];
   if (! obj || ! obj.offsetParent)
    continue;
   obj.style.visibility = '';
  }
 	aObj = document.all.tags('IFRAME');
  for (i = 0; i < aObj.length; i++) {
   obj = aObj[i];
   if (! obj || ! obj.offsetParent || (obj.id).substr(0, 3) == 'if_')
    continue;
   obj.style.visibility = '';
  }
 	aObj = document.all.tags('OBJECT');
  for (i = 0; i < aObj.length; i++) {
   obj = aObj[i];
   if (! obj || ! obj.offsetParent)
    continue;
   obj.style.visibility = '';
  }
 }
}
function DateDiffString(dStart, dEnd)
{
  var sDiff;
  var dDiff = new Date(dEnd.getTime() - dStart.getTime());
	var sMilliSec = parseInt((((dDiff.getMinutes() * 60) + dDiff.getSeconds()) * 1000) + dDiff.getMilliseconds()) + "";
	while(sMilliSec.length < 4) {
		sMilliSec = '0' + sMilliSec;
	}
	iLen = sMilliSec.length;

  sDiff = "" + sMilliSec.substring(0, iLen-3) + '.' + sMilliSec.substring(iLen-3) + ' sec.';
  return sDiff;
}

function FloatNL2US(sString)
{
  var sNewString = '';
  var len = sString.length;
  for(var i=0; i<len; i++)
  {
    if(sString.charAt(i) == '.')
      sNewString += '';
    else if(sString.charAt(i) == ',')
      sNewString += '.';
    else
      sNewString += sString.charAt(i);
  }
  return(sNewString);
}
function FloatUS2NL(sString, iDecimals)
{
	if ( typeof(sString) != "string")
	{
		sString = sString.toString();
	}
	var sNewString = '';
	var len = sString.length;
	var iAfterDecimal = -1;
	for(var i=0; i<len && iAfterDecimal<iDecimals; i++)
	{
		if(sString.charAt(i) == '.')
		{
			sNewString += ',';
			iAfterDecimal = 0;
		}
		else if(sString.charAt(i) == ',')
		{
			sNewString += '.';
		}
		else
		{
			sNewString += sString.charAt(i);
			if(iAfterDecimal>=0) iAfterDecimal++;
		}
	}
  if(iAfterDecimal == -1)
  {
    sNewString += ',';
    iAfterDecimal = 0;
  }
  for(; iAfterDecimal < iDecimals; iAfterDecimal++)
    sNewString += '0';

  return(sNewString);
}
function FloatUS(fVal, iDecimals)
{
	fVal = Round(fVal, iDecimals);
	sVal = fVal.toString();

	if(iDecimals > 0)
	{
		i = sVal.indexOf('.');
		if(i==-1)
		{
			sVal += '.';
			i = sVal.length;
		}

		i = sVal.length - i;
		for(j=i; j<iDecimals; j++)
		{
			sVal += '0';
		}
	}
  return(sVal);
}
function Round(fVal, iDecimals)
{
	iShift = Math.pow(10, iDecimals);
	return (Math.round(fVal*iShift) / iShift);
}
function WizNextOnEnter(evt)
{
	if (!evt) evt = window.event;
	eCode = evt.keyCode;
	switch (eCode) {
		case 13:  // Enter
			try {evt.stopPropagation()} catch (e) {evt.keyCode=0}
			WIZdoNext();
			break;
	}
}
function search_nextPage(sPageName, sURL, iLastIndex)
{
	eval('var iPageNr=parseInt('+sPageName+'_iPageNr);');
	eval('var sIndices='+sPageName+'_sIndices;');

	sPageIndex = (iPageNr+1) + '@' + iLastIndex;
	sRegEx = '/' + iPageNr + '@/';
	iPos = sIndices.search(sRegEx);
	if (iPos != -1)
		sIndices = sIndices.substr(0, iPos) + ':';
	else
		sIndices += ':';
	sIndices += sPageIndex;

	sURL += ((sURL.search(/\?/) == -1) ? "?" : "&");
	var sPagePar = sPageName+'_PageNr='+(iPageNr+1);
	var sIndPar = '&'+sPageName+'_Indices='+sIndices;
	var sSearchPar = '&'+sPageName+'_Search=2';

	document.location = sURL+sPagePar+sIndPar+sSearchPar;
}
function search_prevPage(sPageName, sURL)
{
	eval('var iPageNr=parseInt('+sPageName+'_iPageNr);');
	eval('var sIndices='+sPageName+'_sIndices;');

	sURL += ((sURL.search(/\?/) == -1) ? "?" : "&");
	var sPagePar = sPageName+'_PageNr='+(iPageNr-1);
	var sIndPar = '&'+sPageName+'_Indices='+sIndices;
	var sSearchPar = '&'+sPageName+'_Search=2';

	document.location = sURL+sPagePar+sIndPar+sSearchPar;
}

function trim(s) {
	return ltrim(rtrim(s));
}
function ltrim(s) {
	while (s.length > 0 && s.charAt(0) == ' ')
		s = s.substr(1, s.length);
	return s;
}
function rtrim(s) {
	while (s.length > 0 && s.charAt(s.length - 1) == ' ')
		s = s.substr(0, s.length - 1);
	return s;
}
function br2nl(s)
{
	re = /<\s*br\s*[\/]?>/ig;
	return s.replace(re, '\x0d\x0a');	}
function nl2br(s)
{
	re = /\n/g;
	return s.replace(re, '<br>');
}
function noPopUp(e)
{
	var message="Copyright '2010 - cText_SiteOwner'";

	if(e.button == 2) {
		alert(message);
		return false;
	}
}
function OpenFrameItem(url)
{
	var oFrm = document.frames["_main_"];
	var bUndef = false;

	if ( typeof(oFrm) == "undefined")
	{
		try {
			oFrm = window.parent.document.frames["_main_"];
			if ( typeof(oFrm) == "undefined")
			{
				bUndef = true;
			}
		} catch (e) {
			bUndef = true;
		}
	}
	if (bUndef)
	{
		document.location = url;
	}
	else
	{
		if ( url.search(/InFrame=/) != -1)
		{
			url = url.replace(/[\?&]InFrame=(\d)*/, "");
		}
		var sSep = ((url.indexOf("?") == -1) ? "?" : "&");

		oFrm.location = url + sSep + "InFrame=1";
	}
}

var aBgCol = new Array();
function SetBgColor(item, name, color)
{
	aBgCol[name] = item.style.backgroundColor;
	item.style.backgroundColor = color;
}
function ResetBgColor(item, name)
{
	item.style.backgroundColor = aBgCol[name];
}
function DateBefore(date1, date2)
{
	var aIndices = new Array(2, 1, 0, 3, 4);
	var aStart = GetDateArray(date1);
	var aEnd = GetDateArray(date2);

	for (i=0; i<aIndices.length; i++)
	{
		var idx = aIndices[i];
		if (aStart[idx] < aEnd[idx])
			return false;
		else if (aStart[idx] > aEnd[idx])
			return true;
	}
	return false;
}
function GetDateArray(sDate)
{
	var aDate = new Array(0,0,0,0,0,0);
	if (sDate == "")
		return aDate;

	if (sDate.indexOf(" ") == -1)
	{
		var aElms = new Array(sDate, "");
	}
	else
	{
		var aElms = sDate.split(" ");
		if (aElms.length == 0)
			return aDate;
	}

	var aTemp = aElms[0].split("-");
	for (i=0; i<aTemp.length; i++)
		aDate[i] = parseInt(aTemp[i], 10);
	aTemp = ((aElms[1].length > 0) ? aElms[1].split(":") : new Array());

	aDate[3] = ((aTemp.length > 0) ? parseInt(aTemp[0], 10) : 0);
	aDate[4] = ((aTemp.length > 1) ? parseInt(aTemp[1], 10) : 0);
	aDate[5] = ((aTemp.length > 2) ? parseInt(aTemp[2], 10) : 0);

	return aDate;
}

function preventEventBubble(oEvent) {
	sNavName = navigator.appName.toLowerCase();
	if (sNavName.indexOf('microsoft internet explorer') != -1) {
		// Case MSIE
		oEvent.cancelBubble = true;
	} else if (sNavName.indexOf('netscape') != -1) {
		// Case Mozilla/Netscape
		oEvent.preventBubble();
	}
}

function AddToURL(sVar, sURL)
{
	return sURL + ((sURL.indexOf('?')==-1) ? '?' : '&') + sVar;
}
var bFormChanged = 0;
var bIgnoreEnter = 0;

function SetBtnPressed(sFormName,iButton)
{
	try {
		var oFld = document.forms[sFormName].elements["iBtnPressed"];
		oFld.value = iButton;
	} catch (e) {}
}

function SetKeyHeld(sFormName, evt)
{
	if (!evt) evt = window.event;
	iKeys = 0;
	try {
		iKeys	= (evt["shiftKey"]	? 1 : 0)
					| (evt["ctrlKey"]	? 2 : 0)
					| (evt["altKey"] ? 4 : 0)
					;
		var oFld = document.forms[sFormName].elements['iKeyHeld'];
		oFld.value = iKeys;
	} catch (e) {
	}
}

function SubmitForm2(sFormName, bSkipChecks, evt)
{
	if (!evt) evt = window.event;
	SetKeyHeld(sFormName, evt);

  if(sFormName == '')
    sFormName = 'DefaultForm';
	if (typeof(bSkipChecks) == "undefined")
		bSkipChecks = false;

  eval('SubmitForm_'+sFormName+'(' + bSkipChecks + ');');
}

function FakeSubmitForm2(sFormName, evt)
{
	if (!evt) evt = window.event;
	SetKeyHeld(sFormName, evt);

  if(sFormName == '')
  {
    sFormName = 'DefaultForm';
  }

  var url = document.forms[sFormName].action;
  var num = document.forms[sFormName].elements.length;

  try {document.forms[sFormName].iSearch.value = 1;} catch(e) {}

    if (url.indexOf('#')==-1) {
    urlBeforeAnchor = url;
    urlAnchor = '';
  } else {
    urlBeforeAnchor = url.slice(0, url.indexOf('#'));
    urlAnchor = url.slice(url.indexOf('#'), url.length);
  }

  for(var i=0; i<num; i++)
  {
    with (document.forms[sFormName].elements[i])
    {
			//alert(name +' ( '+ type +' ) = '+ value);
      if(value != null &&
        value != '' &&
        name != 'Submitted' &&
        typeof document.forms[sFormName].elements[i] != 'submit' &&
        typeof document.forms[sFormName].elements[i] != 'reset')
      {
        sName  = name;
        sValue = value;
        if(type == 'checkbox' || type == 'radio')
        {
          if (!checked)	// Only submit value if it is checked
            continue;
        }
        else if(type == 'select-one') // Dropdown box
        {
          if(sValue == -1)
            continue;
        }
        else if(type == 'select-multiple') // select box
        {
          if(sName.indexOf('[]') == -1)
            continue;
          else
          {
            sName  = name.slice(0, -2);
            sValue = '';
            for(j=0; j<all.length; j++)
            {
              if(sValue != '')
                sValue += ',';
              sValue += all[j].value;
            }
          }
        }

        // Replace %-signs.
        sValue = sValue.replace(/%/g, "%25");
        // Replace &-signs.
        sValue = sValue.replace(/&/g, "%26");

        // Find this variable in the old url
        iPos = urlBeforeAnchor.indexOf('?' + sName + '=');
        if(iPos == -1)
        {
          iPos = urlBeforeAnchor.indexOf('&' + sName + '=');
        }

        // Remove this variable if it already existed in the old url
        if(iPos >= 0)
        {
          sLeft = urlBeforeAnchor.substring(0, iPos);
          sRest = urlBeforeAnchor.substring(iPos + sName.length + 2, urlBeforeAnchor.length);

          iPos = sRest.indexOf('&');
          if(iPos >= 0)
          {
            sRest = sRest.substring(iPos, sRest.length);
          }
          else
          {
            sRest = '';
          }

          urlBeforeAnchor = sLeft + sRest;
        }

        urlBeforeAnchor += (urlBeforeAnchor.indexOf('?')==-1) ? '?' : '&';
        urlBeforeAnchor += sName + '=' + sValue;
      }
    }
  }
  url = urlBeforeAnchor + urlAnchor;
  window.document.location = url;
}

function AutoCheckInput2(sFormName)
{
  eval("var missing=((typeof(AutoCheckMissing_"+sFormName+")=='undefined') ? '' : AutoCheckMissing_"+sFormName+"());");
  eval("var invalid=((typeof(AutoCheckInvalid_"+sFormName+")=='undefined') ? '' : AutoCheckInvalid_"+sFormName+"());");

  var error = new Array(2);
  error[0] = missing;
  error[1] = invalid;
  return(error);
};

function AutoConvertInput2(sFormName)
{
  var error = '';
  eval("try {if (typeof(AutoConvertInput_"+sFormName+")!='undefined') error=AutoConvertInput_"+sFormName+"();} catch(e) {error='error in AutoConvertInput()';}");
  return(error);
}

function SubmitOnEnter2(evt,sForm)
{
	if (!evt) evt = window.event;
	if(evt.keyCode == 13)
	{
		try { evt.keyCode=0; } catch (e) {}
		eval('DefaultButton_' + sForm + '(evt);');
		try { evt.stopPropagation(); } catch (e) { evt.cancelBubble=true; }
	}
}

function DecimalPoint()
{
  try {
	  if(event.keyCode == 44) // ,
	    event.keyCode = 46;   // .
	} catch (e) {}
}

function CharAllowed(sChar, sAllowed)
{
  return(sAllowed.indexOf(sChar) >= 0);
}

function PrintItem2(sFormName, iBtn, value)
{
  if(value == null)
    value = 1;
  document.forms[sFormName].action += '&PrintItem=' + value;
	SetBtnPressed(sFormName,iBtn);
  SubmitForm2(sFormName);
}

function CopyItem2(sFormName, iBtn, bSkipChecks, evt)
{
	document.forms[sFormName].action += '&CopyItem=1';
	document.forms[sFormName].elements['ID'].value='new';
	SetBtnPressed(sFormName,iBtn);
	SubmitForm2(sFormName,bSkipChecks,evt);
}

function DeleteItem2(sFormName, iBtn)
{
  if (confirm('Weet u zeker dat u dit item wilt verwijderen?')) {
		SetBtnPressed(sFormName,iBtn);
    with(document.forms[sFormName]) {
      action += '&DeleteItem=1';
      submit();
    }
  }
}

function ArchiveItem2(sFormName,iBtn, evt)
{
  if (confirm('Weet u zeker dat u dit item naar het archief wilt verplaatsen?\\nVeranderingen die niet zijn opgeslagen zullen verloren gaan.'))
  {
		SetBtnPressed(sFormName,iBtn);
    with(document.forms[sFormName]) {
      action += '&ArchiveItem=1';
      submit();
    }
  }
}

function Search2(sFormName, iBtn, bSkipChecks, evt)
{
	var sep = ((document.forms[sFormName].action.search(/\?/) == -1) ? "?" : "&");
	document.forms[sFormName].action += sep + "search=1";
	SetBtnPressed(sFormName,iBtn);
	SubmitForm2(sFormName,bSkipChecks,evt);
}

function CloseForm2(bParentRefresh)
{
  var allowClose=true;
  try { allowClose = AllowClose(); }
  catch(e) {}

	if(allowClose) {
  	if (typeof(bParentRefresh)!='undefined' && bParentRefresh)
			parentRefresh();
		self.close(); // Child window is automatically closed.
	}
}
function DoneForm2()
{
	var allowDone=true;
	try {allowDone=AllowDone();} catch(e) {}
	if(allowDone)
		window.history.go(-1);
}
function CancelForm2()
{
	if(window.opener == null)
		window.history.go(-1);
	else
		windowClose();
}
function mailPassword2(sFormName,iBtn, evt) {
	var sep = ((document.forms[sFormName].action.search(/\?/) == -1) ? "?" : "&");
	document.forms[sFormName].action += sep + "mailPwd=1";
	SetBtnPressed(sFormName,iBtn);
	SubmitForm2(sFormName,false,evt);
}
function MailInfo2(sFormName,iBtn, evt) {
	var sep = ((document.forms[sFormName].action.search(/\?/) == -1) ? "?" : "&");
	document.forms[sFormName].action += sep + "mailInfo=1";
	SetBtnPressed(sFormName,iBtn);
	SubmitForm2(sFormName,false,evt);
}
function login2(sFormName,iBtn, evt) {
	var sep = ((document.forms[sFormName].action.search(/\?/) == -1) ? "?" : "&");
	document.forms[sFormName].action += sep + "login=1";
	SetBtnPressed(sFormName,iBtn);
	SubmitForm2(sFormName,false,evt);
}
function datePopup(sObjectID, bShowTime) {
	sURL  = '/calendar/calendar.html?sObjectID=' + sObjectID;
	sURL += '&selectedDate=' + escape((document.getElementById(sObjectID)).value);
  iHeight = 184;
  if(bShowTime)
  {
    sURL += '&bShowTime=1';
    iHeight += 25;
  }
	calendarwindow = windowOpen(sURL, 'datePopup', 'height=' + iHeight + ', width=208, left=400, top=300', true);
	return;
}

function returnDate(sControlID, sFullDate) {
	oDateField = document.getElementById(sControlID);
	if (sFullDate == -1) {
		// do nothing... 'cancel' pressed
	} else if (sFullDate == -2) {
		// Use no date
		oDateField.value = '';
	} else {
		// fill text field with the selected date
		oDateField.value = sFullDate;
	}

  // Call the correct OnBlur event, if it exists.
  try { this.eval(sControlID + '_OnBlur()'); }
  catch(e) {}

  // Call the correct OnChange event, if it exists.
  try { this.eval(sControlID + '_OnChange()'); }
  catch(e) {}

	return;
}

function RemoveFile(FileID, Title)
{
  if (confirm('Weet u zeker dat u dit bestand wilt verwijderen?\\n\\n' + Title))
  {
    with(document.forms['DefaultForm'])
    {
      action += '&RemoveID=' + FileID + '&RemoveTitle=' + Title;
      submit();
    }
  }
}

function AddFile(FileID, Title)
{
  if (confirm('Weet u zeker dat u dit bestand wilt toevoegen?\\n\\n' + Title))
  {
    with(document.forms['DefaultForm'])
    {
      action += '&AddID=' + FileID + '&AddTitle=' + Title;
      submit();
    }
  }
}

function OnKeyPress2(evt, sForm, iAction, sExtra)
{
	if (!evt) evt = window.event;
  if(iAction & 2 )
    DecimalPoint();

	if(bIgnoreEnter)
		bIgnoreEnter = false;
	else if(iAction & 1 )
	  if (SubmitOnEnter2(evt, sForm))

  if(iAction & 4 )
  {
	  try {
	    sChar = String.fromCharCode(evt.keyCode);
	    if(!CharAllowed(sChar, sExtra)) {
				try { evt.stopPropagation(); } catch (e) {evt.keyCode=0;}
			}
		} catch (e) {}
  }
}
function DblSelectMove(sForm,sFrom,sTo)
{
	eval("var oFrom=document.forms[sForm].elements[\""+sFrom+"\"];");
	eval("var oTo=document.forms[sForm].elements[\""+sTo+"\"];");
	for(nFrom=(oFrom.options.length-1);nFrom>=0;nFrom--) {
		if (oFrom.options[nFrom].selected) {
			var oOpt=oFrom.options[nFrom];
			oFrom.options[nFrom] = null;
			oTo.options[oTo.options.length]=oOpt;
		}
	}
}
function GetSelection(sForm, sSelect)
{
	var oOpt = document.forms[sForm].elements[sSelect].options;
	var aRes = new Array();

	for(var i=0; i < oOpt.length; i++)
	{
    if (oOpt[i].selected)
			aRes.push( oOpt[i].value );
	}
	return aRes;
}
function SelectAll(obj)
{
  for(i=0; i < obj.length; i++)
  {
    obj[i].selected = true;
  }
}

function setTimeNow(sID)
{
	var oSel=document.getElementById(sID);
	var oNow = new Date();
	if (oSel)
		oSel.value= oNow.getHours()+':'+oNow.getMinutes()+':'+oNow.getSeconds();
}

function SetStayHere(bVal)
{
	document.getElementById('bStayHere').value = bVal;
}
function SelAllListItems(sFormName, sElmentName)
{
	var oList = document.forms[sFormName].elements[sElmentName];
	SelectAll(oList.options);
}

function AddListItem(sForm, sElmentName, mID, sText)
{
	var oList = document.forms[sForm].elements[sElmentName];
	for (var i=0; i<oList.length; i++) {
		if (oList.options[i].value==mID)
			return false;
	}
	var oOpt = document.createElement("OPTION");
	oOpt.value = mID;
	oOpt.text = sText;
  oList.options.add(oOpt, i);
}
function DelSelListItems(sForm, sElmentName)
{
	var oList = document.forms[sForm].elements[sElmentName];
	for (var i=0; i<oList.length; i++) {
		if (oList.options[i].selected)
			oList.remove(i);
	}
}
function ChangeFormButton(oBtn, oNew)
{
	try {
		oBtn.src = oNew.src;
	} catch (e) {
	}
}

function CheckMissing(iType,sFormName,sFieldName) {
	var oElm = document.forms[sFormName].elements[sFieldName];
	var bRes;
	try {
		switch (iType) {
			case 1:
				bRes=(oElm.value == '');
				break;
			case 2:
				bRes=(oElm.selectedIndex==-1 || oElm.options[oElm.selectedIndex].value=='');
				break;
			case 3:
				bRes = (!oElm.length>0);
				break;
			case 4:
				bRes = true;
				for (var i=0; i<oElm.options.length; i++) {
					if (oElm.options[i].selected) {
						bRes = false;
						break;
					}
				}
				break;
			case 5:
				if (!ReadHTML(GetEditorID(sFieldName))) return false;
				bRes = (oElm.value == '');
				break;
			case 7:
				bRes = !(oElm.checked);
				break;
		}
	}
	catch (e) {
		bRes=false;
	}
	return bRes;
}
function AutoConvert(iType,sFormName,sFieldName) {
	var oElm = document.forms[sFormName].elements[sFieldName];

	try {
		oElm.value = trim(oElm.value);
		switch (iType) {
			case 1:
				if (oElm.value != '') {
					var aDates = oElm.value.split('-');
					oElm.value = aDates[2] + '-' + aDates[1] + '-' + aDates[0];
				}
				break;

			case 2:
			case 3:
				if (oElm.value != '') {
					var aElms = oElm.value.split(' ');
					var aDates = aElms[0].split('-');
					oElm.value = aDates[2] + '-' + aDates[1] + '-' + aDates[0];
					if(aElms.length > 1) {
						if(aElms[1].length > 0) {
							sTime = aElms[1];
						}
					}
					var aTimes = sTime.split(':');
					oElm.value += ' ' + aTimes[0] + ':' + aTimes[1];
					if (iType == 3)
						oElm.value += ':' + aTimes[2];
				}
				break;

			case 4:
				if (oElm.value != '') {
					var aDates = oElm.value.split('-');
					oElm.value = aDates[2] + '-' + aDates[1] + '-' + aDates[0];
				}
				break;

			case 5:
				if (oElm.value.length == 6)
					oElm.value = oElm.value.substr(0, 4) + ' ' + oElm.value.substr(4, 2);
				break;

			/*
			case 7:
				var sCountryName	= document.forms[sFormName].elements[sFieldName+"_Country"];
				var sAreaName			= document.forms[sFormName].elements[sFieldName+"_Area"];
				var sPhoneName		= document.forms[sFormName].elements[sFieldName+"_Number"];

				oElm.value = '';

			 	sCountryName.value = sCountryName.value.replace(/ /g, '');
				if (sCountryName.value != '')
					oElm.value += sCountryName.value
			 	sAreaName.value = sAreaName.value.replace(/ /g, '');
				if (sAreaName.value != '') {
					if (oElm.value != '')
						oElm.value += ' ';
					oElm.value += sAreaName.value;
				}
			 	sPhoneName.value = sPhoneName.value.replace(/ /g, '');
				if (sPhoneName.value != '') {
					if (oElm.value != '')
						oElm.value += ' ';
					oElm.value += sPhoneName.value;
				}
				break;
			*/
		} // switch (iType)
	}
	catch (e) {}
	return '';
}
function Combo_onkeydown(sName)
{
	eval('Combo_KeyCode_' + sName + '=' + event.keyCode);
	Combo_BoxVis = eval('Combo_BoxVis_' + sName);
	if(Combo_BoxVis)
	{
		switch(event.keyCode)
		{
			case 13:	// Enter
				bIgnoreEnter = true;
				break;
			case 27:	// Esc
				event.keyCode = 0;
				break;
		}
	}
}

function Combo_onkeyup(sName, bShowAll)
{
	var Combo_KeyCode		= eval('Combo_KeyCode_' + sName);
	var Combo_Captions	= eval('Combo_Captions_' + sName);
	var Combo_IDs				= eval('Combo_IDs_' + sName);
	var Combo_Text			= eval('Combo_Text_' + sName);
	var Combo_SelectID	= eval('Combo_SelectID_' + sName);
	var Combo_BoxVis		= eval('Combo_BoxVis_' + sName);

	oCombo	= document.getElementById(sName + '_combo');
	oTxt		= document.getElementById(sName + '_Text');
	oBox		= document.getElementById(sName + '_box');
	oID			= document.getElementById(sName);

	if(Combo_KeyCode == 0)
		return;

	var iMatch = -1;
	var iHilite = 'x';
	var aMatches = [];

	if(Combo_KeyCode == 27 && Combo_BoxVis)
		oTxt.value = Combo_Text;
	else if(Combo_Text != oTxt.value)
	{
		oID.value = '';
		eval('Combo_Text_' + sName + '=\'' + AddSlashes(oTxt.value) + '\'');
	}

	oBox.style.width = '' + (oCombo.offsetWidth) + 'px';
	oBox.style.marginTop = '' + (oCombo.offsetHeight + 3) + 'px';
	oBox.style.display='inline';
	var sSearch = oTxt.value;
	sSearch = sSearch.toUpperCase();
	iLen = sSearch.length;
	for(i=0; i < Combo_Captions.length; i++)
	{
		sItem = Combo_Captions[i].substring(0, iLen);
		sItem = sItem.toUpperCase();
		if(bShowAll || sItem == sSearch)
		{
			if(Combo_IDs[i] == Combo_SelectID)
			{
				iMatch = i;
				iHilite = aMatches.length;
			}
			aMatches.push(i);
		}
	}

	switch(Combo_KeyCode)
	{
		case 13:	// Enter
			if(Combo_BoxVis && iMatch >= 0)
			{
				Combo_select(sName, Combo_IDs[iMatch]);
				aMatches = [];
				iMatch = -1;
			}
			break;
		case 27:	// Esc
			aMatches = [];
			iMatch = -1;
			break;
		case 38:	// up
			if(iHilite != 'x') iHilite--;
			break;
		case 40:	// down
			if(iHilite != 'x') iHilite++;
			break;
		default:
			Combo_SelectID = '';
	}
	var sList="";
	if(aMatches.length > 0)
	{
		if(iHilite == "x")
			iHilite = 0;
		else if(iHilite < 0)
			iHilite = aMatches.length - 1;
		else if(iHilite >= aMatches.length)
			iHilite = 0;
		sList += '<table width="100%" border="0">';
		for(i=0; i < aMatches.length; i++)
		{
			sTrClass = "stClickable";
			sID = "trCombo_"+ sName +"_"+ i;
			if(i == iHilite)
			{
				Combo_SelectID = Combo_IDs[aMatches[i]];
				sTrClass += " stHighLight";
				sID_HiLited = sID;
			}
			sList += '<tr id="'+ sID +'" class="'+ sTrClass + '" onclick="Combo_select(\''+sName+"', '"+ Combo_IDs[aMatches[i]] +'\', 1);"'+ sID +' onmouseover="ClassHilite(this);" onmouseout="ClassUnhilite(this);"><td nowrap>' + Combo_Captions[aMatches[i]] + '&nbsp;</td></tr>';
		}
	}

	eval("Combo_SelectID_"+ sName +"='" + Combo_SelectID + "';");
	if(sList != '' && (!(oTxt.value == '' && Combo_BoxVis == 0) || Combo_KeyCode == -1 || Combo_KeyCode == 40))
	{
		sList += '</table>';
		oBox.style.height = ((aMatches.length > 15) ? '300px' : '');
		oBox.innerHTML = sList;
		Combo_visible(sName, 1);
	}
	else
		Combo_visible(sName, 0);
}

function Combo_onblur(sName)
{
	Combo_KeyCode = eval('Combo_KeyCode_' + sName);
	if(Combo_KeyCode == 9)	// Tab key
	{
		Combo_BoxVis = eval('Combo_BoxVis_' + sName);
		if(Combo_BoxVis )
		{
			Combo_select(sName, eval('Combo_SelectID_' + sName));
		}
		else
		{
			Combo_disable(sName, true);
		}
	}
	eval('Combo_KeyCode_' + sName + '=' + 0);
}

function Combo_visible(sName, iVisible)
{
	oBox = document.getElementById(sName + '_box');
	if(iVisible)
		oBox.style.visibility='visible';
	else
		oBox.style.visibility='hidden';
	eval('Combo_BoxVis_' + sName + '=' + iVisible);
}
function Combo_onDropDown(sName)
{
	eval('Combo_KeyCode_' + sName + '=' + -1);
	Combo_BoxVis = eval('Combo_BoxVis_' + sName);

	if(Combo_BoxVis)
		Combo_visible(sName, 0);
	else
		Combo_onkeyup(sName, 1);
}

function Combo_select(sName, ID, bFocus)
{
	var Combo_Captions = eval('Combo_Captions_' + sName);
	var Combo_IDs = eval('Combo_IDs_' + sName);
	var iIdx = -1;
	for(var i=0; i<Combo_IDs.length; i++)
		if(Combo_IDs[i] == ID)
		{
			iIdx = i;
			break;
		}

	if(iIdx >= 0)
	{
		oTxt = document.getElementById(sName + '_Text');
		oBox = document.getElementById(sName + '_box');
		oID = document.getElementById(sName);
		oTxt.value = Html2Asc(Combo_Captions[iIdx]);
		oID.value = Combo_IDs[iIdx];
		eval("Combo_SelectID_"+ sName + "=oID.value;");
		eval('Combo_Text_' + sName + '=\'' + AddSlashes(oTxt.value) + '\'');
		Combo_visible(sName, 0);
		try { eval('Combo_' + sName + '_onSelect(' + oID.value +', \''+ AddSlashes(oTxt.value) +'\');'); } catch(e) {} // generate onselect event
		Combo_disable(sName, false);
		if(bFocus) oTxt.focus();
	}
	else
	{
		Combo_disable(sName, true);
	}
}
function Combo_disable(sName, bDisabled)
{
	var oImg = document.getElementById(sName+"_adic");
	oImg.src = "/images/form/" + (bDisabled ? "admin_tiny_dis.gif" : "admin_tiny.gif");
}
function ComboEnabled(sName)
{
	var oImg = document.getElementById(sName+"_adic");
	return (oImg.src.match("admin_tiny.gif")!=null);
}
function UpdateComboBoxValue(cmbID, valID, newVal)
{
	var oSel = document.getElementById(cmbID);
	if ( oSel.value == valID)
	{
		var oTxt = document.getElementById(cmbID+"_Text");
		oTxt.value = newVal;

		eval("Combo_Text_" + cmbID + "=newVal;");
	}

	eval("var aIDs = Combo_IDs_" + cmbID + ";");
	for (var i=0; i<aIDs.length; i++)
	{
		if (aIDs[i] == valID)
		{
			eval("var aCapt = Combo_Captions_" + cmbID +"[i] = newVal;");
		}
	}
}
function DeleteComboBoxValue(cmbID, valID)
{
	var oSel = document.getElementById(cmbID);
	if ( oSel.value == valID)
	{
		var oTxt = document.getElementById(cmbID+"_Text");
		oTxt.value = "";

		eval("Combo_Text_" + cmbID + "='';");
	}

	eval("var aIDs = Combo_IDs_" + cmbID + ";");
	eval("var aCapt = Combo_Captions_" + cmbID +";");

	for (var i=0; i<aIDs.length; i++)
	{
		if (aIDs[i] == valID)
		{
			aIDs.splice(i, 1);
			aCapt.splice(i, 1);
		}
	}
}
function CheckInvalid(iType,sFormName,sFieldName)
{
	var oElm = document.forms[sFormName].elements[sFieldName];
	var bRes;

	try
	{
		switch (iType)
		{
			case 1:
				if (oElm.value.replace(/[\d\-]/g, '') != '')
					return 'Een datum veld bestaat uit nummers, gescheiden door het min teken.';
				else if (oElm.value != '') {
					var aDates = oElm.value.split('-');
					if (aDates.length < 3)
						return 'Er is geen geldige datum ingevuld.';
					else {
						var oDate = new Date((aDates[2].valueOf()),(aDates[1].valueOf()) - 1, (aDates[0].valueOf()));
						if(oDate.getDate()!=aDates[0] || (oDate.getMonth()+1)!=aDates[1] || oDate.getFullYear()!=aDates[2])
							return 'De ingevoerde datum bestaat niet.';
					}
				}
				break;

			case 2:
				if (oElm.value.replace(/[\d \-:]/g, "") != "")
					return "Het datum veld is niet juist ingevoerd.";
				else if (value != '')
				{
					var aElms = oElm.value.split(' ');
					var aDates = aElms[0].split('-');
					if(aElms.length > 1)
						sTime = (aElms[1].length > 0) ? aElms[1] : '';	// '' was $sDefaultTime
					else
						sTime = '';	// '' was $sDefaultTime
					var aTimes = sTime.split(':');
					if (aDates.length<3 || aTimes.length < 2) {
						return 'Er is geen geldige datum ingevuld.';
					}
					else
					{
						var oDate = new Date(aDates[2].valueOf(),aDates[1].valueOf()-1, aDates[0].valueOf(), aTimes[0].valueOf(), aTimes[1].valueOf());
						if(oDate.getDate()!=aDates[0] || (oDate.getMonth()+1)!=aDates[1] || oDate.getFullYear()!=aDates[2] || oDate.getHours()!=aTimes[0] || oDate.getMinutes()!=aTimes[1])
							return 'De ingevoerde datum bestaat niet.';
					}
				}
				break;

			case 3:
				if (oElm.value.replace(/[\d \-:]/g, '') != '')
					return 'Het datum veld is niet juist ingevoerd.';
				else if (value != '') {
					var aElms = oElm.value.split(' ');
					var aDates = aElms[0].split('-');
					if(aElms.length > 1)
						sTime = (aElms[1].length > 0) ? aElms[1] : '';	// '' was $sDefaultTime
					else
						sTime = '';	// '' was $sDefaultTime
					var aTimes = sTime.split(':');
					if (aDates.length<3 || aTimes.length < 2)
						return 'Er is geen geldige datum ingevuld.';
					else {
						var oDate = new Date(aDates[2].valueOf(),aDates[1].valueOf()-1, aDates[0].valueOf(), aTimes[0].valueOf(), aTimes[1].valueOf(), aTimes[2].valueOf());
						if(oDate.getDate()!=aDates[0] || (oDate.getMonth()+1)!=aDates[1] || oDate.getFullYear()!=aDates[2] || oDate.getHours()!=aTimes[0] || oDate.getMinutes()!=aTimes[1] || oDate.getSeconds()!=aTimes[2])
							return 'De ingevoerde datum bestaat niet.';
					}
				}
				break;

			case 4:
				if (value.replace(/[\d:]/g, '') != '')
					return 'Een tijd veld bestaat uit nummers, gescheiden door het : teken.';
				else if (value != '') {
					var aDates = value.split(':');
					if (aDates.length < 3)
						return 'Er is geen geldige tijd ingevuld.';
					else {
						var oDate = new Date(0,0,0,aDates[0].valueOf(),aDates[1].valueOf(),aDates[2].valueOf());
						if(oDate.getSeconds()!=aDates[2] || (oDate.getMinutes())!=aDates[1] || oDate.getHours()!=aDates[0])
							return 'De ingevoerde tijd bestaat niet.';
					}
				}
				break;

			case 5:
				if (oElm.value == '') return '';

				m = (oElm.value).match(/^[ ]*[0-9]{4}[ ]?[A-Za-z]{2}[ ]*$/);
				if (m == null || oElm.value != m[0])
					return 'Er is geen geldige postcode ingevuld.';
				break;

			case 6:
				if(oElm.value.match(/^[ ]*[\+\&\.\-\w]+@[\.\-\w]+\.\w{2,4}[ ]*$/)==null && oElm.value!='') {
					return 'Er is geen geldig email-adres ingevuld.';
				}
				break;

			case 7:
				var sCountryName	= sFieldName+'_Country';
				var sAreaName			= sFieldName+'_Area';
				var sPhoneName		= sFieldName+'_Number';
				var sArea					= '';
				var sNumber				= '';
				var sInvalidChar	= '';

				sInvalidChar += sCountryName.value.replace(/[\d\(\) ]/g, '');
				sInvalidChar += sAreaName.value.replace(/[\d\(\) ]/g, '');
				sInvalidChar += sPhoneName.value.replace(/[\d\(\) ]/g, '');
				if (sInvalidChar != '')
					return 'Er zijn ongeldige tekens ingevoerd: ' + sInvalidChar;

			 	if (sCountryName.value.search(/\-/) != -1)
			 		return 'Het landnummer mag alleen nummers bevatten.';
			 	else if ( isNaN(sCountryName.value) )
			 		return 'Het landnummer mag alleen nummers bevatten.';

			 	sArea = sAreaName.value.replace(/\(/, '');
			 	sArea = sArea.replace(/\)/, '');
			 	if ( sArea.search(/\-/) != -1)
			 		return 'Het netnummer mag alleen nummers en ronde haakjes bevatten.';
			 	else if ( isNaN(sArea) )
			 		return 'Het netnummer mag alleen nummers en ronde haakjes bevatten.';

			 	sNumber = sPhoneName.value.replace(/ /g, '');
			 	if ( sNumber.search(/\-/) != -1)
			 		return 'Het abboneenummer mag alleen nummers en spaties bevatten.';
			 	else if ( isNaN(sNumber) )
			 		return 'Het abboneenummer mag alleen nummers en spaties bevatten.';

			 	if (sCountryName.value!='' && (sArea=='' || sNumber==''))
			 		return 'Als u een landnummer invult, moet u ook een net- en abbonneenummer invullen.';
				break;
		}
	}
	catch (e) {}
	return '';
}
var bInitialised = 0;
var c_firstTab = 0;
var aTabIndices = new Array();
var aCurTabIndex = new Array();
var aLastTab = new Array();
var aImg = new Array();

var DOM = (document.getElementById) ? true : false;
var IE  = (document.all) ? true : false;
var NS4 = (document.layers) ? true : false;

function initTab(sTabName, aIndices, iCurIdx, iTabLast, aImages)
{
	aTabIndices[sTabName] = aIndices;
	aCurTabIndex[sTabName] = ((typeof(iCurIdx)=="undefined") ? 0 : iCurIdx);
	aLastTab[sTabName] = iTabLast;
	aImg[sTabName] = aImages;

	bInitialised = 1;
}

function setTabVisible(sTabName, iIdx, bVisible)
{
	var oTab = document.getElementById('tabHandle_'+sTabName+'_'+iIdx);
	var oImg = document.getElementById('tabHandleImg_'+sTabName+'_'+iIdx);

	if (bVisible) {
		oTab.style.display='inline';
		oImg.style.display='inline';
	} else {
		oTab.style.display='none';
		oImg.style.display='none';
	}
}
function getTabVisible(sTabName, iIdx)
{
	eval('var sID = aTabIndices_'+sTabName+'[iIdx];');
	var oTab = window.document.getElementById(sID);
	return(oTab.style.display!='none');
}

function changeImage(oImg, sNewSrc)
{
	if(typeof(oImg) == "undefined")
		return;

	oImg.src = sNewSrc;
	oImg.style.visibility = "visible";
	oImg.style.display = "none";

	oImg.style.visibility = "visible";
	oImg.style.display = "block";
}

function tabClick(sTabName, iTabIndex_clicked)
{
	if (!bInitialised)
		return false;

	if (DOM) {
		var oTab = window.document.getElementById(aTabIndices[sTabName][iTabIndex_clicked]);
		var oCurTab = window.document.getElementById(aTabIndices[sTabName][aCurTabIndex[sTabName]]);
		var oTd = window.document.getElementById("tabHandle_"+ sTabName + "_" + aCurTabIndex[sTabName]);
	} else if (IE) {
		var oTab = window.document.all(aTabIndices[sTabName][iTabIndex_clicked]);
		var oCurTab = window.document.all(aTabIndices[sTabName][aCurTabIndex[sTabName]]);
		var oTd = window.document.all("tabHandle_"+ sTabName +"_" + aCurTabIndex[sTabName]);
	} else {
		var oTab = eval('window.' + aTabIndices[sTabName][iTabIndex_clicked]);
		var oCurTab = eval('window.' + aTabIndices[sTabName][aCurTabIndex[sTabName]]);
		var oTd = eval("window.tabHandle_"+ sTabName +"_" + aCurTabIndex[sTabName]);
	}

	oCurTab.style.display = 'none';
	oTab.style.display = 'block';

	oTd.style.backgroundImage = 'url(' + aImg[sTabName]["Off"].src + ')';
	switch(aCurTabIndex[sTabName])
	{
		case c_firstTab:
		changeImage(window.document.images['tabImg_' + sTabName +'_first'], aImg[sTabName]["FirstOff"].src);
		changeImage(eval('window.document.images[\'tabImg_' + sTabName +'_' + (c_firstTab+1) + '\']'), aImg[sTabName]["BetweenOff"].src);
		break;
	case aLastTab[sTabName]:
		changeImage(window.document.images['tabImg_' + sTabName +'_last'], aImg[sTabName]["LastOff"].src);
		changeImage(eval('window.document.images[\'tabImg_' + sTabName +'_' + aLastTab[sTabName] + '\']'), aImg[sTabName]["BetweenOff"].src);
		break;
	default:
		changeImage(eval('window.document.images[\'tabImg_' + sTabName +'_' + aCurTabIndex[sTabName] + '\']'), aImg[sTabName]["BetweenOff"].src);
		changeImage(eval('window.document.images[\'tabImg_' + sTabName +'_' + (aCurTabIndex[sTabName]+1) + '\']'), aImg[sTabName]["BetweenOff"].src);
	}
	switch(iTabIndex_clicked)
	{
		case c_firstTab:
			changeImage(eval('window.document.images[\'tabImg_' + sTabName +'_first\']'), aImg[sTabName]["FirstOn"].src);
			changeImage(eval('window.document.images[\'tabImg_' + sTabName +'_' + (c_firstTab+1) + '\']'), aImg[sTabName]["BetweenLeftOn"].src);
			break;
		case aLastTab[sTabName]:
			changeImage(eval('window.document.images[\'tabImg_' + sTabName +'_' + aLastTab[sTabName] + '\']'), aImg[sTabName]["BetweenRightOn"].src);
			changeImage(window.document.images['tabImg_' + sTabName +'_last'], aImg[sTabName]["LastOn"].src);
			break;
		default:
			changeImage(eval('window.document.images[\'tabImg_' + sTabName +'_' + iTabIndex_clicked + '\']'), aImg[sTabName]["BetweenRightOn"].src);
			changeImage(eval('window.document.images[\'tabImg_' + sTabName +'_' + (iTabIndex_clicked+1) + '\']'), aImg[sTabName]["BetweenLeftOn"].src);
	}
	oTd = window.document.getElementById("tabHandle_"+ sTabName +"_" + iTabIndex_clicked);
	oTd.style.backgroundImage = 'url(' + aImg[sTabName]["On"].src + ')';
	aCurTabIndex[sTabName] = iTabIndex_clicked;
	return;
}
function setVisibility(layer,on) {
	if (on) {
		if (DOM) {
			document.getElementById(layer).style.visibility = "visible";
		} else if (NS4) {
			document.layers[layer].visibility = "show";
		} else {
			document.all[layer].style.visibility = "visible";
		}
	} else {
		if (DOM) {
			document.getElementById(layer).style.visibility = "hidden";
		} else if (NS4) {
			document.layers[layer].visibility = "hide";
		} else {
			document.all[layer].style.visibility = "hidden";
		}
	}
}
function isVisible(layer) {
	if (DOM) {
		return (document.getElementById(layer).style.visibility == "visible");
	} else if (NS4) {
		return (document.layers[layer].visibility == "show");
	} else {
		return (document.all[layer].style.visibility == "visible");
	}
}
function setLeft(layer,x) {
	if (DOM && !Opera5) {
		document.getElementById(layer).style.left = x + "px";
	} else if (Opera5) {
		document.getElementById(layer).style.left = x;
	} else if (NS4) {
		document.layers[layer].left = x;
	} else {
		document.all[layer].style.pixelLeft = x;
	}
}
function getOffsetLeft(layer) {
	var value = 0;
	if (DOM) {
		object = document.getElementById(layer);
		value = object.offsetLeft;
		while (object.tagName != "BODY" && object.offsetParent) {
			object = object.offsetParent;
			value += object.offsetLeft;
		}
	} else if (NS4) {
		value = document.layers[layer].pageX;
	} else {		if (document.all["IE4" + layer]) {
			layer = "IE4" + layer;
		}
		object = document.all[layer];
		value = object.offsetLeft;
		while (object.tagName != "BODY") {
			object = object.offsetParent;
			value += object.offsetLeft;
		}
	}
	return (value);
}
function setTop(layer,y) {
	if (DOM && !Opera5) {
		document.getElementById(layer).style.top = y + "px";
	} else if (Opera5) {
		document.getElementById(layer).style.top = y;
	} else if (NS4) {
		document.layers[layer].top = y;
	} else {
		document.all[layer].style.pixelTop = y;
	}
}
function getOffsetTop(layer) {
	var value = 0;
	if (DOM) {
		object = document.getElementById(layer);
		value = object.offsetTop;
		while (object.tagName != "BODY" && object.offsetParent) {
			object = object.offsetParent;
			value += object.offsetTop;
		}
	} else if (NS4) {
		value = document.layers[layer].pageY;
	} else {		if (document.all["IE4" + layer]) {
			layer = "IE4" + layer;
		}
		object = document.all[layer];
		value = object.offsetTop;
		while (object.tagName != "BODY") {
			object = object.offsetParent;
			value += object.offsetTop;
		}
	}
	return (value);
}
function setWidth(layer,w) {
	if (DOM) {
		document.getElementById(layer).style.width = w;
	} else if (NS4) {
	} else {
		document.all[layer].style.pixelWidth = w;
	}
}
function getWidth(layer) {
	if (DOM) {
		return document.getElementById(layer).offsetWidth;
	} else if (NS4) {
	} else {
		return document.all[layer].style.pixelWidth;
	}
}
function getHeight(layer) {
	if (DOM) {
		return document.getElementById(layer).offsetHeight;
	} else if (NS4) {
	} else {
		return document.all[layer].style.pixelHeight;
	}
}
function getOffsetWidth(layer) {
	var value = 0;
	if (DOM && !Opera56) {
		value = document.getElementById(layer).offsetWidth;
		if (isNaN(value)) {
			if (abscissaStep) {					value = abscissaStep;
			} else {
				value = 0;
			}
		}
	} else if (NS4) {
		value = document.layers[layer].document.width;
	} else if (Opera56) {
		value = document.getElementById(layer).style.pixelWidth;
	} else {		if (document.all["IE4" + layer]) {
			layer = "IE4" + layer;
		}
		value = document.all[layer].offsetWidth;
	}
	return (value);
}
function setHeight(layer,h) {
	if (DOM) {
		document.getElementById(layer).style.height = h;
	} else if (NS4) {
	} else {
		document.all[layer].style.pixelHeight = h;
	}
}
function getOffsetHeight(layer) {
	var value = 0;
	if (DOM && !Opera56) {
		value = document.getElementById(layer).offsetHeight;
		if (isNaN(value)) {
			value = 25;
		}
	} else if (NS4) {
		value = document.layers[layer].document.height;
	} else if (Opera56) {
		value = document.getElementById(layer).style.pixelHeight;
	} else {		if (document.all["IE4" + layer]) {
			layer = "IE4" + layer;
		}
		value = document.all[layer].offsetHeight;
	}
	return (value);
}
function getWindowWidth() {
	var value = 0;
	if ((DOM && !IE) || NS4 || Konqueror || Opera) {
		value = top.innerWidth;
	} else {	// IE
		if (document.documentElement && document.documentElement.clientWidth) {
			value = document.documentElement.clientWidth;
		} else if (document.body) {
			value = document.body.clientWidth;
		}
	}
	if (isNaN(value)) {
		value = top.innerWidth;
	}
	return (value);
}
function getWindowXOffset() {
	var value = 0;
	if ((DOM && !IE) || NS4 || Konqueror || Opera) {
		value = window.pageXOffset;
	} else {	// IE
		if (document.documentElement && document.documentElement.scrollLeft) {
			value = document.documentElement.scrollLeft;
		} else if (document.body) {
			value = document.body.scrollLeft;
		}
	}
	return (value);
}
function getWindowHeight() {
	var value = 0;
	if ((DOM && !IE) || NS4 || Konqueror || Opera) {
		value = top.innerHeight;
	} else {		if (document.documentElement && document.documentElement.clientHeight) {
			value = document.documentElement.clientHeight;
		} else if (document.body) {
			value = document.body.clientHeight;
		}
	}
	if (isNaN(value)) {
		value = top.innerHeight;
	}
	return (value);
}
function getWindowYOffset() {
	var value = 0;
	if ((DOM && !IE) || NS4 || Konqueror || Opera) {
		value = window.pageYOffset;
	} else {		if (document.documentElement && document.documentElement.scrollTop) {
			value = document.documentElement.scrollTop;
		} else if (document.body) {
			value = document.body.scrollTop;
		}
	}
	return (value);
}
function setLayerPos(layer, parent_layer) {
	if (getOffsetLeft(parent_layer) + getWidth(layer) > getWindowWidth()) {
		if (IE55) setLeft('if_'+layer, getOffsetLeft(parent_layer) + 3 + getWidth(parent_layer) - getWidth(layer));
		setLeft(layer, getOffsetLeft(parent_layer) + 3 + getWidth(parent_layer) - getWidth(layer));
	} else {
		if (IE55) setLeft('if_'+layer, getOffsetLeft(parent_layer) - 3);
		setLeft(layer, getOffsetLeft(parent_layer) - 3);
	}
	if (IE55) setTop('if_'+layer, getOffsetTop(parent_layer) + getOffsetHeight(parent_layer));
	setTop(layer, getOffsetTop(parent_layer) + getOffsetHeight(parent_layer));
}
function setLayerPosXY(layer, top, left) {
	var lpadding = 5;
	var lw = getWidth(layer);
	var lh = getHeight(layer);

	adjLeft = left + document.body.scrollLeft;
	if (adjLeft + lw > getWindowWidth() - lpadding) {
		if (adjLeft - lw > lpadding) adjLeft -= lw;
		else adjLeft = getWindowWidth() - lw - lpadding;
	}
	if (adjLeft < lpadding) adjLeft = lpadding;

	adjTop = top + document.body.scrollTop;
	if (adjTop + lh > getWindowHeight()) {
		if (adjTop - lh > lpadding) adjTop -= lh;
		else adjTop = getWindowHeight() - lh - lpadding;
	}
	if (adjTop < lpadding) adjTop = lpadding;

	if (IE55) setLeft('if_'+layer, adjLeft);
	setLeft(layer, adjLeft);
	if (IE55) setTop('if_'+layer, adjTop);
	setTop(layer, adjTop);
}
loaded = 0;
layersMoved = 0;
elementsHidden = 0;

menuLeftShift = 6;
menuRightShift = 10;

layerPoppedUp = "";

mtimer = 0;

currentY = 0;
function grabMouse(e) {	currentY = e.pageY;
}
if (NS4) {
	document.captureEvents(Event.MOUSEDOWN | Event.MOUSEMOVE);
	document.onmousemove = grabMouse;
}

function shutdown() {
	for (i=1; i<=numl; i++) {
		LMPopUpL(listl[i], false);
	}
	layerPoppedUp = "";
	if (IE && !IE55) {
		showElements();
		elementsHidden = 0;
	}
}
if (NS4) {
	document.onmousedown = shutdown;
} else {
	document.onclick = shutdown;
}

function moveLayerX(menuName) {
	if (!loaded || (isVisible(menuName) && menuName != layerPoppedUp)) {
		return;
	}
	if (father[menuName] != "") {
		if (!Opera5 && !IE4) {
			width0 = lwidth[father[menuName]];
			width1 = lwidth[menuName];
		} else if (Opera5) {
			width0 = abscissaStep;
			width1 = abscissaStep;
		} else if (IE4) {
			width0 = getOffsetWidth(father[menuName]);
			width1 = getOffsetWidth(menuName);
		}
		onLeft = getOffsetLeft(father[menuName]) - width1 + menuLeftShift;
		onRight = getOffsetLeft(father[menuName]) + width0 - menuRightShift;
		windowWidth = getWindowWidth();
		windowXOffset = getWindowXOffset();
		if (onLeft < windowXOffset && onRight + width1 > windowWidth + windowXOffset) {
			if (onRight + width1 - windowWidth - windowXOffset > windowXOffset - onLeft) {
				onLeft = windowXOffset;
			} else {
				onRight = windowWidth + windowXOffset - width1;
			}
		}
		if (back[father[menuName]]) {
			if (onLeft < windowXOffset) {
				back[menuName] = 0;
			} else {
				back[menuName] = 1;
			}
		} else {
			if (onRight + width1 > windowWidth + windowXOffset) {
				back[menuName] = 1;
			} else {
				back[menuName] = 0;
			}
		}
		if (back[menuName]) {
			if (IE55) setLeft('if_'+menuName, onLeft);			setLeft(menuName, onLeft);
		} else {
			if (IE55) setLeft('if_'+menuName, onRight);			setLeft(menuName, onRight);
		}
	}
	moveLayerY(menuName, 0);}

function moveLayerY(menuName, ordinateMargin) {
	if (!loaded || (isVisible(menuName) && menuName != layerPoppedUp)) {
		return;
	}
	if (!layersMoved) {
		moveLayers();
		layersMoved = 1;
	}
	if (!NS4) {
		newY = getOffsetTop("ref" + menuName);
	} else {
		newY = currentY;
	}
	newY -= ordinateMargin;
	layerHeight = getOffsetHeight(menuName);
	windowHeight = getWindowHeight();
	windowYOffset = getWindowYOffset();
	if (newY + layerHeight > windowHeight + windowYOffset) {
		if (layerHeight > windowHeight) {
			newY = windowYOffset;
		} else {
			newY = windowHeight + windowYOffset - layerHeight;
		}
	}
	if (Math.abs(getOffsetTop(menuName) - newY) > thresholdY) {
		if (IE55) setTop('if_'+menuName, newY);		setTop(menuName, newY);
	}
}

function LMPopUp(menuName, isCurrent) {
	if (!loaded || menuName == layerPoppedUp || (isVisible(menuName) && !isCurrent)) {
		return;
	}

	if (menuName == father[layerPoppedUp]) {
		LMPopUpL(layerPoppedUp, false);
	} else if (father[menuName] == layerPoppedUp) {
		LMPopUpL(menuName, true);
	} else {
		shutdown();
		foobar = menuName;
		do {
			LMPopUpL(foobar, true);
			foobar = father[foobar];
		} while (foobar != "")
	}
	layerPoppedUp = menuName;
}

function LMPopUpL(menuName, on) {
	if (!loaded) {
		return;
	}
	if (!layersMoved) {
		moveLayers();
		layersMoved = 1;
	}

	if (IE55) setVisibility('if_' + menuName, on);
	setVisibility(menuName, on);
	if (IE && !IE55) {
		if (!elementsHidden) {
			hideElements();
			elementsHidden = 1;
		}
	}
}

function resizeHandler() {
	if (NS4) {
		window.location.reload();
	}
	shutdown();
	for (i=1; i<=numl; i++) {
		setLeft(listl[i], 0);
		setTop(listl[i], 0);
	}
	layersMoved = 0;
}
windowOnResize('resizeHandler();');

function yaresizeHandler() {
	if (window.innerWidth != origWidth || window.innerHeight != origHeight) {
		if (Konqueror2 || Opera5) {
			window.location.reload();		}
		origWidth  = window.innerWidth;
		origHeight = window.innerHeight;
		resizeHandler();
	}
	setTimeout('yaresizeHandler()', 500);
}
function loadHandler() {
	if (Konqueror2 || Opera56) {
		origWidth  = window.innerWidth;
		origHeight = window.innerHeight;
		yaresizeHandler();
	}
}
window.onload = loadHandler;

function fixieflm(menuName) {
	if (DOM) {
		setWidth(menuName, "100%");
	} else {		document.write("</div>");
		document.write("<div id=\"IE4" + menuName + "\" style=\"position: relative; width: 100%; visibility: visible;\">");
	}
}


function hilite(obj, bOn, stylePrefix) {
	if (bOn) {
		obj.className = stylePrefix + 'phplmmenuitem_hover';
	} else {
		obj.className = stylePrefix + 'phplmmenuitem';
	}
}

function contextLMPopUp(menuName) {
	if (!loaded) return;

	layersMoved = 0;
	LMPopUp(menuName, false);
}
function setLMCookie(name, value) {
	document.cookie = name + "=" + value;
}

function getLMCookie(name) {
	foobar = document.cookie.split(name + "=");
	if (foobar.length < 2) {
		return null;
	}
	tempString = foobar[1];
	if (tempString.indexOf(";") == -1) {
		return tempString;
	}
	yafoobar = tempString.split(";");
	return yafoobar[0];
}

function parseExpandString() {
	expandString = getLMCookie("expand");
	expand = new Array();
	if (expandString) {
		expanded = expandString.split("|");
		for (i=0; i<expanded.length-1; i++) {
			expand[expanded[i]] = 1;
		}
	}
}

function parseCollapseString() {
	collapseString = getLMCookie("collapse");
	collapse = new Array();
	if (collapseString) {
		collapsed = collapseString.split("|");
		for (i=0; i<collapsed.length-1; i++) {
			collapse[collapsed[i]] = 1;
		}
	}
}

parseExpandString();
parseCollapseString();

function saveExpandString() {
	expandString = "";
	for (i=0; i<expand.length; i++) {
		if (expand[i] == 1) {
			expandString += i + "|";
		}
	}
	setLMCookie("expand", expandString);
}

function saveCollapseString() {
	collapseString = "";
	for (i=0; i<collapse.length; i++) {
		if (collapse[i] == 1) {
			collapseString += i + "|";
		}
	}
	setLMCookie("collapse", collapseString);
}
