<!-- // hide scripts for JavaScript disabled browsers

/*
 * Version 11/06/2009
 */

/*
 * GENERAL VARIABLES BLOCK
 */
/* variable to manage the supertooltips and their z-indexes */
var overlaySupertooltipMngr = null;

var maskActive=false;
var leaveMsg=null;
var menuPopupMaskActive=false;

var panel = null;
var panelLoading = null;
var panelConfirm = null;
var panelProgress = null;
var panelSupertooltip = null;
var panelContent = null;
var RIA_PARAM_REDIRECT = "f_AJAXRedirect";
var RIA_PARAM_POPUP = "f_popup";
var RIA_PARAM_ERROR = "f_error";
var Dom = YAHOO.util.Dom;
var Event = YAHOO.util.Event;
var browserName = navigator.appName;
var IE = "Microsoft Internet Explorer";
var NN = "Netscape"; // Firefox also is a Netscape type browser
var quickNavPanel = null;
var quickNavPanelClose = false;
var yuiLoader = new YAHOO.util.YUILoader({base:"script/yui-2.7.0/"});
var hasMask = false;
var confirmOK = "OK";
var confirmCancel = "Cancel";
var activatePanelAfterLoad = false;
var compatibleFlashVersionForFileUpload = "9.0.45";
var compatibleFlashVersionGeneral = "9.0.115";

/**
 * Make sure that all functions described in this file have a unique name
 * even if they're local functions (IE has problems with same named functions)
 */  
initRiaPage();

function initRiaPage() {
	try {
		
		/**
		 * To avoid problems when using multiple applications from different domains (eg 'agenda.dolmen.be' & 'mail.dolmen.be')
		 * we set the domain to the suffix of these domains (eg 'dolmen.be') so that they can communicate
		 * If the domain exist of only one piece (eg 'localhost') we don't change it
		 */
		 var domainParts = document.domain.split(".");
		 var numberOfDomainParts = domainParts.length;
		 
		 if (numberOfDomainParts > 1 ){
		 	document.domain = domainParts[numberOfDomainParts - 2] + "." + domainParts[numberOfDomainParts - 1];
		 }
		
		/*
		 * TODO IE8
		 */
		if (browserName == IE) {
			
			/**
			 * the next method prevents the IE6 flickering problem - must be checked in the future,
			 * can possibly be solved by CSS (see http://www.webreference.com/programming/css_flicker/index.html)
			 * problem = backgroundimages are reloaded every time the mouse is moved over it
			 */
			try {
				document.execCommand("BackgroundImageCache", false, true);
			} catch(error) {
				/**
				 * If an error occurs in the init() method which runs every time a page is loaded, you would expect that the logError method will be called.
				 * However if we would do that the server would log the error and redirect the page to the fault.jsp page and this page also calls the init()
				 * method when loaded resulting in an infinite loop between client and server. To avoid this no logging is done.
				 */
			}
			
		}
		
		/*
		 * AddModules to YUILoader so that we can dynamically load our own CSS files
		 */
		yuiLoader.addModule({name: "popupCSS",
							 type: "css",
							 fullpath: "theme/popup.css"});
		yuiLoader.addModule({name: "quickNavCSS",
							 type: "css",
							 fullpath: "theme/quickNav.css"});
		
		if(window.top.frames[0]) {
					 
			window.top.frames[0].closePopupLoading();
			showMenuPopup("menuPopupMask");
			showMenuPopup("menuPopupConfirmMask");

		}

		
	} catch(error) {
		/**
		 * If an error occurs in the init() method which runs every time a page is loaded, you would expect that the logError method will be called.
		 * However if we would do that the server would log the error and redirect the page to the fault.jsp page and this page also calls the init()
		 * method when loaded resulting in an infinite loop between client and server. To avoid this no logging is done.
		 */
	}
}

/**
 * This function will call a ctrl method asynchronously when the base.jsp loads. Information which needs to be 
 * passed from the javascript to make it available in the session will be passed along with the 
 * request. From the ctrl method, the information can be set in appropriate objects in the session for further
 * processing.
 */
function initializeAppStartupParams() {

	try {
		
		var timeStamp = new Date().getTime();
		var url = "AppServlet?m=RIAStartupCtrl.intializeSessionInfo&rTS=" + timeStamp;
		var paramStr = "";
		var paramsList = new Array();
		var isCompatibleGeneral = isFlashVersionCompatible(compatibleFlashVersionGeneral);
		
		//param 1 - Flash File Upload	
		var isCompatibleFileUpload = isFlashVersionCompatible(compatibleFlashVersionForFileUpload);
		var param1 = new Array("_compatibility_flash_fileUpload", isCompatibleFileUpload);
		paramsList.push(param1);	
		
		//param 2 - Flash Media Player
		var param2 = new Array("_compatibility_flash_general", isCompatibleGeneral);
		paramsList.push(param2);
		
		/* Add needed params in the paramsList below */
		
		//var paramX = new Array("paramX", "valueX");
		//paramsList.push(paramX);	
		
		if(paramsList.length > 0){
		
			var parm;			
			
			for (var i in paramsList) {			
				
				parm = paramsList[i];
				
				paramStr = paramStr + "&";
				paramStr = paramStr + parm[0];
				paramStr = paramStr + "=";
				paramStr = paramStr + parm[1];
			
			}
		
		}	
		
		url = url + paramStr;
									
		YAHOO.util.Connect.asyncRequest("GET", url); 
		
	} catch(error) {
		logError(error, "initializeAppStartupParams");
	}
}

// MASK CODE BELOW
// ***************
function showMask(idOfElement){
	try {
		
		var mask=null;
		
		if (idOfElement != "header") {
			
			mask=window.top.frames[0].document.createElement("div");
			mask.className= idOfElement+"Mask";
			mask.id=idOfElement+"Mask";
			window.top.frames[0].document.body.appendChild(mask);
		
		} else {
			
			mask=document.createElement("div");
			mask.className= idOfElement+"Mask";
			mask.id=idOfElement+"Mask";
			Dom.get("header").appendChild(mask);
			
		}
	
		Event.addListener(mask,"click",disactivateMasks);
		
	} catch(error) {
		logError(error, "showMask");
	}	
}

