function scaleImage(p_o_Image,p_i_MaxWidth,p_i_MaxHeight){

		var l_i_ImgWidth=p_o_Image.clientWidth;
		var l_i_ImgHeight=p_o_Image.clientHeight;
		var l_d_ImgWFact=p_i_MaxWidth/p_o_Image.clientWidth;
		var l_d_ImgHFact=p_i_MaxHeight/p_o_Image.clientHeight;
		if (p_o_Image.src.indexOf("_fixed.")==-1 || p_i_MaxWidth<l_i_ImgWidth || p_i_MaxHeight<l_i_ImgHeight){
			if (l_d_ImgHFact==0 || l_d_ImgWFact<l_d_ImgHFact){
				p_o_Image.style.width=p_i_MaxWidth + "px";
				if (l_i_ImgHeight>0){
					if (p_o_Image.clientHeight==l_i_ImgHeight){
						p_o_Image.style.height=parseInt(p_o_Image.clientHeight*l_d_ImgWFact) + "px";
						p_o_Image.style.width="";
					}
					else{
						p_o_Image.style.height=p_o_Image.clientHeight + "px";
						p_o_Image.style.width="";
					}
				}
			}
			else{
				p_o_Image.style.height=p_i_MaxHeight + "px";
				if (l_i_ImgWidth>0){
					if( l_i_ImgWidth==p_o_Image.clientWidth) {
						p_o_Image.style.width=parseInt(p_o_Image.clientWidth*l_d_ImgHFact)+ "px";
						p_o_Image.style.height="";
					}
					else{
						p_o_Image.style.width=p_o_Image.clientWidth+ "px";
						p_o_Image.style.height="";

					}
				}
			}
		}
}
function str_AppendSearchCharacter(p_str_Search){
	if (p_str_Search==null || p_str_Search==""){
		return "?";
	}
	else{
		return "&";
	}
}
function o_ParentElement(p_o_Element){
	var l_o_ParentElement;
	if (p_o_Element.parentElement){
		//IE
		l_o_ParentElement=p_o_Element.parentElement;
	} else if (p_o_Element.parentNode){
		//firefox
		l_o_ParentElement=p_o_Element.parentNode;
	}
	return l_o_ParentElement;
}
 function setVisibility(p_o_Element,p_b_Visible, p_b_ChildrenIncl){
	if (!p_o_Element) return;
	var l_b_Set=false;
	if (p_o_Element.visibility){
		//IE
		l_b_Set=true;
		if (p_b_Visible){
			p_o_Element.visibility="visible";
		}
		else{
			p_o_Element.visibility="hidden";
		}
	}
	else if (p_o_Element.style){
		l_b_Set=true;
		if (p_b_Visible){
			p_o_Element.style.visibility="visible";
		}
		else{
			p_o_Element.style.visibility="hidden";
		}
	}
	if(l_b_Set && p_b_ChildrenIncl){
		for (var l_i_i=0;l_i_i<p_o_Element.childNodes.length;l_i_i++){
			setVisibility(p_o_Element.childNodes[l_i_i],p_b_Visible, p_b_ChildrenIncl);
		}
	}

}
function isVisible(p_o_Element){
	if (p_o_Element.visibility){
		//IE
		return p_o_Element.visibility;
	}
	else {
		return p_o_Element.style.visibility;
	}
}
function setDisplay(p_o_Element, p_str_DisplayValue){
	if (p_o_Element.display){
		//IE
		p_o_Element.display=p_str_DisplayValue;
	}
	else if(p_o_Element.style){
			p_o_Element.style.display=p_str_DisplayValue;
	}
}
function str_URLparameter(p_str_Url,p_str_ParName){
	if(p_str_Url.indexOf("?")==-1){
		return "";
	}
	var l_str_Pars=p_str_Url.split("?")[1];
	var l_stra_Pars=l_str_Pars.split("&");
	var l_stra_ParsParts;
	for (var l_i_i=0;l_i_i<l_stra_Pars.length;l_i_i++){
		l_stra_ParsParts=l_stra_Pars[l_i_i].split("=");
		if (l_stra_ParsParts[0]==p_str_ParName){
			return l_stra_ParsParts[1];
			
		}
	}
	return "";
}
function i_scaleAttrByWidth(p_i_MinAttrSize,p_i_MaxAttrSize){
	return parseInt(window.windowGeometry.getViewportWidth()/screen.width*(p_i_MaxAttrSize-p_i_MinAttrSize)+p_i_MinAttrSize);	
}
function i_scaleAttrByHeight(p_i_MinAttrSize,p_i_MaxAttrSize){
	return parseInt(window.windowGeometry.getViewportHeight()/screen.height*(p_i_MaxAttrSize-p_i_MinAttrSize) + p_i_MinAttrSize);
}
function i_scaleAttr(p_i_MinAttrSize,p_i_MaxAttrSize){
	var l_i_WidthSize=i_scaleAttrByWidth(p_i_MinAttrSize,p_i_MaxAttrSize);
	var l_i_HeightSize=i_scaleAttrByHeight(p_i_MinAttrSize,p_i_MaxAttrSize);
	if (l_i_WidthSize>l_i_HeightSize){
		return l_i_HeightSize;
	}
	else{
		return l_i_WidthSize;
	}
}
function str_scaleAttr2Width(p_ia_WidthLimits,p_stra_AttrValues,p_i_WindowWidth){
	for (var l_i_i=0;l_i_i<p_ia_WidthLimits.length;l_i_i++){
		if (p_i_WindowWidth<p_ia_WidthLimits[l_i_i]){
			return p_stra_AttrValues[l_i_i];	
		}
		else{
			if (l_i_i<p_ia_WidthLimits.length+1){
				if (p_i_WindowWidth<p_ia_WidthLimits[l_i_i+1]){
					return p_stra_AttrValues[l_i_i];
				}
			}
			else{
				return p_stra_AttrValues[l_i_i];	
			}
		}
	}
	return p_stra_AttrValues[l_i_i-1];
}
function i_clientY(p_o_Element){
	var l_i_clientY=p_o_Element.offsetTop;
	var l_o_parentElement=p_o_Element.offsetParent;
	if (l_o_parentElement!=null){
		do{
			l_i_clientY+=l_o_parentElement.offsetTop;
			l_o_parentElement=l_o_parentElement.offsetParent;	
		} while (l_o_parentElement!=null)
	}
	return l_i_clientY;
}
function i_clientX(p_o_Element){
	var l_i_clientX=p_o_Element.offsetLeft;
	var l_o_parentElement=p_o_Element.offsetParent;
	if (l_o_parentElement!=null){
		do{
			l_i_clientX+=l_o_parentElement.offsetLeft;
			l_o_parentElement=l_o_parentElement.offsetParent;	
		} while (l_o_parentElement!=null)
	}
	return l_i_clientX;
}
function oa_getElementsByTagName(p_str_className,p_str_tagName,p_o_root,p_b_GrandChildrenIncl){
	return oa_getElementsByClass(p_str_className,p_str_tagName,p_o_root,p_b_GrandChildrenIncl);
}
function oa_getElementsByClass(p_str_className,p_str_tagName,p_o_root,p_b_GrandChildrenIncl){
	if (!p_o_root) p_o_root=document;
	else if (typeof p_o_root=="string") p_o_root=document.getElementById(p_o_root);
	if (!p_str_tagName) p_str_tagName="*";
	var l_oa_all=p_o_root.getElementsByTagName(p_str_tagName);
	if (!p_str_className) {
		if(p_b_GrandChildrenIncl){
			return l_oa_all;
		}
		else{
			var l_oa_elements=[];
			for (var l_i_i=0;l_i_i<l_oa_all.length;l_i_i++){
				var l_o_element=l_oa_all[l_i_i];
				if (o_ParentElement(l_o_element)==p_o_root){
					l_oa_elements.push(l_o_element)
				}
			}
			return l_oa_elements;
		}
	}
	var l_oa_elements=[];
	for (var l_i_i=0;l_i_i<l_oa_all.length;l_i_i++){
		var l_o_element=l_oa_all[l_i_i];
		if (isClassMember(l_o_element,p_str_className))
			if (p_b_GrandChildrenIncl || o_ParentElement(l_o_element)==p_o_root){
				l_oa_elements.push(l_o_element);
			}
	}
	return l_oa_elements;
}
function isClassMember(p_o_element,p_str_className){
	var l_str_classes=p_o_element.className;
	if (!l_str_classes) return false;
	if (l_str_classes==p_str_className) return true; //found
	var l_o_whitespace=/\s+/; //regex
	if (!l_o_whitespace.test(l_str_classes)) return false; //not multiple classes
	//check classes individually
	var l_stra_classes=l_str_classes.split(l_o_whitespace);
	for (var l_i_i=0;l_i_i<l_stra_classes.length;l_i_i++){
		if (l_stra_classes[l_i_i]==p_str_className) return true; //found
	}
	return false;
}
function centerElement(p_o_Element){
	var l_o_Parent=o_ParentElement(p_o_Element);
	p_o_Element.style.left=parseInt((l_o_Parent.clientWidth-p_o_Element.clientWidth)/2) + "px";
	p_o_Element.style.top=parseInt((l_o_Parent.clientHeight-p_o_Element.clientHeight)/2) + "px";
}
function o_EventGenerator(p_o_Event){
	if(p_o_Event.srcElement) {/*IE*/
		return p_o_Event.srcElement;
	}
	else{ /*FireFox*/
		return p_o_Event.currentTarget;
		
	}
}
function o_MouseFromElement(p_o_MouseEvent){
	if (p_o_MouseEvent.fromElement){/*IE*/
		return p_o_MouseEvent.fromElement;
		}
	else{
		if (p_o_MouseEvent.type=="mouseover"){
			return p_o_MouseEvent.relatedTarget;
		}
	}
	return null;
}
function o_MouseToElement(p_o_MouseEvent){
	if (p_o_MouseEvent.toElement){/*IE*/
		return p_o_MouseEvent.toElement;
	}
	else{
		if (p_o_MouseEvent.type=="mouseout"){
			return p_o_MouseEvent.relatedTarget;
		}
	}
	return null;
}

