var Widgets = Widgets ? Widgets : function() {
    var private = {
        container: null,
        callback: null,
        clientCallback: null,
        jsonpcall: function(widgetParams, callbackFn) {
            var params = '';
            //create request and add parameter as query string
            for (var _x in widgetParams) {
                if ((_x != '') && (!jQuery.isFunction(widgetParams[_x])) && (typeof widgetParams[_x] != 'object') && _x != "WidgetServerURL")
                    params += _x + "=" + widgetParams[_x] + '&';
            }
            if (typeof ShowBaseWaitImage == 'function') {
                ShowBaseWaitImage();
            }

            if (typeof ScriptFileLoadedArr != 'undefined' && ScriptFileLoadedArr != null) {
                params += "&allJS=" + ScriptFileLoadedArr.join();
            }

            jQuery.getJSON(widgetParams.WidgetServerURL + "/WidgetProxy.ashx?" + params + 'method=?',
                callbackFn);
        },
        loadhtml: function(options, callBack) {
            private.jsonpcall(options,
                function(msg) {
                    //Put the html into widget container.

                    //jQuery("#"+private.container).html(msg);
                    var pid = jQuery("#" + private.container).parent().attr("id");
                    jQuery("#" + pid).html("");
                    jQuery("#" + private.container).remove();
                    jQuery("#" + pid).html(msg);

                    private.WidgetLoad();
                    if (jQuery.isFunction(callBack))
                        callBack(options);
                    if (typeof HideBaseWaitImage == 'function') {
                        HideBaseWaitImage();
                    }
                });
        },
        // wire widget after it's loaded
        WidgetLoad: function() {
            //call the callBack after widget load
            if (jQuery.isFunction(private.clientCallback)) {
                private.clientCallback();
            }
        }
    };
    var public = {
        SearchWidget: function(opts) {
            var settings = {
                widgetName: 'search'
            };
            jQuery.extend(true, settings, opts);
            private.container = settings.container;
            private.clientCallback = null;
            if (jQuery.isFunction(settings.callBack))
                private.clientCallback = settings.callBack;
            private.loadhtml(settings, public.SearchWidgetLoaded);
        },
        SearchWidgetLoaded: function(options) {
        }
    }
    return public;
} ();


function fnGetMultiLingualMessage(key,innerHTMLflag)
{
    try {
        if(typeof innerHTMLflag === 'undefined')
            return jQuery("#msg" + jQuery.trim(key) ).text();
        else
            return jQuery("#msg" + jQuery.trim(key) ).html();
    } catch(ex) {
		handleError(ex, false);
	}
}
function fnShowCustomMessages(errCntId,message)
{
    try {
        if(jQuery.trim(errCntId) == '') 
            errCntId = 'ErrorContainer';
        var oChildElement = jQuery("#" + errCntId).find("ol");
	    oChildElement.removeAttr("style");
	    message = '<li><label generated="true" class="error" style="display: block;">' + message + '</label></li>';
	    oChildElement.html(message + oChildElement.html());
	    jQuery("#" + errCntId).show();
    } catch(ex) {
		handleError(ex, false);
	}
}
function PrintEventStartTime(id)
{
    try
    {
        var now = new Date();
        var objDiv = jQuery('#' + id);
        message = objDiv.text();
        var messageArr = message.split(':');        
        objDiv.text(messageArr[0] + ' : ' + now.getHours() + ":" + now.getMinutes() + ":" + now.getSeconds() + ":" + now.getMilliseconds());    
    } 
    catch(oException) 
    {
		handleError(oException, true);
	}
}
function ShowHideModifySearchLink(show)
{
    try
    {
        if(show)
        {
            jQuery('#divModifySearch').show();
            jQuery('#divHeaderController').show();
        }    
        else
        {
            jQuery('#divModifySearch').hide();    
            jQuery('#divHeaderController').hide();
        }
    }
    catch(oException) 
    {
        handleError(ex, false);
    }                
}

function AdditionalMarkupPercValidation(validatorObject)
{
    try
    {
        validatorObject.addMethod("AdditionalMarkupPerc", function (value, element) {
	    if(value >= 0 && value <= 100)
	        return true;
	    else
	        return false;
	    },
	    '');
	}
    catch(oException)
	{
	    handleError(ex,false);
	}
}