function hideMask(mask){
	try {
		
		if(mask.id != "headerMask") {
			window.top.frames[0].document.body.removeChild(mask);
		} else {
			Dom.get("header").removeChild(mask);
		}
		Event.removeListener(mask,"click",disactivateMasks);
		
	} catch(error) {
		logError(error, "hideMask");
	}	
}

function activateMasks(msg){
	try {
		
		leaveMsg = msg;
		
		if(!maskActive){
		
			showMask("menu");
			showMask("header");
			maskActive=true;
		
		}
		
	} catch(error) {
		logError(error, "activateMasks");
	}	
}

function hideMasks(){
	try {
		
		if(maskActive){
			
			var menuMask=window.top.frames[0].document.getElementById("menuMask");
			var headerMask=document.getElementById("headerMask");
			hideMask(menuMask);
			hideMask(headerMask);
			maskActive=false;
			
		}

	} catch(error) {
		logError(error, "hideMasks");
	}	
}

function disactivateMasks(){
	try {
		activatePopupConfirm(leaveMsg, function(){hideMasks();});
	} catch(error) {
		logError(error, "disactivateMasks");
	}	
}

// RIA JavaScript below
// ********************
/**
 * According to the description of the Event.addListener method there will be polling untill the element
 * we want to attach a listener to is available (using the onAvailable method). In practice however when we
 * apply this to dynamically loaded elements (using AJAX) everything runs well but the listener is not registered.
 * This should be due to the fact that sometimes something can already be available in the DOM-tree but not in 
 * the page which results in listeners not being registered (cfr bugreport 1886727 on sourceforge).
 * The solution is to manually wait untill the element is available (using onAvailable) and then attach the listener.
 */
function webAddListener(sourceId, event, callback, callbackParamArray, override) {
	try {
		
		function onAvailableAddListener(){
			Event.addListener(sourceId, event, callback, callbackParamArray, override);
		}
		
		Event.onAvailable(sourceId, onAvailableAddListener);
		
	} catch(error) {
		logError(error, "webAddListener");
	}
}

function disableSelectTags(disableBoolean) {

	/** because of a bug in IE6 the select tags create a problem -> They sometimes poke through the container 
	 *  and the modal mask. Then you can also change the value.
	 *  To avoid this, YAHOO sets all select tags in IE when a container is shown to unvisible, but then they
	 *  completely dissappear. If we however disable them then we can still see them but the values are not sent
	 *  to the server when a form is submitted. So we opted for the invisible scenario.
	 * 	TODO IE8
	 */ 

	if (browserName == IE) {

		var selectArray = document.getElementsByTagName("select");
		
		if (disableBoolean) {
		
			for (var i = 0; i < selectArray.length; i++){
				selectArray[i].style.visibility = "hidden";
			}
		
		} else {
				
			for (var i = 0; i < selectArray.length; i++){
				selectArray[i].style.visibility = "visible";
			}
		
		}
	
	}

}

function loadPopupCSSInBase() {
	try {
		
		yuiLoader.require("popupCSS");
		yuiLoader.onSuccess = null;
		yuiLoader.insert({});
				
	} catch(error) {
		logError(error, "loadPopupCSSInBase");
	}	
}

function extractScriptHTML(target, html){
	try {
		
		/**
		 * delete previous script input to avoid profileration of scripts
		 */
		var Node =document.getElementById(target + "Script");
		if (Node!=null) {
			Node.parentNode.removeChild(Node);
		}
	
		/**
		 * parse new content and put script in <head>
		 */
		var recogStartJs = "<script";
		var recogEndJs = "<\/script>";
		var scriptFound = false;
	
		var head= document.getElementsByTagName('head')[0];
		var script= document.createElement('script');
		script.type= 'text/javascript';
		script.id=target + "Script";
	
		while(html.indexOf(recogStartJs) != -1) {
			
			scriptFound = true;
			var startPos = html.indexOf(recogStartJs);
			var startPosScript = html.indexOf(">", startPos + recogStartJs.length)
			var stopPos = html.indexOf(recogEndJs);
			
			var js = html.substring(startPosScript + 1, stopPos);
	
			html = html.substring(0, startPos) + html.substring(stopPos + recogEndJs.length);
			script.text= script.text + js;
			
		}
		
		if(scriptFound){
			head.appendChild(script);
		}
	
		return html;
		
	} catch(error) {
		logError(error,"extractScriptHTML");
	}
}

function initGetJSP() {
	try {
	
		yuiLoader.require("connection");
		yuiLoader.onSuccess = null;
		yuiLoader.insert({});
		
	} catch(error) {
		logError(error, "initGetJSP");
	}	
}

