var j_NORECORDS = 'Geen records om af te drukken!';
var j_REMOVEPOPUPCHECK = 'Om deze pagina te kunnen weergeven, dient u het blokkeren van popups voor deze site uit te zetten';
var j_PATIENCEPLEASE = 'Even geduld a.u.b.';
var j_APPBUSYONSERVER = 'De applicatie is nog bezig met uw vorige opdracht en wacht op een antwoord van de server.';
var j_SWYXERRORLINE1 = 'Op dit moment bent u niet verbonden met een extern telefoonnummer.';
var j_SWYXERRORLINE2 = 'Er kunnen geen details bij het huidige nummer gevonden worden.';
var j_NOSELECTIONACTIVE = 'U heeft geen record geselecteerd';
var j_THISROW = 'deze rij';
var j_REMOVEQUESTION = 'Druk op OK voor het verwijderen van';
var j_DOWNLOADQUESTIONLINE1 = 'Om dit programma optimaal te kunnen gebruiken hebt u Internet Explorer 5.0 of hoger nodig.';
var j_DOWNLOADQUESTIONLINE2 = 'Wilt u dit nu downloaden druk dan op OK, om door te gaan druk op Cancel.';
var j_ERROROCCURRED = 'Er is een fout opgetreden';
var j_NREMAILSSENT = 'Aantal e-mails verstuurd: ';
var j_EMAILINQUEUE = 'De e-mails worden verstuurd, u ontvangt per e-mail bericht over het resultaat.';

// HTML Editor
var j_MODEDESIGN = "Ontwerp weergave";
var j_MODEHTML = "HTML weergave";
var j_MODEPREVIEW = "Voorbeeld weergave";
var j_MODEPDF = "PDF weergave";
var j_MODEPRINT = "Afdrukken";
var j_FULLSCREEN = "Vol scherm";
var j_CUT = "Knippen";
var j_COPY = "Kopieren";
var j_PASTE = "Plakken";
var j_UNDO = "Ongedaan maken";
var j_REDO = "Herhalen";
var j_REMOVETAGS = "HTML opschonen, verwijdert o.a. alle ongewenste MS Word codes";
var j_BOLD = "Vet";
var j_ITALIC = "Cursief";
var j_UNDERLINE = "Onderstrepen";
var j_JUSTIFYLEFT = "Links uitlijnen";
var j_JUSTIFYCENTER = "Centreren";
var j_JUSTIFYRIGHT = "Rechts uitlijnen";
var j_JUSTIFYFULL = "Uitlijnen";
var j_INSERTORDEREDLIST = "Nummering";
var j_INSERTUNORDEREDLIST = "Opsommingstekens";
var j_OUTDENT = "Inspringing verkleinen";
var j_INDENT = "Inspringing vergroten";
var j_FORECOLOR = "Tekstkleur";
var j_BACKCOLOR = "Tekst achtergrondkleur";
var j_INSERTEXTFRAME = "Textblok invoegen";
var j_ABSOLUTEPOSITION = "Absolute positie";
var j_IMAGEFROMWEB = "Afbeelding van de webserver toevoegen";
var j_INSERTFILEWEB = "Link naar bestand op de webserver toevoegen";
var j_INSERTTABLE = "Nieuwe tabel invoegen";
var j_TABLEPROPERTIES = "Tabel eigenschappen";
var j_CELLPROPERTIES = "Cel eigenschappen";
var j_INSERTROWUP = "Rij hierboven invoegen";
var j_INSERTROWDOWN = "Rij hieronder invoegen";
var j_INSERTCOLLEFT = "Kolom links invoegen";
var j_INSERTCOLRIGHT = "Kolom rechts invoegen";
var j_DELROW = "Rij verwijderen";
var j_DELCOL = "Kolom verwijderen";
var j_DELCELL = "Cel verwijderen";
var j_MERGERIGHTCELL = "Cel samenvoegen met rechter cel";
var j_MERGEDOWNCELL = "Cel samenvoegen met cel eronder";
var j_SPLITCELLRIGHT = "Cel horizontaal splitsen";
var j_SPLITCELLBELOW = "Cel verticaal splitsen";
var j_CREATELINK = "HTML link invoegen";
var j_LINKDOCUMENT = "HTML Link naar ander document invoegen";
var j_INSERTDOCUMENT = "Ander document invoegen middels code, als het brondocument verandert zijn de veranderingen zichtbaar.";
var j_COPYDOCUMENT = "Inhoud van ander document kopieren en invoegen";
var j_INSERTCRMFIELD = "Gepersonaliseerd veld toevoegen";
var j_INSERTDBFIELD = "Database veld of groep toevoegen";
var j_PARAGRAPHTYPE = "Paragraaftype";
var j_FONTNAME = "Lettertype";
var j_FONTSIZE = "Lettergrootte";
var j_ZOOM = "Zoom";
var j_DBGROUPFIELD = "Database groep/veld";
var j_CHOOSEFIELD = "Kies een veld";
var j_SELECTION = "Selectie";
var j_TYPETEXTHERE = "Type hier uw text";
var j_TYPETITLEHERE = "type hier uw bestandstitel";
var j_EXISTINGFILES = "Bestaande bestanden";
var j_WAITFORPREVIEW = "Een moment geduld a.u.b. de voorbeeldweergave wordt gegenereerd.";
var j_TEMPLATELIST = "Kies een veld";


function j_Debug()
{
}
function ja_CheckInputLen(ctrlId, Maxlen)
{
	if (document.all.item(ctrlId).value.length>=Maxlen) 
		return false;
}
function ja_CheckPasteLen(ctrlId, Maxlen)
{
	var PasteText = clipboardData.getData('Text');
	var ctrl = document.all.item(ctrlId);
	if (ctrl!=null && ctrl.value.length + PasteText.length >= Maxlen) 
	{
		ctrl.value += PasteText;
		ctrl.value = ctrl.value.substr(0, Maxlen);
		return false;
	}
}

function j_insertText(id, text)
{
	var	sRange;
	var elem	= document.all.item(id);
	
	if (elem != null)
	{
		elem.focus();
		sRange		= document.selection.createRange();

		sRange.text = text;               // overwrite

		// move to end of new content
		sRange.collapse(false); // move to end of range
		sRange.select();        // re-select	
	}
}

function j_EnableButton(ctrl, enabled)
{
	if (ctrl != null)
		ctrl.disabled = !enabled;
}

function ja_NewRecordAddedInPickPlace(Id, Name)
{
	dialogArguments.opener.dialogArguments.hidCurrentId = Id;
	dialogArguments.opener.dialogArguments.hidId = Id;
	dialogArguments.opener.dialogArguments.Description = Name;
	dialogArguments.opener.returnValue = Id;
	
	window.close();
}
function ja_checkActiononlyResult()
{
	var action = document.all.item("hidCommand");
	
	if (action!=null && action.value.length>0 && typeof(ja_processSilentAction)!="undefined")
		ja_processSilentAction(action.value);
		
	// This is happening in the 'actiononly' frame, to access the 'current' frame use the
	// frameElement.document.parentWindow.document.all
	// collection
}

function ja_actionOnly(action)
{
	var frame = document.all.item("frmActiononly");
	var newurl = j_setUrlParam(document.location.href, "action", action);
	
	if (frame!=null)
		frame.src = newurl;
	else
	{
		frame = document.createElement("<IFRAME style=\"display:none\" id=\"frmActiononly\" width=\"0\" height=\"0\" src=\"" + newurl + "\"></IFRAME>");
		document.body.appendChild(frame);
	}
}

function ja_actionOnlyForm(action, ExtraParams)
{
	var frame = document.all.item("frmActiononly");
	var newurl, inputs;
	
	newurl =j_setUrlParam(document.location.href, "action", action);
	if (ExtraParams!=null && ExtraParams != "")
		newurl+= "&" + ExtraParams
		 
	inputs	= document.body.getElementsByTagName("INPUT");
	for (i = 0; i < inputs.length; i++)
	{
		if (inputs[i].type == 'text' && inputs[i].onchange != null && inputs[i].onchange != "")
			newurl = j_setUrlParam(newurl, inputs[i].name, inputs[i].value.replace(".",","));		
	}
	
	if (frame!=null)
		frame.src = newurl;
	else
	{
		frame = document.createElement("<IFRAME style=\"display:none\" id=\"frmActiononly\" width=\"0\" height=\"0\" src=\"" + newurl + "\"></IFRAME>");
		document.body.appendChild(frame);
	}
}

