// BEGIN RESIZEPANEL SUBCLASS //
YAHOO.widget.ResizePanel = function(el, userConfig) {
    if (arguments.length > 0) {
        YAHOO.widget.ResizePanel.superclass.constructor.call(this, el, userConfig);
    }
}
YAHOO.widget.ResizePanel.CSS_PANEL_RESIZE = "yui-resizepanel";
YAHOO.widget.ResizePanel.CSS_RESIZE_HANDLE = "resizehandle";
YAHOO.extend(YAHOO.widget.ResizePanel, YAHOO.widget.Panel, {
    init: function(el, userConfig) {
        YAHOO.widget.ResizePanel.superclass.init.call(this, el);
        this.beforeInitEvent.fire(YAHOO.widget.ResizePanel);
        var Dom = YAHOO.util.Dom,
            Event = YAHOO.util.Event,
            oInnerElement = this.innerElement,
            oResizeHandle = document.createElement("DIV"),
            sResizeHandleId = this.id + "_resizehandle";
         oResizeHandle.id = sResizeHandleId;
         oResizeHandle.className = YAHOO.widget.ResizePanel.CSS_RESIZE_HANDLE;
        Dom.addClass(oInnerElement, YAHOO.widget.ResizePanel.CSS_PANEL_RESIZE);
        this.resizeHandle = oResizeHandle;
        function initResizeFunctionality() {
            var me = this,
                oHeader = this.header,
                oBody = this.body,
                oFooter = this.footer,
                nStartWidth,
                nStartHeight,
                aStartPos,
                nBodyBorderTopWidth,
                nBodyBorderBottomWidth,
                nBodyTopPadding,
                nBodyBottomPadding,
                nBodyOffset;
            oInnerElement.appendChild(oResizeHandle);
            this.ddResize = new YAHOO.util.DragDrop(sResizeHandleId, this.id);
            this.ddResize.setHandleElId(sResizeHandleId);
            this.ddResize.onMouseDown = function(e) {
                nStartWidth = oInnerElement.offsetWidth;
                nStartHeight = oInnerElement.offsetHeight;
                if (YAHOO.env.ua.ie && document.compatMode == "BackCompat") {
                    nBodyOffset = 0;
                } else {
                    nBodyBorderTopWidth = parseInt(Dom.getStyle(oBody, "borderTopWidth"), 10),
                    nBodyBorderBottomWidth = parseInt(Dom.getStyle(oBody, "borderBottomWidth"), 10),
                    nBodyTopPadding = parseInt(Dom.getStyle(oBody, "paddingTop"), 10),
                    nBodyBottomPadding = parseInt(Dom.getStyle(oBody, "paddingBottom"), 10),
                    nBodyOffset = nBodyBorderTopWidth + nBodyBorderBottomWidth + nBodyTopPadding + nBodyBottomPadding;
                }
                me.cfg.setProperty("width", nStartWidth + "px");
                aStartPos = [Event.getPageX(e), Event.getPageY(e)];
            };
            this.ddResize.onMouseUp = function(e) {
            	me.cfg.setProperty("width", oInnerElement.offsetWidth + "px");
            };
            this.ddResize.onDrag = function(e) {
                var aNewPos = [Event.getPageX(e), Event.getPageY(e)],
                    nOffsetX = aNewPos[0] - aStartPos[0],
                    nOffsetY = aNewPos[1] - aStartPos[1],
                    nNewWidth = Math.max(nStartWidth + nOffsetX, 10),
                    nNewHeight = Math.max(nStartHeight + nOffsetY, 10),
                    nBodyHeight = (nNewHeight - (oFooter.offsetHeight + oHeader.offsetHeight + nBodyOffset));
                me.cfg.setProperty("width", nNewWidth + "px");
                me.cfg.setProperty("height", nNewHeight + "px");
                if (nBodyHeight < 0) {
                    nBodyHeight = 0;
                }
                oBody.style.height =  nBodyHeight + "px";
            };
        }
    
        function onBeforeShow() {
           initResizeFunctionality.call(this);
           this.unsubscribe("beforeShow", onBeforeShow);
        }
    
        function onBeforeRender() {
            if (!this.footer) {
                this.setFooter("");
            }
            if (this.cfg.getProperty("visible")) {
                initResizeFunctionality.call(this);
            } else {
                this.subscribe("beforeShow", onBeforeShow);
            }
            this.unsubscribe("beforeRender", onBeforeRender);
        }
    
        this.subscribe("beforeRender", onBeforeRender);
        if (userConfig) {
            this.cfg.applyConfig(userConfig, true);
        }
        this.initEvent.fire(YAHOO.widget.ResizePanel);
    
    },
    
    toString: function() {
        return "ResizePanel " + this.id;
    },
    set_title: function(title) {
    	var header=this.header.firstChild.nextSibling;
     	if(header.className=='topbuttons') header=header.nextSibling;
    	if(header) header.innerHTML=title;
    },
    hide_footer: function() {
    	footer=this.footer;
    	if(footer) footer.style.display='none';
    },
    show_footer: function() {
    	footer=this.footer;
    	if(footer) footer.style.display='block';
    },
    fix_width: function()
    {
    	//IE doesn't automatically adjust the body width when content causes the panel to
    	//stretch. So call this after updating the content.
    	this.cfg.setProperty("width", this.innerElement.offsetWidth + "px");
    }
});