function activateGetJSP(e, obj) {
	try {
		
		var m = obj[0];
		var target = obj[1];
		var form = obj[2];
		var timeStamp = new Date().getTime();
		var tempForm = null;
												
		function responseActivateGetJSPSuccess(o) {
		
			if(o.responseText.indexOf(RIA_PARAM_ERROR) != -1) {
				
				handleError();
				
			} else {
				
				try {
										
					var responseString = o.responseText.split(",",2);
					
					if (responseString[0] == RIA_PARAM_REDIRECT) {
					
						if(responseString[1].indexOf(".jsp") == -1) {
						
							if (form != null) {
															
								fillMAndSubmit(Dom.get(form), responseString[1]);
								
							} else {
									
								window.location = "AppServlet?m=" + responseString[1];
									
							}							
								
						} else {
													
							window.location = responseString[1];
											
						}
					
					} else {
			
						if (form != null) {
							
							tempForm = null;
							
						}
			
						var tempHTML = extractScriptHTML(target, o.responseText);
				
						if(Dom.get(target).innerHTML !=  tempHTML) {
					
							Dom.get(target).innerHTML = tempHTML;
					
						}
					
					}
						
				} catch(error) {
							
					logError(error, "responseActivateGetJSPSuccess");
				
				}
						
			}
		
		}
		
		function responseActivateGetJSPFailure(o) {
			
			var error = new Error();
			error.message = "failure retrieving JSP -> HTTP status: " + o.status + ", HTTP message: " + o.statusText + ", TransactionID: " + o.tld;
			error.lineNumber = "310";
			logError(error, "activateGetJSP");
			
		}
		
		var url = null;
		
		if (form!=null){
			
			/**
			 * To be able to upload files present in the form, set the second parameter of setForm to true
			 * This does however not use the _sFormData as container of the formdata but a iFrame copy in _formNode
			 */
			YAHOO.util.Connect.setForm(form); 
			url = "AppServlet?f_AJAX=Y&rTS=" + timeStamp;
			
			/**
			 * To be able to change the m of the form to the AJAX m we change it directly in the postFormData.
			 * This way we don't have to alter the real form on the HTML page but only in this specific request.
			 */
			var tempFormData = YAHOO.util.Connect._sFormData.split("&");
			
			for(var i=0; i<tempFormData.length; i++) {
				if (tempFormData[i].substring(0,2) == "m=") {
					tempFormData[i] = m;
					i = tempFormData.length;
				}
			}
			
			YAHOO.util.Connect._sFormData = tempFormData.join("&");
			
		} else {
			
			url = "AppServlet?f_AJAX=Y&" + m + "&rTS=" + timeStamp;
			
		}
					
		var callback = {
			success:responseActivateGetJSPSuccess,
			failure:responseActivateGetJSPFailure
		}
					
		YAHOO.util.Connect.asyncRequest("POST", url, callback); 
		
	} catch(error) {
		logError(error, "activateGetJSP");
	}
}

/* This function will be used for loading a prototype jsp asynchronously 
 * in a prototype application.
 * Currently getJSP tag is not implemented for prototypes. But this will
 * be used in the fileupload component.
 */
function activateGetJSPProto(e, obj) {

	try {
		
		var dest = obj[0];
		var target = obj[1];
		var timeStamp = new Date().getTime();
												
		function responseActivateGetJSPProtoSuccess(o) {
		
			if(o.responseText.indexOf(RIA_PARAM_ERROR) != -1) {
				
				handleError();
				
			} else {
				
				try {									
			
					var tempHTML = extractScriptHTML(target, o.responseText);
			
					if(Dom.get(target).innerHTML !=  tempHTML) {
				
						Dom.get(target).innerHTML = tempHTML;
				
					}
						
				} catch(error) {
							
					logError(error, "responseActivateGetJSPProtoSuccess");
				
				}
						
			}
		
		}
		
		function responseActivateGetJSPProtoFailure(o) {
			
			var error = new Error();
			error.message = "failure retrieving JSP -> HTTP status: " + o.status + ", HTTP message: " + o.statusText + ", TransactionID: " + o.tld;
			error.lineNumber = "310";
			logError(error, "responseActivateGetJSPProtoFailure");
			
		}
		
		var url = "AppServlet?f_AJAX=Y&" + dest + "&rTS=" + timeStamp;
						
		var callback = {
			success:responseActivateGetJSPProtoSuccess,
			failure:responseActivateGetJSPProtoFailure
		}
					
		YAHOO.util.Connect.asyncRequest("POST", url, callback); 
		
	} catch(error) {
		logError(error, "activateGetJSPProto");
	}
}

function initPopup(){
	try {

		function initPopupLoaderReady(){
		
			/*
			 * The following code will extend the panel widget:
			 * 1. when showing the popup we will also cover the menu & disable selecttags
			 * 2. when hiding the popup we will also show the menu again & enable selecttags
			 * this because we call the popup from inside the iframe of the
			 * application and from there we can't cover the menu automatically
			 */
			
			YAHOO.example.Popup = function(id, sGroup, config) {
			    YAHOO.example.Popup.superclass.constructor.apply(this, arguments);
			};
			
			YAHOO.lang.extend(YAHOO.example.Popup, YAHOO.widget.Panel, {
			    show: function() {
			    	 //Call the parent's show method
			        YAHOO.example.Popup.superclass.show.apply(this, arguments);
			        hideMenuPopup("menuPopupMask");
			        disableSelectTags(true);
			        
			        /*
			         * Position panel in the middle of the screen including the menu
			         * We must still change the position of the panel when we resize 
			         * (now it only is center on initial opening)
			         */
			        var newCenterX = this.cfg.getProperty("x") - (window.top.frames[0].document.getElementById("menu").offsetWidth /2);
			        this.cfg.setProperty("x", newCenterX);
			    },
			    hide: function() {
			        //Call the parent's hide method
			        YAHOO.example.Popup.superclass.hide.apply(this, arguments);
			       	showMenuPopup("menuPopupMask");
			       	disableSelectTags(false);
			    }
			    
			});
								
			panel = new YAHOO.example.Popup("myPopup", {zindex:15000,
													    fixedcenter: true,
													    close:false,  
													    visible:false,  
													    modal:true,
													    draggable: true,
													    constraintoviewport:true} );
						    
		}
		
		/**
		 * We test first whether we don't already have a panel. I we have there's
		 * no need to import the container widget of YUI and to initialize the panel again
		 * Beware of changing the structure of this function -> it might give problems
		 */
		if (panel == null) {
			
			function loadPopupCSS() {
		
				yuiLoader.require("popupCSS");
				yuiLoader.onSuccess = initPopupLoaderReady;
				yuiLoader.insert({});			 	
			
			}
			
			window.top.frames[0].loadPopupCSSInBase();
			
			/**
			 * If you use YUI Loader you have to initialize every instance you use in different methods
			 * because otherwise some methods might run when others are also running and thus overwritting
			 * some properties (eg if you load the "button" widget and in the mean time also the "container" widget
			 * you might overwrite the onSuccess function hence only doing one function in stead of both of them
			 */
			yuiLoader.require(["connection", "dragdrop", "container"]);
			yuiLoader.onSuccess = loadPopupCSS;
			yuiLoader.insert({});
				
		}
		
	} catch(error) {
		logError(error, "initPopup");
	}	
}

