﻿YAHOO.namespace("CSUtils");
YAHOO.CSUtils.Utils = function() {
    var m_oYEVNT = YAHOO.util.Event, //Contains Event Fxns
        m_oYDOM = YAHOO.util.Dom, //Contains DOM Manip Fxns
        m_oValidators = {
            "alpha": /^[a-zA-Z\s]*$/,
            "phone": /^(\(\d{3}\)|\d{3})[- ]?\d{3}[- ]?\d{4}([\s]?(x{1}|ext[.]?)[\s]?\d{2,6})?$/,
            "alpha num plus (max 50)": /^["'\-,\.#\/\\\w\s\d\$]*$/,
            "zip": /^\d{5}([- ]?\d{4})?$/,
            "email": /^[a-zA-Z0-9\-][a-zA-Z0-9\._%\-\+]*@[\-a-zA-Z0-9]+(\.[\-a-zA-Z0-9]+)*\.([cC][oO][mM]|[eE][dD][uU]|[iI][nN][fF][oO]|[gG][oO][vV]|[iI][nN][tT]|[mM][iI][lL]|[nN][eE][tT]|[oO][rR][gG]|[bB][iI][zZ]|[nN][aA][mM][eE]|[mM][uU][sS][eE][uU][mM]|[cC][oO]{2}[pP]|[aA][eE][rR][oO]|[pP][rR][oO]|[a-zA-Z]{2})$/,
            "date": /^(10|11|12|[0]?\d)\/(30|31|(0|1|2)?\d)\/(\d{2}|\d{4})$/,
            "comments": /^[^\^]*$/
        },
        m_oOptions = {
            "CStatesAbbrev": [{ key: -1, value: "set state" }, { key: 1, value: "AL" }, { key: 2, value: "AK" }, { key: 3, value: "AZ" }, { key: 4, value: "AR" }, { key: 5, value: "CA" }, { key: 6, value: "CO" }, { key: 7, value: "CT" }, { key: 8, value: "DE" }, { key: 9, value: "DC" }, { key: 10, value: "FL" }, { key: 11, value: "GA" }, { key: 12, value: "HI" }, { key: 13, value: "ID" }, { key: 14, value: "IL" }, { key: 15, value: "IN" }, { key: 16, value: "IA" }, { key: 17, value: "KS" }, { key: 18, value: "KY" }, { key: 19, value: "LA" }, { key: 20, value: "ME" }, { key: 21, value: "MD" }, { key: 22, value: "MA" }, { key: 23, value: "MI" }, { key: 24, value: "MN" }, { key: 25, value: "MS" }, { key: 26, value: "MO" }, { key: 27, value: "MT" }, { key: 28, value: "NE" }, { key: 29, value: "NV" }, { key: 30, value: "NH" }, { key: 31, value: "NJ" }, { key: 32, value: "NM" }, { key: 33, value: "NY" }, { key: 34, value: "NC" }, { key: 35, value: "ND" }, { key: 36, value: "OH" }, { key: 37, value: "OK" }, { key: 38, value: "OR" }, { key: 39, value: "PA" }, { key: 40, value: "PR" }, { key: 41, value: "RI" }, { key: 42, value: "SC" }, { key: 43, value: "SD" }, { key: 44, value: "TN" }, { key: 45, value: "TX" }, { key: 46, value: "UT" }, { key: 47, value: "VT" }, { key: 48, value: "VI" }, { key: 49, value: "VA" }, { key: 50, value: "WA" }, { key: 51, value: "WV" }, { key: 52, value: "WI" }, { key: 53, value: "WY"}],
            "CFrequency": [{ key: 0, value: "Never" }, { key: 1, value: "Daily" }, { key: 2, value: "Weekly" }, { key: 3, value: "Bi-Weekly" }, { key: 4, value: "Monthly"}]
        };

    var EQUALTO = 0, GT = 1, LT = 2;

    /* 
    *  Called by the function CreateElement. Adds the options to the dropdown
    * 
    *  @param {object} element  - The dropdown element
    *  @param {object} options  - Dropdown options
    *  @param {string} dispText - Text to be selected on dropdown
    */
    var AddOptions = function(element, options, dispText) {
        var oOption = null;
        for (iOptionIdx in options) {
            oOption = document.createElement("option");
            oOption.value = options[iOptionIdx].key;
            oOption.text = options[iOptionIdx].value;
            element.options.add(oOption);
            if (options[iOptionIdx].value == dispText) element.selectedIndex = options[iOptionIdx].key + "";
        }
    };

    return {
        GetOptions: function() {
            return m_oOptions;
        },

        /* 
        *  Creates element with passed attributes  
        * 
        *  @param {string} eTag            - tag type
        *  @param {string} eId             - Id for the new element
        *  @param {string} dispText        - display text
        *  @param {string} eValue          - value attribute (ignored if options is null)
        *  @param {string} eHref           - href attribute
        *  @param {string} eClass          - class name
        *  @param {string} style           - style attribute
        *  @param {object} options         - Item Collection for dropdown
        *  @param {string} eventType       - event type
        *  @param {function} hndlrFunction - Click event handler function
        *  @param {object} scope           - Scope for Listener 
        *  @param {string} src             - src attribute 
        *  @param {string} alt             - alt attribute   
        */
        CreateElement: function(eTag, eId, dispText, eValue, eHref, eClass, style, options, eventType, hndlrFunction, scope, src, alt) {
            var oEle = document.createElement(eTag);
            if (eId) {
                m_oYDOM.setAttribute(oEle, "id", eId);
                m_oYDOM.setAttribute(oEle, "name", eId); //Support for IE6
            }
            if (dispText) oEle.innerHTML = dispText;
            if (eValue) m_oYDOM.setAttribute(oEle, "value", eValue);
            if (eHref) m_oYDOM.setAttribute(oEle, "href", eHref);
            if (eClass) m_oYDOM.setAttribute(oEle, "class", eClass);
            if (style) m_oYDOM.setAttribute(oEle, "style", style);
            if (options) {
                eValue = eValue == "" ? "0" : eValue;
                AddOptions(oEle, m_oOptions[options], m_oOptions[options][eValue].value);
            }
            if (hndlrFunction && eventType) m_oYEVNT.addListener(oEle, eventType, hndlrFunction, scope == null ? oEle : scope, true);
            if (src) m_oYDOM.setAttribute(oEle, "src", src);
            if (alt) m_oYDOM.setAttribute(oEle, "alt", alt);
            return oEle;
        },

        DisablePop: function() {
            //Remove mask
            var oMask = m_oYDOM.get("PopOver_mask")
            oMask.parentNode.removeChild(oMask);
            m_oYDOM.removeClass(oMask.parentNode, "masked");

            //Hide the container 
            var oPopUp = m_oYDOM.get("PopOver");
            m_oYDOM.addClass(oPopUp, "DfltHidden");

            //Add PopUp div as a child to parent div of panel container and then remove panel container.
            //   A panel container is created with id PopOver_c over PopOver when a panel wizard is created.
            var oPopParent = m_oYDOM.get("PopOver_c");
            oPopParent.parentNode.appendChild(oPopUp);
            oPopParent.parentNode.removeChild(oPopParent);
        },

        CreateIFrame: function(id, src, height, width) {
            var oIFrame = this.CreateElement("iframe", id);
            m_oYDOM.setAttribute(oIFrame, "scrolling", "auto");
            m_oYDOM.setAttribute(oIFrame, "frameborder", "0");
            if (src) m_oYDOM.setAttribute(oIFrame, "src", src);
            m_oYDOM.setAttribute(oIFrame, "width", width);
            m_oYDOM.setAttribute(oIFrame, "height", height);
            m_oYDOM.setAttribute(oIFrame, "allowtransparency", false);
            return oIFrame;
        },

        /* 
        *  Creates a popup, and adds eventhandlers to disable it. If src is passed, cretes a popup
        *     with an IFrame pointing to src
        * 
        *  @param {string} src - Url        
        */
        CreatePopUpWizard: function(src) {
            var oPopUp = m_oYDOM.get("PopOver");
            m_oYDOM.removeClass(oPopUp, "DfltHidden"); //Unhide the the container
            oPopUp.innerHTML = ""; //Clear existing fields

            var oCloseDiv = this.CreateElement("div", null, null, null, null, null, "text-align:right;"); //Close Element
            oCloseDiv.appendChild(this.CreateElement("span", "close", "[x]"));
            oPopUp.appendChild(oCloseDiv);

            if (src != null) oPopUp.appendChild(this.CreateIFrame("popFrame", src, "600px", "700px"));

            var oPop = new YAHOO.widget.Panel("PopOver", { fixedcenter: true, constraintoviewport: true, visible: false, draggable: false, modal: true, underlay: "none", close: false });
            oPop.subscribe("showMask", function(e) { m_oYEVNT.preventDefault(e); this.showMask() });
            oPop.render();
            oPop.show();

            //Close popup on clicking the mask. The mask is not available before
            var oMask = m_oYDOM.get("PopOver_mask");
            m_oYEVNT.addListener(oMask, "click", this.DisablePop, oPop, true);

            //Close Email PopUp listener
            var oClosePop = m_oYDOM.get("close");
            m_oYEVNT.addListener(oClosePop, "click", this.DisablePop, oPop, true);
        },

        /* 
        *  It validates the input of the field with the validation expression
        *     and assigns corresponding classes.
        * 
        *  @param {object} inputElement - The input element 
        *  @param {string} regExp - regular expression for validation 
        */
        ValidateField: function(inputElement, validate) {
            m_oYDOM.removeClass(inputElement, "Success");
            m_oYDOM.removeClass(inputElement, "Error");

            var oInputValue = inputElement.value;

            //If the value is empty return
            if (oInputValue == null || oInputValue.length == 0) return;

            if (oInputValue.match(m_oValidators[validate]) == null) {
                //Validation Failed
                m_oYDOM.addClass(inputElement, "Error");
            }
            else {
                //Validation Success
                m_oYDOM.addClass(inputElement, "Success");
            }
        },

        /* 
        *  Validates all the input fields and builds output object 
        * 
        *  @param {object} fields - Json object with all fields
        *  @param {string} fldPreFix - prefix to be added to the field name to get the input element's ID 
        */
        ValidateAllFields: function(fields, fldPreFix) {
            var IsRequired = false, IsSuccess = true, IsEmptySelect = false, m_oOut = { fields: {} };

            for (field in fields) {
                IsRequired = fields[field].required;
                oElement = m_oYDOM.get(fldPreFix + field);
                IsEmptySelect = fields[field].type == "select" && oElement.value == "-1";

                //Check Validation (which would have occurred on blur
                if (oElement.className.indexOf("Error") > -1)
                    IsSuccess = false;

                //Check Required fields
                else if (IsRequired && (oElement.value == "" || IsEmptySelect)) {
                    m_oYDOM.addClass(oElement, "Error");
                    IsSuccess = false;
                }

                //Build ouput object if successfully validated
                if (IsSuccess && !IsEmptySelect) {
                    m_oOut.fields[field] = { value: oElement.value, dbCol: fields[field].dbCol };
                }
            }
            if (IsSuccess) return m_oOut.fields;
            return null;
        },

        CleanResponse: function(response) {
            response = response.replace('<?xml version="1.0" encoding="utf-8"?>', "").replace('</string>', "").replace('<string xmlns="http://www.dfadmin.com/">', "");
            if (!YAHOO.lang.JSON.isSafe(response)) return response;

            var oJSResp = YAHOO.lang.JSON.parse(response);
            if (oJSResp.d) {
                if (YAHOO.lang.JSON.isSafe(oJSResp.d))
                    oJSResp = YAHOO.lang.JSON.parse(oJSResp.d);
                else
                    oJSResp = oJSResp.d;
            }
            return oJSResp;
        },

        /*
        * This utility function is used to create a consistent Year Make Model SubModel text.
        * 
        * Parameters:
        *   year            - Item is used to create YMMMS String 
        *    mk              - Item is used to create YMMMS String 
        *   mdl             - Item is used to create YMMMS String 
        *   dflt            - Item is used to indicate if it has YMMS created or not 
        */
        YMMSText: function(year, mk, mdl, smdl, dflt) {
            var sYMMS = "";
            if (year && year > 0) sYMMS = " " + year.toString();
            if (mk && mk.length > 0) sYMMS += " " + mk;
            if (mdl && mdl.length > 0) sYMMS += " " + mdl;
            if (smdl && smdl.length > 0) sYMMS += " " + smdl;
            if (sYMMS.length == 0) return dflt;
            return sYMMS.trim();
        },

        /*
        * This utility function is used to create a consistent Year Make Model SubModel text
        *   with a maximum character count.
        * 
        * Parameters:
        *   year            - Item is used to create YMMMS String 
        *    mk             - Item is used to create YMMMS String 
        *   mdl             - Item is used to create YMMMS String 
        *   dflt            - Item is used to indicate if it has YMMS created or not
        *   maxChars        - Max length of the YMMS text
        */
        YMMSTextMax: function(year, mk, mdl, smdl, dflt, maxChars) {

            //Year Make Model SubModel
            var sYMMS = this.YMMSText(year, mk, mdl, smdl, dflt);
            if (sYMMS.length <= maxChars) return sYMMS;

            //Year Make Model
            sYMMS = this.YMMSText(year, mk, mdl, null, dflt);
            if (sYMMS.length <= maxChars) return sYMMS;

            //Make Model
            sYMMS = this.YMMSText(null, mk, mdl, null, dflt);
            if (sYMMS.length <= maxChars) return sYMMS;

            //Year Model
            sYMMS = this.YMMSText(year, null, mdl, null, dflt);
            if (sYMMS.length <= maxChars) return sYMMS;

            //Model
            if (mdl && mdl.length <= maxChars) return mdl;

            return dflt;
        },

        /*
        *This utility function is used to make money more readable. 
        * Parameters:
        * sValueToBeautify     - Make Price more readable with $ sign 
        */
        Convert2PrettyString: function(sValueToBeautify) {

            var oRegExp = /(^[-]?\d+$)|(^[-]?\d*[\.]\d{1,2}$)/; //find if it is any integer or float(2 precision) like 0.12, .12, or 12.23
            if (!oRegExp.test(sValueToBeautify)) return "";
            sValueToBeautify = sValueToBeautify.split(".")[0];
            oRegExp = /(-?[0-9]+)([0-9]{3})/;
            while (oRegExp.test(sValueToBeautify)) {
                //replace original string with first group match,a comma, then second group match
                sValueToBeautify = sValueToBeautify.replace(oRegExp, '$1,$2');
            }
            return '$' + sValueToBeautify;
        },

        /*
        *This utility function is used to parse moneny into normal number. 
        * Parameters:
        * sDollarNumb     - it probably contain $ or , 
        */
        Currency2Numb: function(sDollarNumb) {
            if (!sDollarNumb || sDollarNumb == "") return 0;

            var iNumber = sDollarNumb.replace(/(\$|,)/gi, '');
            //check if iNumber is integer or float
            if (!(/(^[-]?\d+$)|(^[-]?\d*[\.]\d{1,2}$)/).test(iNumber))
                iNumber = 0;
            return iNumber;
        },

        /*
        * Description: Creates a menu and subscribes to its events.
        * 
        * Returns: 
        *   n/a
        * 
        * Parameters:
        *   menuID   - ID of the menu that needs to be rendered
        */
        CSCreateMainNavMenu: function(menuID) {
            var oMenu = new YAHOO.widget.MenuBar(menuID, { autosubmenudisplay: true, keepopen: true });

            //Stay visible after clicking on the menu bar root element
            oMenu.subscribe("click", function(eventType, eventArgs) {
                var oSubMenu = eventArgs[1].cfg.getProperty("submenu");
                if (oSubMenu && !oSubMenu.cfg.getProperty("visible"))
                    oSubMenu.show();
            });

            //CSS Hooks
            oMenu.subscribe("beforeShow", this.MenuCSHdrFtr);
            oMenu.render();
        },

        /*
        * Description: Assumes that in the current operating context, 
        *   the keyword this is a reference to a yi-menu object.  This function
        *   preprends our CSHd and appends our CSFt divs as CSS hooks
        *   *if* this menu is not scrolled.  If it is, we do not.
        *
        *   In the case where we are scrolled, we replace the reserved CSS hook
        *   classes with "XXX".
        * 
        * Returns: 
        *   n/a
        * 
        * Parameters:
        *   eventType   - Name of the event that triggered this callback
        *   eventArgs   - Event arguments (empty in at least beforeShow and show
        */
        MenuCSHdrFtr: function(eventType, eventArgs) {
            var menuID = this.id, menuBD = null;
            try { menuBD = m_oYDOM.getElementsByClassName("bd", "div", menuID)[0]; } catch (err) { }
            if (!menuBD) return;


            //Remove CS curvy corners holder if this is scrolled
            if (m_oYDOM.hasClass(menuBD, "yui-menu-body-scrolled")) {

                try { m_oYDOM.replaceClass(m_oYDOM.getElementsByClassName("CShd", "div", menuID)[0], "CShd", "XXX"); }
                catch (err) { alert("CShd " + err); }
                try { m_oYDOM.replaceClass(m_oYDOM.getElementsByClassName("CSft", "div", menuID)[0], "CSft", "XXX"); }
                catch (err) { alert("CSft " + err); }
                return;
            }

            //Create/insert CShd
            var oCssHook = m_oYDOM.getElementsByClassName("CShd", "div", menuID)[0];
            if (!oCssHook) oCssHook = m_oYDOM.getElementsByClassName("XXX", "div", menuID)[0];
            if (!oCssHook) {
                oDiv = document.createElement("div");
                sDivID = m_oYDOM.generateId(oDiv, "Hdr");
                oDiv.id = sDivID;
                oDiv.className = "CShd";
                m_oYDOM.insertBefore(oDiv, menuBD);
            }
            else { m_oYDOM.replaceClass(oCssHook, "XXX", "CShd"); }

            //Create/insert CSft
            oCssHook = m_oYDOM.getElementsByClassName("CSft", "div", menuID)[0];
            if (!oCssHook) oCssHook = m_oYDOM.getElementsByClassName("XXX", "div", menuID)[0];
            if (!oCssHook) {
                oDiv = document.createElement("div");
                sDivID = m_oYDOM.generateId(oDiv, "Ftr");
                oDiv.id = sDivID;
                oDiv.className = "CSft";
                m_oYDOM.insertAfter(oDiv, menuBD);
            }
            else { m_oYDOM.replaceClass(oCssHook, "XXX", "CSft"); }
        },

        /*
        *This utility function is used to encode query string.
        *escape function does not properly encode the '+' and '/' character 
        *these characters need to be converted manually
        http://www.permadi.com/tutorial/urlEncoding/
        */
        EncodeString: function(sEncoding) {

            var sEncoded = escape(sEncoding);
            if (sEncoded.indexOf('+') > -1)
                sEncoded = sEncoded.replace(/[+]/, "%2B");

            if (sEncoded.indexOf('/') > -1)
                sEncoded = sEncoded.replace(/[\/]/g, "%2F");
            return sEncoded;
        },

        /* 
        * Decodes the URL string 
        */
        DecodeURL: function(sURL) {
            return unescape(sURL).replace(/[+]/g, " ");
        },

        /*
        *This utility function is used to decode paramValue. 
        * Parameters:
        * paramValue        - Value has encoded value and junk sign '+'
        */
        GetDecodedParamValue: function(paramValue) {
            if (YAHOO.lang.isNull(paramValue)) return paramValue;
            return unescape(paramValue.replace(/[+]/g, " "));
        },

        /* Client-side access to querystring name=value pairs
        * Version 1.3
        * 28 May 2008
        *
        * License (Simplified BSD):
        * http://adamv.com/dev/javascript/qslicense.txt
        */
        Querystring: function(qs) { // optionally pass a querystring to parse
            this.params = {};

            if (qs == null) qs = location.search.substring(1, location.search.length);
            if (qs.length == 0) return;

            // Turn <plus> back to <space>
            // See: http://www.w3.org/TR/REC-html40/interact/forms.html#h-17.13.4.1
            qs = qs.replace(/\+/g, ' ');
            var args = qs.split('&'); // parse out name/value pairs separated via &

            // split out each name=value pair
            for (var i = 0; i < args.length; i++) {
                var pair = args[i].split('=');
                var name = decodeURIComponent(pair[0]).toLowerCase();

                var value = (pair.length == 2) ? decodeURIComponent(pair[1]) : name;

                this.params[name] = value;
            }
        },

        /*
        *   This utility function creates key value pairs suitable for a querystring GET request
        *
        *   Parameters:
        *       qs              - if set, we will use this QueryString object
        *       paramName        - As a new key for new querystring
        *       paramKey         - key in querystring
        *       isSimple         - decide whether or not to call GetDecodedParamValue
        *       preventQuotes   - Set to have the value returned with quotes around it
        */
        GetParam: function(paramName, paramKey, isSimple, preventQuotes) {
            return this.GetParam(new Querystring(), paramName, paramKey, isSimple, preventQuotes);
        },

        /*
        *   This utility function creates key value pairs suitable for a querystring GET request
        *
        *   Parameters:
        *       qs              - if set, we will use this QueryString object
        *       paramName        - As a new key for new querystring
        *       paramKey         - key in querystring
        *       isSimple         - decide whether or not to call GetDecodedParamValue
        *       preventQuotes   - Set to have the value returned with quotes around it
        */
        GetParam: function(qs, paramName, paramKey, isSimple, preventQuotes) {
            if (!qs) qs = new Querystring();
            return paramName + "=" + this.QSVal(qs, paramKey, isSimple, preventQuotes) + "&";
        },

        /*
        *   This utility function is used to get the value of a QS parameter
        * 
        *   Parameters:
        *       qs              - if set, we will use this QueryString object
        *       paramKey        - key in querystring
        *       isSimple        - decide whether or not to call GetDecodedParamValue
        *       preventQuotes   - Set to have the value returned with quotes around it
        */
        QSVal: function(qs, paramKey, isSimple, preventQuotes) {
            if (!qs) qs = new Querystring();
            var sParamValue = qs.get(paramKey.toLowerCase(), null);

            if (!isSimple) {
                sParamValue = this.GetDecodedParamValue(sParamValue);
            }

            if (!YAHOO.lang.isNull(sParamValue) && !preventQuotes)
                sParamValue = "\"" + escape(sParamValue) + "\"";

            return sParamValue;
        },

        YFromViewPort: function(inputEle) {
            var iWinOffset = null;
            try {
                if (window) iWinOffset = window.pageYOffset;
                if (iWinOffset == null || iWinOffset == undefined) {
                    if (document.documentElement && document.documentElement.clientHeight)
                        iWinOffset = document.documentElement.scrollTop;
                    else iWinOffset = document.body.scrollTop;
                }
            }
            catch (err) { }
            return m_oYDOM.getY(inputEle) - +iWinOffset;
        },

        /**********************Prototype Functions***********************/
        CSStrCompareTo: function(s) {
            var sThis = this.toLowerCase();
            s = s.toString().toLowerCase();
            if (sThis === s)
                return EQUALTO;
            else if (sThis < s)
                return LT;

            return GT;
        },

        CSNumCompareTo: function(s) {
            s = s - 0;
            if (this == s)
                return EQUALTO;
            else if (this < s)
                return LT;

            return GT;
        },

        CSDateCompareTo: function(s) {
            var dtThis = Date.parse(this);
            s = Date.parse(s)
            if (dtThis == s)
                return EQUALTO;
            else if (dtThis < s)
                return LT;

            return GT;
        },

        /* false = 0 and true = 1 so, false < true and true > false */
        CSBooleanCompareTo: function(s) {
            s = Boolean(s);
            if (this == s)
                return EQUALTO;
            else if (this < s)
                return LT;

            return GT;
        },

        Trim: function() { return this.replace(/^\s+|\s+$/g, ""); },

        LTrim: function() { return this.replace(/^\s+/, ""); },

        RTrim: function() { return this.replace(/\s+$/, ""); },

        GetVal: function(key, default_) {
            var value = this.params[key];
            return (value != null) ? value : default_;
        },

        QSContains: function(key) {
            var value = this.params[key];
            return (value != null);
        }
    }
} ();
/**********************Prototype Declarations***********************/
String.prototype.CSCompareTo = YAHOO.CSUtils.Utils.CSStrCompareTo;
Number.prototype.CSCompareTo = YAHOO.CSUtils.Utils.CSNumCompareTo;
Date.prototype.CSCompareTo = YAHOO.CSUtils.Utils.CSDateCompareTo;
Boolean.prototype.CSCompareTo = YAHOO.CSUtils.Utils.CSBooleanCompareTo;
String.prototype.trim = YAHOO.CSUtils.Utils.Trim;
String.prototype.ltrim = YAHOO.CSUtils.Utils.LTrim;
String.prototype.rtrim = YAHOO.CSUtils.Utils.RTrim;
Querystring = YAHOO.CSUtils.Utils.Querystring;
Querystring.prototype.get = YAHOO.CSUtils.Utils.GetVal;
Querystring.prototype.contains = YAHOO.CSUtils.Utils.QSContains;