function j_checkExplorerVersion()
{
	var DownloadUrl = "http://www.microsoft.com/windows/ie_intl/nl/download/default.asp";
	var Question = j_DOWNLOADQUESTIONLINE1;
	Question += '\n';
	Question += j_DOWNLOADQUESTIONLINE2;
	if (j_explorerVersion() < 5.0 && confirm(Question))
	{
		if (top.dialogArguments==null)
			document.location.href = DownloadUrl;
		else if (typeof(top.dialogArguments.opener)!='undefined')
		{
			top.dialogArguments.opener.document.location.href = DownloadUrl;
			close();
		}
	}
}

function j_explorerVersion()
{
  var rv = -1; // Return value assumes failure
  if (navigator.appName == 'Microsoft Internet Explorer')
  {
    var ua = navigator.userAgent;
    var re  = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
    if (re.exec(ua) != null)
      rv = parseFloat( RegExp.$1 );
  }
  return rv;
}

//////////////////////////////////////////////////////
// The only way to do postbacks
//////////////////////////////////////////////////////
function j_ClickButton(Button)
{	
	j_Command(Button);
}

function j_getBaseUrl(url)
{
	if (url == null)
	{
	    var oBaseColl = document.all.tags('BASE');
		url = (oBaseColl && oBaseColl.length) ? oBaseColl[0].href : window.location.href;
	}

	var urlArray = url.split('?')[0].split('/');
	urlArray[urlArray.length-2] = ""; // Pages part
	urlArray[urlArray.length-1] = ""; // pagename
	var Result = urlArray.join('/');
	// skip the last / token
	return Result.substring(0, Result.length-1);
}

function j_ctmLoginOnload()
{
	if (top.dialogArguments!=null && top.dialogArguments.opener!=null)
	{
		var pageUrl = document.location.href;
		var bgUrl = j_getUrlParam(pageUrl, "backgroundimgurl");
		var bgColor = j_getUrlParam(pageUrl, "backgroundcolor");

		try
		{
			bgUrl = decodeURIComponent(bgUrl);
		}
		catch(e)
		{
		}
		var ResolutionString = screen.width + "x" + screen.height;
		var AllResolutions = "1024x768, 1152x864, 1280x1024, 1280x960, 1600x1200, 640x480, 800x600";
		if (AllResolutions.indexOf(ResolutionString)>=0)
			bgUrl = bgUrl.replace(".jpg", ResolutionString + ".jpg");
		bgUrl = j_getBaseUrl(pageUrl) + (bgUrl.substring(0,1)=='/' ? bgUrl.substring(1, bgUrl.length) : bgUrl);
		
		top.dialogArguments.opener.document.body.background = bgUrl;
		top.dialogArguments.opener.document.body.bgProperies = "fixed";
		top.dialogArguments.opener.document.body.style.backgroundColor = bgColor;
	}

	OnLoad();

	var UserName = document.all.item('tbLogin');
	var PassWord = document.all.item('tbPassword');
	if(UserName!=null && j_explorerVersion()>=6)
	{
		if (UserName.value.length==0)
			UserName.focus();
		else if (PassWord != null)
			PassWord.focus();
	}
}

//////////////////////////////////////////////////////
// Function j_getUrlParam returns the value 
// of a parameter (par paramName) in the query part of 
// an url (par url). If the parameter does not exist in the 
// given url, an empty string is returned.
//////////////////////////////////////////////////////
function j_getUrlParam(url, paramName)
{
	var paramValue		= '';
	var name			= paramName.toLowerCase();
	var requestParts	= url.toLowerCase().split('?');
	var paramPair, i, requestArray;

	if (requestParts.length==2)
	{
		requestArray = requestParts[1].split('&');
		for (i=0;i<requestArray.length && paramValue=='';i++)
		{
			paramPair = requestArray[i].split('=');
			if (paramPair.length==2 && paramPair[0]==name)
				paramValue = paramPair[1];
		}
	}
	return paramValue;
}

//////////////////////////////////////////////////////
// Function j_setUrlParam replaces the value (par paramValue) 
// of a parameter (par paramName) in the query part of 
// an url. If the parameter does not exist yet in the 
// given url, the parameter value pair is appended.
//////////////////////////////////////////////////////
function j_setUrlParam(url, paramName, paramValue)
{
	var urlParts	= url.split('?');
	var newUrl		= urlParts[0] + "?";
	var paramFound	= false;
	var paramParts,	paramPair, i;

	if (urlParts.length==2)
	{
		paramParts	= urlParts[1].split('&');
		
		for(i=0;i<paramParts.length && !paramFound;i++)
		{
			paramPair  = paramParts[i].split('=');
			paramFound = paramPair.length==2 && paramPair[0].toLowerCase()==paramName.toLowerCase();

			if (paramFound)
				paramParts[i] = paramPair[0] + "=" + paramValue;
		}
		
		newUrl += paramParts.join("&") + (!paramFound ? "&" : "");
	}

	return newUrl + (!paramFound ? paramName + "=" + paramValue : "");
}

//////////////////////////////////////////////////////
// Function j_showImportPage() navigates to the 
// amiimportpage with a given importname and import 
// arguments ;
//////////////////////////////////////////////////////
function j_showImportPage(importName, args)
{
	j_openLinesView("amiimportpage", "IMPORTNAME=" + importName + "&IMPORTARGS=" + args + "&CurrentSelection=" + document.all.hidId.value, 0, true);
}
//////////////////////////////////////////////////////
// Function j_showAnalyzePage() navigates to the 
// PageName
//////////////////////////////////////////////////////
function j_showAnalyzePage(PageName)
{
	j_openLinesView(PageName, 'CurrentSelection=' + document.all.hidId.value, 0, true);
}
var source;
function j_opendialog_base(BasePageUrl, FormName, Params, DialogWidth, DialogHeight, ExtraDialogProps, Obj, Title)
{
	if (typeof(Obj)=='undefined' || Obj == null)
		var Obj			= new Object();
	var ParmUrl		= ((Params.length>0 && Params.substr(0,1)!='&') ? "&" : "") + Params;
	var DialogProps;

	DialogProps = 'status:yes;dialogWidth:'+ DialogWidth + 'px;dialogHeight:' + DialogHeight + 'px;' + ExtraDialogProps;
	 
	try
	{
		Obj.src		= BasePageUrl + "?page=" + FormName + ParmUrl;
	}
	catch (e)
	{
		Obj.src		= null;
	}
	Obj.title	= typeof(Title)=="string" ? Title : "";
	Obj.opener	= window;

	if (DialogWidth>100 && DialogHeight>100)
		Obj.noresize = true;

	if (Obj.src!=null)
	{
		try
		{
			Obj.Result = window.showModalDialog(j_getBaseUrl() + "Pages/amipopup.htm", Obj, DialogProps);
		}
		catch (e)
		{
			try
			{
				DialogProps = 'status=yes,width='+ DialogWidth + ',height=' + DialogHeight + ',' + ExtraDialogProps;
				source= Obj.src;
				Obj.Result = window.open(j_getBaseUrl() + "Pages/amipopup.htm", Obj.title, DialogProps);
			}
			catch (e)
			{
				alert(j_REMOVEPOPUPCHECK);
			}
		}
	}

	return Obj;
}