function activatePopup(e, args) {
	try {		
		
		/**
		 * To make sure we can show a popup when we only have a selectPanel on the screen we must always check whether we have
		 * already a popup initialized, if not we create one	 
		 */
		if (panel == null) {
			initPopup();
		}
				
		var m = args[0];
		var width = args[1];
		var header = args[2];
		var formId = args[3];
		var timeStamp = new Date().getTime();
		var newRequest = m + timeStamp;
		var url = null;
				
		function showPopup(){
		
			panel.render(document.body);
			Dom.addClass(panel.id, "popup");
			panel.show();
			
		}
		
		function setPopupProperties(){
		
			if (width == "1px" && browserName == NN) {
				panel.cfg.setProperty("width", "");
			} else {
				panel.cfg.setProperty("width", width);
			}
			
			/**
			 * if we just set the header to "" in IE we still see an empty header block
			 */
			if (header != "") { 
				displayProperty = "block";
			} else {
				displayProperty = "none";
			}
			
			panel.setHeader(header);
			panel.header.style.display = displayProperty;
			
			/**
			 * change underlay to fit panel with(out) header
			 */
			panel.sizeUnderlay();
					
		}
		
		function responseSearchPopupSuccess(o){
		
			if(o.responseText.indexOf(RIA_PARAM_ERROR) != -1) {
				
				handleError();
				
			} else {
					
				try {	
							
					var responseString = o.responseText.split(",",2);
					
					if (responseString[0] == RIA_PARAM_REDIRECT) {
					
						if(responseString[1].indexOf(".jsp") == -1) {
						
							if (formId != "") {
															
								fillMAndSubmit(Dom.get(formId), responseString[1]);
								
							} else {
									
								window.location = "AppServlet?m=" + responseString[1];
									
							}							
								
						} else {
													
							window.location = responseString[1];
											
						}
					
					} else {
						
						panel.setBody(extractScriptHTML("panelPopup", o.responseText));
						panelContent=newRequest;
							
						setPopupProperties();
						showPopup();
					
					}
				
				} catch(error) {
	
					logError(error, "responseSearchPopupSucces");
				
				}
			
			}
			
		}
		
		function responseSearchPopupFailure(o){
			var error = new Error();
			error.message = "failure retrieving popup -> HTTP status: " + o.status + ", HTTP message: " + o.statusText + ", TransactionID: " + o.tld;
			error.lineNumber = "530";
			logError(error, "responseSearchPopupFailure");
		}
									
		var callback = {
			success:	responseSearchPopupSuccess,
			failure:	responseSearchPopupFailure
		}
		
		/**
		 * to make sure that scripts are only loaded once (otherwise listeners are not added correctly) and for performance
		 * if parameters are added to 'm' other then directly in the m-var then panelContent must be updated to 
		 * ensure uniqueness per JPS loaded
		 */	
		if (formId != ""){
						
			var newForm = YAHOO.util.Connect.setForm(formId);
			newRequest = newRequest + newForm;
			url = "AppServlet?f_AJAX=Y&rTS=" + timeStamp;
			
			var tempPos_index = m.indexOf("_index=");
			
			/**
			 * To be able to change the m of the form to the AJAX m we change it directly in the postFormData.
			 * This way we don't have to alter the real form on the HTML page but only in this specific request.
			 */
			var tempFormData = YAHOO.util.Connect._sFormData.split("&");
		
			/**
			 * To be able to set the _index value we must reset in the copy of the form because we're setting it on the server in the m argument
			 * of the function. If we don't change it here we have 2 fields with name = "_index" and then the server can't process the correct m
			 */
			if (tempPos_index != -1) {
								
				for(var i=0; i<tempFormData.length; i++) {
					if (tempFormData[i].substring(0,7) == "_index=") {
						tempFormData[i] = m.substring(tempPos_index);
						i = tempFormData.length;
					}
				}
				
				m = m.substring(0, tempPos_index - 1);
			
			}
					
			for(var i=0; i<tempFormData.length; i++) {
				if (tempFormData[i].substring(0,2) == "m=") {
					tempFormData[i] = m;
					i = tempFormData.length;
				}
			}
			
			YAHOO.util.Connect._sFormData = tempFormData.join("&");
			
		} else {
			
			url = "AppServlet?f_AJAX=Y&" + m + "&rTS=" + timeStamp;
		}
		
		if (newRequest != panelContent) {
		    
			YAHOO.util.Connect.asyncRequest("GET", url, callback);
			
		} else {
			
			setPopupProperties();
			showPopup();
			
		}
		
	} catch(error) {
		logError(error, "activatePopup");
	}
}

function initPopupLoading() {
	try {
			
		window.top.frames[0].initPopupLoadingBase();
		
	} catch(error) {
		logError(error, "initPopupLoading");
	}	
}

function initPopupLoadingBase(){
	try {
		
		function initPopupLoadingLoaderReady(){
		
			/*
			 * The following code will extend the panel widget:
			 * 1. when showing the popup we will disable selecttags
			 * 2. when hiding the popup we will enable selecttags
			 */
			
			YAHOO.example.PopupLoading = function(id, sGroup, config) {
			    YAHOO.example.PopupLoading.superclass.constructor.apply(this, arguments);
			};
			
			YAHOO.lang.extend(YAHOO.example.PopupLoading, YAHOO.widget.Panel, {
			    show: function() {
			    	 //Call the parent's show method
			        YAHOO.example.PopupLoading.superclass.show.apply(this, arguments);
			        window.top.baseFrame.application.disableSelectTags(true);
			    },
			    hide: function() {
			        //Call the parent's hide method
			        YAHOO.example.PopupLoading.superclass.hide.apply(this, arguments);
			       	window.top.baseFrame.application.disableSelectTags(false);
			    }
			    
			});
													
			panelLoading = new YAHOO.example.PopupLoading("myPopupLoading", {zindex:15000,
													    		   fixedcenter: true,
	         												       close:false,  
													    		   visible:false,  
													    		   modal:true,
													    		   draggable: false,
													    		   constraintoviewport:true} );
					
													    
		}
			
		/**
		 * We test first whether we don't already have a panel. I we have there's
		 * no need to import the container widget of YUI and to initialize the panel again
		 * Beware of changing the structure of this function -> it might give problems
		 */
		if (panelLoading == null) {
			
			function loadPopupLoadingCSS() {
								
				yuiLoader.require("popupCSS");
				yuiLoader.onSuccess = initPopupLoadingLoaderReady;
				yuiLoader.insert({});			 	
			
			}
			
			/**
			 * If you use YUI Loader you have to initialize every instance you use in different methods
			 * because otherwise some methods might run when others are also running and thus overwritting
			 * some properties (eg if you load the "button" widget and in the mean time also the "container" widget
			 * you might overwrite the onSuccess function hence only doing one function in stead of both of them
			 */
			yuiLoader.require("dragdrop", "container");
			yuiLoader.onSuccess = loadPopupLoadingCSS;
			yuiLoader.insert({});
				
		} else {
			
			initPopupLoadingLoaderReady();
			
		}
		
	} catch(error) {
		logError(error, "initPopupLoadingBase");
	}		
}