//jquery validate
(function(a) {
    a.extend(a.fn, {
        validate: function(b) {
            if (!this.length) {
                b && b.debug && window.console && console.warn("nothing selected, can't validate, returning nothing");
                return
            }
            var c = a.data(this[0], "validator");
            if (c) {
                return c
            }
            c = new a.validator(b, this[0]);
            a.data(this[0], "validator", c);
            if (c.settings.onsubmit) {
                this.find("input, button").filter(".cancel").click(function() {
                    c.cancelSubmit = true
                });
                if (c.settings.submitHandler) {
                    this.find("input, button").filter(":submit").click(function() {
                        c.submitButton = this
                    })
                }
                this.submit(function(d) {
                    if (c.settings.debug) {
                        d.preventDefault()
                    }

                    function e() {
                        if (c.settings.submitHandler) {
                            if (c.submitButton) {
                                var f = a("<input type='hidden'/>").attr("name", c.submitButton.name).val(c.submitButton.value).appendTo(c.currentForm)
                            }
                            c.settings.submitHandler.call(c, c.currentForm);
                            if (c.submitButton) {
                                f.remove()
                            }
                            return false
                        }
                        return true
                    }
                    if (c.cancelSubmit) {
                        c.cancelSubmit = false;
                        return e()
                    }
                    if (c.form()) {
                        if (c.pendingRequest) {
                            c.formSubmitted = true;
                            return false
                        }
                        return e()
                    } else {
                        c.focusInvalid();
                        return false
                    }
                })
            }
            return c
        },
        valid: function() {
            if (a(this[0]).is("form")) {
                if (!this.validate().form()) {
                    callbackValid();
                }
                return this.validate().form();
            } else {
                var c = true;
                var b = a(this[0].form).validate();
                this.each(function() {
                    c &= b.element(this)
                });
                return c
            }
        },
        removeAttrs: function(d) {
            var b = {},
                c = this;
            a.each(d.split(/\s/), function(e, f) {
                b[f] = c.attr(f);
                c.removeAttr(f)
            });
            return b
        },
        rules: function(e, b) {
            var g = this[0];
            if (e) {
                var d = a.data(g.form, "validator").settings;
                var i = d.rules;
                var j = a.validator.staticRules(g);
                switch (e) {
                    case "add":
                        a.extend(j, a.validator.normalizeRule(b));
                        i[g.name] = j;
                        if (b.messages) {
                            d.messages[g.name] = a.extend(d.messages[g.name], b.messages)
                        }
                        break;
                    case "remove":
                        if (!b) {
                            delete i[g.name];
                            return j
                        }
                        var h = {};
                        a.each(b.split(/\s/), function(k, l) {
                            h[l] = j[l];
                            delete j[l]
                        });
                        return h
                }
            }
            var f = a.validator.normalizeRules(a.extend({}, a.validator.metadataRules(g), a.validator.classRules(g), a.validator.attributeRules(g), a.validator.staticRules(g)), g);
            if (f.required) {
                var c = f.required;
                delete f.required;
                f = a.extend({
                    required: c
                }, f)
            }
            return f
        }
    });
    a.extend(a.expr[":"], {
        blank: function(b) {
            return !a.trim(b.value)
        },
        filled: function(b) {
            return !!a.trim(b.value)
        },
        unchecked: function(b) {
            return !b.checked
        }
    });
    a.validator = function(b, c) {
        this.settings = a.extend({}, a.validator.defaults, b);
        this.currentForm = c;
        this.init()
    };
    a.validator.format = function(b, c) {
        if (arguments.length == 1) {
            return function() {
                var d = a.makeArray(arguments);
                d.unshift(b);
                return a.validator.format.apply(this, d)
            }
        }
        if (arguments.length > 2 && c.constructor != Array) {
            c = a.makeArray(arguments).slice(1)
        }
        if (c.constructor != Array) {
            c = [c]
        }
        a.each(c, function(d, e) {
            b = b.replace(new RegExp("\\{" + d + "\\}", "g"), e)
        });
        return b
    };
    a.extend(a.validator, {
        defaults: {
            messages: {},
            groups: {},
            rules: {},
            errorClass: "error",
            validClass: "valid",
            errorElement: "label",
            focusInvalid: true,
            errorContainer: a([]),
            errorLabelContainer: a([]),
            onsubmit: true,
            ignore: [],
            ignoreTitle: false,
            onfocusin: function(b) {
                this.lastActive = b;
                if (this.settings.focusCleanup && !this.blockFocusCleanup) {
                    this.settings.unhighlight && this.settings.unhighlight.call(this, b, this.settings.errorClass, this.settings.validClass);
                    this.errorsFor(b).hide()
                }
            },
            onfocusout: function(b) {
                if (!this.checkable(b) && (b.name in this.submitted || !this.optional(b))) {
                    this.element(b)
                }
            },
            onkeyup: function(b) {
                if (b.name in this.submitted || b == this.lastElement) {
                    this.element(b)
                }
            },
            onclick: function(b) {
                if (b.name in this.submitted) {
                    this.element(b)
                }
            },
            highlight: function(d, b, c) {
                a(d).addClass(b).removeClass(c)
            },
            unhighlight: function(d, b, c) {
                a(d).removeClass(b).addClass(c)
            }
        },
        setDefaults: function(b) {
            a.extend(a.validator.defaults, b)
        },
        messages: {
            required: "This field is required.",
            remote: "Please fix this field.",
            email: "Please enter a valid email address.",
            url: "Please enter a valid URL.",
            date: "Please enter a valid date.",
            dateISO: "Please enter a valid date (ISO).",
            dateDE: "Bitte geben Sie ein gültiges Datum ein.",
            number: "Please enter a valid number.",
            numberDE: "Bitte geben Sie eine Nummer ein.",
            digits: "Please enter only digits",
            creditcard: "Please enter a valid credit card number.",
            equalTo: "Please enter the same value again.",
            accept: "Please enter a value with a valid extension.",
            maxlength: a.validator.format("Please enter no more than {0} characters."),
            minlength: a.validator.format("Please enter at least {0} characters."),
            rangelength: a.validator.format("Please enter a value between {0} and {1} characters long."),
            range: a.validator.format("Please enter a value between {0} and {1}."),
            max: a.validator.format("Please enter a value less than or equal to {0}."),
            min: a.validator.format("Please enter a value greater than or equal to {0}.")
        },
        autoCreateRanges: false,
        prototype: {
            init: function() {
                this.labelContainer = a(this.settings.errorLabelContainer);
                this.errorContext = this.labelContainer.length && this.labelContainer || a(this.currentForm);
                this.containers = a(this.settings.errorContainer).add(this.settings.errorLabelContainer);
                this.submitted = {};
                this.valueCache = {};
                this.pendingRequest = 0;
                this.pending = {};
                this.invalid = {};
                this.reset();
                var b = (this.groups = {});
                a.each(this.settings.groups, function(e, f) {
                    a.each(f.split(/\s/), function(h, g) {
                        b[g] = e
                    })
                });
                var d = this.settings.rules;
                a.each(d, function(e, f) {
                    d[e] = a.validator.normalizeRule(f)
                });

                function c(f) {
                    var e = a.data(this[0].form, "validator");
                    e.settings["on" + f.type] && e.settings["on" + f.type].call(e, this[0])
                }
                a(this.currentForm).delegate("focusin focusout keyup", ":text, :password, :file, select, textarea", c).delegate("click", ":radio, :checkbox", c);
                if (this.settings.invalidHandler) {
                    a(this.currentForm).bind("invalid-form.validate", this.settings.invalidHandler)
                }
            },
            form: function() {
                this.checkForm();
                a.extend(this.submitted, this.errorMap);
                this.invalid = a.extend({}, this.errorMap);
                if (!this.valid()) {
                    a(this.currentForm).triggerHandler("invalid-form", [this])
                }
                this.showErrors();
                return this.valid()
            },
            checkForm: function() {
                this.prepareForm();
                for (var b = 0, c = (this.currentElements = this.elements()); c[b]; b++) {
                    this.check(c[b])
                }
                return this.valid()
            },
            element: function(c) {
                c = this.clean(c);
                this.lastElement = c;
                this.prepareElement(c);
                this.currentElements = a(c);
                var b = this.check(c);
                if (b) {
                    delete this.invalid[c.name]
                } else {
                    this.invalid[c.name] = true
                }
                if (!this.numberOfInvalids()) {
                    this.toHide = this.toHide.add(this.containers)
                }
                this.showErrors();
                return b
            },
            showErrors: function(c) {
                if (c) {
                    a.extend(this.errorMap, c);
                    this.errorList = [];
                    for (var b in c) {
                        this.errorList.push({
                            message: c[b],
                            element: this.findByName(b)[0]
                        })
                    }
                    this.successList = a.grep(this.successList, function(d) {
                        return !(d.name in c)
                    })
                }
                this.settings.showErrors ? this.settings.showErrors.call(this, this.errorMap, this.errorList) : this.defaultShowErrors()
            },
            resetForm: function() {
                if (a.fn.resetForm) {
                    a(this.currentForm).resetForm()
                }
                this.submitted = {};
                this.prepareForm();
                this.hideErrors();
                this.elements().removeClass(this.settings.errorClass)
            },
            numberOfInvalids: function() {
                return this.objectLength(this.invalid)
            },
            objectLength: function(d) {
                var c = 0;
                for (var b in d) {
                    c++
                }
                return c
            },
            hideErrors: function() {
                this.addWrapper(this.toHide).hide()
            },
            valid: function() {
                return this.size() == 0
            },
            size: function() {
                return this.errorList.length
            },
            focusInvalid: function() {
                if (this.settings.focusInvalid) {
                    try {
                        a(this.findLastActive() || this.errorList.length && this.errorList[0].element || []).filter(":visible").focus()
                    } catch (b) { }
                }
            },
            findLastActive: function() {
                var b = this.lastActive;
                return b && a.grep(this.errorList, function(c) {
                    return c.element.name == b.name
                }).length == 1 && b
            },
            elements: function() {
                var c = this,
                    b = {};
                return a([]).add(this.currentForm.elements).filter(":input").not(":submit, :reset, :image, [disabled]").not(this.settings.ignore).filter(function() {
                    !this.name && c.settings.debug && window.console && console.error("%o has no name assigned", this);
                    if (this.name in b || !c.objectLength(a(this).rules())) {
                        return false
                    }
                    b[this.name] = true;
                    return true
                })
            },
            clean: function(b) {
                return a(b)[0]
            },
            errors: function() {
                return a(this.settings.errorElement + "." + this.settings.errorClass, this.errorContext)
            },
            reset: function() {
                this.successList = [];
                this.errorList = [];
                this.errorMap = {};
                this.toShow = a([]);
                this.toHide = a([]);
                this.formSubmitted = false;
                this.currentElements = a([])
            },
            prepareForm: function() {
                this.reset();
                this.toHide = this.errors().add(this.containers)
            },
            prepareElement: function(b) {
                this.reset();
                this.toHide = this.errorsFor(b)
            },
            check: function(c) {
                c = this.clean(c);
                if (this.checkable(c)) {
                    c = this.findByName(c.name)[0]
                }
                var h = a(c).rules();
                var d = false;
                for (method in h) {
                    var g = {
                        method: method,
                        parameters: h[method]
                    };
                    try {
                        var b = a.validator.methods[method].call(this, c.value.replace(/\r/g, ""), c, g.parameters);
                        if (b == "dependency-mismatch") {
                            d = true;
                            continue
                        }
                        d = false;
                        if (b == "pending") {
                            this.toHide = this.toHide.not(this.errorsFor(c));
                            return
                        }
                        if (!b) {
                            this.formatAndAdd(c, g);
                            return false
                        }
                    } catch (f) {
                        this.settings.debug && window.console && console.log("exception occured when checking element " + c.id + ", check the '" + g.method + "' method");
                        throw f
                    }
                }
                if (d) {
                    return
                }
                if (this.objectLength(h)) {
                    this.successList.push(c)
                }
                return true
            },
            customMetaMessage: function(b, d) {
                if (!a.metadata) {
                    return
                }
                var c = this.settings.meta ? a(b).metadata()[this.settings.meta] : a(b).metadata();
                return c && c.messages && c.messages[d]
            },
            customMessage: function(c, d) {
                var b = this.settings.messages[c];
                return b && (b.constructor == String ? b : b[d])
            },
            findDefined: function() {
                for (var b = 0; b < arguments.length; b++) {
                    if (arguments[b] !== undefined) {
                        return arguments[b]
                    }
                }
                return undefined
            },
            defaultMessage: function(b, c) {
                return this.findDefined(this.customMessage(b.name, c), this.customMetaMessage(b, c), !this.settings.ignoreTitle && b.title || undefined, a.validator.messages[c], "<strong>Warning: No message defined for " + b.name + "</strong>")
            },
            formatAndAdd: function(b, d) {
                var c = this.defaultMessage(b, d.method);
                if (typeof c == "function") {
                    c = c.call(this, d.parameters, b)
                }
                this.errorList.push({
                    message: c,
                    element: b
                });
                this.errorMap[b.name] = c;
                this.submitted[b.name] = c
            },
            addWrapper: function(b) {
                if (this.settings.wrapper) {
                    b = b.add(b.parent(this.settings.wrapper))
                }
                return b
            },
            defaultShowErrors: function() {
                for (var c = 0; this.errorList[c]; c++) {
                    var b = this.errorList[c];
                    this.settings.highlight && this.settings.highlight.call(this, b.element, this.settings.errorClass, this.settings.validClass);
                    this.showLabel(b.element, b.message)
                }
                if (this.errorList.length) {
                    this.toShow = this.toShow.add(this.containers)
                }
                if (this.settings.success) {
                    for (var c = 0; this.successList[c]; c++) {
                        this.showLabel(this.successList[c])
                    }
                }
                if (this.settings.unhighlight) {
                    for (var c = 0, d = this.validElements(); d[c]; c++) {
                        this.settings.unhighlight.call(this, d[c], this.settings.errorClass, this.settings.validClass)
                    }
                }
                this.toHide = this.toHide.not(this.toShow);
                this.hideErrors();
                this.addWrapper(this.toShow).show()
            },
            validElements: function() {
                return this.currentElements.not(this.invalidElements())
            },
            invalidElements: function() {
                return a(this.errorList).map(function() {
                    return this.element
                })
            },
            showLabel: function(c, d) {
                var b = this.errorsFor(c);
                if (b.length) {
                    b.removeClass().addClass(this.settings.errorClass);
                    b.attr("generated") && b.html(d)
                } else {
                    b = a("<" + this.settings.errorElement + "/>").attr({
                        "for": this.idOrName(c),
                        generated: true
                    }).addClass(this.settings.errorClass).html(d || "");
                    if (this.settings.wrapper) {
                        b = b.hide().show().wrap("<" + this.settings.wrapper + "/>").parent()
                    }
                    if (!this.labelContainer.append(b).length) {
                        this.settings.errorPlacement ? this.settings.errorPlacement(b, a(c)) : b.insertAfter(c)
                    }
                }
                if (!d && this.settings.success) {
                    b.text("");
                    typeof this.settings.success == "string" ? b.addClass(this.settings.success) : this.settings.success(b)
                }
                this.toShow = this.toShow.add(b)
            },
            errorsFor: function(b) {
                return this.errors().filter("[for='" + this.idOrName(b) + "']")
            },
            idOrName: function(b) {
                return this.groups[b.name] || (this.checkable(b) ? b.name : b.id || b.name)
            },
            checkable: function(b) {
                return /radio|checkbox/i.test(b.type)
            },
            findByName: function(b) {
                var c = this.currentForm;
                return a(document.getElementsByName(b)).map(function(d, e) {
                    return e.form == c && e.name == b && e || null
                })
            },
            getLength: function(c, b) {
                switch (b.nodeName.toLowerCase()) {
                    case "select":
                        return a("option:selected", b).length;
                    case "input":
                        if (this.checkable(b)) {
                            return this.findByName(b.name).filter(":checked").length
                        }
                }
                return c.length
            },
            depend: function(c, b) {
                return this.dependTypes[typeof c] ? this.dependTypes[typeof c](c, b) : true
            },
            dependTypes: {
                "boolean": function(c, b) {
                    return c
                },
                string: function(c, b) {
                    return !!a(c, b.form).length
                },
                "function": function(c, b) {
                    return c(b)
                }
            },
            optional: function(b) {
                return !a.validator.methods.required.call(this, a.trim(b.value), b) && "dependency-mismatch"
            },
            startRequest: function(b) {
                if (!this.pending[b.name]) {
                    this.pendingRequest++;
                    this.pending[b.name] = true
                }
            },
            stopRequest: function(b, c) {
                this.pendingRequest--;
                if (this.pendingRequest < 0) {
                    this.pendingRequest = 0
                }
                delete this.pending[b.name];
                if (c && this.pendingRequest == 0 && this.formSubmitted && this.form()) {
                    a(this.currentForm).submit()
                } else {
                    if (!c && this.pendingRequest == 0 && this.formSubmitted) {
                        a(this.currentForm).triggerHandler("invalid-form", [this])
                    }
                }
            },
            previousValue: function(b) {
                return a.data(b, "previousValue") || a.data(b, "previousValue", previous = {
                    old: null,
                    valid: true,
                    message: this.defaultMessage(b, "remote")
                })
            }
        },
        classRuleSettings: {
            required: {
                required: true
            },
            email: {
                email: true
            },
            url: {
                url: true
            },
            date: {
                date: true
            },
            dateISO: {
                dateISO: true
            },
            dateDE: {
                dateDE: true
            },
            number: {
                number: true
            },
            numberDE: {
                numberDE: true
            },
            digits: {
                digits: true
            },
            creditcard: {
                creditcard: true
            }
        },
        addClassRules: function(b, c) {
            b.constructor == String ? this.classRuleSettings[b] = c : a.extend(this.classRuleSettings, b)
        },
        classRules: function(c) {
            var d = {};
            var b = a(c).attr("class");
            b && a.each(b.split(" "), function() {
                if (this in a.validator.classRuleSettings) {
                    a.extend(d, a.validator.classRuleSettings[this])
                }
            });
            return d
        },
        attributeRules: function(c) {
            var e = {};
            var b = a(c);
            for (method in a.validator.methods) {
                var d = b.attr(method);
                if (d) {
                    e[method] = d
                }
            }
            if (e.maxlength && /-1|2147483647|524288/.test(e.maxlength)) {
                delete e.maxlength
            }
            return e
        },
        metadataRules: function(b) {
            if (!a.metadata) {
                return {}
            }
            var c = a.data(b.form, "validator").settings.meta;
            return c ? a(b).metadata()[c] : a(b).metadata()
        },
        staticRules: function(c) {
            var d = {};
            var b = a.data(c.form, "validator");
            if (b.settings.rules) {
                d = a.validator.normalizeRule(b.settings.rules[c.name]) || {}
            }
            return d
        },
        normalizeRules: function(c, b) {
            a.each(c, function(f, e) {
                if (e === false) {
                    delete c[f];
                    return
                }
                if (e.param || e.depends) {
                    var d = true;
                    switch (typeof e.depends) {
                        case "string":
                            d = !!a(e.depends, b.form).length;
                            break;
                        case "function":
                            d = e.depends.call(b, b);
                            break
                    }
                    if (d) {
                        c[f] = e.param !== undefined ? e.param : true
                    } else {
                        delete c[f]
                    }
                }
            });
            a.each(c, function(d, e) {
                c[d] = a.isFunction(e) ? e(b) : e
            });
            a.each(["minlength", "maxlength", "min", "max"], function() {
                if (c[this]) {
                    c[this] = Number(c[this])
                }
            });
            a.each(["rangelength", "range"], function() {
                if (c[this]) {
                    c[this] = [Number(c[this][0]), Number(c[this][1])]
                }
            });
            if (a.validator.autoCreateRanges) {
                if (c.min && c.max) {
                    c.range = [c.min, c.max];
                    delete c.min;
                    delete c.max
                }
                if (c.minlength && c.maxlength) {
                    c.rangelength = [c.minlength, c.maxlength];
                    delete c.minlength;
                    delete c.maxlength
                }
            }
            if (c.messages) {
                delete c.messages
            }
            return c
        },
        normalizeRule: function(c) {
            if (typeof c == "string") {
                var b = {};
                a.each(c.split(/\s/), function() {
                    b[this] = true
                });
                c = b
            }
            return c
        },
        addMethod: function(b, d, c) {
            a.validator.methods[b] = d;
            a.validator.messages[b] = c || a.validator.messages[b];
            if (d.length < 3) {
                a.validator.addClassRules(b, a.validator.normalizeRule(b))
            }
        },
        methods: {
            required: function(d, c, e) {
                if (!this.depend(e, c)) {
                    return "dependency-mismatch"
                }
                switch (c.nodeName.toLowerCase()) {
                    case "select":
                        var b = a("option:selected", c);
                        return b.length > 0 && (c.type == "select-multiple" || (a.browser.msie && !(b[0].attributes.value.specified) ? b[0].text : b[0].value).length > 0);
                    case "input":
                        if (this.checkable(c)) {
                            return this.getLength(d, c) > 0
                        }
                    default:
                        return a.trim(d).length > 0
                }
            },
            remote: function(f, c, g) {
                if (this.optional(c)) {
                    return "dependency-mismatch"
                }
                var d = this.previousValue(c);
                if (!this.settings.messages[c.name]) {
                    this.settings.messages[c.name] = {}
                }
                this.settings.messages[c.name].remote = typeof d.message == "function" ? d.message(f) : d.message;
                g = typeof g == "string" && {
                    url: g
} || g;
                    if (d.old !== f) {
                        d.old = f;
                        var b = this;
                        this.startRequest(c);
                        var e = {};
                        e[c.name] = f;
                        a.ajax(a.extend(true, {
                            url: g,
                            mode: "abort",
                            port: "validate" + c.name,
                            dataType: "json",
                            data: e,
                            success: function(i) {
                                var j = i === true;
                                if (j) {
                                    var h = b.formSubmitted;
                                    b.prepareElement(c);
                                    b.formSubmitted = h;
                                    b.successList.push(c);
                                    b.showErrors()
                                } else {
                                    var k = {};
                                    k[c.name] = d.message = i || b.defaultMessage(c, "remote");
                                    b.showErrors(k)
                                }
                                d.valid = j;
                                b.stopRequest(c, j)
                            }
                        }, g));
                        return "pending"
                    } else {
                        if (this.pending[c.name]) {
                            return "pending"
                        }
                    }
                    return d.valid
                },
                minlength: function(c, b, d) {
                    return this.optional(b) || this.getLength(a.trim(c), b) >= d
                },
                maxlength: function(c, b, d) {
                    return this.optional(b) || this.getLength(a.trim(c), b) <= d
                },
                rangelength: function(d, b, e) {
                    var c = this.getLength(a.trim(d), b);
                    return this.optional(b) || (c >= e[0] && c <= e[1])
                },
                min: function(c, b, d) {
                    return this.optional(b) || c >= d
                },
                max: function(c, b, d) {
                    return this.optional(b) || c <= d
                },
                range: function(c, b, d) {
                    return this.optional(b) || (c >= d[0] && c <= d[1])
                },
                email: function(c, b) {
                    return this.optional(b) || /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i.test(c)
                },
                url: function(c, b) {
                    return this.optional(b) || /^(https?|ftp):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i.test(c)
                },
                date: function(c, b) {
                    return this.optional(b) || !/Invalid|NaN/.test(new Date(c))
                },
                dateISO: function(c, b) {
                    return this.optional(b) || /^\d{4}[\/-]\d{1,2}[\/-]\d{1,2}$/.test(c)
                },
                dateDE: function(c, b) {
                    return this.optional(b) || /^\d\d?\.\d\d?\.\d\d\d?\d?$/.test(c)
                },
                number: function(c, b) {
                    return this.optional(b) || /^-?(?:\d+|\d{1,3}(?:,\d{3})+)(?:\.\d+)?$/.test(c)
                },
                numberDE: function(c, b) {
                    return this.optional(b) || /^-?(?:\d+|\d{1,3}(?:\.\d{3})+)(?:,\d+)?$/.test(c)
                },
                digits: function(c, b) {
                    return this.optional(b) || /^\d+$/.test(c)
                },
                creditcard: function(f, c) {
                    if (this.optional(c)) {
                        return "dependency-mismatch"
                    }
                    if (/[^0-9-]+/.test(f)) {
                        return false
                    }
                    var g = 0,
                    e = 0,
                    b = false;
                    f = f.replace(/\D/g, "");
                    for (n = f.length - 1; n >= 0; n--) {
                        var d = f.charAt(n);
                        var e = parseInt(d, 10);
                        if (b) {
                            if ((e *= 2) > 9) {
                                e -= 9
                            }
                        }
                        g += e;
                        b = !b
                    }
                    return (g % 10) == 0
                },
                accept: function(c, b, d) {
                    d = typeof d == "string" ? d.replace(/,/g, "|") : "png|jpe?g|gif";
                    return this.optional(b) || c.match(new RegExp(".(" + d + ")$", "i"))
                },
                equalTo: function(c, b, d) {
                    return c == a(d).val()
                }
            }
        });
        a.format = a.validator.format
    })(jQuery);

    (function(c) {
        var b = c.ajax;
        var a = {};
        c.ajax = function(e) {
            e = c.extend(e, c.extend({}, c.ajaxSettings, e));
            var d = e.port;
            if (e.mode == "abort") {
                if (a[d]) {
                    a[d].abort()
                }
                return (a[d] = b.apply(this, arguments))
            }
            return b.apply(this, arguments)
        }
    })(jQuery);

    (function(a) {
        a.each({
            focus: "focusin",
            blur: "focusout"
        }, function(c, b) {
            a.event.special[b] = {
                setup: function() {
                    if (a.browser.msie) {
                        return false
                    }
                    this.addEventListener(c, a.event.special[b].handler, true)
                },
                teardown: function() {
                    if (a.browser.msie) {
                        return false
                    }
                    this.removeEventListener(c, a.event.special[b].handler, true)
                },
                handler: function(d) {
                    arguments[0] = a.event.fix(d);
                    arguments[0].type = b;
                    return a.event.handle.apply(this, arguments)
                }
            }
        });
        a.extend(a.fn, {
            delegate: function(d, c, b) {
                return this.bind(d, function(e) {
                    var f = a(e.target);
                    if (f.is(c)) {
                        return b.apply(f, arguments)
                    }
                })
            },
            triggerEvent: function(b, c) {
                return this.triggerHandler(b, [a.event.fix({
                    type: b,
                    target: c
                })])
            }
        })
    })(jQuery);

    /* Metadata */
    (function($) {
        $.extend({
            metadata: {
                defaults: {
                    type: "class",
                    name: "metadata",
                    cre: /({.*})/,
                    single: "metadata"
                },
                setType: function(type, name) {
                    this.defaults.type = type;
                    this.defaults.name = name
                },
                get: function(elem, opts) {
                    var settings = $.extend({}, this.defaults, opts);
                    if (!settings.single.length) {
                        settings.single = "metadata"
                    }
                    var data = $.data(elem, settings.single);
                    if (data) {
                        return data
                    }
                    data = "{}";
                    if (settings.type == "class") {
                        var m = settings.cre.exec(elem.className);
                        if (m) {
                            data = m[1]
                        }
                    } else {
                        if (settings.type == "elem") {
                            if (!elem.getElementsByTagName) {
                                return undefined
                            }
                            var e = elem.getElementsByTagName(settings.name);
                            if (e.length) {
                                data = $.trim(e[0].innerHTML)
                            }
                        } else {
                            if (elem.getAttribute != undefined) {
                                var attr = elem.getAttribute(settings.name);
                                if (attr) {
                                    data = attr
                                }
                            }
                        }
                    }
                    if (data.indexOf("{") < 0) {
                        data = "{" + data + "}"
                    }
                    data = eval("(" + data + ")");
                    $.data(elem, settings.single, data);
                    return data
                }
            }
        });
        $.fn.metadata = function(opts) {
            return $.metadata.get(this[0], opts)
        }
    })(jQuery);

    /*Additional Methods*/
    jQuery.validator.addMethod("maxWords", function(value, element, params) {
        return this.optional(element) || value.match(/\b\w+\b/g).length < params;
    }, jQuery.validator.format("Please enter {0} words or less."));

    jQuery.validator.addMethod("minWords", function(value, element, params) {
        return this.optional(element) || value.match(/\b\w+\b/g).length >= params;
    }, jQuery.validator.format("Please enter at least {0} words."));

    jQuery.validator.addMethod("rangeWords", function(value, element, params) {
        return this.optional(element) || value.match(/\b\w+\b/g).length >= params[0] && value.match(/bw+b/g).length < params[1];
    }, jQuery.validator.format("Please enter between {0} and {1} words."));


    jQuery.validator.addMethod("letterswithbasicpunc", function(value, element) {
        return this.optional(element) || /^[a-z-.,()'\"\s]+$/i.test(value);
    }, "Letters or punctuation only please");

    jQuery.validator.addMethod("alphanumeric", function(value, element) {
        return this.optional(element) || /^\w+$/i.test(value);
    }, "Letters, numbers, spaces or underscores only please");

    jQuery.validator.addMethod("lettersonly", function(value, element) {
        return this.optional(element) || /^[a-z]+$/i.test(value);
    }, "Letters only please");

    jQuery.validator.addMethod("nowhitespace", function(value, element) {
        return this.optional(element) || /^\S+$/i.test(value);
    }, "No white space please");

    jQuery.validator.addMethod("ziprange", function(value, element) {
        return this.optional(element) || /^90[2-5]\d\{2}-\d{4}$/.test(value);
    }, "Your ZIP-code must be in the range 902xx-xxxx to 905-xx-xxxx");


    /**
    * Return true, if the value is a valid vehicle identification number (VIN).
    *
    * Works with all kind of text inputs.
    *
    * @example <input type="text" size="20" name="VehicleID" class="{required:true,vinUS:true}" />
    * @desc Declares a required input element whose value must be a valid vehicle identification number.
    *
    * @name jQuery.validator.methods.vinUS
    * @type Boolean
    * @cat Plugins/Validate/Methods
    */
    jQuery.validator.addMethod("vinUS", function(v) {
        if (v.length != 17) return false;
        var i, n, d, f, cd, cdv;
        var LL = ["A", "B", "C", "D", "E", "F", "G", "H", "J", "K", "L", "M", "N", "P", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"];
        var VL = [1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4, 5, 7, 9, 2, 3, 4, 5, 6, 7, 8, 9];
        var FL = [8, 7, 6, 5, 4, 3, 2, 10, 0, 9, 8, 7, 6, 5, 4, 3, 2];
        var rs = 0;
        for (i = 0; i < 17; i++) {
            f = FL[i];
            d = v.slice(i, i + 1);
            if (i == 8) {
                cdv = d;
            }
            if (!isNaN(d)) {
                d *= f;
            } else {
                for (n = 0; n < LL.length; n++) {
                    if (d.toUpperCase() === LL[n]) {
                        d = VL[n];
                        d *= f;
                        if (isNaN(cdv) && n == 8) {
                            cdv = LL[n];
                        }
                        break;
                    }
                }
            }
            rs += d;
        }
        cd = rs % 11;
        if (cd == 10) {
            cd = "X";
        }
        if (cd == cdv) {
            return true;
        }
        return false;
    }, "The specified vehicle identification number (VIN) is invalid.");

    /**
    * Return true, if the value is a valid date, also making this formal check dd/mm/yyyy.
    *
    * @example jQuery.validator.methods.date("01/01/1900")
    * @result true
    *
    * @example jQuery.validator.methods.date("01/13/1990")
    * @result false
    *
    * @example jQuery.validator.methods.date("01.01.1900")
    * @result false
    *
    * @example <input name="pippo" class="{dateITA:true}" />
    * @desc Declares an optional input element whose value must be a valid date.
    *
    * @name jQuery.validator.methods.dateITA
    * @type Boolean
    * @cat Plugins/Validate/Methods
    */
    jQuery.validator.addMethod("dateITA", function(value, element) {
        var check = false;
        var re = /^\d{1,2}\/\d{1,2}\/\d{4}$/
        if (re.test(value)) {
            var adata = value.split('/');
            var gg = parseInt(adata[0], 10);
            var mm = parseInt(adata[1], 10);
            var aaaa = parseInt(adata[2], 10);
            var xdata = new Date(aaaa, mm - 1, gg);
            if ((xdata.getFullYear() == aaaa) && (xdata.getMonth() == mm - 1) && (xdata.getDate() == gg)) check = true;
            else check = false;
        } else check = false;
        return this.optional(element) || check;
    }, "Please enter a correct date");

    /**
    * Return true, if the value is a valid date, also making this formal check dd/mm/yyyy.
    *
    * @example jQuery.validator.methods.isvaliddate("01/01/1900")
    * @result true
    *
    * @example jQuery.validator.methods.isvaliddate("01/13/1990")
    * @result false
    *
    * @example <input name="birthdate" class="{isvaliddate:true}" />
    * @desc Declares an optional input element whose value must be a valid date.
    *
    * @name jQuery.validator.methods.isvaliddate
    * @type Boolean
    * @cat Plugins/Validate/Methods
    */
    jQuery.validator.addMethod("isvaliddate", function(value, element) {

        if (!value.IsEmpty()) {
            if (value.length <= 10) return isDate(value, Date.format);
            else
                return false;
        } else {
            return true;
        }
    }, "Please enter a correct date");
    jQuery.validator.addMethod("dateNL", function(value, element) {
        return this.optional(element) || /^\d\d?[\.\/-]\d\d?[\.\/-]\d\d\d?\d?$/.test(value);
    }, "Vul hier een geldige datum in.");

    jQuery.validator.addMethod("time", function(value, element) {
        return this.optional(element) || /^([01][0-9])|(2[0123]):([0-5])([0-9])$/.test(value);
    }, "Please enter a valid time, between 00:00 and 23:59");

    /**
    * matches US phone number format 
    * 
    * where the area code may not start with 1 and the prefix may not start with 1 
    * allows '-' or ' ' as a separator and allows parens around area code 
    * some people may want to put a '1' in front of their number 
    * 
    * 1(212)-999-2345
    * or
    * 212 999 2344
    * or
    * 212-999-0983
    * 
    * but not
    * 111-123-5434
    * and not
    * 212 123 4567
    */
    jQuery.validator.addMethod("phone", function(phone_number, element) {
        phone_number = phone_number.replace(/\s+/g, "");
        return this.optional(element) || phone_number.length > 9 && phone_number.match(/^(1-?)?(\([2-9]\d{2}\)|[2-9]\d{2})-?[2-9]\d{2}-?\d{4}$/);
    }, "Please specify a valid phone number");

    // TODO check if value starts with <, otherwise don't try stripping anything
    jQuery.validator.addMethod("strippedminlength", function(value, element, param) {
        return jQuery(value).text().length >= param;
    }, jQuery.validator.format("Please enter at least {0} characters"));

    // same as email, but TLD is optional
    jQuery.validator.addMethod("email2", function(value, element, param) {
        return this.optional(element) || /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)*(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i.test(value);
    }, jQuery.validator.messages.email);

    // same as url, but TLD is optional
    jQuery.validator.addMethod("url2", function(value, element, param) {
        return this.optional(element) || /^(https?|ftp):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)*(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i.test(value);
    }, jQuery.validator.messages.url);

    // NOTICE: Modified version of Castle.Components.Validator.CreditCardValidator
    // Redistributed under the the Apache License 2.0 at http://www.apache.org/licenses/LICENSE-2.0
    // Valid Types: mastercard, visa, amex, dinersclub, enroute, discover, jcb, unknown, all (overrides all other settings)
    jQuery.validator.addMethod("creditcardtypes", function(value, element, param) {

        if (/[^0-9-]+/.test(value)) return false;

        value = value.replace(/\D/g, "");

        var validTypes = 0x0000;

        if (param.mastercard) validTypes |= 0x0001;
        if (param.visa) validTypes |= 0x0002;
        if (param.amex) validTypes |= 0x0004;
        if (param.dinersclub) validTypes |= 0x0008;
        if (param.enroute) validTypes |= 0x0010;
        if (param.discover) validTypes |= 0x0020;
        if (param.jcb) validTypes |= 0x0040;
        if (param.unknown) validTypes |= 0x0080;
        if (param.all) validTypes = 0x0001 | 0x0002 | 0x0004 | 0x0008 | 0x0010 | 0x0020 | 0x0040 | 0x0080;

        if (validTypes & 0x0001 && /^(51|52|53|54|55)/.test(value)) { //mastercard
            return value.length == 16;
        }
        if (validTypes & 0x0002 && /^(4)/.test(value)) { //visa
            return value.length == 16;
        }
        if (validTypes & 0x0004 && /^(34|37)/.test(value)) { //amex
            return value.length == 15;
        }
        if (validTypes & 0x0008 && /^(300|301|302|303|304|305|36|38)/.test(value)) { //dinersclub
            return value.length == 14;
        }
        if (validTypes & 0x0010 && /^(2014|2149)/.test(value)) { //enroute
            return value.length == 15;
        }
        if (validTypes & 0x0020 && /^(6011)/.test(value)) { //discover
            return value.length == 16;
        }
        if (validTypes & 0x0040 && /^(3)/.test(value)) { //jcb
            return value.length == 16;
        }
        if (validTypes & 0x0040 && /^(2131|1800)/.test(value)) { //jcb
            return value.length == 15;
        }
        if (validTypes & 0x0080) { //unknown
            return true;
        }
        return false;
    }, "Please enter a valid credit card number.");

//default.js
//function ModifySearch() { try { $("#tblBookingEngineSearch").toggle(); $("#tbLoginTable").hide(); arguments[0] && arguments[0] == "V" && $(".Box-A1-Bg").removeClass("Box-A1-Bg") } catch (a) { handleError(a, true) } } function ModifySearchFilter() { try { $("#tdFilter").toggle(); $("#tbLoginTable").hide(); arguments[0] && arguments[0] == "V" && $(".Box-A1-Bg").removeClass("Box-A1-Bg") } catch (a) { handleError(a, true) } } function TabClick_OnSuccess(a) { try { var c = a.GetSectionByName("BookingEngineSearchHTML"), d = a.GetSectionByName("TabClicked"); $("#divTabBody").html(c); ShowHideModifySearchLink(false); ShowHideBookingEngineSearch(true); var b = a.GetSectionByName("templatename"); if (b == "TemplateLRB" || b == "TemplateStandard") typeof window.parent.fnShowImages != "undefined" && window.parent.fnShowImages(); $("#tdTab_" + d).focus(); unBindCurrentTab() } catch (e) { handleError(e, true) } } function TabClick_OnFailure() { } function ModifySearch_OnSuccess(oContent) { try { var bookingEngineSearchHTML = oContent.GetSectionByName("BookingEngineSearchHTML"), tabClicked = oContent.GetSectionByName("TabClicked"); $("#tblBookingEngineSearch td").html(bookingEngineSearchHTML); $("#tblBookingEngineSearch").show(); var templatename = oContent.GetSectionByName("templatename"); $("#lnkModifySearch").attr("onclick", $("#lnkModifySearch").attr("clientfunctionname")); $("#lnkModifySearch").bind("click", function(event) { eval($("#lnkModifySearch").attr("clientfunctionname")) }); $("#tdTab_" + tabClicked).focus() } catch (ex) { handleError(ex, true) } } function ModifySearch_OnFailure() { } function ActionBeforeTabClick(d, b, c) { try { var a = ""; $("#frmDefault").AddORSetHC("TabClicked", b); $(".BookingEngineTab").each(function(g, e) { var f = e.id, b = ""; if (d == f) b = "activeclass"; else b = "inactiveclass"; if (c) { a = $(e).attr("shortDesc"); $("#imgTab" + a).attr("class", $("#imgTab" + a).attr(b)) } $(e).find("td").each(function(c, a) { $(a).attr("class", $(a).attr(b)) }) }); return true } catch (e) { handleError(e, true) } } function ShowHideModifySearchLink(a) { try { if (a) $("#divModifySearch").show(); else $("#divModifySearch").hide() } catch (b) { handleError(ex, false) } } function ShowHideBookingEngineSearch(a) { try { if (a) $("#tblBookingEngineSearch").show(); else $("#tblBookingEngineSearch").hide() } catch (b) { handleError(b, false) } } function BindOnKeyPressForTabs() { try { $(".BookingEngineTab").each(function(b, a) { $(a).bind("keypress", function(b) { var c; if (b.keyCode > 0) c = b.keyCode; else if (typeof b.charCode != "undefined") c = b.charCode; if (c == 9) { var d = parseInt($(a).attr("tabindex")); d += 1; var e = $(".BookingEngineTab[tabindex='" + d + "']"); $(e).trigger("click") } }) }); $(".BookingEngineTab[tabindex='1']").focus() } catch (a) { handleError(a, true) } } $(function() { unBindCurrentTab() }); function unBindCurrentTab() { $("td.BookingEngineTab").each(function(b, a) { if ($($("#" + a.id + " td[activeclass]")[0]).attr("class") == $($("#" + a.id + " td[activeclass]")[0]).attr("activeclass")) { $(a).unbind("click"); $(a).attr("onclick", "") } }) };
//autocomplete.js
//(function(a) { a.fn.extend({ autocomplete: function(c, b) { var d = typeof c == "string"; b = a.extend({}, a.Autocompleter.defaults, { url: d ? c : null, data: d ? null : c, delay: d ? a.Autocompleter.defaults.delay : 10, max: b && !b.scroll ? 10 : 150 }, b); b.highlight = b.highlight || function(a) { return a }; b.formatMatch = b.formatMatch || b.formatItem; return this.each(function() { new a.Autocompleter(this, b) }) }, result: function(a) { return this.bind("result", a) }, search: function(a) { return this.trigger("search", [a]) }, flushCache: function() { return this.trigger("flushCache") }, setOptions: function(a) { return this.trigger("setOptions", [a]) }, unautocomplete: function() { return this.trigger("unautocomplete") } }); a.Autocompleter = function(f, b) { var e = { UP: 38, DOWN: 40, DEL: 46, TAB: 9, RETURN: 13, ESC: 27, COMMA: 188, PAGEUP: 33, PAGEDOWN: 34, BACKSPACE: 8 }, d = a(f).attr("autocomplete", "off").addClass(b.inputClass), i, g = "", n = a.Autocompleter.Cache(b), l = 0, o, t = { mouseDownOnSelect: false }, c = a.Autocompleter.Select(b, f, r, t), p; a.browser.opera && a(f.form).bind("submit.autocomplete", function() { if (p) { p = false; return false } }); d.bind((a.browser.opera ? "keypress" : "keydown") + ".autocomplete", function(d) { o = d.keyCode; switch (d.keyCode) { case e.UP: d.preventDefault(); if (c.visible()) c.prev(); else h(0, true); break; case e.DOWN: d.preventDefault(); if (c.visible()) c.next(); else h(0, true); break; case e.PAGEUP: d.preventDefault(); if (c.visible()) c.pageUp(); else h(0, true); break; case e.PAGEDOWN: d.preventDefault(); if (c.visible()) c.pageDown(); else h(0, true); break; case b.multiple && a.trim(b.multipleSeparator) == "," && e.COMMA: case e.TAB: case e.RETURN: if (r()) { d.preventDefault(); p = true; return false } break; case e.ESC: c.hide(); break; default: clearTimeout(i); i = setTimeout(h, b.delay) } }).focus(function() { l++ }).blur(function() { l = 0; !t.mouseDownOnSelect && u() }).click(function() { l++ > 1 && !c.visible() && h(0, true) }).bind("search", function() { var c = arguments.length > 1 ? arguments[1] : null; function b(f, b) { var a; f = d.val(); if (b && b.length) for (var e = 0; e < b.length; e++) if (b[e].result.toLowerCase() == f.toLowerCase()) { a = b[e]; break } if (typeof c == "function") c(a); else d.trigger("result", a && [a.data, a.value]) } a.each(k(d.val()), function(c, a) { s(a, b, b) }) }).bind("flushCache", function() { n.flush() }).bind("setOptions", function() { a.extend(b, arguments[1]); "data" in arguments[1] && n.populate() }).bind("unautocomplete", function() { c.unbind(); d.unbind(); a(f.form).unbind(".autocomplete") }); function r() { var e = c.selected(); if (!e) return false; var a = e.result; g = a; if (b.multiple) { var f = k(d.val()); if (f.length > 1) a = f.slice(0, f.length - 1).join(b.multipleSeparator) + b.multipleSeparator + a; a += b.multipleSeparator } d.val(a); j(); d.trigger("result", [e.data, e.value]); return true } function h(h, f) { if (o == e.DEL) { c.hide(); return } var a = d.val(); if (!f && a == g) return; g = a; a = m(a); if (a.length >= b.minChars) { d.addClass(b.loadingClass); if (!b.matchCase) a = a.toLowerCase(); s(a, v, j) } else { q(); c.hide() } } function k(d) { if (!d) return [""]; var e = d.split(b.multipleSeparator), c = []; a.each(e, function(d, b) { if (a.trim(b)) c[d] = a.trim(b) }); return c } function m(a) { if (!b.multiple) return a; var c = k(a); return c[c.length - 1] } function w(h, c) { if (b.autoFill && m(d.val()).toLowerCase() == h.toLowerCase() && o != e.BACKSPACE) { d.val(d.val() + c.substring(m(g).length)); a.Autocompleter.Selection(f, g.length, g.length + c.length) } } function u() { clearTimeout(i); i = setTimeout(j, 200) } function j() { var e = c.visible(); c.hide(); clearTimeout(i); q(); b.mustMatch && d.search(function(c) { if (!c) if (b.multiple) { var a = k(d.val()).slice(0, -1); d.val(a.join(b.multipleSeparator) + (a.length ? b.multipleSeparator : "")) } else d.val("") }); e && a.Autocompleter.Selection(f, f.value.length, f.value.length) } function v(b, a) { if (a && a.length && l) { q(); c.display(a, b); w(b, a[0].value); c.show() } else j() } function s(d, h, i) { if (!b.matchCase) d = d.toLowerCase(); var e = n.load(d); if (e && e.length) h(d, e); else if (typeof b.url == "string" && b.url.length > 0) { var g = { timestamp: +new Date }; a.each(b.extraParams, function(b, a) { g[b] = typeof a == "function" ? a() : a }); a.ajax({ mode: "abort", port: "autocomplete" + f.name, dataType: b.dataType, url: b.url, data: a.extend({ q: m(d), limit: b.max }, g), success: function(c) { var a = b.parse && b.parse(c) || x(c); n.add(d, a); h(d, a) } }) } else { c.emptyList(); i(d) } } function x(g) { for (var d = [], f = g.split("\n"), e = 0; e < f.length; e++) { var c = a.trim(f[e]); if (c) { c = c.split("|"); d[d.length] = { data: c, value: c[0], result: b.formatResult && b.formatResult(c, c[0]) || c[0]} } } return d } function q() { d.removeClass(b.loadingClass) } }; a.Autocompleter.defaults = { inputClass: "ac_input", resultsClass: "ac_results", loadingClass: "ac_loading", minChars: 1, delay: 400, matchCase: false, matchSubset: true, matchContains: false, cacheLength: 10, max: 100, mustMatch: false, extraParams: {}, selectFirst: true, formatItem: function(a) { return a[0] }, formatMatch: null, autoFill: false, width: 0, multiple: false, multipleSeparator: ", ", highlight: function(a, b) { return a.replace(new RegExp("(?![^&;]+;)(?!<[^<>]*)(" + b.replace(/([\^\$\(\)\[\]\{\}\*\.\+\?\|\\])/gi, "\\$1") + ")(?![^<>]*>)(?![^&;]+;)", "gi"), "<strong>$1</strong>") }, scroll: true, scrollHeight: 180 }; a.Autocompleter.Cache = function(b) { var c = {}, d = 0; function e(a, d) { if (!b.matchCase) a = a.toLowerCase(); var c = a.indexOf(d); if (b.matchContains == "word") c = a.toLowerCase().search("\\b" + d.toLowerCase()); return c == -1 ? false : c == 0 || b.matchContains } function h(a, e) { d > b.cacheLength && g(); if (!c[a]) d++; c[a] = e } function f() { if (!b.data) return false; var d = {}, j = 0; if (!b.url) b.cacheLength = 1; d[""] = []; for (var f = 0, k = b.data.length; f < k; f++) { var c = b.data[f]; c = typeof c == "string" ? [c] : c; var e = b.formatMatch(c, f + 1, b.data.length); if (e === false) continue; var g = e.charAt(0).toLowerCase(); if (!d[g]) d[g] = []; var i = { value: e, data: c, result: b.formatResult && b.formatResult(c) || e }; d[g].push(i); j++ < b.max && d[""].push(i) } a.each(d, function(c, a) { b.cacheLength++; h(c, a) }) } setTimeout(f, 25); function g() { c = {}; d = 0 } return { flush: g, add: h, populate: f, load: function(f) { if (!b.cacheLength || !d) return null; if (!b.url && b.matchContains) { var g = []; for (var j in c) if (j.length > 0) { var h = c[j]; a.each(h, function(b, a) { e(a.value, f) && g.push(a) }) } return g } else if (c[f]) return c[f]; else if (b.matchSubset) for (var i = f.length - 1; i >= b.minChars; i--) { var h = c[f.substr(0, i)]; if (h) { var g = []; a.each(h, function(b, a) { if (e(a.value, f)) g[g.length] = a }); return g } } return null } } }; a.Autocompleter.Select = function(d, k, r, n) { var f = { ACTIVE: "ac_over" }, b, c = -1, i, l = "", m = true, g, e; function s() { if (!m) return; g = a("<div/>").hide().addClass(d.resultsClass).css("position", "absolute").appendTo(document.body); e = a("<ul/>").appendTo(g).mouseover(function(b) { if (j(b).nodeName && j(b).nodeName.toUpperCase() == "LI") { c = a("li", e).removeClass(f.ACTIVE).index(j(b)); a(j(b)).addClass(f.ACTIVE) } }).click(function(b) { a(j(b)).addClass(f.ACTIVE); r(); k.focus(); return false }).mousedown(function() { n.mouseDownOnSelect = true }).mouseup(function() { n.mouseDownOnSelect = false }); d.width > 0 && g.css("width", d.width); m = false } function j(b) { var a = b.target; while (a && a.tagName != "LI") a = a.parentNode; return !a ? [] : a } function h(h) { b.slice(c, c + 1).removeClass(f.ACTIVE); p(h); var g = b.slice(c, c + 1).addClass(f.ACTIVE); if (d.scroll) { var a = 0; b.slice(0, c).each(function() { a += this.offsetHeight }); if (a + g[0].offsetHeight - e.scrollTop() > e[0].clientHeight) e.scrollTop(a + g[0].offsetHeight - e.innerHeight()); else a < e.scrollTop() && e.scrollTop(a) } } function p(a) { c += a; if (c < 0) c = b.size() - 1; else if (c >= b.size()) c = 0 } function o(a) { return d.max && d.max < a ? d.max : a } function q() { e.empty(); for (var j = o(i.length), g = 0; g < j; g++) { if (!i[g]) continue; var h = d.formatItem(i[g].data, g + 1, j, i[g].value, l); if (h === false) continue; var k = a("<li/>").html(d.highlight(h, l)).addClass(g % 2 == 0 ? "ac_even" : "ac_odd").appendTo(e)[0]; a.data(k, "ac_data", i[g]) } b = e.find("li"); if (d.selectFirst) { b.slice(0, 1).addClass(f.ACTIVE); c = 0 } a.fn.bgiframe && e.bgiframe() } return { display: function(a, b) { s(); i = a; l = b; q() }, next: function() { h(1) }, prev: function() { h(-1) }, pageUp: function() { if (c != 0 && c - 8 < 0) h(-c); else h(-8) }, pageDown: function() { if (c != b.size() - 1 && c + 8 > b.size()) h(b.size() - 1 - c); else h(8) }, hide: function() { g && g.hide(); b && b.removeClass(f.ACTIVE); c = -1 }, visible: function() { return g && g.is(":visible") }, current: function() { return this.visible() && (b.filter("." + f.ACTIVE)[0] || d.selectFirst && b[0]) }, show: function() { var h = a(k).offset(); g.css({ width: typeof d.width == "string" || d.width > 0 ? d.width : a(k).width(), top: h.top + k.offsetHeight, left: h.left }).show(); if (d.scroll) { e.scrollTop(0); e.css({ maxHeight: d.scrollHeight, overflow: "auto" }); if (a.browser.msie && typeof document.body.style.maxHeight === "undefined") { var c = 0; b.each(function() { c += this.offsetHeight }); var f = c > d.scrollHeight; e.css("height", f ? d.scrollHeight : c); !f && b.width(e.width() - parseInt(b.css("padding-left")) - parseInt(b.css("padding-right"))) } } }, selected: function() { var c = b && b.filter("." + f.ACTIVE).removeClass(f.ACTIVE); return c && c.length && a.data(c[0], "ac_data") }, emptyList: function() { e && e.empty() }, unbind: function() { g && g.remove() } } }; a.Autocompleter.Selection = function(a, c, d) { if (a.createTextRange) { var b = a.createTextRange(); b.collapse(true); b.moveStart("character", c); b.moveEnd("character", d); b.select() } else if (a.setSelectionRange) a.setSelectionRange(c, d); else if (a.selectionStart) { a.selectionStart = c; a.selectionEnd = d } a.focus() } })(jQuery);

