MdaradUtilsPrototype = Class.create();
MdaradUtilsPrototype.prototype = {

    MILLISECONDS_IN_A_MINUTE : null,
    MILLISECONDS_IN_AN_HOUR : null,
    MILLISECONDS_IN_A_DAY : null,
    MILLISECONDS_IN_A_YEAR : null,

    initialize: function() {
        this.MILLISECONDS_IN_A_MINUTE = parseInt(60 * 1000);
        this.MILLISECONDS_IN_AN_HOUR = parseInt(this.MILLISECONDS_IN_A_MINUTE * 60);
        this.MILLISECONDS_IN_A_DAY = parseInt(this.MILLISECONDS_IN_AN_HOUR * 24);
        this.MILLISECONDS_IN_A_YEAR = parseInt(this.MILLISECONDS_IN_A_DAY * 365);
    },

    /*************************************************************************
     * Methods used to manipulate window or document
     *************************************************************************/        
    getVisibleHeight: function() {
        var height = window.innerHeight;
        if(!height || height < 0) {
            height = document.documentElement.clientHeight;
        }        
        if(!height || height < 0) {
            height = document.body.clientHeight;
        }
        return height;    
    },
    
    getVisibleWidth: function() {
        var width = window.innerWidth;
        if(!width || width < 0) {
            width = document.documentElement.clientWidth;
        }        
        if(!width || width < 0) {
            width = document.body.clientWidth;
        }
        return width;
    },
    
    changeImageSrc : function (elementId, imgSrc) {
        var element = $(elementId);
        element.src = imgSrc;
        
    },
    
    /*************************************************************************
     * Methods used to navigate the DOM
     *************************************************************************/        
    findChild: function(parentNode, tagName) {
        for(var i = 0; i < parentNode.childNodes.length; i++) {
            var child = parentNode.childNodes[i];
            if(tagName && child.tagName) {
                if(child.tagName.toLowerCase() == tagName.toLowerCase()) {
                    return child;
                }
            }
        }
        return null;
    },

    findChildWithId: function(parentNode, tagName, id) {
        for(var i = 0; i < parentNode.childNodes.length; i++) {
            var child = parentNode.childNodes[i];
            if(tagName && child.tagName) {
                if(child.tagName.toLowerCase() == tagName.toLowerCase() && id.toLowerCase() == child.id.toLowerCase()) {
                    return child;
                }
            }
        }
        return null;
    },
    
    findChildren: function(parentNode, tagName) {
        var childArray = new Array();
        for(var i = 0; i < parentNode.childNodes.length; i++) {
            var child = parentNode.childNodes[i];
            if(tagName && child.tagName) {
                if(child.tagName.toLowerCase() == tagName.toLowerCase()) {
                    childArray.push(child);
                } 
            }
        }
        return $A(childArray);
    },
    
    appendChildren: function(parent, childList) {
        if (parent && childList) {
            for(var i = 0; i < childList.length; i++) {
                var child = childList[i];
                parent.appendChild(child);
            }
         }
    },
    
    deleteChildren: function(parent, childList) {
        if ($(parent) && childList) {
            for(var i = 0; i < childList.length; i++) {
                var child = childList[i];
                parent.removeChild(child);
            }
        }
    },
    
    deleteAllChildren: function(element) {
        if(element) {
            while(element.firstChild) {
                element.removeChild(element.firstChild);
            }
        }
    },
    
    createXMLDocument: function () {
       try {
           if (document.implementation && document.implementation.createDocument) {
               var doc = document.implementation.createDocument("", "", null);
        
               // some versions of Moz do not support the readyState property
               // and the onreadystate event so we patch it!
               if (doc.readyState == null) {
                   doc.readyState = 1;
                   doc.addEventListener("load", function () {
                       doc.readyState = 4;
                       if (typeof doc.onreadystatechange == "function")
                           doc.onreadystatechange();
                   }, false);
               }
               return doc;
           }
           if (window.ActiveXObject) {
               return new ActiveXObject(MdaradUtils.getControlPrefix() + ".XmlDom");
           }
       } catch (ex) {}
       throw new Error("Your browser does not support XmlDocument objects");
    },

    getXMLFragment: function(requestObject, pathPrefix) {
        var returnedDataislandXMLDocument = null;
        //Not IE 
        if (document.implementation && document.implementation.createDocument){
            returnedDataislandXMLDocument = requestObject.responseXML;      
        } 
        //IE
        else if (window.ActiveXObject) {
            try {
                returnedDataislandXMLDocument = new ActiveXObject("MSXML.DomDocument");
            } catch(e) {
                try {
                    returnedDataislandXMLDocument = new ActiveXObject("Msxml2.XMLHTTP");
                } catch(e) {
                    try {
                        returnedDataislandXMLDocument = new ActiveXObject("Microsoft.XMLHTTP");
                    } catch(e) {
                        throw "The ActiveXObject could not be created when retrieving XML document: " + e;
                    }
                }
            }
            returnedDataislandXMLDocument.loadXML(requestObject.responseText);
        }

        var returnedXMLDocumentFragment = null;
        if(returnedDataislandXMLDocument.firstChild && returnedDataislandXMLDocument.firstChild.nodeName == "xml") {
            returnedXMLDocumentFragment = returnedDataislandXMLDocument.childNodes[1];
        } else if(returnedDataislandXMLDocument.firstChild) {
            returnedXMLDocumentFragment = returnedDataislandXMLDocument.firstChild;
        } else {
            returnedXMLDocumentFragment = returnedDataislandXMLDocument;
        }
        
        if(returnedXMLDocumentFragment.tagName == 'Message') {
            var errorCode = returnedXMLDocumentFragment.getAttribute("statusCode");
            if(errorCode == "403") {
                window.location = pathPrefix + '/authentication/display.do?errorMessage=global.login.exception.exception.UnauthorizedUserException';            
            }
        }
        return returnedXMLDocumentFragment;
    },
    
    getControlPrefix: function() {
        var prefixes = ["MSXML2", "MSXML", "MSXML3", "Microsoft"];
        var o, o2;
        for (var i = 0; i < prefixes.length; i++) {
            try {
                // try to create the objects
                o = new ActiveXObject(prefixes[i] + ".XmlHttp");
                o2 = new ActiveXObject(prefixes[i] + ".XmlDom");
                return prefixes[i];
            } catch (ex) {};
        }
       throw new Error("Could not find an installed XML parser");
    },
    
    checkFirstSelectOption: function(selectId) {
        for(var i = 0; i < $(selectId).childNodes.length; i++ ) {
            var child = $(selectId).childNodes[i];
            if(child.nodeType == 1) {
                child.selected = true;
                break;
            }
        }
    },
    
    removeAllSelectOptionsExceptFirst: function(selectId) {
        var select = $(selectId);
        
        for (var i = select.length - 1; i >= 0; i--) {
            var child = select.options[i];
            if(i != 0) {
                select.remove(i);
            }
        }
    },

    /*************************************************************************
     * Methods used to parse information
     *************************************************************************/
    convertDateToDateString: function(date) {
        var year = date.getFullYear().toString();
        var month = (date.getMonth() + 1).toString();
        if(month.length == 1) {
            month = '0' + month;
        }
        var day = date.getDate().toString();
        if(day.length == 1) {
            day = '0' + day;
        }
        
        return year + '-' + month + '-' + day;
    },

    convertDateToDatetimeString: function(date) {
        var year = date.getFullYear().toString();
        var month = (date.getMonth() + 1).toString();
        if(month.length == 1) {
            month = '0' + month;
        }
        var day = date.getDate().toString();
        if(day.length == 1) {
            day = '0' + day;
        }
        var hours = date.getHours().toString();
        if(hours.length == 1) {
            hours = '0' + hours;
        }
        var minutes = date.getMinutes().toString();
        if(minutes.length == 1) {
            minutes = '0' + minutes;
        }
        
        return year + '-' + month + '-' + day + " " + hours + ":" + minutes;
    },

    convertDateToTimeString: function(date) {
        var hours = date.getHours().toString();
        var minutes = date.getMinutes().toString();
        if(hours.length == 1) {
            hours = '0' + hours;
        }
        if(minutes.length == 1) {
            minutes = '0' + minutes;
        }
        
        return hours + ':' + minutes;
    },
    
    convertDateStringToDate: function(dateString) {
        var date = new Date();
        var dateRegExp = /([0-9][0-9][0-9][0-9])-([0-1]?[0-9])-([0-3]?[0-9])/;
        var dateRegExpArray = dateString.match(dateRegExp);
        if(dateRegExpArray != null) {
            var yearValue = dateRegExpArray[1];
            var monthValue = dateRegExpArray[2];
            var dayValue = dateRegExpArray[3];
            date.setFullYear(new Number(yearValue));
            date.setMonth(new Number(monthValue) - 1);
            date.setDate(new Number(dayValue));
            date.setHours(new Number(0));
            date.setMinutes(new Number(0));
            date.setSeconds(new Number(0));
            date.setMilliseconds(new Number(0));
        } else {
            return null;
        }
        return date;
    }, 

    convertDatetimeStringToDate: function(dateString) {
        var date = new Date();
        var dateRegExp = /([0-9][0-9][0-9][0-9])-([0-1]?[0-9])-([0-3]?[0-9])\s([0-2]?[0-9]):([0-5]?[0-9])/;
        var dateRegExpArray = dateString.match(dateRegExp);
        var yearValue = dateRegExpArray[1];
        var monthValue = dateRegExpArray[2];
        var dayValue = dateRegExpArray[3];
        var hoursValue = dateRegExpArray[4];
        var minutesValue = dateRegExpArray[5];
        
        date.setFullYear(new Number(yearValue));
        date.setMonth(new Number(monthValue) - 1);
        date.setDate(new Number(dayValue));
        date.setHours(new Number(hoursValue));
        date.setMinutes(new Number(minutesValue));
        date.setSeconds(new Number(0));
        date.setMilliseconds(new Number(0));
        
        return date;
    }, 
    
    convertTimeStringToDate: function(date, timeString) {
        var dateRegExp = /([0-2]?[0-9]):([0-5]?[0-9])/;
        var dateRegExpArray = timeString.match(dateRegExp);
        var hoursValue = dateRegExpArray[1];
        var minutesValue = dateRegExpArray[2];
        
        date.setHours(hoursValue);
        date.setMinutes(minutesValue);
        return date;
    },
    
    addYearsToDate: function(dateObj, nbOfYears) {
        var datesAsMillis = dateObj.getTime();
        var newDateTime = datesAsMillis + this.MILLISECONDS_IN_A_YEAR * parseInt(nbOfYears);
        var newDate = new Date();
        newDate.setTime(newDateTime);
        return newDate;
    },
    
    /********************************************
     * Convert a number to currency format.
     * Ex:"45" -> "45.00$"
     *********************************************/
    convertNumberToCurrency: function(number) {
        if(!number) {
            number = 0.0;
        }
        return parseFloat(number).toFixed(2) + "$";
    },
    
    /**********************************************
     * Convert a currency format to number.
     * Ex:"45.00$" -> "45.00"
     *********************************************/
    convertCurrencyToNumber : function(currency){
        var number = "";
        
        if(currency.charAt(currency.length - 1) == '$'){
            number = currency.substring(0, currency.length - 1);
        }
        else {
            throw ("Node is not currency format");
        }
       
       return number;
    },
    
    isNumeric : function(strString) {
        if(strString == null) {
            return false;
        }
        
        //  check for valid numeric strings 
        var strValidChars = "0123456789.-";
        var strChar;
        var blnResult = true;
    
        if (strString.length == 0) return false;
            //  test strString consists of valid characters listed above
            for (i = 0; i < strString.length && blnResult == true; i++) {
                strChar = strString.charAt(i);
                if (strValidChars.indexOf(strChar) == -1) {
                    blnResult = false;
            }
        }
        return blnResult;
    },
    
    firstCharLowerCase: function(string) {
        if(string.length > 1) {
            return string.substr(0,1).toLowerCase() + string.substr(1,string.length);
        }
        return string;
    },

        
    /*************************************************************************
     * Methods used to manage events
     *************************************************************************/
    addEvent: function(elem, evType, func, useCapture) {
        Event.observe(elem, evType, func, useCapture);
    },
    
    generateRandomNumber : function() {
        return Math.floor(Math.random()* 1000000 +1)
    },
    
    getTarget: function(event) {
        var target;
        if (!event) {
            event = window.event;
        }
        
        if (event.target) {
            target = event.target;
        } else if (event.srcElement) {
            target = event.srcElement;
        }
        return target;
    }, 
    
    /*************************************************************************
     * General object methods
     *************************************************************************/
    cloneObject : function(objectToClone){
        var clonedObject = {};
        for(var i in objectToClone){
            clonedObject[i] = objectToClone[i];
        }
        return clonedObject;
    },
    
    numberFormat: function(num, dec) {
        var mul = Math.pow(10,dec);
        num = num * mul;
        num = Math.round(num);
        num = num/mul;
        
        var numstr=String(num);
        if(numstr.indexOf(".") == -1) {
            numstr = numstr + ".";
            for(nfi = 0; nfi < dec; nfi++) {
                numstr = numstr + "0";
            }
        }
        var decpl = numstr.length - numstr.indexOf(".");
        decpl = decpl - 1;
        if (decpl < dec) {
            for(nfi = decpl; nfi < dec; nfi++) {
                numstr = numstr + "0";
            }
        }
        return (numstr);
    },

    getURLParameter: function(strParamName){
      var strReturn = "";
      var strHref = window.location.href;
      if ( strHref.indexOf("?") > -1 ){
        var strQueryString = strHref.substr(strHref.indexOf("?"));
        var aQueryString = strQueryString.split("&");
        for ( var iParam = 0; iParam < aQueryString.length; iParam++ )
        {
          if (aQueryString[iParam].indexOf(strParamName + "=") > -1 )
          {
            var aParam = aQueryString[iParam].split("=");
            strReturn = aParam[1];
            break;
          }
        }
      }
      return strReturn;
    },
    
    /**
     * This method returns a url string with the parameters passed
     * as arguments.
     * @param url string containing the url to which add the parameters
     * @param JSON or Hash containing the parameters
     */
    addParametersToURL: function(url, parameters) {
        parameters = $H(parameters);
        if(parameters.keys().length > 0) {
            url += "?";
            url += parameters.toQueryString(parameters);
        }
        
        return url;
    },
    
    roundTo2Decimals: function(number) {
        return Math.round(parseFloat(number) * 100) / 100;
    },
     
    /*************************************************************************
     * Localization Methods
     *************************************************************************/
     getLocaleSuffix: function(locale) {
         if (locale && locale != '')  return '[' + locale + ']';
         else return '';
     },

    /*************************************************************************
     * XML vs JSON converters
     *************************************************************************/
    xml2json: function(xml, tab) {
       if(!tab) {tab = '';}
       var X = {
          toObj: function(xml) {
             var o = {};
             if (xml.nodeType==1) {   // element node ..
                if (xml.attributes.length)   // element with attributes  ..
                   for (var i=0; i<xml.attributes.length; i++)
                      o["@"+xml.attributes[i].nodeName] = (xml.attributes[i].nodeValue||"").toString();
                if (xml.firstChild) { // element has child nodes ..
                   var textChild=0, cdataChild=0, hasElementChild=false;
                   for (var n=xml.firstChild; n; n=n.nextSibling) {
                      if (n.nodeType==1) hasElementChild = true;
                      else if (n.nodeType==3 && n.nodeValue.match(/[^ \f\n\r\t\v]/)) textChild++; // non-whitespace text
                      else if (n.nodeType==4) cdataChild++; // cdata section node
                   }
                   if (hasElementChild) {
                      if (textChild < 2 && cdataChild < 2) { // structured element with evtl. a single text or/and cdata node ..
                         X.removeWhite(xml);
                         for (var n=xml.firstChild; n; n=n.nextSibling) {
                            if (n.nodeType == 3)  // text node
                               o["#text"] = X.escape(n.nodeValue);
                            else if (n.nodeType == 4)  // cdata node
                               o["#cdata"] = X.escape(n.nodeValue);
                            else if (o[n.nodeName]) {  // multiple occurence of element ..
                               if (o[n.nodeName] instanceof Array)
                                  o[n.nodeName][o[n.nodeName].length] = X.toObj(n);
                               else
                                  o[n.nodeName] = [o[n.nodeName], X.toObj(n)];
                            }
                            else  // first occurence of element..
                               o[n.nodeName] = X.toObj(n);
                         }
                      }
                      else { // mixed content
                         if (!xml.attributes.length)
                            o = X.escape(X.innerXml(xml));
                         else
                            o["#text"] = X.escape(X.innerXml(xml));
                      }
                   }
                   else if (textChild) { // pure text
                      if (!xml.attributes.length)
                         o = X.escape(X.innerXml(xml));
                      else
                         o["#text"] = X.escape(X.innerXml(xml));
                   }
                   else if (cdataChild) { // cdata
                      if (cdataChild > 1)
                         o = X.escape(X.innerXml(xml));
                      else
                         for (var n=xml.firstChild; n; n=n.nextSibling)
                            o["#cdata"] = X.escape(n.nodeValue);
                   }
                }
                if (!xml.attributes.length && !xml.firstChild) o = null;
             }
             else if (xml.nodeType==9) { // document.node
                o = X.toObj(xml.documentElement);
             }
             else
                alert("unhandled node type: " + xml.nodeType);
             return o;
          },
          toJson: function(o, name, ind) {
             var json = name ? ("\""+name+"\"") : "";
             if (o instanceof Array) {
                for (var i=0,n=o.length; i<n; i++)
                   o[i] = X.toJson(o[i], "", ind+"\t");
                json += (name?":[":"[") + (o.length > 1 ? ("\n"+ind+"\t"+o.join(",\n"+ind+"\t")+"\n"+ind) : o.join("")) + "]";
             }
             else if (o == null)
                json += (name&&":") + "null";
             else if (typeof(o) == "object") {
                var arr = [];
                for (var m in o)
                   arr[arr.length] = X.toJson(o[m], m, ind+"\t");
                json += (name?":{":"{") + (arr.length > 1 ? ("\n"+ind+"\t"+arr.join(",\n"+ind+"\t")+"\n"+ind) : arr.join("")) + "}";
             }
             else if (typeof(o) == "string")
                json += (name&&":") + "\"" + o.toString() + "\"";
             else
                json += (name&&":") + o.toString();
             return json;
          },
          innerXml: function(node) {
             var s = ""
             if ("innerHTML" in node)
                s = node.innerHTML;
             else {
                var asXml = function(n) {
                   var s = "";
                   if (n.nodeType == 1) {
                      s += "<" + n.nodeName;
                      for (var i=0; i<n.attributes.length;i++)
                         s += " " + n.attributes[i].nodeName + "='" + (n.attributes[i].nodeValue||"").toString() + "'";
                      if (n.firstChild) {
                         s += ">";
                         for (var c=n.firstChild; c; c=c.nextSibling)
                            s += asXml(c);
                         s += "</"+n.nodeName+">";
                      }
                      else
                         s += "/>";
                   }
                   else if (n.nodeType == 3)
                      s += n.nodeValue;
                   else if (n.nodeType == 4)
                      s += "<![CDATA[" + n.nodeValue + "]]>";
                   return s;
                };
                for (var c=node.firstChild; c; c=c.nextSibling)
                   s += asXml(c);
             }
             return s;
          },
          escape: function(txt) {
             return txt.replace(/[\\]/g, "\\\\")
                       .replace(/[\"]/g, "\\\"")
                       .replace(/[\n]/g, '\\n')
                       .replace(/[\r]/g, '\\r');
          },
          removeWhite: function(e) {
             e.normalize();
             for (var n = e.firstChild; n; ) {
                if (n.nodeType == 3) {  // text node
                   if (!n.nodeValue.match(/[^ \f\n\r\t\v]/)) { // pure whitespace text node
                      var nxt = n.nextSibling;
                      e.removeChild(n);
                      n = nxt;
                   }
                   else
                      n = n.nextSibling;
                }
                else if (n.nodeType == 1) {  // element node
                   X.removeWhite(n);
                   n = n.nextSibling;
                }
                else                      // any other node
                   n = n.nextSibling;
             }
             return e;
          }
       };
       if (xml.nodeType == 9) // document node
          xml = xml.documentElement;
       var json = X.toJson(X.toObj(X.removeWhite(xml)), xml.nodeName, "\t");
       return "{" + tab + (tab ? json.replace(/\t/g, tab) : json.replace(/\t|\n/g, "")) + "}";
    },

    json2xml: function(o, tab) {
       var toXml = function(v, name, ind) {
          var xml = "";
          if (v instanceof Array) {
             for (var i=0, n=v.length; i<n; i++)
                xml += ind + toXml(v[i], name, ind+"\t") + "\n";
          }
          else if (typeof(v) == "object") {
             var hasChild = false;
             xml += ind + "<" + name;
             for (var m in v) {
                if (m.charAt(0) == "@")
                   xml += " " + m.substr(1) + "=\"" + v[m].toString() + "\"";
                else
                   hasChild = true;
             }
             xml += hasChild ? ">" : "/>";
             if (hasChild) {
                for (var m in v) {
                   if (m == "#text")
                      xml += v[m];
                   else if (m == "#cdata")
                      xml += "<![CDATA[" + v[m] + "]]>";
                   else if (m.charAt(0) != "@")
                      xml += toXml(v[m], m, ind+"\t");
                }
                xml += (xml.charAt(xml.length-1)=="\n"?ind:"") + "</" + name + ">";
             }
          }
          else {
             xml += ind + "<" + name + ">" + (v? v.toString(): "") +  "</" + name + ">";
          }
          return xml;
       }, xml="";
       for (var m in o)
          xml += toXml(o[m], m, "");
       return tab ? xml.replace(/\t/g, tab) : xml.replace(/\t|\n/g, "");
    },
    
    jsonElementArray: function(element) {
        if(element instanceof Array) {
            return element;
        } else {
            return $A([element]);
        }
    },
    
    
    /**
     * This method returns the objects contained in the association of a JSON
     * object
     * @param jsonElement : the element from which the association must be found
     * @param associationName : string that contains the name of the association
     * @param associationType : string that contains the type of the association object
     */
    jsonAssociationObjectArray: function(jsonAssociationElement, associationType) {
        var returnArray = $A();

        if(jsonAssociationElement != null) {
            var associationObject = jsonAssociationElement[associationType];
            if(associationObject != null) {
                returnArray = this.jsonElementArray(associationObject);
            }
        }
        return returnArray;
    },
    
    jsonLocalizedValue: function(localeElementXMLNodes, locale) {
        if (localeElementXMLNodes) {
            // find the xml localized element and populate the dom element
            for(var i = 0; i < localeElementXMLNodes.length; i++) {
                var elementXMLNode = localeElementXMLNodes[i];
                if (locale == elementXMLNode["@xml:lang"]) {
                    return elementXMLNode["#text"];         
                }
            }
        }
        return null;
    },
    
    getJsonLocalizedProperty: function(value, locale) {
        var returnedValue = null;
        if(locale != null && value != null) {
            returnedValue = {};
            returnedValue["@xml:lang"] = locale;
            returnedValue["#text"] = value;
        }
        return returnedValue;
    },
    
    getLabelFromInstance: function(jsonElement, attributeNames) {
        var strLabel = "";
        for(var i = 0; i < attributeNames.length; i++) {
            if(i > 0) {
                strLabel += " ";
            }
            var value = jsonElement[attributeNames[i]];
            if(value != null) {
                strLabel += value;
            }
        }
        
        return strLabel;
    },
    
    /**
     * This method returns the attribute value of an association node.  If no association
     * setted or attribute value is not setted, returns null.
     */
    getJsonAssociationAttribute: function(jsonNode, tagName, attributeName) {
        var assoc = null;
        var returnValue = null;
        if(jsonNode) {
            assoc = jsonNode[tagName];
            if(assoc) {
                returnValue = assoc['@' + attributeName];
            }
        }
        
        return returnValue;
    },
    
    /**
     * Return the available locales found in a localized property of
     * a json object.
     * @param jsonLocalizedPropertyArray array of locales (json property)
     * @return an Array of locales (string).
     */
    getAvailableLocales: function(jsonLocalizedPropertyArray) {
        var locales = new Array();
        if (jsonLocalizedPropertyArray) {
            // find the xml localized element and populate the dom element
            for(var i = 0; i < jsonLocalizedPropertyArray.length; i++) {
                locales.push(jsonLocalizedPropertyArray[i]["@xml:lang"]);
            }
        }
        return locales;
    },
    
    /*************************************************************************
     * Other methods
     *************************************************************************/
    logException: function(e) {
//        if(console) {
//            if(typeof e == "string") {
//                console.error("Error: " + e);
//            } else {
//                console.error("Error: " + e.message + "\n" + e.stack);
//            }
//        }
    },
    
    /*************************************************************************
     * General method
     *************************************************************************/
    getOptionElement : function(options, elementName, defaultValue) {
        var returnValue = defaultValue;
        if(options) {
            options = $H(options);
            if(options.get(elementName) != null) {
                returnValue = options.get(elementName);
            }
        }
        
        return returnValue;
    },
    
    /**
     * This method is used to execute method on success (usually of a call back handler)
     */
    executeOnSuccessCallback: function(onSuccessCallback) {
        if(onSuccessCallback) {
            // only one method
            if(!(onSuccessCallback instanceof Array)) {
                onSuccessCallback();
            // call all methods of array
            } else {
                for(var i = 0; i < onSuccessCallback.length; i++) {
                    onSuccessCallback[i]();
                }
            }
        }
    }
};
MdaradUtils = new MdaradUtilsPrototype();