function activatePopupLoading(e, args) {
	try {
		
		window.top.frames[0].activatePopupLoadingBase(e, args);
		
	} catch(error) {
		logError(error, "activatePopupLoading");
	}	
}

function activatePopupLoadingBase(e, args) {
	try {
		
		/**
		 * To make sure we can show a popup when we only have a selectPanel on the screen we must always check whether we have
		 * already a popup initialized, if not we create one	 
		 */
		if (panelLoading == null) {
			initPopupLoading();
		}
		
		var header = args[0];
		var bodyLoading = "<div align='center'><br/><img alt='Please wait...' src='pic/loader_bar.gif'></div>";
				
		function showPopupLoading(){
		
			panelLoading.render(document.body);
			Dom.addClass(panelLoading.id, "popup");
			panelLoading.show();
			
		}
		
		function setPopupLoadingProperties(){
		
			panelLoading.cfg.setProperty("width", "240px");
						
			/**
			 * if we just set the header to "" in IE we still see an empty header block
			 */
			if (header != "") { 
				displayProperty = "block";
			} else {
				displayProperty = "none";
			}
			
			if (header != undefined) {
				panelLoading.setHeader(header);
				panelLoading.header.style.display = displayProperty;
			}
						
			/**
			 * change underlay to fit panel with(out) header
			 */
			panelLoading.sizeUnderlay();
					
		}
		
		panelLoading.setBody(bodyLoading);
					
		setPopupLoadingProperties();
		showPopupLoading();
		
	} catch(error) {
		logError(error, "activatePopupLoadingBase");
	}	
}

function closePopupLoading() {
	try {
		
		if (panelLoading != null) {
			
			panelLoading.hide();
	
		}
		
	} catch(error) {
		logError(error, "closePopupLoading");
	}	
}

function initPopupProgress() {
	try {
	
		if(window.top.frames[0].name == "baseFrame"){
			window.top.frames[0].initPopupProgressBase();
		} else {
			window.top.initPopupProgressBase();
		}
		
	} catch(error) {
		logError(error, "initPopupProgress");
	}	
}

function initPopupProgressBase(){

	try {
		
		function initPopupProgressLoaderReady(){
		
			/*
			 * The following code will extend the panel widget:
			 * 1. when showing the popup we will disable selecttags
			 * 2. when hiding the popup we will enable selecttags
			 */
			 
			var baseFrameObj = null;
		
			if(window.top.frames[0].name == "baseFrame"){
				baseFrameObj = window.top.frames[0];
			} else {
				baseFrameObj = window.top;
			}
			
			YAHOO.example.PopupLoading = function(id, sGroup, config) {
			    YAHOO.example.PopupLoading.superclass.constructor.apply(this, arguments);
			};
			
			YAHOO.lang.extend(YAHOO.example.PopupLoading, YAHOO.widget.Panel, {
			    show: function() {
			    	 //Call the parent's show method
			        YAHOO.example.PopupLoading.superclass.show.apply(this, arguments);
			        baseFrameObj.application.disableSelectTags(true);
			    },
			    hide: function() {
			        //Call the parent's hide method
			        YAHOO.example.PopupLoading.superclass.hide.apply(this, arguments);
			       	baseFrameObj.application.disableSelectTags(false);
			    }
			    
			});
													
			panelProgress = new YAHOO.example.PopupLoading("myPopupProgress", {zindex:15000,
													    		   fixedcenter: true,
	         												       close:false,  
													    		   visible:false,  
													    		   modal:true,
													    		   draggable: false,
													    		   constraintoviewport:true} );
													    
		}
			
		/**
		 * We test first whether we don't already have a panel. I we have there's
		 * no need to import the container widget of YUI and to initialize the panel again
		 * Beware of changing the structure of this function -> it might give problems
		 */
		if (panelProgress == null) {
			
			function loadPopupProgressCSS() {
								
				yuiLoader.require(["popupCSS"]);
				yuiLoader.onSuccess = initPopupProgressLoaderReady;
				yuiLoader.insert({});			 	
			
			}
			
			/**
			 * If you use YUI Loader you have to initialize every instance you use in different methods
			 * because otherwise some methods might run when others are also running and thus overwritting
			 * some properties (eg if you load the "button" widget and in the mean time also the "container" widget
			 * you might overwrite the onSuccess function hence only doing one function in stead of both of them
			 */
			yuiLoader.require("dragdrop", "container");
			yuiLoader.onSuccess = loadPopupProgressCSS;
			yuiLoader.insert({});
				
		} else {
			
			initPopupProgressLoaderReady();
			
		}
		
	} catch(error) {
		logError(error, "initPopupProgressBase");
	}	
		
}

function activatePopupProgress(e, args) {
	try {
			
		if(window.top.frames[0].name == "baseFrame"){
			window.top.frames[0].activatePopupProgressBase(e, args);
		} else {
			window.top.activatePopupProgressBase(e, args);
		}	
		
	} catch(error) {
		logError(error, "activatePopupProgress");
	}	
}