function j_scaleMm2Dots(Width, Height)
{
	var XFactor = screen.deviceXDPI / 25.4;
	var YFactor = screen.deviceYDPI / 25.4;
	var X = Math.min(Width * XFactor, screen.availWidth);
	var Y = Math.min(Height * YFactor, screen.availHeight);
	
	return new Array(X, Y);
}
function j_FormType2Size(FormType, Width, Height)
{
	var Size;

	switch (FormType)
	{
	case "A4Portrait" :
	case "A5Portrait" :
	case "A6Portrait" :
	case "A7Portrait" :
	case "A4Landscape" :
	case "A5Landscape" :
	case "A6Landscape" :
	case "A7Landscape" :
		Size = j_scaleMm2Dots(Width, Height);
		this.Width = Size[0];
		this.Height = Size[1];
		break;
	case "Print":
	case "PrintPortrait":
		// A4 maten voor het printen
		Size = j_scaleMm2Dots(240, 297);
		this.Width = Size[0];
		this.Height = Size[1];
		break;
    case "PrintLandscape":
		// A4 maten voor het printen
		Size = j_scaleMm2Dots(325, 230);
		this.Width = Size[0];
		this.Height = Size[1];
		break;
	case "DoubleColumns800x600": 
		this.Width = 600;
		this.Height = 800;
		break;
	case "FreeForm" :
	case "Automatic" :
	default:
		this.Width = Width;
		this.Height = Height;
		break;
	}
	
	// since IE 7 dialog height and dialog width set the content area (IE 6 and less set the window size)
	if (j_explorerVersion() >= 7.0)
	{
        var estimated_total_chrome_elements_width = 4; // left and right frame edge
        var estimated_total_chrome_elements_height = 29 + 25 + 4; // title + status bar	
	    
	    this.Width -= estimated_total_chrome_elements_width;
		this.Height -= estimated_total_chrome_elements_height;
	}
}

function j_showForm(FormName, Params, DialogWidth, DialogHeight, Title, Resizable)
{
	var Obj			= new Object();
	var ParmUrl		= ((Params.length>0 && Params.substr(0,1)!='&') ? "&" : "") + Params;
	var DialogProps;

	var Resize = 'no';
	if (typeof(Resizable)!='undefined' && Resizable==true)
		Resize = 'yes';
	DialogProps = 'help:no;resizable:' + Resize + ';status:yes;dialogWidth:'+ DialogWidth + 'px;dialogHeight:' + DialogHeight + 'px;';

	try
	{
		Obj.src		= j_baseAspx() + "?Page=" + FormName + ParmUrl;
	}
	catch (e)
	{
		Obj.src		= null;
	}
	Obj.title	= typeof(Title)=="undefined" ? "" : Title;
	Obj.opener	= window;

	if (DialogWidth>100 && DialogHeight>100)
		Obj.noresize = true;

	if (Obj.src!=null)
	{
		try
		{
			window.showModalDialog(j_basePath() + "amipopup.htm", Obj, DialogProps);
		}
		catch (e)
		{
			alert(j_REMOVEPOPUPCHECK);		
		}
	}
}

function j_opendialog(FormName, Params, DialogWidth, DialogHeight, Title, FormType, Resizable)
{
	var Obj			= new Object();
	var ParmUrl		= ((Params.length>0 && Params.substr(0,1)!='&') ? "&" : "") + Params;
	var DialogProps;

	if (typeof(FormType)=="string")
	{
		var Size		= new j_FormType2Size(FormType, DialogWidth, DialogHeight);
		DialogWidth		= Size.Width;
		DialogHeight	= Size.Height;
	}
	var Resize = 'no';
	if (typeof(Resizable)!='undefined' && Resizable==true)
		Resize = 'yes';
	DialogProps = 'help:no;resizable:' + Resize + ';status:yes;dialogWidth:'+ DialogWidth + 'px;dialogHeight:' + DialogHeight + 'px;';

	try
	{
		Obj.src		= j_baseAspx() + "?Page=" + FormName + ParmUrl;
	}
	catch (e)
	{
		Obj.src		= null;
	}
	Obj.title	= typeof(Title)=="undefined" ? "" : Title;
	Obj.opener	= window;

	if (DialogWidth>100 && DialogHeight>100)
		Obj.noresize = true;

	if (Obj.src!=null)
	{
		try
		{
			Obj.result	= window.showModalDialog("../Pages/amipopup.htm", Obj, DialogProps);
		}
		catch (e)
		{
			alert(j_REMOVEPOPUPCHECK);
		}
	}
	return Obj;
}

function j_openfullscreendialogurl(url, title, resizable)
{
    var width = window.screen.availWidth * 0.80;
    var height = window.screen.availHeight * 0.80;
 
	var resizable = 'no';
	if (typeof(resizable)!='undefined' && resizable==true)
		resizable = 'yes';

	return j_opendialogurl(url, width, height, title, resizable);
}


function j_opendialogurl(url, DialogWidth, DialogHeight, Title, Resizable)
{
	var Obj			= new Object();
	var DialogProps;

	var Resize = 'no';
	if (typeof(Resizable)!='undefined' && Resizable==true)
		Resize = 'yes';

	DialogProps = 'help:no;resizable:' + Resize + ';status:yes;dialogWidth:'+ DialogWidth + 'px;dialogHeight:' + DialogHeight + 'px;';

	if(url.indexOf('?')<0)url += "?";
	Obj.src		= url;
	Obj.title	= typeof(Title)=="undefined" ? "" : Title;
	Obj.opener	= window;

	if (DialogWidth>100 && DialogHeight>100)
		Obj.noresize = true;

	if (Obj.src!=null)
	{
		try
		{
			Obj.result	= window.showModalDialog("../Pages/amipopup.htm", Obj, DialogProps);
		}
		catch (e)
		{
			alert(j_REMOVEPOPUPCHECK);
		}
	}
	return Obj;
}

function j_Command(Command, CurrentId)
{	
	var hidCurrentId= document.all.item("hidCurrentId");
	var hidCommand	= document.all.item("hidCommand");
	var btnCommand	= document.all.item("btnCommand");
	var ValidationActive	= false;
	if (typeof(Page_ValidationActive) != "undefined")
		ValidationActive	= Page_ValidationActive;

	if (CurrentId != null && hidCurrentId != null)
	{
		hidCurrentId.value = CurrentId;
	}

	if (hidCommand!=null && btnCommand!=null && (btnCommand.disabled==false || ValidationActive))
	{
		btnCommand.disabled = false;
		hidCommand.value = Command;
		btnCommand.click();
		btnCommand.disabled = true;
	}
	else 
	{
		if (event==null || event.type!="keydown")
			j_ShowWaitingForResponse();
	}
}

function j_copyStyle2PDF(oSrc, oDst)
{
	var	i;

	if (oDst.style)
	{
		if (oSrc.currentStyle.backgroundColor.length > 0 && oSrc.currentStyle.backgroundColor != "transparent")
			oDst.bgColor				= oSrc.currentStyle.backgroundColor;

		if (oSrc.currentStyle.textAlign.length > 0)
			oDst.align					= oSrc.currentStyle.textAlign;

		if (oSrc.currentStyle.width.length > 0 && oSrc.currentStyle.width != 'auto' && oSrc.currentStyle.width[0] != '0')
			oDst.width					= oSrc.currentStyle.width;
			
		if (oSrc.tagName == "TD" && oSrc.colSpan <= 1)
			oDst.colspan = 1;

		for (i=0; i<oSrc.children.length; i++)
			j_copyStyle2PDF(oSrc.children[i], oDst.children[i]);
			
		oDst.className = '';
	}
}

function j_showPDFElement(oElem)
{
	var oClone;
	
	if (oElem != null)
	{
		oClone	= oElem.cloneNode(true);
		
		j_copyStyle2PDF(oElem, oClone);
		j_showPDFPreview(oClone.outerHTML);
	}
}

function j_showPDFPreview(html)
{
	var features = 'width=1000px,height=750px';
	var oWnd;
	var oDoc;

	oWnd = window.open('about:blank','_blank', features);
	oDoc = oWnd.document.open("text/html", "replace");
	oDoc.writeln("<HTML><BODY>");
	oDoc.writeln("<FORM METHOD=\"POST\" ACTION=\"" + j_basePath() + "AMIHTML2PDF.aspx\">");
	oDoc.writeln("<INPUT NAME=\"HTML\" ID=\"HTML\" TYPE=\"HIDDEN\">");
	oDoc.writeln("</FORM>");
	oDoc.writeln("</BODY></HTML>");
	oDoc.close();
	
	oDoc.all.HTML.value = html;
	oDoc.forms[0].submit();
}

var _styleProperties	= null;