// BEGIN RESIZEDIALOG SUBCLASS //
YAHOO.widget.ResizeDialog = function(el, userConfig) {
    if (arguments.length > 0) {
        YAHOO.widget.ResizeDialog.superclass.constructor.call(this, el, userConfig);
    }
}
YAHOO.widget.ResizeDialog.CSS_PANEL_RESIZE = "yui-resizepanel";
YAHOO.widget.ResizeDialog.CSS_RESIZE_HANDLE = "resizehandle";
YAHOO.extend(YAHOO.widget.ResizeDialog, YAHOO.widget.Dialog, {
    init: function(el, userConfig) {
        YAHOO.widget.ResizeDialog.superclass.init.call(this, el);
        this.beforeInitEvent.fire(YAHOO.widget.ResizeDialog);
        var Dom = YAHOO.util.Dom,
            Event = YAHOO.util.Event,
            oInnerElement = this.innerElement,
            oResizeHandle = document.createElement("DIV"),
            sResizeHandleId = this.id + "_resizehandle";
         oResizeHandle.id = sResizeHandleId;
         oResizeHandle.className = YAHOO.widget.ResizeDialog.CSS_RESIZE_HANDLE;
        Dom.addClass(oInnerElement, YAHOO.widget.ResizeDialog.CSS_PANEL_RESIZE);
        this.resizeHandle = oResizeHandle;
        function initResizeFunctionality() {
            var me = this,
                oHeader = this.header,
                oBody = this.body,
                oFooter = this.footer,
                nStartWidth,
                nStartHeight,
                aStartPos,
                nBodyBorderTopWidth,
                nBodyBorderBottomWidth,
                nBodyTopPadding,
                nBodyBottomPadding,
                nBodyOffset;
            oInnerElement.appendChild(oResizeHandle);
            this.ddResize = new YAHOO.util.DragDrop(sResizeHandleId, this.id);
            this.ddResize.setHandleElId(sResizeHandleId);
            this.ddResize.onMouseDown = function(e) {
                nStartWidth = oInnerElement.offsetWidth;
                nStartHeight = oInnerElement.offsetHeight;
                if (YAHOO.env.ua.ie && document.compatMode == "BackCompat") {
                    nBodyOffset = 0;
                } else {
                    nBodyBorderTopWidth = parseInt(Dom.getStyle(oBody, "borderTopWidth"), 10),
                    nBodyBorderBottomWidth = parseInt(Dom.getStyle(oBody, "borderBottomWidth"), 10),
                    nBodyTopPadding = parseInt(Dom.getStyle(oBody, "paddingTop"), 10),
                    nBodyBottomPadding = parseInt(Dom.getStyle(oBody, "paddingBottom"), 10),
                    nBodyOffset = nBodyBorderTopWidth + nBodyBorderBottomWidth + nBodyTopPadding + nBodyBottomPadding;
                }
                me.cfg.setProperty("width", nStartWidth + "px");
                aStartPos = [Event.getPageX(e), Event.getPageY(e)];
            };
            this.ddResize.onMouseUp = function(e) {
            	me.cfg.setProperty("width", oInnerElement.offsetWidth + "px");
            };
            this.ddResize.onDrag = function(e) {
                var aNewPos = [Event.getPageX(e), Event.getPageY(e)],
                    nOffsetX = aNewPos[0] - aStartPos[0],
                    nOffsetY = aNewPos[1] - aStartPos[1],
                    nNewWidth = Math.max(nStartWidth + nOffsetX, 10),
                    nNewHeight = Math.max(nStartHeight + nOffsetY, 10),
                    nBodyHeight = (nNewHeight - (oFooter.offsetHeight + oHeader.offsetHeight + nBodyOffset));
                me.cfg.setProperty("width", nNewWidth + "px");
                me.cfg.setProperty("height", nNewHeight + "px");

                if (nBodyHeight < 0) {
                    nBodyHeight = 0;
                }
                oBody.style.height =  nBodyHeight + "px";
            };
        }
        
        function onBeforeShow() {
           initResizeFunctionality.call(this);
           this.unsubscribe("beforeShow", onBeforeShow);
        }
    
        function onBeforeRender() {
            if (!this.footer) {
                this.setFooter("");
            }
            if (this.cfg.getProperty("visible")) {
                initResizeFunctionality.call(this);
            } else {
                this.subscribe("beforeShow", onBeforeShow);
            }
            this.unsubscribe("beforeRender", onBeforeRender);
        }
    
        this.subscribe("beforeRender", onBeforeRender);
        if (userConfig) {
            this.cfg.applyConfig(userConfig, true);
        }
        this.initEvent.fire(YAHOO.widget.ResizeDialog);
    
    },
    
    toString: function() {
        return "ResizeDialog " + this.id;
    },
    set_title: function(title) {
    	var header=this.header.firstChild.nextSibling;
    	if(header.className=='topbuttons') header=header.nextSibling;
    	if(header) header.innerHTML=title;
    },
    hide_footer: function() {
    	footer=this.footer;
    	if(footer) footer.style.display='none';
    },
    show_footer: function() {
    	footer=this.footer;
    	if(footer) footer.style.display='block';
    },
    fix_width: function()
    {
    	//IE doesn't automatically adjust the body width when content causes the panel to
    	//stretch. So call this after updating the content.
    	this.cfg.setProperty("width", this.innerElement.offsetWidth + "px");
    }
});