function activatePopupProgressBase(e, args) {

	try {
		
		/**
		 * To make sure we can show a popup when we only have a selectPanel on the screen we must always check whether we have
		 * already a popup initialized, if not we create one	 
		 */
		if (panelProgress == null) {
			initPopupProgress();
		}
		
		var header = args[0];
		var progressBarEl = args[1];
		var displayProperty;
				
		function showPopupProgress(){
		
			panelProgress.render(document.body);
			Dom.addClass(panelProgress.id, "popup");
			panelProgress.show();
			
		}
		
		function setPopupProgressProperties(){
		
			panelProgress.cfg.setProperty("width", "240px");
						
			/**
			 * if we just set the header to "" in IE we still see an empty header block
			 */
			if (header != "") { 
				displayProperty = "block";
			} else {
				displayProperty = "none";
			}
			
			if (header != undefined) {
				panelProgress.setHeader(header);
				panelProgress.header.style.display = displayProperty;
			}
						
			/**
			 * change underlay to fit panel with(out) header
			 */
			panelProgress.sizeUnderlay();
					
		}
		
		var baseFrameObj = null;
		
		if(window.top.frames[0].name == "baseFrame"){
			baseFrameObj = window.top.frames[0];
		} else {
			baseFrameObj = window.top;
		}
		
		var progress = baseFrameObj.application.document.getElementById(progressBarEl);		
		var bodyLoading = '<div align="center"><div id="popupProgressbar" class="uploadProgressBar">' + progress.innerHTML + '</div></div>';
		
		panelProgress.setBody(bodyLoading);
					
		setPopupProgressProperties();
		showPopupProgress();
		
	} catch(error) {
		logError(error, "activatePopupProgressBase");
	}	
	
}

function refreshPopupProgress(args) {
	try {
			
		if(window.top.frames[0].name == "baseFrame"){
			window.top.frames[0].refreshPopupProgressBase(args);
		} else {
			window.top.refreshPopupProgressBase(args);
		}	
		
	} catch(error) {
		logError(error, "refreshPopupProgress");
	}	
}

function refreshPopupProgressBase(args) {

	try {	
		
		var baseFrameObj = null;
		
		if(window.top.frames[0].name == "baseFrame"){
			baseFrameObj = window.top.frames[0];
		} else {
			baseFrameObj = window.top;
		}
		
		var progressBarEl = args[0];
		var progress = baseFrameObj.application.document.getElementById(progressBarEl);
		document.getElementById("popupProgressbar").innerHTML = progress.innerHTML;	
		
	} catch(error) {
		logError(error, "refreshPopupProgressBase");
	}
		
}

function closePopupProgress() {
	try {
			
		if(window.top.frames[0].name == "baseFrame"){
			window.top.frames[0].closePopupProgressBase();
		} else {
			window.top.closePopupProgressBase();
		}
		
	} catch(error) {
		logError(error, "closePopupProgress");
	}	
}

function closePopupProgressBase() {

	try {		
		
		if (panelProgress != null) {			
			panelProgress.hide();	
		}
		
	} catch(error) {
		logError(error, "closePopupProgressBase");
	}	
	
}

function initPopupConfirm(e, args, obj){
	try {
		/**
		 * This method is called using the Event.onDomReady listener and the calling signature
		 * is ("onDomReady", [], obj) therefore we use obj in stead of args since args is empty
		 */
		var buttonOKLabel = obj[0];
		var buttonCancelLabel = obj[1];
		
		/**
		 * Set button labels
		 */
		 confirmOK = buttonOKLabel;
		 confirmCancel = buttonCancelLabel;
		
		function initPopupLoadingConfirmReady(){
			
			YAHOO.example.PopupConfirm = function(id, sGroup, config) {
			    YAHOO.example.PopupConfirm.superclass.constructor.apply(this, arguments);
			};
	
			YAHOO.lang.extend(YAHOO.example.PopupConfirm, YAHOO.widget.SimpleDialog, {
			    show: function() {
			    	 //Call the parent's show method
			        YAHOO.example.PopupConfirm.superclass.show.apply(this, arguments);
			        hideMenuPopup("menuPopupConfirmMask");
			        disableSelectTags(true);
			        /*
			         * Position panel in the middle of the screen including the menu
			         * We must still change the position of the panel when we resize 
			         * (now it only is center on initial opening)
			         */
			        var newCenterX = this.cfg.getProperty("x") - (window.top.frames[0].document.getElementById("menu").offsetWidth /2);
			        this.cfg.setProperty("x", newCenterX);
			    },
			    hide: function() {
			        //Call the parent's hide method
			        YAHOO.example.PopupConfirm.superclass.hide.apply(this, arguments);
			       	showMenuPopup("menuPopupConfirmMask");
			       	disableSelectTags(false);
			    }
			    
			});
								
			panelConfirm = new YAHOO.example.PopupConfirm("myPopupConfirm", {zindex:15000,
													    		   			fixedcenter: true,
	         												       			close:false,  
													    		   			visible:false,  
													    		   			modal:true,
													    		   			draggable: true,
													    		   			constraintoviewport:true} );

		}
		
		/**
		 * We test first whether we don't already have a panel. I we have there's
		 * no need to import the container widget of YUI and to initialize the panel again
		 * Beware of changing the structure of this function -> it might give problems
		 */
		if (panelConfirm == null) {
			
			function loadPopupConfirmCSS() {
				
				yuiLoader.require("popupCSS");
				yuiLoader.onSuccess = initPopupLoadingConfirmReady;
				yuiLoader.insert({});
				
			
			}
			
			window.top.frames[0].loadPopupCSSInBase();
			
			/**
			 * If you use YUI Loader you have to initialize every instance you use in different methods
			 * because otherwise some methods might run when others are also running and thus overwritting
			 * some properties (eg if you load the "button" widget and in the mean time also the "container" widget
			 * you might overwrite the onSuccess function hence only doing one function in stead of both of them
			 */
			yuiLoader.require("dragdrop", "container");
			yuiLoader.onSuccess = loadPopupConfirmCSS;
			yuiLoader.insert({});
				
		} else {
			
			initPopupLoadingConfirmReady();
			
		}
		
	} catch(error) {
		logError(error, "initPopupConfirm");
	}		
}