function j_getStyleProperties()
{
	if (_styleProperties == null)
	{
		var	i	= 0;
		_styleProperties	= new Array(); 
		
		_styleProperties[i++]	= "width";
		_styleProperties[i++]	= "height";
		_styleProperties[i++]	= "borderTopColor";
		_styleProperties[i++]	= "borderTopStyle";
		_styleProperties[i++]	= "borderTopWidth";
		_styleProperties[i++]	= "borderBottomColor";
		_styleProperties[i++]	= "borderBottomStyle";
		_styleProperties[i++]	= "borderBottomWidth";
		_styleProperties[i++]	= "borderLeftColor";
		_styleProperties[i++]	= "borderLeftStyle";
		_styleProperties[i++]	= "borderLeftWidth";
		_styleProperties[i++]	= "borderRightColor";
		_styleProperties[i++]	= "borderRightStyle";
		_styleProperties[i++]	= "borderRightWidth";
		_styleProperties[i++]	= "paddingTop";
		_styleProperties[i++]	= "paddingBottom";
		_styleProperties[i++]	= "paddingLeft";
		_styleProperties[i++]	= "paddingRight";
		_styleProperties[i++]	= "backgroundColor";
		_styleProperties[i++]	= "color";
		_styleProperties[i++]	= "fontWeight";
		_styleProperties[i++]	= "fontFamily";
		_styleProperties[i++]	= "fontSize";
		_styleProperties[i++]	= "textAlign";
		_styleProperties[i++]	= "verticalAlign";
	}
	return _styleProperties;
}
function j_copyStyle(oSrc, oDst)
{
	if (oSrc.currentStyle)
	{
		var i;
		var properties	= j_getStyleProperties();

		for (i=0; i<properties.length; i++)
			oDst.style[properties[i]] = oSrc.currentStyle[properties[i]];

		for (i=0; i<oSrc.children.length; i++)
			j_copyStyle(oSrc.children[i], oDst.children[i]);
	}
}

function j_showMailElement(subject, oElem)
{
	var oClone;
	
	if (oElem != null)
	{
		oClone	= oElem.cloneNode(true);
		
		j_copyStyle(oElem, oClone);
		j_showMailHtml(subject, oClone.outerHTML);
	}
}

function j_showMailHtml(subject, html)
{
	var features = 'width=640px,height=480px';
	var oWnd;
	var oDoc;
	var sUrl	= document.URL.split('?')[0] + "?page=AMIHTMLMailMessageForm&ispopup=true";
	
	oWnd = window.open('about:blank','_blank', features);
	oDoc = oWnd.document.open("text/html", "replace");
	oDoc.writeln("<HTML><BODY>");
	oDoc.writeln("<FORM METHOD=\"POST\" ACTION=\"" + sUrl + "\">");
	oDoc.writeln("<INPUT NAME=\"__SUBJECT\" ID=\"__SUBJECT\" TYPE=\"HIDDEN\">");
	oDoc.writeln("<INPUT NAME=\"__BODY\" ID=\"__BODY\" TYPE=\"HIDDEN\">");
	oDoc.writeln("</FORM>");
	oDoc.writeln("</BODY></HTML>");
	oDoc.close();

	oDoc.all.__SUBJECT.value = subject;
	oDoc.all.__BODY.value = html;
	oDoc.forms[0].submit();
}

function j_ShowWaitingForResponse()
{
	if (document.all.iEvenGeduldFrame==null)
	{
		var oFrame = document.createElement("IFRAME");
		
		oFrame.style.position	= "absolute";
		oFrame.style.width		= "200px";
		oFrame.style.height		= "130px";
		oFrame.style.left		= (document.body.clientWidth - parseInt(oFrame.style.width)) / 2;
		oFrame.style.top		= (document.body.clientHeight - parseInt(oFrame.style.height)) / 2;
		oFrame.style.padding	= "4px";
		oFrame.style.textAlign	= "center";
		oFrame.style.borderStyle= "ridge";
		oFrame.style.borderWidth= "thin";
		oFrame.frameBorder		= "0";
		oFrame.id				= "iEvenGeduldFrame";
		oFrame.src				= "../images/spacer.gif"; // to prevent security error in https site
		
		document.body.appendChild(oFrame);
		
		oFrame.contentWindow.document.writeln("<HTML>");
		oFrame.contentWindow.document.writeln("<HEAD>");
		for(i=0; i<document.styleSheets.length; i++)
			oFrame.contentWindow.document.writeln("<LINK href=\"" + document.styleSheets[i].href + "\" type=\"text/css\" rel=\"stylesheet\">");
		oFrame.contentWindow.document.writeln("</HEAD>");
		oFrame.contentWindow.document.writeln("<BODY style=\"text-align:center\">");
		oFrame.contentWindow.document.writeln("<BR><SPAN class=\"AError\">" + j_PATIENCEPLEASE + "</SPAN><BR><BR>" + j_APPBUSYONSERVER + "");
		oFrame.contentWindow.document.writeln("</BODY>");
		oFrame.contentWindow.document.writeln("</HTML>");
	}
}

function j_ShowWaitMessage(message)
{
	if (document.all.iEvenGeduldFrame==null)
	{
		var oFrame = document.createElement("IFRAME");
		
		oFrame.style.position	= "absolute";
		oFrame.style.width		= "200px";
		oFrame.style.height		= "130px";
		oFrame.style.left		= (document.body.clientWidth - parseInt(oFrame.style.width)) / 2;
		oFrame.style.top		= (document.body.clientHeight - parseInt(oFrame.style.height)) / 2;
		oFrame.style.padding	= "4px";
		oFrame.style.textAlign	= "center";
		oFrame.style.borderStyle= "ridge";
		oFrame.style.borderWidth= "thin";
		oFrame.frameBorder		= "0";
		oFrame.id				= "iEvenGeduldFrame";
		oFrame.src				= "../images/spacer.gif"; // to prevent security error in https site
		
		document.body.appendChild(oFrame);
		
		oFrame.contentWindow.document.writeln("<HTML>");
		oFrame.contentWindow.document.writeln("<HEAD>");
		for(i=0; i<document.styleSheets.length; i++)
			oFrame.contentWindow.document.writeln("<LINK href=\"" + document.styleSheets[i].href + "\" type=\"text/css\" rel=\"stylesheet\">");
		oFrame.contentWindow.document.writeln("</HEAD>");
		oFrame.contentWindow.document.writeln("<BODY style=\"text-align:center\">");
		oFrame.contentWindow.document.writeln("<BR><SPAN class=\"AError\">" + j_PATIENCEPLEASE + "</SPAN><BR><BR>" + message + "");
		oFrame.contentWindow.document.writeln("</BODY>");
		oFrame.contentWindow.document.writeln("</HTML>");
        document.body.style.overflow = "hidden";
	}
}

//////////////////////////////////////////////////////
// OnLoad() hulpfuncties
//////////////////////////////////////////////////////

function j_disableHelp()
{
	if ( typeof(event.cancelBubble) != "undefined" )
	{
		event.cancelBubble = false;
		event.returnValue = false;
		event.keyCode = 0;
	}
}

// Wordt soms overschreven in dialogen
function OnKey() {}

function OnLoad()
{
	//alert(document.body.innerHTML);
	j_checkExplorerVersion();
	
	// Disable Windows Help
	window.onhelp = j_disableHelp;

	// Asign KeyHandler
	document.body.onkeydown = OnKey;
	
	j_SetFocus();
}

//Zet de focus op het eerste editable textbox die op een form staat:
function j_SetFocus()
{
	var colltags = document.forms[0].elements.tags("input");

	try
	{
		for(index=0;index<colltags.length;index++)
		{
			if(!colltags[index].disabled)
			{
				if(colltags[index].className == "AInput" && colltags[index].type != "hidden" && colltags[index].type != "submit" && colltags[index].isContentEditable)
				{
					colltags[index].focus();
					colltags[index].value = colltags[index].value; //move cursor to end													
					break;
				}
			}
		}
	}
	catch(e)
	{
	}
}