YAHOO.util.Event.onDOMReady(function() {
	/**
	 * This class was created to:
	 *	-override the loadHandler object in YAHOO.widget.Tab to address YUI's 
	 * 		inability to handle Javascript in the response of Ajax requests
	 *	-create new methods to allow tabs to reload dynamically
	 *
	 * @author	WS
	 * @see	#2386
	 */
	YAHOO.widget.DynamicTab = function(userConfig) {
		YAHOO.widget.DynamicTab.superclass.constructor.call(this, userConfig);
		
		this.loadHandler = {
			success: function(o) {
				var response = o.responseText;
				if( doRedirect = /\[REDIRECT\]\[(.*?)\]/.exec(response))
				{
					window.location.href=doRedirect[1];
	 			} else {
					// most other JS libraries do this for us - why can't YUI?
					
					//Execute any javacript directly
					//NOTE - This will not parse correctly in IE if you surround the javascript in comment
					//tags, i.e. <!-- and -->
					var ScriptFragment = "<\s*script.*?>((\n|\r|\r\n|\n\r|.)*?)<\s*\/script";
					var match = new RegExp(ScriptFragment, "img");
					var scripts = o.responseText.match(match);
					
					if (scripts) {
						var match = new RegExp(ScriptFragment, "im");	
						var js = "";
						for (var s = 0; s < scripts.length; s++) {
							js += scripts[s].match(match)[1];
						}
						eval(js);
					}
					this.set("content", o.responseText);
	 			}
			},
			failure: function(o) {
			}
		};
	}
	YAHOO.extend(YAHOO.widget.DynamicTab, YAHOO.widget.Tab, {
		// overridden to add/remove the loading panel
		_dataConnect: function() {
			if (!YAHOO.util.Connect) {
				return false;
			}
			
			YAHOO.util.Dom.addClass(this.get("contentEl").parentNode, this.LOADING_CLASSNAME);
			// ideally this should be done in CSS, but IE seems to have real trouble
			// dealing with opacity (and the cursor property support seems wobbly too)
			YAHOO.util.Dom.setStyle(this.get("contentEl").parentNode, "opacity", 0.7);
			document.body.style.cursor = "wait";  
			
			// add loading panel
			var loadingPanel = document.createElement("div");
			loadingPanel.setAttribute("id", "loadingPanel");
			loadingPanel.setAttribute("class", "tab_reloading");
			
			// just to please IE
			loadingPanel.setAttribute("className", "tab_reloading");
			loadingPanel.innerHTML = "&nbsp;";
			
			var tabPanel = this.get("contentEl").parentNode.parentNode;
			tabPanel.appendChild(loadingPanel);
			
			this._loading = true; 
			this.dataConnection = YAHOO.util.Connect.asyncRequest(
			
				this.get("loadMethod"),
				this.get("dataSrc"), 
				{
					success: function(o) {
						this.loadHandler.success.call(this, o);
						this.set("dataLoaded", true);
						this.dataConnection = null;
						// remove loading panel (if any)
						var loadingPanel = document.getElementById("loadingPanel");
						if (loadingPanel) {
							try{
								var tabPanel = this.get("contentEl").parentNode.parentNode;
								tabPanel.removeChild(loadingPanel);
							}catch(e){}
						}
						YAHOO.util.Dom.removeClass(this.get("contentEl").parentNode, this.LOADING_CLASSNAME);
						//godam IE.. you have to remove to opacity filter otherwise popup menus don't work - dgb 20100525
						if(YAHOO.env.ua.ie && document.getElementById(this.get("contentEl").parentNode)){
							document.getElementById(this.get("contentEl").parentNode).style.filter = 'alpha(opacity=100)'; 
							document.getElementById(this.get("contentEl").parentNode).style.filter = ''; 
						}else{
							YAHOO.util.Dom.setStyle(this.get("contentEl").parentNode, "opacity", 1.0); 
						}
						 
						document.body.style.cursor = "default";
						this._loading = false;
					},
					failure: function(o) {
						this.loadHandler.failure.call(this, o);
						this.dataConnection = null;
						// remove loading panel (if any)
						var loadingPanel = document.getElementById("loadingPanel");
						if (loadingPanel) {
							var tabPanel = this.get("contentEl").parentNode.parentNode;
							tabPanel.removeChild(loadingPanel);
						}
						YAHOO.util.Dom.removeClass(this.get("contentEl").parentNode, this.LOADING_CLASSNAME);
						//godam IE.. you have to remove to opacity filter otherwise popup menus don't work - dgb 20100525
						if(YAHOO.env.ua.ie && document.getElementById(this.get("contentEl").parentNode)){
							document.getElementById(this.get("contentEl").parentNode).style.filter = 'alpha(opacity=100)'; 
							document.getElementById(this.get("contentEl").parentNode).style.filter = ''; 
						}else{
							YAHOO.util.Dom.setStyle(this.get("contentEl").parentNode, "opacity", 1.0); 
						}
						
						document.body.style.cursor = "default";
						this._loading = false;
					},
					scope: this,
					timeout: this.get("dataTimeout")
				},
				
				this.get("postData")
			);
		},
		// reload the tab
		reload: function() {
			var datasrc = this.get("dataSrc");
			if (datasrc.indexOf("reloaded") == -1) {
				// set the 'reloaded' flag to indicate it is not a first-time dynamic
				// tab fetch
				this.set("dataSrc", datasrc + "&reloaded=1");
			}
			
			this._dataConnect();
		},
		// submit handler for when the submit button is clicked
		submit: function() {
			var forms = YAHOO.util.Dom.getElementsByClassName("yui-panel-form");
			var thisForm;
			// find the right form
			//alert(this.formId);
			for (var i = 0; i < forms.length; i++) {
				var formId = forms[i].id;
				//alert(formId);
				var controlId = formId.substring(formId.length - 6, formId.length - 5);
				if (controlId == this.formId || formId == this.formId) {
					thisForm = forms[i];
				}
			}
			if (this.get("dataSrc") == null) {
				// this is a static tab, add the datasrc manually
				this.set("dataSrc", thisForm.action);
			}
			YAHOO.util.Connect.setForm(thisForm);
			this.reload();
		},
		toString: function() {
			return "DynamicTab";
		},
    fix_width: function()
    {
    	//Ignore this one. Not required here.
    }
	});
});