function activatePopupConfirm(message, functionOK) {
	try {
		
		/**
		 * To make sure we can show a popup when we only have a selectPanel on the screen we must always check whether we have
		 * already a popup initialized, if not we create one	 
		 */
		if (panelConfirm == null) {
			initPopupConfirm("activatePopupConfirm", "", [confirmOK, confirmCancel]);
		}
		
		var handleOK = function() {this.hide();
								   functionOK();}
		var handleCancel = function() {this.hide();}	
													    		   			
		var myConfirmButtons = [{text:confirmOK,
								handler:handleOK},
								{text:confirmCancel,
								handler:handleCancel}];
		
		function showPopupConfirm(){
							
			panelConfirm.render(document.body);
			Dom.addClass(panelConfirm.id, "popup");
			
			/**
			 * Set the CSS class of the buttons to "button" 
			 * so the web.css style will be applied
			 */
			Dom.getElementsBy(function(){return true;}, "button", Dom.get("myPopupConfirm"), function(el){Dom.addClass(el,"button")});
			
			panelConfirm.show();
			
		}
		
		function setPopupConfirmProperties(){
		
			panelConfirm.cfg.setProperty("width", "400px");
				
			panelConfirm.setHeader("&nbsp;");
			panelConfirm.header.style.display = "block";
			
			/**
			 * change underlay to fit panel with(out) header
			 */
			panelConfirm.sizeUnderlay();
					
		}

		panelConfirm.cfg.queueProperty("buttons", myConfirmButtons);
		panelConfirm.cfg.queueProperty("icon", YAHOO.widget.SimpleDialog.ICON_HELP);
			
		panelConfirm.setBody(message);
					
		setPopupConfirmProperties();
		showPopupConfirm();
		
	} catch(error) {
		logError(error, "activatePopupConfirm");
	}						
	
}

function hideMenuPopup(id) {
	try {
		
		if(!menuPopupMaskActive) {
		
			mask=window.top.frames[0].document.createElement("div");
			mask.className= "mask menuMask " + id;
			mask.id=id;
			window.top.frames[0].document.body.appendChild(mask);
			menuPopupMaskActive = true;
		
		}
		
	} catch(error) {
		logError(error, "hideMenuPopup");
	}	
}

function showMenuPopup(id) {
	try {
		
		var menuPopupMask = window.top.frames[0].document.getElementById(id);
		
		if(menuPopupMask != null) {
		
			window.top.frames[0].document.body.removeChild(menuPopupMask);
			menuPopupMaskActive = false;
		
		}
		
	} catch(error) {
		logError(error, "showMenuPopup");
	}
}

function fillParamPanel(param,source) {
	try {
		
	    Dom.get(param).value = source.innerHTML;
		panel.hide();
		
	} catch(error) {
		logError(error, "fillParamPanel");
	}
}

function initQuickNavPanel(e, args){
	try {
		
		function initQuickNavPanelLoaderReady() {
			
			quickNavPanel = new YAHOO.widget.Panel("myQuickNavPanel", {visible:false, 
															   underlay:"none",
															   close:false,
															   modal:false,
															   draggable:false });
	
			if(activatePanelAfterLoad) {
				activatePanelAfterLoad = false;
				activateQuickPanelReady(e, args);	
			}			
	
		}
		
		if (quickNavPanel == null) {
			
			function loadQuickNavCSS() {
		
				yuiLoader.require("quickNavCSS");
				yuiLoader.onSuccess = initQuickNavPanelLoaderReady;
				yuiLoader.insert({});			 	
			
			}
			
			/**
			 * If you use YUI Loader you have to initialize every instance you use in different methods
			 * because otherwise some methods might run when others are also running and thus overwritting
			 * some properties (eg if you load the "button" widget and in the mean time also the "container" widget
			 * you might overwrite the onSuccess function hence only doing one function in stead of both of them
			 */
			yuiLoader.require("dragdrop", "container");
			yuiLoader.onSuccess = loadQuickNavCSS;
			yuiLoader.insert({});
			
		} else {
			
			initQuickNavPanelLoaderReady();
			
		}
		
	} catch(error) {
		logError(error, "initQuickNavPanel");
	}
}

function activateQuickPanelReady(e, args) {
	try {
		
		var width = args[0];
		var source = args[1];
			
		quickNavPanel.hide();
			
		if (width != null) {
			quickNavPanel.cfg.queueProperty("width", width);
		} else {
			quickNavPanel.cfg.queueProperty("width", "");
		}
		
		quickNavPanel.cfg.queueProperty ("context", [source,"tl","bl"]);  // use queueProperty iso setProperty because is before rendering
	
		quickNavPanel.setBody(Dom.get(source + "Content").innerHTML);
	
		quickNavPanel.render(document.body);
		Dom.addClass(quickNavPanel.id, "quickNav");
		quickNavPanel.show();
		
		// we delete the listeners on clicking outside when we click in a triggerzone because otherwise the former panelClicked will 
		// close the newly created panel
		Event.removeListener(document, 'click', quickNavPanelClicked);
				
		Event.addListener(document, 'click', quickNavPanelClicked, [quickNavPanel, source]);
		
	} catch(error) {
		logError(error, "activateQuickNavPanelReady");
	}
			
}

function activateQuickNavPanel(e, args) {
	try {
		
		// to be able to create a fully new panel with all options correctly set when there's already a panel open
		if (quickNavPanel == null) {
		
			activatePanelAfterLoad = true;
			initQuickNavPanel(e, args);
		
		} else {
			
			activateQuickPanelReady(e, args);
			
		}
			
	} catch(error) {
		logError(error, "activateQuickNavPanel");
	}
}

function quickNavPanelClicked(mouseClick, args) {
	try {
		
		quickNavPanelClose = true;
		var quickNavPanelRef = args[0];
		var triggerField = args[1];
		
		// closes the panels if we click somewhere outside of it
		
	 	var targ = (mouseClick.target) ? mouseClick.target : mouseClick.srcElement;
	
	 	// we exceed the clickable zone to include the inputField so it doesn't close immediatly when we click the inputField to select it
	 	//use panel.id because this is not a straightforward HTML-element normally element is ok here we need id
	 	if(Dom.isAncestor(quickNavPanelRef.id, targ) || triggerField == targ.id) {
	 		
	 		quickNavPanelClose = false;
	 		return; 
	 		
	 	}
				
		quickNavPanelRef.hide();
		
		// deactivate close on clicking outside panel
		
	    Event.removeListener(document, 'click', quickNavPanelClicked);
	    quickNavPanelClose = false;
  
	} catch(error) {
		logError(error, "quickNavPanelClicked");
	}
}