/////////////////////////////////////////////////////////////////////////
/// Used by personalized pages to send e-mail with help of a template.
/////////////////////////////////////////////////////////////////////////
function j_sendMail(TemplateName, Url)
{
	var hidRedirect = document.all.item('hidRedirect');
	var hidTemplateCode = document.all.item('hidTemplateCode');
	
	if ( ( hidRedirect != null ) && ( hidTemplateCode != null ) )
	{
		hidRedirect.value = Url;
		hidTemplateCode.value = TemplateName;
		
		j_Command('Email');
	}
}

function j_checkDateKeyCode(tb)
{
	var	keyCode	= window.event.keyCode;
	return (
	((keyCode >= 96 && keyCode <=105) || (keyCode >= 48 && keyCode <= 57))
	 && tb.value.length >= tb.maxLength );
}

/// checks if the pressed key is within a set of valid characters
/// example for a numerical textbox
///    <INPUT type=text onkeypressed="return j_checkKeyCode('0123456789.') ...
function j_checkKeyCode(validChars)
{
	var	keyCode	= window.event.keyCode;
	
	switch (keyCode) {
		case null:
		case 0:
		case 8:
		case 9:
		case 13:
		case 27:
			return true;
		default:
			var	keyChar	= String.fromCharCode(keyCode).toLowerCase();
			return		validChars.indexOf(keyChar) != -1;
	}
}

/// checks if the pressed key is within a set of valid characters
/// example for a numerical textbox
///    <INPUT type=text onbeforepaste="return j_checkPaste('0123456789.') ...
function j_checkPaste(validChars)
{
	var pasteText	= window.clipboardData.getData("Text");
	
	if (pasteText != null && pasteText.length > 0)
	{
		for (i = 0; i < pasteText.length; i++)
		{
			if (validChars.indexOf(pasteText.charAt(i)) == -1) return false;
		}
	}
	
	return true;
}
function j_PrintReportPage(HTML)
{
	window.document.body.style.cursor = "wait";

	var printwindow = j_FormatForPrinting(HTML);

	if (printwindow!= null)
	{
		var obj = new Object();
		obj.innerHTML = printwindow.document.body.innerHTML;
		printwindow.close();
		var features = 'dialogHide:on;status:no;dialogHeight:100;dialogWidth:100;dialogLeft:4000;dialogTop:4000;';
		showModalDialog('printdoc.htm', obj, features);
	}
	window.document.body.style.cursor = "default";
	close();
}
function j_FormatForPrinting(HTML)
{
	var printobject = new j_CreateNewWindow(HTML);

	j_ProcessTag(printobject.document, "INPUT", j_ProcessButton);
	j_ProcessTag(printobject.document, "SPAN", j_ProcessSpan);
	
	return printobject.window;
}

function j_CreateNewWindow(HTML)
{
	var features = 'width=100px,height=100px,top=8000px,left=8000px';
	this.window = window.open('about:blank','_blank', features);
	this.document = this.window.document.open("text/html", "replace");
	this.document.writeln("<HTML><BODY>");
	this.document.writeln(HTML);
	this.document.writeln("</BODY></HTML>");
	this.document.close();
}

function j_ProcessTag(newdoc, tag, j_ProcessControl)
{
	var Index;
	var tags = newdoc.all.tags(tag);
	if (tags!=null)
	{
		for (Index=tags.length-1;Index>-1;Index--)
		{
			j_ProcessControl(newdoc, tags[Index]);
		}
	}
}

function j_ProcessButton(newdoc, input)
{
	input.onclick = null;
	if (input.className=="AButton")
	{
		input.style.display = 'none';
		if (input.type=='submit')
		{
			var Text = newdoc.createElement("");
			input.replaceNode(Text);
		}
	}
}

function j_ProcessSpan(newdoc, span)
{
	span.onclick = null;
	if (span.className=="ATitle")
		span.style.display = 'none';
}

function j_onClickClose()
{
	if ( window.opener != null )
	{
		window.opener.focus();
		window.close();
	}
	else if (window == window.top)
	{
		window.close();
	}
	else if (typeof(dialogArguments)!='undefined' && dialogArguments!=null && dialogArguments.opener!=null)
	{
		window.close();
	}
	else if (typeof(window.top.dialogArguments)!='undefined' && window.top.dialogArguments!=null && window.top.dialogArguments.opener!=null)
	{
		window.top.close();
		window.close();
	}
	else
	{
		window.top.document.location.reload();
	}
}

function j_setSessionSetting(Name, Value, NextScript)
{
	var Cont = typeof(NextScript)!="undefined" ? NextScript : "";
	eval("function Done(){" + Cont.replace("\"", "\\\"") + ";}");
	document.all.service.wsService.callService(Done, "setSessionSetting", Name, Value);
}

function j_setUserSetting(Name, Value, NextScript)
{
    if (typeof(NextScript)=="function")
	    document.all.service.wsService.callService(NextScript, "setUserSetting", Name, Value);
    else
    {
	    var Cont = typeof(NextScript)!="undefined" ? NextScript : "";
	    eval("function Done(){" + Cont.replace("\"", "\\\"") + ";}");
	    document.all.service.wsService.callService(Done, "setUserSetting", Name, Value);
	}
}

function j_setUserSettings(Names, Values, NextScript)
{
    if (typeof(NextScript)=="function")
	    document.all.service.wsService.callService(NextScript, "setUserSettings", Names, Values);
    else
    {
	    var Cont = typeof(NextScript)!="undefined" ? NextScript : "";
	    eval("function Done(){" + Cont.replace("\"", "\\\"") + ";}");
	    document.all.service.wsService.callService(Done, "setUserSettings", Names, Values);
	}
}

function j_setAdministration(accountingId, periodId, NextScript)
{
    if (typeof(NextScript)=="function")
	    document.all.service.wsService.callService(NextScript, "setAdministration", accountingId, periodId);
    else
    {
	    var Cont = typeof(NextScript)!="undefined" ? NextScript : "";
	    eval("function Done(){" + Cont.replace("\"", "\\\"") + ";}");
	    document.all.service.wsService.callService(Done, "setAdministration", accountingId, periodId);
	}
}

function j_silent_dialog(Action, BasePageUrl, DialogForm, DialogWidth, DialogHeight, Title, FormType, Redirect, DescriptionColumn, ExtraParam)
{
	var hidCurrentId = document.all.item("hidCurrentId");
	var hidTable	 = document.all.item("hidTable");
	var hidId		 = document.all.item("hidId");
	var hidParentId  = document.all.item("hidParentId");
	var hidParentTable  = document.all.item("hidParentTable");
	var Obj, ActionUrl, SilentAction;

	SilentAction = Action != null && Action != '' ? Action : 'UpdateGridAfterSilentAction';
	if (typeof(Title)=="undefined") Title = "";
	if (typeof(ExtraParam)=="undefined") ExtraParam = "";
	if (typeof(FormType)=="string")
	{
		var Size = new j_FormType2Size(FormType, DialogWidth, DialogHeight);
		DialogWidth = Size.Width;
		DialogHeight = Size.Height;
	}
	Obj = j_opendialog_base(BasePageUrl, 
					DialogForm, 
					'currentid=' + hidCurrentId.value +'&table=' + hidTable.value + '&parentid=' + (hidParentId != null ? hidParentId.value : "") + '&parenttable=' + (hidParentTable != null ? hidParentTable.value : "") + '&CurrentSelection=' + hidId.value + ExtraParam, 
					DialogWidth, 
					DialogHeight,
					null,
					null,
					Title);				
	if (typeof(Obj)!='undefined'&& typeof(Obj.Result)!='undefined' && Obj.Result!='Abort') 
	{
		j_silent_action(BasePageUrl, SilentAction, Obj.Setting);
		if (typeof(Redirect)=="undefined") Redirect = "";
		if (Redirect!="") 
		{
			// Navigation
			var urlHistory		= j_setUrlParam(document.URL, "CurrentId", hidCurrentId.value);
			j_AddToHistory(urlHistory, DescriptionColumn);
			// Redirect to tab not longer available!
			var sUrl = j_setUrlParam(document.location.href, "page", Redirect);
			sUrl	 = j_setUrlParam(sUrl, "ParentPage", j_getUrlParam(document.location.href, "Page"));
			// Reset ParentId!!
			sUrl	= j_setUrlParam(sUrl, "ParentId", "0");
			window.navigate(sUrl);
		}
	}
	else
	    j_Command('Refresh');
}