function b_MouseInElement(p_o_MouseEvent, p_o_Element){
	if (p_o_MouseEvent==null || p_o_Element==null)return false;
	var l_i_UpperLeftX=i_clientX(p_o_Element);
	var l_i_UpperLeftY=i_clientY(p_o_Element);
	var l_i_Width=p_o_Element.clientWidth;
	var l_i_Height=p_o_Element.clientHeight;
	return (p_o_MouseEvent.clientX>=l_i_UpperLeftX && p_o_MouseEvent.clientX<=l_i_UpperLeftX+p_o_Element.clientWidth
		&& p_o_MouseEvent.clientY>=l_i_UpperLeftY && p_o_MouseEvent.clientY<=l_i_UpperLeftY+p_o_Element.clientHeight);
}
function str_HomeDir(){
	var l_str_Dir=window.location.pathname;
	var l_i_Index=l_str_Dir.indexOf("/htmlpages");
	if (l_i_Index==-1) l_i_Index=l_str_Dir.lastIndexOf("/");
	l_str_Dir=l_str_Dir.substring(0,l_i_Index+1);
	return l_str_Dir;
}
var eventHandler = {};

// In DOM-compliant browsers, our functions are trivial wrappers around
// addEventListener() and removeEventListener().
if (document.addEventListener) {
    eventHandler.add = function(element, eventType, handler) {
        element.addEventListener(eventType, handler, false);
    };

    eventHandler.remove = function(element, eventType, handler) {
        element.removeEventListener(eventType, handler, false);
    };
}
// In IE 5 and later, we use attachEvent() and detachEvent(), with a number of
// hacks to make them compatible with addEventListener and removeEventListener.
else if (document.attachEvent) {
    eventHandler.add = function(element, eventType, handler) {
        // Don't allow duplicate handler registrations
        // _find() is a private utility function defined below.
        if (eventHandler._find(element, eventType, handler) != -1) return;
        
        // To invoke the handler function as a method of the
        // element, we've got to define this nested function and register
        // it instead of the handler function itself.
        var wrappedeventHandler = function(e) {
            if (!e) e = window.event;

            // Create a synthetic event object with partial compatibility
            // with DOM events.
            var event = {
                _event: e,    // In case we really want the IE event object
                type: e.type,           // Event type
                target: e.srcElement,   // Where the event happened
                currentTarget: element, // Where we're handling it
                relatedTarget: e.fromElement?e.fromElement:e.toElement,
                eventPhase: (e.srcElement==element)?2:3,

                // Mouse coordinates
                clientX: e.clientX, clientY: e.clientY,
                screenX: e.screenX, screenY: e.screenY,
                
                // Key state
                altKey: e.altKey, ctrlKey: e.ctrlKey,
                shiftKey: e.shiftKey, charCode: e.keyCode,

                // Event management functions
                stopPropagation: function() {this._event.cancelBubble = true;},
                preventDefault: function() {this._event.returnValue = false;}
            }

            // Invoke the handler function as a method of the element, passing
            // the synthetic event object as its single argument.
            // Use Function.call() if defined; otherwise do a hack
            if (Function.prototype.call) 
                handler.call(element, event);
            else {
                // If we don't have Function.call, fake it like this
                element._currenteventHandler = handler;
                element._currenteventHandler(event);
                element._currenteventHandler = null;
            }
        };

        // Now register that nested function as our event handler.
        element.attachEvent("on" + eventType, wrappedeventHandler);
        
        // Now we must do some record keeping to associate the user-supplied
        // handler function and the nested function that invokes it.

        // We have to do this so that we can deregister the handler with the
        // remove() method and also deregister it automatically on page unload.

        // Store all info about this handler into an object
        var h = {
            element: element,
            eventType: eventType,
            handler: handler,
            wrappedeventHandler: wrappedeventHandler
        };

        // Figure out what document this handler is part of.
        // If the element has no "document" property, it is not
        // a window or a document element, so it must be the document
        // object itself.
        var d = element.document || element;
        // Now get the window associated with that document
        var w = d.parentWindow;

        // We have to associate this handler with the window,
        // so we can remove it when the window is unloaded
        var id = eventHandler._uid();  // Generate a unique property name
        if (!w._alleventHandlers) w._alleventHandlers = {};  // Create object if needed
        w._alleventHandlers[id] = h; // Store the handler info in this object

        // And associate the id of the handler info with this element as well
        if (!element._handlers) element._handlers = [];
        element._handlers.push(id);

        // If there is not an onunload handler associated with the window,
        // register one now.
        if (!w._onunloadeventHandlerRegistered) {
            w._onunloadeventHandlerRegistered = true;
            w.attachEvent("onunload", eventHandler._removeAlleventHandlers);
        }
    };

    eventHandler.remove = function(element, eventType, handler) {
        // Find this handler in the element._handlers[] array.
        var i = eventHandler._find(element, eventType, handler);
        if (i == -1) return;  // If the handler was not registered, do nothing

        // Get the window of this element
        var d = element.document || element;
        var w = d.parentWindow;

        // Look up the unique id of this handler
        var handlerId = element._handlers[i];
        // And use that to look up the handler info
        var h = w._alleventHandlers[handlerId];
        // Using that info, we can detach the handler from the element
        element.detachEvent("on" + eventType, h.wrappedeventHandler);
        // Remove one element from the element._handlers array
        element._handlers.splice(i, 1);
        // And delete the handler info from the per-window _alleventHandlers object
        delete w._alleventHandlers[handlerId];
    };

    // A utility function to find a handler in the element._handlers array
    // Returns an array index or -1 if no matching handler is found
    eventHandler._find = function(element, eventType, handler) {
        var handlers = element._handlers;
        if (!handlers) return -1;  // if no handlers registered, nothing found

        // Get the window of this element
        var d = element.document || element;
        var w = d.parentWindow;

        // Loop through the handlers associated with this element, looking
        // for one with the right type and function.
        // We loop backward because the most recently registered handler
        // is most likely to be the first removed one.
        for(var i = handlers.length-1; i >= 0; i--) {
            var handlerId = handlers[i];        // get handler id
            var h = w._alleventHandlers[handlerId];  // get handler info
            // If handler info matches type and handler function, we found it.
            if (h.eventType == eventType && h.handler == handler) 
                return i;
        }
        return -1;  // No match found
    };

    eventHandler._removeAlleventHandlers = function() {
        // This function is registered as the onunload handler with 
        // attachEvent.  This means that the this keyword refers to the
        // window in which the event occurred.
        var w = this;

        // Iterate through all registered handlers
        for(id in w._alleventHandlers) {
            // Get handler info for this handler id
            var h = w._alleventHandlers[id]; 
            // Use the info to detach the handler
            h.element.detachEvent("on" + h.eventType, h.wrappedeventHandler);
            // Delete the handler info from the window
            delete w._alleventHandlers[id];
        }
    }

    // Private utility to generate unique handler ids
    eventHandler._counter = 0;
    eventHandler._uid = function() { return "h" + eventHandler._counter++; };
}