function initSupertooltip() {
	try {
		
		if (overlaySupertooltipMngr == null) {
	
			function loadSupertooltipCSS() {
				
				yuiLoader.require("popupCSS");
			yuiLoader.onSuccess = null;
			yuiLoader.insert({});		
			
		} 
	
			yuiLoader.require(["dragdrop", "container"]);
			yuiLoader.onSuccess = loadSupertooltipCSS;
			yuiLoader.insert({});		
			
		} 
	
	} catch(error) {
		logError(error, "initSupertooltip");
	}
}
		
function activateSupertooltip(e , args) {
	try {
		
		var linkId = args[0] ;
		var url = args[1] ;
		var popupWidth = args[2] ;
		var popupHeight = args[3] ;
		var title = args[4] ;
	
		if(overlaySupertooltipMngr == null) {
			
			initSupertooltip();
			overlaySupertooltipMngr = new YAHOO.widget.OverlayManager();
			
		}
	
		var supertooltipId = linkId + "Supertooltip";
	
		/* lookup if there is already a panel for this */
		var panelSupertooltip = overlaySupertooltipMngr.find(supertooltipId);
			
		/* if panelSupertooltip already exist realign it to its starting position */
		if(panelSupertooltip) {
			
			var xy = Dom.get(supertooltipId).xy;
			panelSupertooltip.moveTo(xy[0],xy[1]);
			overlaySupertooltipMngr.focus(panelSupertooltip);
			panelSupertooltip.show();
			Dom.get(panelSupertooltip.id + "OuterDiv").style.display="block";
			
		} else {
								
			panelSupertooltip = new YAHOO.widget.Panel(supertooltipId, {width: popupWidth ,
											         context:[linkId,"tl","bl"],  
											         close:true,    
											         draggable:true,     
											         modal:false,   
											         visible:false,
											         constraintoviewport:true,
											         underlay:"none",
											         zindex:15000} );   
			
			/* IE has a problem with supertooltips and iframes -> when we open one and we close it again 
			 * then the possible underlying textareas are no longer selectable because some structure elements (e.g. div, table)
			 * from inside the supertooltip are still there creating an invisible mask. To avoid this problem
			 * we put a <div id="supertooltipOuterDiv"> around the content of the supertooltip and set this
			 * div to "display:none" when we close the div (thus enabling the textarea) and when a supertooltip
			 * that has already been called on this page is called again we have to set the div to "display:block"
			 * otherwise the content of the supertooltip will not be visible, only the panel itself.
			 */								         
		
			panelSupertooltip.hideEvent.subscribe(function() {Dom.get(panelSupertooltip.id + "OuterDiv").style.display="none"});
									        
			
			if(title) {
				
				panelSupertooltip.setHeader(title);
				
			} else {
				
				panelSupertooltip.setHeader("&nbsp;");
				
			}
			
			/* build body */
			panelSupertooltip.setBody('<div id="' + panelSupertooltip.id + 'OuterDiv" style="display:block"><iframe id="' + linkId + 'Iframe" frameborder="0" style="width: 100%; height: ' + popupHeight + '" src="' + url + '"></iframe></div>');
	
			/* render the popup */
			panelSupertooltip.render(document.body);
			Dom.addClass(panelSupertooltip.id, "popup");
			
			/* store starting position */
			Dom.get(supertooltipId).xy = Dom.getXY(supertooltipId);
			
			/* show */
			panelSupertooltip.show();
	
			/* register to overlayoverlaySupertooltipMngr */
			overlaySupertooltipMngr.register(panelSupertooltip);
			overlaySupertooltipMngr.blurAll();
			
		}
		
	} catch(error) {
		logError(error, "activateSupertooltip");
	}	
}

/* This function will iterate the entire form and make an object containing the input form fields.
 * The objects behaves like a map having the property name as the field name and the property value as the field value.
 * For checkboxes and multiple-selects, the value will be a array of selected values.<b> 
 * values can be retrieved by map[propertyName].
 */
function returnFormAsMap(theForm){

	try {

		var fieldsMap = {
			set : function(key, value) {
				this[key] = value;
			},
			get : function(key) {
				return this[key];
			}
		};
		
		var fieldIndex=0;
		var field;
		var paramsArray;
		
		while(fieldIndex < theForm.length){
		
			field = theForm.elements[fieldIndex];
			
			if( field.type == "checkbox" || 
				field.type == "radio" || 
				field.type == "select-one" || 
				field.type == "select-multiple" || 
				field.type == "text" || 
				field.type == "hidden" || 
				field.type == "textarea"){			
				
				if (field.type == "radio") {					
					if(field.checked){
						fieldsMap.set(field.name, field.value);								
					}									
				} else if (field.type == "checkbox") {
					
					if(fieldsMap.get(field.name) == null){						
						paramsArray = new Array();
						fieldsMap.set(field.name, paramsArray);							
					}
										
					if(field.checked){
						fieldsMap.get(field.name).push(field.value);						
					}									
				} else if (field.type == "select-multiple") {
					
					if(fieldsMap.get(field.name) == null){						
						paramsArray = new Array();
						fieldsMap.set(field.name, paramsArray);							
					}
					
					var selectIndex = 0;
					var selectField;
					
					while(selectIndex < field.length){
						selectField = field[selectIndex];
						
						if(selectField.selected){
							fieldsMap.get(field.name).push(selectField.value);						
						}
						
						selectIndex++;
						
					}													
					
				} else {				
					fieldsMap.set(field.name, field.value);					
				}				
						
			}
			
			fieldIndex++;		
		}
		
		return fieldsMap;
		
	} catch(error) {
		logError(error, "returnFormAsMap");
	}

}

// end hiding of JavaScript code -->