function j_show_dialog(BasePageUrl, DialogForm, DialogWidth, DialogHeight, Title, FormType, ExtraParam)
{
	var hidCurrentId = document.all.item("hidCurrentId");
	var hidTable	 = document.all.item("hidTable");
	var hidId		 = document.all.item("hidId");
	var hidParentId = document.all.item("hidParentId");
	var Obj;

	if (typeof(Title)=="undefined") Title = "";
	if (typeof(ExtraParam)=="undefined") ExtraParam = "";
	if (typeof(FormType)=="string")
	{
		var Size = new j_FormType2Size(FormType, DialogWidth, DialogHeight);
		DialogWidth = Size.Width;
		DialogHeight = Size.Height;
	}
	Obj = j_opendialog_base(BasePageUrl, 
					DialogForm, 
					'currentid=' + hidCurrentId.value +'&table=' + hidTable.value + '&parentid=' + (hidParentId != null ? hidParentId.value : "") + '&CurrentSelection=' + hidId.value + ExtraParam, 
					DialogWidth, 
					DialogHeight,
					null,
					null,
					Title);				
}

// ----------------------------------------------------------------------------
// Variables and functions for tabbed dialog pages, see ADialogPage for more
// information
// ----------------------------------------------------------------------------
var	SelectedTabIndex	= -1;
var	hidSelectedTab;
var	TabPanelStates;

function tabPanelState(TabPanel, TabHeader)
{
	this.TabPanel	= TabPanel;
	this.TabHeader	= TabHeader;
}

function j_showTabPanel(Index)
{
	if (Index != SelectedTabIndex)
	{
		if (SelectedTabIndex >= 0 && SelectedTabIndex < TabPanelStates.length)
		{
			TabPanelStates[SelectedTabIndex].TabPanel.className	= 'TABPANEL';
			TabPanelStates[SelectedTabIndex].TabHeader.className= 'TABHEADER';
		}

		if (Index >= 0 && Index < TabPanelStates.length && TabPanelStates[Index].TabPanel != null)
		{
			TabPanelStates[Index].TabPanel.className			= 'TABPANELSELECTED';
			TabPanelStates[Index].TabHeader.className			= 'TABHEADERSELECTED';
		}

		SelectedTabIndex	= Index;

		if (hidSelectedTab != null)
			hidSelectedTab.value	= Index;
	}
}

//////////////////////////////////////////////////////
// Function j_pcSetRowDisplay sets the style display
// property of a row of a positioning control.
//
// Parameters:
//  controlId:	Id of a control. The style display 
//				property of the table row containing this
//				control will be set;
//	display:	New style display value. Valid values are:
//				'block', 'none';
//////////////////////////////////////////////////////
function j_pcSetRowDisplay(controlId, display)
{
	var	control	= document.all.item(controlId);
	var row;
	
	if (control != null)
	{
		if (control.length>0)
			control	= control[0];

		row	= control;
		while(row.parentElement != null)
		{
			if ((row.parentElement.tagName == "TBODY" && row.parentElement.parentElement.className == "APositioningSubTable")
			|| (row.parentElement.tagName == "TABLE" && row.parentElement.className == "APositioningSubTable"))
			{
				row.style.display = display;
				break;
			}
			row	= row.parentElement
		}
		//control.parentElement.parentElement.style.display = display;
		control.style.display = display;
	}
}

//////////////////////////////////////////////////////
// Function j_pcSetLabelText sets the label text
// for a control in a positioning control.
//
// Parameters:
//  controlId:	Id of a control. The corresponding label
//				of this control will be set;
//	labelText:	New label value.
//////////////////////////////////////////////////////
function j_pcSetLabelText(controlId, labelText)
{
	var	control	= document.all.item(controlId);
	var	labelTd, label;
	
	if (control != null)
	{
		labelTd	= control.parentElement.previousSibling;
		if (labelTd != null)
		{
			label			= labelTd.hasChildNodes() ? labelTd.firstChild : labelTd;
			label.innerText	= labelText;
		}
	}
}

//////////////////////////////////////////////////////
// Function j_LogWebPage calls amiweblogpage to log a 
// web request.
//
// Parameters:
//  iFrameId:	Id of IFRAME to use for hidden request;
//	menuId:		Database id of the menu selected by the 
//				user;
//	url:		The url the page that is displayed;
//	pageTitle:	User friendly page title of the page 
//				which is displayed, e.g., the menu 
//				item label.
//////////////////////////////////////////////////////
function j_LogWebPage(iFrameId, menuId, url, pageTitle, projectPage)
{
	iFrame	= document.all.item(iFrameId);

	if (iFrame != null && url != null && url.length>0)
	{
		url = url.replace(/\?/g,"%3F");
		url = url.replace(/&/g,"%26");
		url = url.replace(/=/g,"%3D");

		iFrame.src = projectPage + "?Page=AMIWebLogPage&MenuId=" + menuId + "&PageTitle=" + pageTitle + "&LogPage=" + url;
	}
}

function j_reDirect(Page)
{
	var form		= document.forms[0];
	var btnCommand	= document.all.item("btnCommand");
	
	
	if (btnCommand!=null && btnCommand.disabled==false)
	{
		btnCommand.disabled = true;
		form.action = form.action.split('?')[0] + '?Page=' + Page;
		form.submit();
	}
	else 
		if (event==null || event.type!="keydown")
			j_ShowWaitingForResponse();
	
}


///////////////////////////////////
// Excel import/export functions //
///////////////////////////////////
var Alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
function jx_getExcelColumnIndex(oRow, cellIndex)
{
	var value;
	var result = 0;
	
	if ( oRow != null )
	{
		value = oRow.cells[cellIndex].value;
		if ( (value != null) && (typeof(value) != 'undefined') )
		{
			while ( value.length > 0 )
			{
				if ( value.length > 1 )
					result += 26 * ( Alphabet.indexOf(value.charAt(0)) + 1 );
				else
					result += Alphabet.indexOf(value.charAt(0));
				
				value = value.substring(1, value.length);
			}
		}
	}

	return result;	
}

function jx_getExcelColumnValue(ColumnIndex)
{
	var temp;
	var result = '';

	while ( ColumnIndex >= 0 )
	{
		temp = parseInt(ColumnIndex / 26);
		if ( temp > 0 )
		{
			result		+= Alphabet.charAt(temp-1);
			ColumnIndex -= temp*26;
		}
		else
		{
			result		+= Alphabet.charAt(ColumnIndex);
			ColumnIndex  = -1;
		}
	}
	
	return result;
}

function jx_setNextExcelColumnValue(oEvent, newCellIndex)
{
	var index, tmpindex;
	var newValue = null;
	
	if ( oEvent.prevrow == null )
		newValue = Alphabet.charAt(0);
	else if ( newCellIndex < oEvent.newrow.cells.length )
	{
		index = jx_getExcelColumnIndex(oEvent.prevrow, newCellIndex);
		for ( var i = 0; i < oEvent.allrows.length; i++ )
		{
			tmpindex = jx_getExcelColumnIndex(oEvent.allrows[i], newCellIndex);
			if ( tmpindex > index )
				index = tmpindex;
		}
			
		newValue = ( index >= 0 ) ? jx_getExcelColumnValue(index + 1) : "";
	}
	
	if ( oEvent.newrow != null )
		if ( oEvent.newrow.cells.length > newCellIndex )
		{
			try
			{
				oEvent.newrow.cells[newCellIndex].value = newValue;
				for ( index = 0; index < oEvent.newrow.cells[newCellIndex].all.length; index++ )
					if ( oEvent.newrow.cells[newCellIndex].all(index).tagName == "INPUT" )
						oEvent.newrow.cells[newCellIndex].all(index).value = newValue;
			}
			catch (e) {}
		}
}

/*--------------------------------*/

function jx_checkExcelObject(id)
{
	var Excel	= document.all.item(id);
	if (Excel != null)
		if (typeof(Excel.Cells) != "undefined")
			return Excel.classid;
			
	return "";
}