if (!YAHOO.ks) {
	YAHOO.namespace("ks");
}

YAHOO.util.Event.onDOMReady(function () {

	// Define various event handlers for Dialog   
	YAHOO.ks.handleSubmit = function(dialogObj) {   
		if (! dialogObj.ksClassName ) {
			var dialogObj = this;
		}
		if (! dialogObj.ksPostData ) {
			dialogObj.ksPostData = "";
		}
		if (! dialogObj.ksFileUpload ) {
			dialogObj.ksFileUpload = false;
		}	
//alert("do submit " + dialogObj.ksClassName + " form = " + dialogObj.ksFormName);
		var formObject = document.getElementById(dialogObj.ksFormName);
//alert(formObject);
		YAHOO.util.Connect.setForm(formObject, dialogObj.ksFileUpload);
		var callback = {
			//handle upload case. This function will be invoked after file upload is finished.
			success: function(o) {
				var response = o.responseText;
				o.argument.submitting=false;
				
				// WS #2416 handle JSON response
				var isJSON, json;
				try {
					json = YAHOO.lang.JSON.parse(response);
					isJSON = true;
				} catch (e) {
					isJSON = false;
				}
				
				if (isJSON) {
					// this certainly needs work to be more generic
					// currently, it only works for the curriculum framework
					var success = json.success;	// flag whether the submission was successful or not
					var content = json.content;	// the content to display
					var target = json.target;	// the name of the target object in which to update
					var targetProperty = json.targetProperty;	// the property name of the target to update
					var customJs = json.customJs;	// string containing any custom javascript to execute
					var customJs2 = json.customJs2;	// string containing any custom javascript to execute
					
					if (target != null && target != "") {
						target = eval(target);
					}
					
					if (content != null && content != "") {
						// Execute any javacript directly
						// NOTE - This will not parse correctly in IE if you surround the javascript in comment
						// tags, i.e. <!-- and -->
						var scriptFragment = "<\s*script.*?>((\n|\r|\r\n|\n\r|.)*?)<\s*\/script";
						var match = new RegExp(scriptFragment, "img");
						var scripts = content.match(match);
					
						if (scripts) {
							var match = new RegExp(scriptFragment, "im");	
							var js = "";
							for (var s = 0; s < scripts.length; s++) {
								js += scripts[s].match(match)[1];
							}
							eval(js);
						}
					}
					
					var callerObj = o.argument;
					if (success) {
						if (target != null && targetProperty != null && targetProperty != "") {
							// this will obviously only work if target supports the set() method
							// if not, resort to customJs
							target.set(targetProperty, content);
						}
						callerObj.cancel();
						eval(customJs);
						eval(customJs2);
						//godam IE.. you have to remove to opacity filter otherwise popup menus don't work - dgb 20100525
						if(YAHOO.env.ua.ie){
							document.getElementById(callerObj.element.firstChild.id).style.filter = 'alpha(opacity=100)'; 
							document.getElementById(callerObj.element.firstChild.id).style.filter = ''; 
						}else{
							YAHOO.util.Dom.setStyle(callerObj.element.firstChild.id, "opacity", 1.0); 
						}
						
						
						document.body.style.cursor = "default";
					} else {
						// not yet implemented
					}
					
				} else {
					if( doRedirect = /\[REDIRECT\]\[(.*?)\]/.exec(response))
					{
						window.location.href=doRedirect[1];
		 			} else {
						var callerObj = o.argument;
						//alert(response.substr(1,2000));
						callerObj.setBody(response);
						
						//Execute any javacript directly
						//NOTE - This will not parse correctly in IE if you surround the javascript in comment
						//tags, i.e. <!-- and -->
						var ScriptFragment = "<\s*script.*?>((\n|\r|\r\n|\n\r|.)*?)<\s*\/script";
						var match    = new RegExp(ScriptFragment, "img");
						var scripts  = response.match(match);
					
						if(scripts) {
							var match = new RegExp(ScriptFragment, "im");	
							var js = "";
						    for(var s = 0; s < scripts.length; s++) {
						        js += scripts[s].match(match)[1];
						 	}
						    try{
						    	eval(js);
							} catch(e)
							{
								vDebug=e.name + " - " + e.message+"\n";
								for (var prop in e)
							    { 
									if(prop!='stack') vDebug += prop+ " = "+ e[prop]+ "\n";
							    } 
								alert(vDebug);
								alert(js);
							}
						}
						//godam IE.. you have to remove to opacity filter otherwise popup menus don't work - dgb 20100525
						if(YAHOO.env.ua.ie){
							document.getElementById(callerObj.element.firstChild.id).style.filter = 'alpha(opacity=100)'; 
							document.getElementById(callerObj.element.firstChild.id).style.filter = ''; 
						}else{
							YAHOO.util.Dom.setStyle(callerObj.element.firstChild.id, "opacity", 1.0);  
						}					
						//callerObj.focusFirst();
						if (callerObj.ksHideAfterSubmit) {
							callerObj.cancel();
						} else if (callerObj.ksDontShowOrHide) {
                     callerObj.ksDontShowOrHide=false;
                  } else {
							callerObj.show();
							callerObj.render();
						}
						document.body.style.cursor="default";
						//callerObj.focusFirst(); //needs to be called a second time to work in IE..
		 			}
				}
				if (dialogObj.fix_width) {
					dialogObj.fix_width();
				}
	 		},
				
			upload: function(o) {
				var response = o.responseText;
				var callerObj = o.argument;
				//alert(response);
				response=response.replace(/&amp;/g,'&').replace(/&lt;/g,'<').replace(/&gt;/g,'>');
				o.argument.submitting=false;
				var r, isJSON;
				try {
					r = YAHOO.lang.JSON.parse(response);
					isJSON = true;
				} catch (e) {
					isJSON = false;
				}
				
				if (isJSON) {
					var ok=r.ok;
					var fail=r.fail;
					var message=r.message;
					try {
					if(r.update_top)
					{
						for(var i=0;i<r.update_top.length; i++)
						{
							eval('window.top.YAHOO.ks.'+ r.update_top[i].id +'_el.set(\''+ r.update_top[i].name +'\',\''+ r.update_top[i].value +'\');');
						}
					}
					} catch(e)
					{
						// do nothing
					}
					try {
					if(r.call_javascript)
					{
						for(var i=0;i<r.call_javascript.length; i++)
						{
							eval(r.call_javascript[i].javascript);
						}
					}
					} catch(e)
					{
						// do nothing
					}
					//godam IE.. you have to remove to opacity filter otherwise popup menus don't work - dgb 20100525
					if(YAHOO.env.ua.ie){
						document.getElementById(callerObj.element.firstChild.id).style.filter = 'alpha(opacity=100)'; 
						document.getElementById(callerObj.element.firstChild.id).style.filter = ''; 
					}else{
						YAHOO.util.Dom.setStyle(callerObj.element.firstChild.id, "opacity", 1.0);  
					}					
					document.body.style.cursor="default";
					if(fail)
					{
						alert(message);
						//callerObj.focusFirst();
						callerObj.show();
						callerObj.render();
						//callerObj.focusFirst(); //needs to be called a second time to work in IE..
					} else
					{
						callerObj.hide();
					}
				} else
				{
					if( doRedirect = /\[REDIRECT\]\[(.*?)\]/.exec(response))
					{
						window.location.href=doRedirect[1];
		 			} else {
				//alert(response.substr(1,2000));
						callerObj.setBody(response);
						
						//Execute any javacript directly
						//NOTE - This will not parse correctly in IE if you surround the javascript in comment
						//tags, i.e. <!-- and -->
						var ScriptFragment = "<\s*script.*?>((\n|\r|\r\n|\n\r|.)*?)<\s*\/script";
						var match    = new RegExp(ScriptFragment, "img");
						var scripts  = response.match(match);
					
						if(scripts) {
							var match = new RegExp(ScriptFragment, "im");	
							var js = "";
						    for(var s = 0; s < scripts.length; s++) {
						        js += scripts[s].match(match)[1];
						 	}
						    try{
						    	eval(js);
							} catch(e)
							{
								vDebug=e.name + " - " + e.message+"\n";
								for (var prop in e)
							    { 
							       if(prop!='stack') vDebug += prop+ " = "+ e[prop]+ "\n";
							    } 
								alert(vDebug);
								alert(js);
							}
						}
	
						//godam IE.. you have to remove to opacity filter otherwise popup menus don't work - dgb 20100525
						if(YAHOO.env.ua.ie){
							document.getElementById(callerObj.element.firstChild.id).style.filter = 'alpha(opacity=100)'; 
							document.getElementById(callerObj.element.firstChild.id).style.filter = ''; 
						}else{
							YAHOO.util.Dom.setStyle(callerObj.element.firstChild.id, "opacity", 1.0);  
						}						
						if (callerObj.ksHideAfterSubmit) {
							callerObj.cancel();
						} else if (callerObj.ksDontShowOrHide) {
                     callerObj.ksDontShowOrHide=false;
                  } else {
							callerObj.show();
							callerObj.render();
						}
						document.body.style.cursor="default";
		 			}
				}
	 		},
				
			failure: function(o) {
				//alert("Submission failed: " + o.statusText);
				var callerObj = o.argument;
				callerObj.submitting=false;
	
				//godam IE.. you have to remove to opacity filter otherwise popup menus don't work - dgb 20100525
				if(YAHOO.env.ua.ie){
					document.getElementById(callerObj.element.firstChild.id).style.filter = 'alpha(opacity=100)'; 
					document.getElementById(callerObj.element.firstChild.id).style.filter = ''; 
				}else{
					YAHOO.util.Dom.setStyle(callerObj.element.firstChild.id, "opacity", 1.0);  
				}
					 
				document.body.style.cursor="default";	
			},
				 
			timeout: 60000,   
			argument: dialogObj  				
		};
		if(dialogObj.ksFileUpload)
		{
			var action=formObject.action;
		} else if(dialogObj.ksCustomParam != null && dialogObj.ksCustomParam != "")
		{
			var action="./index.php?page=" + dialogObj.ksClassName + "&action=kn_update"+dialogObj.ksCustomParam;
		} else
		{
			var action="./index.php?page=" + dialogObj.ksClassName + "&action=kn_update";
		}
		if(!dialogObj.submitting)
		{
         //dialogObj.setBody("");
			var cObj = YAHOO.util.Connect.asyncRequest("POST", action, callback, dialogObj.ksPostData);
			YAHOO.util.Dom.setStyle(dialogObj.element.firstChild.id, "opacity", 0.5);
			dialogObj.ksPostData = "";
			dialogObj.submitting=true;
			document.body.style.cursor="wait";
		}
	};   

	YAHOO.ks.handleCancel = function() {   
		this.cancel();   
	}; 
	//This next bit looks painful, and it is...
	YAHOO.ks.handleParamSubmit1 = function(dialogObj) {
		if (! dialogObj.ksClassName ) {
			var dialogObj = this;
		}
		dialogObj.ksCustomParam=dialogObj.ksCustomParam1;
		YAHOO.ks.handleSubmit(dialogObj);
	}
	YAHOO.ks.handleParamSubmit2 = function(dialogObj) {
		if (! dialogObj.ksClassName ) {
			var dialogObj = this;
		}
		dialogObj.ksCustomParam=dialogObj.ksCustomParam2;
		YAHOO.ks.handleSubmit(dialogObj);
	}
	YAHOO.ks.handleParamSubmit3 = function(dialogObj) {
		if (! dialogObj.ksClassName ) {
			var dialogObj = this;
		}
		dialogObj.ksCustomParam=dialogObj.ksCustomParam3;
		YAHOO.ks.handleSubmit(dialogObj);
	}
	YAHOO.ks.handleParamSubmit4 = function(dialogObj) {
		if (! dialogObj.ksClassName ) {
			var dialogObj = this;
		}
		dialogObj.ksCustomParam=dialogObj.ksCustomParam4;
		YAHOO.ks.handleSubmit(dialogObj);
	}
	YAHOO.ks.manager = new YAHOO.widget.OverlayManager();
    /**
     * Places the Overlay on top of all other instances of 
     * YAHOO.widget.Overlay.
     * @method bringToTop
     */
	YAHOO.ks.manager.bringToTop = function(p_oOverlay) {
        var oOverlay = this.find(p_oOverlay),
	        nTopZIndex,
	        oTopOverlay,
	        aOverlays;
		var Dom = YAHOO.util.Dom;
	
	    if (oOverlay) {
	
	        aOverlays = this.overlays;
	        aOverlays.sort(this.compareZIndexDesc);

	        oTopOverlay = aOverlays[0];
	    	
	        if (oTopOverlay) {
	            nTopZIndex = Dom.getStyle(oTopOverlay.element, "zIndex");
	
	            if (!isNaN(nTopZIndex)) {
	
	                var bRequiresBump = false;
	
	                if (oTopOverlay !== oOverlay) {
	                    bRequiresBump = true;
	                } else if (aOverlays.length > 1) {
	                    var nNextZIndex = Dom.getStyle(aOverlays[1].element, "zIndex");
	                    // Don't rely on DOM order to stack if 2 overlays are at the same zindex.
	                    if (!isNaN(nNextZIndex) && (nTopZIndex == nNextZIndex)) {
	                        bRequiresBump = true;
	                    }
	                }
	
	                if (bRequiresBump) {
	                    oOverlay.cfg.setProperty("zindex", (parseInt(nTopZIndex, 10) + 2));
	                }
	            }
	            aOverlays.sort(this.compareZIndexDesc);
	        }
	        
		    if (aOverlays.length > 1) {
		        //Rejig them down to a sensible zIndex
		        var z=10;
		        aOverlays[aOverlays.length-1].cfg.setProperty("zindex", z);
		        z+=2;
		        
			    for(var s = aOverlays.length-2; s >0; s--) {
			    	oTopOverlay = aOverlays[s];
		            nTopZIndex = Dom.getStyle(oTopOverlay.element, "zIndex");
		
		            if (!isNaN(nTopZIndex)) {
		            	oTopOverlay.cfg.setProperty("zindex", z);
		            }
		            z+=2;
		        }
			    //and set the last one to 1500, which should be below the menu (2000) and above the WYSIWYG panels (1200)
			    if(aOverlays[0].id=='np_wysiwyg_control1_ypd1_container')
			    {
				    //Unless of course it's the WYSIWYG itself, which needs to stay below its own panels!
			    	aOverlays[0].cfg.setProperty("zindex", 200);
			    } else if(aOverlays[0].id=='np_file_uploader_control1_ypd1_container')
			    {
				    //If it's the uploader, we need to keep the filing cabinet just behind it
			    	aOverlays[0].cfg.setProperty("zindex", 1500);
			    	aOverlays[1].cfg.setProperty("zindex", 1498);
			    } else 
			    {
			    	aOverlays[0].cfg.setProperty("zindex", 1500);
			    }
		    }
	    }
	}	
	
	YAHOO.ks.displayAndFocus = function(e, obj) {
		if(obj.hideAllOthers){	
			YAHOO.ks.manager.hideAll();
		}
		obj.show();
		obj.focus();
		document.body.style.cursor="default";
	}
	
	YAHOO.ks.displayAndFocusDialog = function(e, obj) {
		if(obj.hideAllOthers){	
			YAHOO.ks.manager.hideAll();
		}
		obj.show();
		obj.focus();
		window.scrollTo(0,0);	// #dgb 20090824 set focus to top of window
								// again
		document.body.style.cursor="default";
// obj.focusFirst();
		obj.blurButtons();
	}	
	
	YAHOO.ks.display = function(e, obj) {
		obj.show();
		document.body.style.cursor="default";
	}
	
	YAHOO.ks.showThisOnOk = function() {
		eval(this.ksLinkOkButtonTo + ".show()");
		document.body.style.cursor="default";
	}
	YAHOO.ks.submitThisOnOk = function() {
		this.cancel(); 
		eval('YAHOO.ks.handleSubmit(' + this.ksLinkOkButtonTo + ')');
	}
/**
* Drag Drop
**/

	YAHOO.ks.DragDrop = function(id, sGroup, config) {
	
	    YAHOO.ks.DragDrop.superclass.constructor.call(this, id, sGroup, config);
	
	    this.logger = this.logger || YAHOO;
	    var el = this.getDragEl();
	    YAHOO.util.Dom.setStyle(el, "opacity", 0.67); // The proxy is slightly transparent
	
	    this.goingUp = false;
	    this.lastY = 0;
	    this.lastX = 0;
	};
	
	YAHOO.extend(YAHOO.ks.DragDrop, YAHOO.util.DDProxy, {
	
	    startDrag: function(x, y) {
	        this.logger.log(this.id + " startDrag");
	
	        // make the proxy look like the source element
	        var dragEl = this.getDragEl();
	        var clickEl = this.getEl();
	        YAHOO.util.Dom.setStyle(clickEl, "visibility", "hidden");
	
	        dragEl.innerHTML = clickEl.innerHTML;
	
	        YAHOO.util.Dom.setStyle(dragEl, "color", YAHOO.util.Dom.getStyle(clickEl, "color"));
	        YAHOO.util.Dom.setStyle(dragEl, "backgroundColor", YAHOO.util.Dom.getStyle(clickEl, "backgroundColor"));
	        YAHOO.util.Dom.setStyle(dragEl, "border", "2px solid gray");
	    },
	
	    endDrag: function(e) {
	
	        var srcEl = this.getEl();
	        var proxy = this.getDragEl();

	        // Show the proxy element and animate it to the src element's location
	        YAHOO.util.Dom.setStyle(proxy, "visibility", "");
	        var a = new YAHOO.util.Motion( 
	            proxy, { 
	                points: { 
	                    to: YAHOO.util.Dom.getXY(srcEl)
	                }
	            }, 
	            0.2, 
	            YAHOO.util.Easing.easeOut 
	        )
	        var proxyid = proxy.id;
	        var thisid = this.id;
	
	        // Hide the proxy and show the source element when finished with the animation
	        a.onComplete.subscribe(function() {
	                YAHOO.util.Dom.setStyle(proxyid, "visibility", "hidden");
	                YAHOO.util.Dom.setStyle(thisid, "visibility", "");
	            });
	        a.animate();
	        eval('YAHOO.ks.'+srcEl.parentNode.id+'_drop_event();')
	    },
	
	    onDragDrop: function(e, id) {
	
	        // If there is one drop interaction, the li was dropped either on the list,
	        // or it was dropped on the current location of the source element.
	        if (YAHOO.util.DragDropMgr.interactionInfo.drop.length === 1) {
	
	            // The position of the cursor at the time of the drop (YAHOO.util.Point)
	            var pt = YAHOO.util.DragDropMgr.interactionInfo.point; 
	
	            // The region occupied by the source element at the time of the drop
	            var region = YAHOO.util.DragDropMgr.interactionInfo.sourceRegion; 
	
	            // Check to see if we are over the source element's location.  We will
	            // append to the bottom of the list once we are sure it was a drop in
	            // the negative space (the area of the list without any list items)
	            if (!region.intersect(pt)) {
	                var destEl = YAHOO.util.Dom.get(id);
	                var destDD = YAHOO.util.DragDropMgr.getDDById(id);
	                destEl.appendChild(this.getEl());
	                destDD.isEmpty = false;
	                YAHOO.util.DragDropMgr.refreshCache();
	            }
	
	        }
	    },
	
	    onDrag: function(e) {
	
	        // Keep track of the direction of the drag for use during onDragOver
	        var x = YAHOO.util.Event.getPageX(e);
	        var y = YAHOO.util.Event.getPageY(e);
	
	        if (y < this.lastY) {
	            this.goingUp = true;
	        } else if (y > this.lastY) {
	            this.goingUp = false;
	        } else if (x < this.lastX) {
	            this.goingUp = true;
	        } else if (x > this.lastX) {
	            this.goingUp = false;
	        }
	        this.lastX = x;
	        this.lastY = y;
	    },
	
	    onDragOver: function(e, id) {
	    
	        var srcEl = this.getEl();
	        var destEl = YAHOO.util.Dom.get(id);
	
	        // We are only concerned with list items, we ignore the dragover
	        // notifications for the list.
	        if (destEl.nodeName.toLowerCase() == "div") {
	            var orig_p = srcEl.parentNode;
	            var p = destEl.parentNode;
	
	            if (this.goingUp) {
	                p.insertBefore(srcEl, destEl); // insert above
	            } else {
	                p.insertBefore(srcEl, destEl.nextSibling); // insert below
	            }
	
	            YAHOO.util.DragDropMgr.refreshCache();
	        }
	    }
	});
	var blind_ajax_ajax = {
		handleSuccess:function(o){},
		handleFailure:function(o){},
		startRequest:function(url) {
		   YAHOO.util.Connect.asyncRequest("POST", url, blind_ajax_callback);
		}
	};
	var blind_ajax_callback =
	{
		success: blind_ajax_ajax.handleSuccess,
		failure: blind_ajax_ajax.handleFailure,
		scope:   blind_ajax_ajax
	};
	YAHOO.ks.blind_ajax=function(url)
	{
		blind_ajax_ajax.startRequest(url);
	}
});