
	/**
	 * This is the default javascript file included in every act
	 * if you do not wish to include core/base.js add the following param to your front
	 * protected $bIncludeJavascriptCoreBase = false;
	 */


	/**
	 * This function retrieves an Element By Id
	 * @param sElementName
	 * @return object or null
	 */
	function getElement(sElementName)
	{
		return getElementById(sElementName);
	}

	/**
	 * This function retrieves an Element By Id
	 * @param sElementName
	 * @return object or null
	 */
	function getElementById(sElementName)
	{
		return document.getElementById(sElementName);
	}

	/**
	 * This function retrieves all element by a given tagname
	 * @param sElementName
	 * @return array of objects
	 */
	function getElementsByTagName(sTagName)
	{
		return document.getElementsByTagName(sTagName);
	}

	/**
	 * This function retrieves a first parent by class name
	 * @param oElement
	 * @param sClassName
	 * @return element or false
	 */
	function getFirstParentByClassName( oElement, sClassName )
	{
		if ("object" === typeof(oElement) && oElement.parentNode && "undefined" !== typeof(oElement.parentNode))
		{
			if ("undefined" !== typeof(oElement.parentNode.className) && -1 !== oElement.parentNode.className.indexOf(sClassName) )
			{
				return oElement.parentNode;
			}
			return getFirstParentByClassName( oElement.parentNode, sClassName );
		}
		return false;
	}

	/**
	 * This function inserts a node after a reference node instead of before.
	 * @param oNode
	 * @param oReferenceNode
	 * @return null;
	 */
	function insertAfter(oNode, oReferenceNode)
	{
		oParent = oReferenceNode.parentNode;
		if (null !== oParent && "undefined" !== typeof(oParent))
		{
			oParent.insertBefore(oNode, oReferenceNode.nextSibling);
		}
		return null;
	}

	/**
	 * This function sets an attribute to an object holding in regards the best methods
	 * to use for multi-browser-compatability 
	 * @param oObject
	 * @param sAttributeName
	 * @param mAttributeValue
	 * @return oObject
	 */
	function setAttribute(oObject, sAttributeName, mAttributeValue)
	{
		if ("object" !== typeof(oObject))
		{
			return false;
		}
		switch(sAttributeName)
		{
			case 'class':
			{
				alert("You cannot add the class attribute with this function use the class functions instead");
				return false;
			}
			break;

			case 'id':
			{
				oObject.id = mAttributeValue;
				oObject.setAttribute(sAttributeName, mAttributeValue);
			}
			break;

			default:
			{
				if (sAttributeName.indexOf('breox') === -1)
				{
					return false;
				}
				oObject.setAttribute(sAttributeName, mAttributeValue);
			}
			break;
		}
		return oObject;
	}

	/**
	 * This function switches boxes in visibility
	 * @param oBoxOne
	 * @param oBoxTwo
	 * @return null
	 */
	function switchBoxes(oBoxOne, oBoxTwo)
	{
		if ("undefined" !== typeof(oBoxOne) && "undefined" !== typeof(oBoxTwo))
		{
			if (oBoxOne.style.display === 'none')
			{
				oBoxOne.style.display = '';
				oBoxTwo.style.display = 'none';
			}
			else
			{
				oBoxOne.style.display = 'none';
				oBoxTwo.style.display = '';
			}
		}
	}

	/**
	 * This function switches texts within an object
	 * @param oObject
	 * @param sStringOne
	 * @param sStringTwo
	 * @return
	 */
	function switchText(oObject, sStringOne, sStringTwo)
	{
		if (oObject.innerHTML === sStringTwo)
		{
			oObject.innerHTML = sStringOne;
		}
		else
		{
			oObject.innerHTML = sStringTwo;
		}
	}

	/**
	 * This function reverses a string
	 * @param sString
	 * @return
	 */
	function reverseString(sString)
	{
		var sNewString = '';
		for (i = strlen(sString); i >= 0; i--)
		{
			sNewString += sString.substr(i,1);
		}
		return sNewString;
	}

	/**
	 * this function checks if a variable has been set
	 * @param sVarname
	 * @return
	 */
	function isset(sVarname)
	{
		return sVarname != undefined;
	}

	/**
	 * This function checks wether a variable exists out of numbers (and .) only
	 * @param sText
	 * @return
	 */
	function isNumeric(sText)
	{
		var sValidChars = "0123456789.";
		var bIsNumber=true;
		var sChar;
		var iTextLength	=	sText.length;

		for (var iCount = 0; iCount < iTextLength && bIsNumber == true; iCount++)
		{
			sChar = sText.charAt(iCount);
			if (sValidChars.indexOf(sChar) == -1)
			{
				bIsNumber = false;
			}
		}
		return bIsNumber;
	}

	/**
	 * This function checks wether a string is empty or not
	 * @param sText
	 * @return
	 */
	function empty(sText)
	{
		if (sText === "" || sText === null)
		{
			return true;
		}
		return false;
	}

	/**
	 * This function returns the length of a string
	 * @param sText
	 * @return
	 */
	function strlen(sText)
	{
		return sText.length;
	}

	/**
	 * this function returns a string in uppercase
	 * @param sText
	 * @return
	 */
	function strtoupper(sText)
	{
		return sText.toUpperCase();
	}

	/**
	 * this function returns a string in lowercase
	 * @param sText
	 * @return
	 */
	function strtolower(sText)
	{
		return sText.toLowerCase();
	}

	/**
	 * This function trims a string
	 * @param sText
	 * @return
	 */
	function trim(sText)
	{
  		sText = sText.replace(/^\s+/,'');
  		sText = sText.replace(/\s+$/,'');
  		return sText;
	}

	/**
	 * this function returns the strposition
	 * @param sHayStack
	 * @param sNeedle
	 * @return
	 */
	function strpos(sHayStack, sNeedle)
	{
		return sHayStack.indexOf(sNeedle);
	}

	/**
	 * this function checks if its a valid date
	 * @param sMonth
	 * @param sDay
	 * @param sYear
	 * @return
	 */
	function checkdate( sMonth, sDay, sYear )
	{
	    var sMyDate = new Date();
    	sMyDate.setFullYear( sYear, (sMonth - 1), sDay );
	    return ( (sMyDate.getMonth()+1) == sMonth );
	}

	/**
	 * This function checks wether an object is an array
	 * @param mArray
	 * @return
	 */
	function is_array(mArray)
	{
		return typeof(mArray).toLowerCase() === 'array';
	}

	/**
	 * this function adds an event to an object
	 * @param sEventType
	 * @param oEvent
	 * @param oParentObject
	 * @return
	 */
	function addEvent(sEventType, oEvent, oParentObject)
	{
		if ("undefined" === typeof(oParentObject))
		{
			oParentObject = window;
		}

		if ("undefined" !== typeof(oParentObject.addEventListener))
		{
			oParentObject.addEventListener(sEventType, oEvent, true);
		}
		else if ("undefined" !== typeof(oParentObject.attachEvent))
		{
			oParentObject.attachEvent(sEventType, oEvent);
		}
		else
		{
			if (null !== oParentObject.getAttribute(sEventType))
			{
				oParentObject.setAttribute(sEventType, oParentObject.getAttribute(sEventType)+oEvent.toString());
			}
			else
			{
				oParentObject.setAttribute(sEventType, oEvent.toString());
			}
		}
		return true;
	}

	/**
	 * This function is an alternative option to add an event to an object
	 * @param sEventType
	 * @param sFunction
	 * @param oElement
	 * @param bUseCapture
	 * @return
	 */
	function d_addEvent(sEventType, sFunction, oElement, bUseCapture)
	{
		if(oElement.addEventListener) {
			oElement.addEventListener(sEventType, sFunction, bUseCapture);
			return true;
		} else if (oElement.attachEvent) {
			var bResult = oElement.attachEvent("on"+sEventType, sFunction);
			return bResult;
		} else {
			alert('Handler could not be added');
		}
	}

	/**
	 * this function returns an events source
	 * @param oEvent
	 * @return
	 */
	function getEventSource(oEvent)
	{
		if ("undefined" !== typeof(window.event))
		{
			oEvent	=	window.event;
			return oEvent.srcElement;
		}
		return oEvent.target;
	}

	/**
	 * this function lets the browser sleep, though the browser does lock
	 * @param iMiliSeconds
	 * @return
	 */
	function sleep(iMiliSeconds)
	{
		var iStart = new Date().getTime();
		while (new Date().getTime() < iStart + iMiliSeconds)
		{
			// sleep
		}
	}
	
	/**
	 * This function tries to call the given function by string object etc.
	 * @param mFunction
	 * @param aParams
	 * @return
	 */
	function call_user_func(mFunction, aParams)
	{
		var mReturn = null;
		if ("undefined" === typeof(aParams))
		{
			aParams = new Array();
		}
		else if ("object" !== typeof(aParams))
		{
			var sTmp	= aParams;
			aParams 	= new Array();
			aParams[0]	= sTmp;
		}

		var sParams = "";
		for (var pCount = 0; pCount < aParams.length; pCount++)
		{
			eval("var mParam"+pCount+ " = aParams[pCount]");
			if (sParams !== "")
			{
				sParams += ", ";
			}
			sParams += "mParam"+pCount;
		}

		if ("function" === typeof(mFunction))
		{
			try
			{
				eval("mReturn = mFunction("+sParams+")");
			}
			catch (e)
			{

			}
		}
		else if ("object" === typeof(mFunction) && "undefined" !== typeof(mFunction[0]) && "undefined" !== typeof(mFunction[1]))
		{
			if ("object" === typeof(mFunction[1]) && "function" === typeof(mFunction[0].mFunction[1]))
			{
				try
				{
					eval("mReturn = mFunction[0].mFunction[1]("+sParams+")");
				}
				catch (e)
				{

				}
			}
			else if("function" === typeof(eval("mFunction[0]."+mFunction[1])))
			{
				try
				{
					eval("mReturn = mFunction[0]."+mFunction[1]+"("+sParams+")");
				}
				catch (e)
				{

				}
			}
		}
		else
		{
			try
			{
				eval("mReturn = "+mFunction);
			}
			catch (e)
			{
				eval(mFunction);
			}
		}
		return mReturn;
	}
	
	/**
	 * this function checks wether an item is currently displayed or not and then reverses that.
	 * @param sElementId
	 * @return
	 */
	function showHideItem( sElementId )
	{
		oObject = getElementById( sElementId );
		
		if ( null !== oObject )
		{
			if ( oObject.style.display === 'none' )
			{
				oObject.style.display = '';
			}
			else
			{
				oObject.style.display = 'none';
			}
		}
		return oObject;
	}
	
	/**
	 * This function adds given param
	 * @param sUrl
	 * @param aParams
	 * @return
	 */
	function addParamsToUrl(sUrl, aParams)
	{
		var sChar	=	'?';
		if (-1 !== sUrl.indexOf("?"))
		{
			sChar	=	'&';
		}
		
		for (var sParamName in aParams)
		{
			if ("indexOf" !== sParamName)
			{
				sUrl += sChar + sParamName + '=' + escape(aParams[sParamName]);
			}
		}
		return sUrl;
	}
	
	/**
	 * This function renders a flash string
	 */
	function getFlashHtmlCode(sFileName, iFlashWidth, iFlashHeight, sScriptAccess)
	{
		if ('undefined' === typeof(sScriptAccess))
		{
			sScriptAccess = 'sameDomain';
		}
		var sFlashCode	=	'<object type="application/x-shockwave-flash" id="flash_item_%CUSTOMID%" data="%FLASHURL%" width="%FLASHWIDTH%" height="%FLASHHEIGHT%" class="swfupload">'
						+	'<param name="wmode" value="transparent" />'
						+	'<param name="movie" value="%FLASHURL%" />'
						+	'<param name="quality" value="high" />'
						+	'<param name="menu" value="false" />'
						+	'<param name="allowScriptAccess" value="%SCRIPTACCES%" />'
						+	'</object>';
		return sFlashCode.replace(/%FLASHURL%/g, sFileName).replace(/%CUSTOMID%/g, Math.round(Math.random() * Math.random() * 1000000)).replace(/%FLASHWIDTH%/g, iFlashWidth).replace(/%FLASHHEIGHT%/g, iFlashHeight).replace(/%SCRIPTACCES%/, sScriptAccess);
	}
	