// ----------------------------------------------------------------------------
// function jx_writeExcelObjectBeginTag determines which version of the MS 
// spreadsheet web component is installed on the client. After determinating 
// the correct classid, it dynamically writes a document tag with the correct 
// classid attribute.
// ----------------------------------------------------------------------------
function jx_writeExcelObjectBeginTag(id)
{
    // check if Office 11 spreadsheet web component is installed
	var a = "CLSID:";
	var b1 = "0002E559";
	var b2 = "0002E551";
	var b3 = "0002E510";
	document.writeln("<object id=\"excel1\" classid=\"" + a + b1 + "-0000-0000-C000-000000000046\" VIEWASTEXT style=\"display:none\"></OBJECT>");
	var	classid	= jx_checkExcelObject("excel1");

	if (classid.length == 0)
	{
		// check if Office 10 spreadsheet web component is installed
		document.writeln("<object id=\"excel2\" classid=\"" + a + b2 + "-0000-0000-C000-000000000046\" VIEWASTEXT style=\"display:none\"></OBJECT>");
		classid = jx_checkExcelObject("excel2");

		// Default to Office 9 web component
		if (classid.length == 0) classid = a + b3 + "-0000-0000-C000-000000000046";
	}

	document.writeln("<object id=\"" + id + "\" classid=\"" + classid + "\" VIEWASTEXT>");
}

function j_AddToEnd(Text, Delim, Value)
{
	return Text + (Text.length>0 ? Delim : "") + Value;
}
function j_RemoveLast(Text, Delim)
{
	var LastIndex = Text.lastIndexOf(Delim);
	return LastIndex>=0 ? Text.substr(0, LastIndex) : "";
}
function j_RollBack(Text, Delim, Index)
{
	var Count = Text.split(Delim).length;
	for (var i=0;i<Count-Index;i++)
		Text = j_RemoveLast(Text, Delim);
	return Text;
}
function j_RollBackHistory(Index)
{
	if (parent != null && parent.document != null)
	{
		if (parent.document.all.hidHistory != null) 
			parent.document.all.hidHistory.value	= j_RollBack(parent.document.all.hidHistory.value, '#', Index);
		if (parent.document.all.hidNavInfo != null) 
			parent.document.all.hidNavInfo.value	= j_RollBack(parent.document.all.hidNavInfo.value, ' -> ', Index);
		if (parent.document.all.hidNavLabel != null) 
			parent.document.all.hidNavLabel.value	= j_RollBack(parent.document.all.hidNavLabel.value, ' -> ', Index);
	}
}
function j_openPageOnHistoryStack(pageName, ExtraParams, Description)
{
	var urlPage;
	
	j_AddDescriptionToHistory(document.URL, Description)

	urlPage	= document.URL.split('?')[0] + "?page=" + pageName;
	urlPage	= j_setUrlParam(urlPage	, "ParentPage", j_getUrlParam(document.URL, "page"));
	if (ExtraParams && ExtraParams.length > 0)
		urlPage	+= ExtraParams[0] == '&' ? ExtraParams : '&' + ExtraParams;
		
	document.location.href = urlPage;
}

function j_openLinesView(linesView, ExtraParams, descriptionColumn, ignoreCurrentId)
{
	var urlHistory, urlLinesView;
	var currentView	= j_getUrlParam(document.URL, "page");
	var ParentId	= j_getUrlParam(document.URL, "ParentId");
	var ParentPage	= j_getUrlParam(document.URL, "ParentPage");
	var ParentTable	= j_getUrlParam(document.URL, "ParentTable");
	var	currentId	= document.all.hidCurrentId.value;
	var	currentTable= document.all.hidTable.value;
	var	startRow	= document.all.hidStartRow.value;
	
	if (ignoreCurrentId == null)
		ignoreCurrentId = false;
	
	if (!ignoreCurrentId && (currentId == "" || currentId == 0))
		window.alert(j_NOSELECTIONACTIVE);
	else
	{
		urlHistory		= j_setUrlParam(document.URL, "CurrentId", currentId);
		urlHistory		= j_setUrlParam(urlHistory, "StartRow", startRow);

		urlLinesView	= document.URL.split('?')[0] + "?page=" + linesView;
		urlLinesView	= j_setUrlParam(urlLinesView, "ParentId", currentId);
		urlLinesView	= j_setUrlParam(urlLinesView, "ParentTable", currentTable);
		urlLinesView	= j_setUrlParam(urlLinesView, "ParentPage", currentView);
		if (ExtraParams && ExtraParams.length > 0)
			urlLinesView	+= ExtraParams.substring(0,1) == '&' ? ExtraParams : '&' + ExtraParams;
		
		j_AddToHistory(urlHistory, descriptionColumn);
		document.location.href = urlLinesView;
	}
}

function j_AddToHistory(Url, descriptionColumn)
{
	var CurrentRow;
	var Text;
	var Label;
	
	if (descriptionColumn == null) 
	    descriptionColumn = 0;

	if (parent != null && parent.document != null)
	{
		CurrentRow	= document.all.item(document.all.hidTable.value + document.all.hidCurrentId.value);
		Text = '';
		if (CurrentRow!=null && CurrentRow.cells!=null)
		{
		    if (2 + descriptionColumn >= CurrentRow.cells.length)
		        descriptionColumn = 0;
		    Text = CurrentRow.cells(2 + descriptionColumn).innerText;
		}
		Label = document.all.lblTitle != null ? document.all.lblTitle.innerText : document.title;

		if (parent.document.all.hidNavInfo != null) 
			parent.document.all.hidNavInfo.value = j_AddToEnd(parent.document.all.hidNavInfo.value, " -> ", Text);
		if (parent.document.all.hidNavLabel != null) 
			parent.document.all.hidNavLabel.value = j_AddToEnd(parent.document.all.hidNavLabel.value, " -> ", Label);
		if (parent.document.all.hidHistory != null) 
			parent.document.all.hidHistory.value = j_AddToEnd(parent.document.all.hidHistory.value, '#', Url);
	}
}

function j_AddDescriptionToHistory(Url, Description)
{
	var Label;
	
	if (parent != null && parent.document != null)
	{
		Label		= document.all.lblTitle != null ? document.all.lblTitle.innerText : document.title;

		if (parent.document.all.hidNavInfo != null) 
			parent.document.all.hidNavInfo.value = j_AddToEnd(parent.document.all.hidNavInfo.value, " -> ", Description);
		if (parent.document.all.hidNavLabel != null) 
			parent.document.all.hidNavLabel.value = j_AddToEnd(parent.document.all.hidNavLabel.value, " -> ", Label);
		if (parent.document.all.hidHistory != null) 
			parent.document.all.hidHistory.value = j_AddToEnd(parent.document.all.hidHistory.value, '#', Url);
	}
}

function j_showMapPointWait(BtnId)
{
	var ctl		= null;
	var oFrame	= null;
	
	try 
	{
		ctl    = document.all.item(BtnId);
		oFrame = document.all.iMapPointFrame;
		
		if ( ctl != null )
			ctl.disabled = true;
		if ( oFrame == null )
		{
			oFrame = document.createElement("IFRAME");
			
			oFrame.style.position	= "absolute";
			oFrame.style.width		= "200px";
			oFrame.style.height		= "40px";
			oFrame.style.padding	= "4px";
			oFrame.style.textAlign	= "center";
			oFrame.style.borderStyle= "ridge";
			oFrame.style.borderWidth= "thin";
			oFrame.frameBorder		= "0";
			oFrame.id				= "iMapPointFrame";
			oFrame.src				= "about:blank";
			
			document.body.appendChild(oFrame);
			
			oFrame.contentWindow.document.writeln("<HTML>");
			oFrame.contentWindow.document.writeln("<HEAD>");
			
			for ( i=0; i < document.styleSheets.length; i++ )
				oFrame.contentWindow.document.writeln("<LINK href=\"" + document.styleSheets[i].href + "\" type=\"text/css\" rel=\"stylesheet\">");
				
			oFrame.contentWindow.document.writeln("</HEAD>");
			oFrame.contentWindow.document.writeln("<BODY style=\"text-align:center\">");
			oFrame.contentWindow.document.writeln("<BR><SPAN class=\"AError\">" + j_PATIENCEPLEASE + "</SPAN>");
			oFrame.contentWindow.document.writeln("</BODY>");
			oFrame.contentWindow.document.writeln("</HTML>");
		}

		oFrame.style.left		= (document.body.clientWidth - parseInt(oFrame.style.width)) / 2;
		oFrame.style.top		= (document.body.clientHeight - parseInt(oFrame.style.height)) / 2;		
		oFrame.style.visibility = 'visible';
	}
	catch (e) 
	{ 
		alert(j_REMOVEPOPUPCHECK);
	}
}

function j_showContentPickPlace(oTextBox)
{
	var fileSrc;
	var obj			= new Object();
	var	result;
	var dialogArg	= "resizable: no; help: no; status: no; scroll: no;dialogWidth:540px;dialogHeight:440px;";

	obj.noresize= true;
	obj.src		= "../Pages/AMIContentList.aspx?";
	obj.title	= "Selecteer bestand";
	obj.opener	= window;

	fileSrc		= window.showModalDialog("../Pages/amipopup.htm", obj, dialogArg);

	if (fileSrc != null && fileSrc.length > 0)
		oTextBox.value = fileSrc;
}

function j_showImagePickPlace(oTextBox)
{
	var fileSrc;
	var obj			= new Object();
	var	result;
	var dialogArg	= "resizable: no; help: no; status: no; scroll: no;dialogWidth:540px;dialogHeight:440px;";

	obj.noresize= true;
	obj.src		= "../Pages/AMIImageList.aspx?";
	obj.title	= "Selecteer afbeelding";
	obj.opener	= window;

	fileSrc		= window.showModalDialog("../Pages/amipopup.htm", obj, dialogArg);

	if (fileSrc != null && fileSrc.length > 0)
		oTextBox.value = fileSrc;
}

function j_vpHelp()
{
	var page		= j_getUrlParam(window.location.href, "Page");

	if(page != null && page.length > 0 && page.toLowerCase() != "ctmdocumentpage")
		window.open("../Help/" + page + ".aspx",'_blank','width=800,height=600,toolbar=no,menubar=no,resizable=yes');
}

function j_basePath()
{
	url	= j_baseAspx();
	url	= url.substring(0, url.lastIndexOf("/") + 1);

	return url;
}

function j_baseAspx()
{
	var oBaseColl = document.all.tags('BASE');
	url = (oBaseColl && oBaseColl.length) ? oBaseColl[0].href : window.location.href;
	url	= url.split('?')[0];
	
	return url;
}

/** Swyx functions **/

var oPhoneLineMgr = null;
function j_swyxDial(telno)
{
	try
	{
		if (oPhoneLineMgr == null)
			oPhoneLineMgr	= new ActiveXObject("CLMgr.ClientLineMgr");
		oPhoneLineMgr.DispSimpleDial("0" + telno);
	}
	catch (e) {}
}

function j_swyxSpeedDial(telno)
{
	try
	{
		if (oPhoneLineMgr == null)
			oPhoneLineMgr	= new ActiveXObject("CLMgr.ClientLineMgr");
		oPhoneLineMgr.DispSimpleDial(telno);
	}
	catch (e) {}
}

function j_swyxCurrentPeer()
{
	try
	{
		if ( oPhoneLineMgr == null )
			oPhoneLineMgr = new ActiveXObject("CLMgr.ClientLineMgr");
			
		if ( oPhoneLineMgr.DispSelectedLine != null )
		{
			var CurrentPeer = oPhoneLineMgr.DispSelectedLine.DispPeerNumber;
			if ( CurrentPeer.length > 4 )
				j_Command("Swyx:" + CurrentPeer, null);
			else
				alert(j_SWYXERRORLINE1 + '\n' + j_SWYXERRORLINE2);
		}
	}
	catch (e) {}
}

function j_getSwyxSpeedDials(status)
{
    var speedDials = new Array();
	try
	{
		if ( oPhoneLineMgr == null )
			oPhoneLineMgr = new ActiveXObject("CLMgr.ClientLineMgr");
        for (var i=0; i<oPhoneLineMgr.DispNumberOfSpeedDials; i++)
            if (oPhoneLineMgr.DispSpeedDialState(i) == status)
                speedDials[speedDials.length] = oPhoneLineMgr.DispSpeedDialName(i);
	}
	catch (e) 
	{
	    speedDials = new Array();
	}
	return speedDials;
}

function j_getSwyxSpeedStatus()
{
    var speedDials = new Array();
	try
	{
		if ( oPhoneLineMgr == null )
			oPhoneLineMgr = new ActiveXObject("CLMgr.ClientLineMgr");
        for (var i=0; i<oPhoneLineMgr.DispNumberOfSpeedDials; i++)
            if (oPhoneLineMgr.DispSpeedDialState(i) == 2 || oPhoneLineMgr.DispSpeedDialState(i) == 3)
            {
                var item = new Array();
                item[0] = oPhoneLineMgr.DispSpeedDialName(i);
                item[1] = oPhoneLineMgr.DispSpeedDialState(i);
                item[2] = oPhoneLineMgr.DispSpeedDialNumber(i);
                speedDials[speedDials.length] = item;
            }
	}
	catch (e) 
	{
	    speedDials = new Array();
	}
	return speedDials;
}

function j_getAvailableSwyxSpeedDials()
{
    return j_getSwyxSpeedDials(2);
}

function j_getBusySwyxSpeedDials()
{
    return j_getSwyxSpeedDials(3);
}

function j_getCurrentSwyxPeer()
{
	var CurrentPeer = '';
	
	try
	{
		if ( oPhoneLineMgr == null )
			oPhoneLineMgr = new ActiveXObject("CLMgr.ClientLineMgr");
			
		if ( oPhoneLineMgr.DispSelectedLine != null )
			CurrentPeer = oPhoneLineMgr.DispSelectedLine.DispPeerNumber;
	}
	catch (e) {}
		
	return CurrentPeer;
}

/** Toolbar Menu functions **/
function j_showToolBarMenu(IconId, TableId)
{
	var tblMenu = document.all.item(TableId);
	if ( tblMenu != null )
	{
		if ( event.srcElement != null )
		{
			if ( event.srcElement.id == IconId  )
			{
				// Set correct position and show the clicked menu.
				tblMenu.style.pixelLeft = event.clientX;
				tblMenu.style.pixelTop  = event.clientY;
							
				var frameHeight = document.body.clientHeight;
				var tableHeight = tblMenu.offsetHeight;
				
				if ( (tableHeight + event.clientY) > frameHeight )
					tblMenu.style.pixelTop = frameHeight - tableHeight - 5;
			
				tblMenu.style.visibility = 'visible';
				
				// Focus on the clicked menu.				
				tblMenu.focus();
			}
		}
	}
}

function j_hideToolBarMenu(TableId)
{
	var tblMenu = document.all.item(TableId)
	if ( tblMenu != null )
	{
		if ( document.activeElement != null )
		{
			// Only hide menu when the clicked element doesn't belong to the menu.
			if ( document.activeElement.id.indexOf(TableId) != 0 )
				j_runFilterAndHide(tblMenu);
		}
		else
			j_runFilterAndHide(tblMenu);
	}
}


function j_runFilterAndHide(Table)
{
	if ( Table != null )
	{
		if ( Table.filters.length > 0 )
		{
			Table.filters[0].Apply();
			Table.style.visibility = 'hidden';
			Table.filters[0].Play();
		}
		else
			Table.style.visibility = 'hidden';
	}
}

/** Fullscreen toolbaricon function **/
function j_showFullScreen()
{
	var height	= window.screen.availHeight;
	var width	= window.screen.availWidth;
	var url		= j_setUrlParam(window.location.href, 'FullScreen', 'true');
	var props	= 'help:no;resizable:no;status:yes;dialogWidth:' + width + 'px;dialogHeight:' + height + 'px;';
	var obj		= new Object();
	
	obj.opener = window;
	
	try
	{
		var result = window.showModalDialog(url, obj, props);
		if ( document.forms.length > 0 )
			document.forms[0].submit();
	}
	catch (e)
	{
		alert(j_REMOVEPOPUPCHECK);
	}	
}
