jQuery.fn.extend({
    disableSelection: function () {
        return this.each(function () {
            this.onselectstart = function () { return false; };
            this.unselectable = "on";
            jQuery(this).css('user-select', 'none');
            jQuery(this).css('-o-user-select', 'none');
            jQuery(this).css('-moz-user-select', 'none');
            jQuery(this).css('-khtml-user-select', 'none');
            jQuery(this).css('-webkit-user-select', 'none');
        });
    }
});
jQuery.expr[':'].Contains = function (a, i, m) {
    return (a.textContent || a.innerText || "").toUpperCase().indexOf(m[3].toUpperCase()) >= 0;
};
function DefaultEnter(ctrl, event, validationGroup, clientFunction) {
    var intKeyPressed = document.all ? event.keyCode : event.which;
    var char13ReturnType = "submit";
    if(intKeyPressed == 13) {
        if(ctrl.attr('type') == 'submit') {
            char13ReturnType = "submit";
        } else {
            Page_IsValid = null; // Initialize to avoid 'Page_IsValid is undefined' JavaScript error 
            if((validationGroup != null) && (validationGroup != "")) {
                WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(ctrl.attr('id').replace(/_/g, '$'), '', true, validationGroup, '', false, false));
                if((Page_IsValid == null) || (Page_IsValid == false)) {
                    char13ReturnType = "submit";
                } else {
                    char13ReturnType = "validationsRanSuccessfully";
                }
            } else {
                char13ReturnType = "postback";
            }
        }
        if(char13ReturnType == 'submit') {
            if(clientFunction != null) {
                clientFunction(); // this is needed in case we need to call a OnClientClick function
            }
            return WebForm_FireDefaultButton(event, ctrl.attr('id'));
        } else {
            __doPostBack(ctrl.attr('id').replace(/_/g, '$'), '');
            event.preventDefault();
        }
    }
};
/*
End Common Functions
*/
/*
Start Common Client-Side Validation functions
*/

function ValidateForEmpty(validationControl, args) {
    var validateControlId = validationControl.controltovalidate;
    if(EvaluateForEmpty(args.Value) == true) {
        args.IsValid = false;
    } else {
        args.IsValid = true;
    }
    FormatAssociatedLabel(args.IsValid, validateControlId);
};

function ValidateForNumbersOnly(validationControl, args) {
    var validateControlId = validationControl.controltovalidate;
    if(EvaluateForNumbersOnly(args.Value) == true) {
        args.IsValid = true;
    } else {
        args.IsValid = false;
    }
    FormatAssociatedLabel(args.IsValid, validateControlId);
};

function ValidateForEmail(validationControl, args) {
    var validateControlId = validationControl.controltovalidate;
    if(EvaluateForEmail(args.Value) == true) {
        args.IsValid = true;
    } else {
        args.IsValid = false;
    }
    FormatAssociatedLabel(args.IsValid, validateControlId);
};

function ValidateForDropdownSelect(validationControl, args) {
    var validateControlId = validationControl.controltovalidate;
    if(args.Value == "None" || args.Value == "0" || args.valueOf == "-1") {
        args.IsValid = false;
    } else {
        args.IsValid = true;
    }
    FormatAssociatedLabel(args.IsValid, validateControlId);
};

function ValidateForPhone(validationControl, args) {
    var validateControlId = validationControl.controltovalidate;
    if(EvaluateForPhone(args.Value) == true) {
        args.IsValid = true;
    } else {
        args.IsValid = false;
    }
    FormatAssociatedLabel(args.IsValid, validateControlId);
};

function ValidateForRequiredShortUrl(validationControl, args) {
    var validateControlId = validationControl.controltovalidate;
    if((EvaluateForEmpty(args.Value) == false) && (EvaluateForValidUrl(args.Value) == false)) {
        FormatAssociatedLabel(false, validateControlId);
        args.IsValid = false;
    } else {
        if(EvaluateForEmpty(args.Value) == true) {
            FormatAssociatedLabel(false, validateControlId);
        } else {
            FormatAssociatedLabel(true, validateControlId);
        }
    }
    return true;
};

function ValidateForMoney(validationControl, args) {
    var validateControlId = validationControl.controltovalidate;
    if(EvaluateForMoney(args.Value) == true) {
        args.IsValid = true;
    } else {
        args.IsValid = false;
    }
    FormatAssociatedLabel(args.IsValid, validateControlId);
};

function EvaluateForEmpty(targetValue) {
    if((targetValue == null) || (targetValue == "")) {
        return true;
    } else {
        return false;
    }
};

function EvaluateForNumbersOnly(targetValue) {
    if(targetValue.match(/^[0-9]*$/)) {
        return true;
    } else {
        return false;
    }
};

function EvaluateForEmail(targetValue) {
    if((targetValue.match(/^$|([0-9a-zA-Z]+[-._+&])*[0-9a-zA-Z]+@([-0-9a-zA-Z]+[.])+[a-zA-Z]{2,6}$/))) {
        return true;
    } else {
        return false;
    }
};

function EvaluateForPhone(targetValue) {
    if((targetValue.match(/^$|([\(]{1}[0-9]{3}[\)]{1}[\.| |\-]{0,1}|^[0-9]{3}[\.|\-| ]?)?[0-9]{3}(\.|\-| )?[0-9]{4}(|\s.+)$/))) {
        return true;
    } else {
        return false;
    }
};
/*
Allow letters, numbers, underscores (_) and dashes (-), but must begin and end with a number or letter
*/

function EvaluateForValidUrl(targetValue) {
    if((targetValue.match(/^[a-zA-Z0-9]+((-|_)[a-zA-Z0-9]+)*$/))) {
        return true;
    } else {
        return false;
    }
}

function EvaluateForMoney(targetValue) {
    if((targetValue.match(/^\$?([0-9]{1,3},([0-9]{3},)*[0-9]{3}|[0-9]+)(\.[0-9][0-9])?$/))) {
        return true;
    } else {
        return false;
    }
};

function FormatAssociatedLabel(isValid, validateControlId) {
    return 0; // don't know whats up with this!          
    $('label').each(function () {
        var ctl = $(this)[0].attributes['for'].value;
        if(ctl == $(validateControlId).selector) {
            if(isValid == false) {
                $(this).addClass("alert");
            } else {
                $(this).removeClass("alert");
            }
        }
    });
};

function CheckForHTML(args) {
    if(args.get_error() != undefined) {
        var errorMessage = args.get_error().message;
        $(".alertBox").html("Please remove the HTML formatting, then save your information.");
        $(".alertBox").toggle();
        args.set_errorHandled(true);
        ReadyFunction();
        return false;
    } else {
        return true;
    }
};
/*
End Common Client-Side Validation functions
*/

function CloseWindow() {
    var Shadowbox = window.parent.Shadowbox;
    if(Shadowbox != null) {
        Shadowbox.close()
    } else {
        self.close();
    }
};

function log(message) {
    if (window.console && console.log) {
        console.log(message); //for firebug
    }

};

function timeStamp() {
    var date = new Date();
    var hours = date.getHours();
    var minutes = date.getMinutes();
    if(minutes <= 9) {
        minutes = "0" + minutes;
    }
    var seconds = date.getSeconds();
    if(seconds <= 9) {
        seconds = "0" + seconds;
    }
    return "{0}:{1}:{2}".format(hours, minutes, seconds);
};

String.prototype.format = function () {
    var pattern = /\{\d+\}/g;
    var args = arguments;
    return this.replace(pattern, function (capture) {
        return args[capture.match(/\d+/)];
    });
};

String.prototype.hasValue = function () {
    return !isEmpty(this);
};

String.prototype.isEmpty = function () {
    return isEmpty(this);
};

function isEmpty(s) {
    if(s) {
        return s.length > 0 ? false : true;
    }
    return true;
};

String.prototype.formatWith = function () {
    var pattern = /\{\d+\}/g;
    var args = arguments;
    return this.replace(pattern, function (capture) {
        return args[capture.match(/\d+/)];
    });
};

String.prototype.replaceAll = function (oldValue, newValue) {
    return this.replace(new RegExp(oldValue, 'g'), newValue);
};

String.prototype.htmlEncode = function (value) {
    if(value !== undefined) {
        return $('<div/>').text(value).html();
    } else {
        return value;
    }
};

String.prototype.htmlDecode = function (value) {
    return $('<div/>').html(value).text();
};

function htmlEncode(value) {
    return value.htmlEncode();
};

function htmlDecode(value) {
    return value.htmlDecode();
};

function makeSafeUrl(thisText) {
    var w = "!@#$%^&*()+=[]\\\';,./{}|\":<>?";
    var s = 'abcdefghijklmnopqrstuvwxyz0123456789-_';
    var x = new Array('àáâãäå', 'ç', 'èéêë', 'ìíîï', 'ñ', 'ðóòôõöø', 'ùúûü', 'ýÿ');
    var r = new Array('a', 'c', 'e', 'i', 'n', 'o', 'u', 'y');
    thisText = thisText.replaceAll(' ', '-').toLowerCase();
    var newText = new Array();
    for(i = 0; i < thisText.length; i++) {
        thisChar = thisText.charAt(i);
        if(w.indexOf(thisChar) == -1) {
            if(s.match('' + thisChar + '')) {
                newText[i] = thisChar;
            } else {
                for(j = 0; j < x.length; j++) {
                    if(x[j].match(thisChar)) {
                        newText[i] = r[j];
                    }
                }
            }
        }
    }
    return newText.join('');
};

function ajaxRequest(configObject) {
    if (configObject.contentType) {
        switch (configObject.dataType) {
            case "json":
                configObject.contentType = "application/json; charset=utf-8";
                break;
            case "xml":
                configObject.contentType = "application/xml; charset=utf-8";
                break;
            case "html":
                configObject.contentType = "application/html; charset=utf-8";
                break;
            case "text":
                configObject.contentType = "application/text; charset=utf-8";
                break;
            default:
                break;
        }
    }
    else {
        configObject.contentType = "application/json; charset=utf-8"
    }

    return $.ajax({
        type: configObject.type,
        url: configObject.url,
        data: configObject.data,
        contentType: configObject.contentType,
        dataType: configObject.dataType,
        processData: configObject.processData || true,
        async: (configObject.async == null) ? true : configObject.async,
        cache: (configObject.cache == null) ? false : configObject.cache,
        beforeSend: configObject.beforeCallback,
        success: configObject.successCallback,
        complete: configObject.completeCallback,        
        error: function (xhr, status, error) {
            if ($.isFunction(configObject.errorCallback)) {
                configObject.errorCallback.apply();
            }
        }
    });
};


/***** jQuery Extensions *****/

(function ($) {

    $.extend({

        debounce: function (fn, timeout, invokeAsap, ctx) {

            if (arguments.length == 3 && typeof invokeAsap != 'boolean') {
                ctx = invokeAsap;
                invokeAsap = false;
            }

            var timer;

            return function () {

                var args = arguments;
                ctx = ctx || this;

                invokeAsap && !timer && fn.apply(ctx, args);

                clearTimeout(timer);

                timer = setTimeout(function () {
                    !invokeAsap && fn.apply(ctx, args);
                    timer = null;
                }, timeout);

            };

        },

        throttle: function (fn, timeout, ctx) {

            var timer, args, needInvoke;

            return function () {

                args = arguments;
                needInvoke = true;
                ctx = ctx || this;

                if (!timer) {
                    (function () {
                        if (needInvoke) {
                            fn.apply(ctx, args);
                            needInvoke = false;
                            timer = setTimeout(arguments.callee, timeout);
                        }
                        else {
                            timer = null;
                        }
                    })();
                }

            };

        }

    });

})(jQuery);


(function ($) {
    $.extend($.fn, {
        livequery: function (type, fn, fn2) {
            var self = this,
                q;
            if($.isFunction(type)) fn2 = fn, fn = type, type = undefined;
            $.each($.livequery.queries, function (i, query) {
                if(self.selector == query.selector && self.context == query.context && type == query.type && (!fn || fn.$lqguid == query.fn.$lqguid) && (!fn2 || fn2.$lqguid == query.fn2.$lqguid)) return (q = query) && false;
            });
            q = q || new $.livequery(this.selector, this.context, type, fn, fn2);
            q.stopped = false;
            q.run();
            return this;
        },
        expire: function (type, fn, fn2) {
            var self = this;
            if($.isFunction(type)) fn2 = fn, fn = type, type = undefined;
            $.each($.livequery.queries, function (i, query) {
                if(self.selector == query.selector && self.context == query.context && (!type || type == query.type) && (!fn || fn.$lqguid == query.fn.$lqguid) && (!fn2 || fn2.$lqguid == query.fn2.$lqguid) && !this.stopped) $.livequery.stop(query.id);
            });
            return this;
        }
    });
    $.livequery = function (selector, context, type, fn, fn2) {
        this.selector = selector;
        this.context = context;
        this.type = type;
        this.fn = fn;
        this.fn2 = fn2;
        this.elements = [];
        this.stopped = false;
        this.id = $.livequery.queries.push(this) - 1;
        fn.$lqguid = fn.$lqguid || $.livequery.guid++;
        if(fn2) fn2.$lqguid = fn2.$lqguid || $.livequery.guid++;
        return this;
    };
    $.livequery.prototype = {
        stop: function () {
            var query = this;
            if(this.type) this.elements.unbind(this.type, this.fn);
            else if(this.fn2) this.elements.each(function (i, el) {
                query.fn2.apply(el);
            });
            this.elements = [];
            this.stopped = true;
        },
        run: function () {
            if(this.stopped) return;
            var query = this;
            var oEls = this.elements,
                els = $(this.selector, this.context),
                nEls = els.not(oEls);
            this.elements = els;
            if(this.type) {
                nEls.bind(this.type, this.fn);
                if(oEls.length > 0) $.each(oEls, function (i, el) {
                    if($.inArray(el, els) < 0) $.event.remove(el, query.type, query.fn);
                });
            } else {
                nEls.each(function () {
                    query.fn.apply(this);
                });
                if(this.fn2 && oEls.length > 0) $.each(oEls, function (i, el) {
                    if($.inArray(el, els) < 0) query.fn2.apply(el);
                });
            }
        }
    };
    $.extend($.livequery, {
        guid: 0,
        queries: [],
        queue: [],
        running: false,
        timeout: null,
        checkQueue: function () {
            if($.livequery.running && $.livequery.queue.length) {
                var length = $.livequery.queue.length;
                while(length--)
                    $.livequery.queries[$.livequery.queue.shift()].run();
            }
        },
        pause: function () {
            $.livequery.running = false;
        },
        play: function () {
            $.livequery.running = true;
            $.livequery.run();
        },
        registerPlugin: function () {
            $.each(arguments, function (i, n) {
                if(!$.fn[n]) return;
                var old = $.fn[n];
                $.fn[n] = function () {
                    var r = old.apply(this, arguments);
                    $.livequery.run();
                    return r;
                }
            });
        },
        run: function (id) {
            if(id != undefined) {
                if($.inArray(id, $.livequery.queue) < 0) $.livequery.queue.push(id);
            } else $.each($.livequery.queries, function (id) {
                if($.inArray(id, $.livequery.queue) < 0) $.livequery.queue.push(id);
            });
            if($.livequery.timeout) clearTimeout($.livequery.timeout);
            $.livequery.timeout = setTimeout($.livequery.checkQueue, 20);
        },
        stop: function (id) {
            if(id != undefined) $.livequery.queries[id].stop();
            else $.each($.livequery.queries, function (id) {
                $.livequery.queries[id].stop();
            });
        }
    });
    $.livequery.registerPlugin('append', 'prepend', 'after', 'before', 'wrap', 'attr', 'removeAttr', 'addClass', 'removeClass', 'toggleClass', 'empty', 'remove', 'html');
    $(function () {
        $.livequery.play();
    });
})(jQuery);

(function ($) {
    var default_options = {
        labelClass: 'placeholder'
    };
    var ph = "PLACEHOLDER-INPUT";
    var phl = "PLACEHOLDER-LABEL";
    var boundEvents = false;
    //check for browser support for placeholder attribute
    var input = document.createElement("input");
    /* using custom placeholder for all browsers now
    if('placeholder' in input) {
        $.fn.placeholder = $.fn.unplaceholder = function () { }; //empty function
        delete input;
        return;
    };
    */
    delete input;
    $.fn.placeholder = function (options) {
        bindEvents();
        var opts = $.extend(default_options, options)
        this.each(function () {
            var rnd = Math.random().toString(32).replace(/\./, ''),
                input = $(this),
                label = $('<label style="position:absolute; z-index:100; "></label>');
            if(!input.attr('placeholder') || input.data(ph) === ph) return;
            //make sure the input tag has an ID assigned, if not, assign one.
            if(!input.attr('id')) {
                input.attr('id', 'input_' + rnd);
                }
            label.attr('id', input.attr('id') + "_placeholder").data(ph, '#' + input.attr('id')) //reference to the input tag
            .attr('for', input.attr('id')).addClass(opts.labelClass).addClass(opts.labelClass + '-for-' + this.tagName.toLowerCase()) //ex: watermark-for-textarea
            .addClass(phl).text(input.attr('placeholder'));
            input.data(phl, '#' + label.attr('id')) //set a reference to the label
            .data(ph, ph) //set that the field is watermarked
            .addClass(ph) //add the watermark class
            .before(label); //add the label field to the page
            itemOut.call(this);
        });
         $('label').disableSelection(); 
    };
    $.fn.unplaceholder = function () {
        this.each(function () {
            var input = $(this),
                label = $(input.data(phl));
            if(input.data(ph) !== ph) return;
            label.remove();
            input.removeData(ph).removeData(phl).removeClass(ph);
        });
    };

    function bindEvents() {
        if(boundEvents) return;
        $('.' + ph).live('click', itemIn).live('focusin', itemIn).live('change', itemIn).live('focusout', itemOut).live('keyup', itemKeyStroke);
        bound = true;
        boundEvents = true;
    };

    function itemIn() {
        var input = $(this),
        label = $(input.data(phl));
        if( $(input).val().length > 0)
            $(label).addClass('hasValue').removeClass('FocusNoValue');
        else 
            $(label).addClass('FocusNoValue').removeClass('hasValue');
    };

    function itemOut() {
        var input = $(this),
        label = $(input.data(phl));
        if( $(input).val().length > 0)
            $(label).addClass('hasValue').removeClass('FocusNoValue');
        else 
            $(label).removeClass('FocusNoValue').removeClass('hasValue');
    };
    function itemKeyStroke(){
        var input = $(this),
            label = $(input.data(phl));
            if( $(input).val().length > 0)
                $(label).addClass('hasValue').removeClass('FocusNoValue');
            else 
                $(label).addClass('FocusNoValue').removeClass('hasValue');
    };
} (jQuery));

$.extend({
    getUrlVars: function () {
        var vars = [], hash;
        var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
        for (var i = 0; i < hashes.length; i++) {
            hash = hashes[i].split('=');
            vars.push(hash[0]);
            vars[hash[0]] = hash[1];
        }
        return vars;
    },
    getUrlVar: function (name) {
        return $.getUrlVars()[name];
    }
});


function buildHTML(tag, html, attrs) {
    if (typeof (html) != 'string') {
        attrs = html;
        html = null;
    }
    var h = '<' + tag;
    for (attr in attrs) {
        if (attrs[attr] === false) continue;
        h += ' ' + attr + '="' + attrs[attr] + '"';
    }
    return h += html ? ">" + html + "</" + tag + ">" : "/>";
}

function creditCardTypeFromNumber(num) {
    num = num.replace(/[^\d]/g, '');
    if (num.match(/^5[1-5]\d{14}$/)) {
        return 'MasterCard';
    } else if (num.match(/^4\d{15}/) || num.match(/^4\d{12}/)) {
        return 'Visa';
    } else if (num.match(/^3[47]\d{13}/)) {
        return 'AmEx';
    } else if (num.match(/^6011\d{12}/)) {
        return 'Discover';
    }
    return 'UNKNOWN';
}

/****Hash Change handler **/
(function ($, window, undefined) {
    '$:nomunge';
    var str_hashchange = 'hashchange',
    doc = document,
    fake_onhashchange,
    special = $.event.special,
    doc_mode = doc.documentMode,
    supports_onhashchange = 'on' + str_hashchange in window && (doc_mode === undefined || doc_mode > 7);
    function get_fragment(url) {
        url = url || location.href;
        return '#' + url.replace(/^[^#]*#?(.*)$/, '$1');
    };
    $.fn[str_hashchange] = function (fn) {
        return fn ? this.bind(str_hashchange, fn) : this.trigger(str_hashchange);
    };

    $.fn[str_hashchange].delay = 50;
    special[str_hashchange] = $.extend(special[str_hashchange], {
        setup: function () {
            if (supports_onhashchange) { return false; }
            $(fake_onhashchange.start);
        },
        teardown: function () {
            if (supports_onhashchange) { return false; }
            $(fake_onhashchange.stop);
        }

    });

    fake_onhashchange = (function () {
        var self = {},
      timeout_id,
      last_hash = get_fragment(),
      fn_retval = function (val) { return val; },
      history_set = fn_retval,
      history_get = fn_retval;
        self.start = function () {
            timeout_id || poll();
        };
        self.stop = function () {
            timeout_id && clearTimeout(timeout_id);
            timeout_id = undefined;
        };
        function poll() {
            var hash = get_fragment(),
        history_hash = history_get(last_hash);

            if (hash !== last_hash) {
                history_set(last_hash = hash, history_hash);

                $(window).trigger(str_hashchange);

            } else if (history_hash !== last_hash) {
                location.href = location.href.replace(/#.*/, '') + history_hash;
            }

            timeout_id = setTimeout(poll, $.fn[str_hashchange].delay);
        };

        $.browser.msie && !supports_onhashchange && (function () {

            var iframe,
        iframe_src;


            self.start = function () {
                if (!iframe) {
                    iframe_src = $.fn[str_hashchange].src;
                    iframe_src = iframe_src && iframe_src + get_fragment();


                    iframe = $('<iframe tabindex="-1" title="empty"/>').hide()


            .one('load', function () {
                iframe_src || history_set(get_fragment());
                poll();
            })


            .attr('src', iframe_src || 'javascript:0')


            .insertAfter('body')[0].contentWindow;


                    doc.onpropertychange = function () {
                        try {
                            if (event.propertyName === 'title') {
                                iframe.document.title = doc.title;
                            }
                        } catch (e) { }
                    };

                }
            };


            self.stop = fn_retval;


            history_get = function () {
                return get_fragment(iframe.location.href);
            };


            history_set = function (hash, history_hash) {
                var iframe_doc = iframe.document,
          domain = $.fn[str_hashchange].domain;

                if (hash !== history_hash) {

                    iframe_doc.title = doc.title;


                    iframe_doc.open();


                    domain && iframe_doc.write('<script>document.domain="' + domain + '"</script>');

                    iframe_doc.close();


                    iframe.location.hash = hash;
                }
            };

        })();

        return self;
    })();

})(jQuery, this);
/*** end hash change handler  ***/

/*********** Facebook Stuff *************/
var ApiInit = false;
function fbCore(){    /*document.domain = 'firstgiving.com';*/
    window.fbAsyncInit = function () {
        FB.init({
            appId: '251632261525136',
            status: false,
            cookie: true,
            xfbml: true,
            channelUrl: 'http://www.firstgiving.com/channel.html'
        });

        fbApiInit = true; /*usage:  fbEnsureInit(callback) */
    };
    (function () {
        var e = document.createElement('script'); e.async = true;
        e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
        document.getElementById('fb-root').appendChild(e);
    } ());
    }
function fbEnsureInit(callback) {
    if (!window.fbApiInit) {
        setTimeout(function () { fbEnsureInit(callback); }, 50);
    } else {
        if (callback) {
            callback();
        }
    }
}
fbEnsureInit(function () {
    log("Facebook SDK is ready");
    FB.Event.subscribe('edge.create', function (href) {
        session = FB.getSession();
        uid = session['uid'];
        //log(uid);

        
    });
})
function FbAuth(success, error, opts) {
    if (opts === undefined) { opts = {}; }
    FB.getLoginStatus(function (response) {
        if (response.session) {
            success(response);
        } else {
            FB.login(function (response) {
                if (response.session) {
                    success(response);
                } else {
                    error(response);
                }
            }, opts);
        }
    });
}

function fbGetUserInfo() {
     return 

}

/*********** End facebook ***************/



jQuery.fn.exists = function () {
    return jQuery(this).length > 0
};

function getNumber (num, pos){
  var sNum = num + "";
  if(pos > sNum.length || pos <= 0){
        return "";
    }
  return sNum[sNum.length - pos];
}
var isEven = function(someNumber){
    return (someNumber%2 == 0) ? true : false;
}


function getTestCopy(num, position, copies){
    var a = getNumber(num, position);
    if(isEven(a)){
        return copies[0];
    }
    else{
        return copies[1];
    }
}



/**
* jQuery Cookie plugin
*
* Copyright (c) 2010 Klaus Hartl (stilbuero.de)
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*
*/
jQuery.cookie = function (key, value, options) {

    // key and at least value given, set cookie...
    if (arguments.length > 1 && String(value) !== "[object Object]") {
        options = jQuery.extend({}, options);

        if (value === null || value === undefined) {
            options.expires = -1;
        }

        if (typeof options.expires === 'number') {
            var days = options.expires, t = options.expires = new Date();
            t.setDate(t.getDate() + days);
        }

        value = String(value);

        return (document.cookie = [
            encodeURIComponent(key), '=',
            options.raw ? value : encodeURIComponent(value),
            options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
            options.path ? '; path=' + options.path : '',
            options.domain ? '; domain=' + options.domain : '',
            options.secure ? '; secure' : ''
        ].join(''));
    }

    // key and possibly options given, get cookie...
    options = value || {};
    var result, decode = options.raw ? function (s) { return s; } : decodeURIComponent;
    return (result = new RegExp('(?:^|; )' + encodeURIComponent(key) + '=([^;]*)').exec(document.cookie)) ? decode(result[1]) : null;
};

function checkForExistingAccount() {
    var a = $("#Consumer_EmailAddress").val();
    var b = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
    b.test(a) ? $.ajax({
        url: "/process/child/Receiver.asp?email=" + a + "&searchtype=emailsearch",
        global: false,
        success: function (a) {
            $(a).find("emailaddress").text() == "NotAvailable" ? userHasFgLogin("It looks like you already have an account") : undoUserHasFgLogin()

        }

    }) : undoUserHasFgLogin();
    return true
}

/** this used to be in profile/plugins **/
(function (a) { })(this.jQuery);
window.log = function () {
    log.history = log.history || [];
    log.history.push(arguments);
    if (this.console) {
        console.log(Array.prototype.slice.call(arguments))
    }
}; (function (b) {
    /*var a = b.write; b.write = function (d) { log("document.write(): ", arguments); if (/docwriteregexwhitelist/.test(d)) { a.apply(b, arguments) } } */
})(document); (function (a) {
    a.widget("ui.selectmenu", {
        getter: "value",
        version: "1.8",
        eventPrefix: "selectmenu",
        options: {
            transferClasses: true,
            style: "dropdown",
            positionOptions: {
                my: "left top",
                at: "left bottom",
                offset: "2px"
            },
            width: null,
            menuWidth: null,
            handleWidth: 26,
            maxHeight: null,
            icons: null,
            format: null,
            bgImage: function () { },
            wrapperElement: ""
        },
        _create: function () {
            var r = this,
            f = this.options;
            var h = this.element.attr("id") || "ui-selectmenu-" + Math.random().toString(16).slice(2, 10);
            this.ids = [h + "-button", h + "-menu"];
            this._safemouseup = true;
            this.newelement = a('<a class="' + this.widgetBaseClass + ' ui-widget ui-state-default ui-corner-all" id="' + this.ids[0] + '" role="button" href="#" tabindex="0" aria-haspopup="true" aria-owns="' + this.ids[1] + '"></a>').insertAfter(this.element);
            this.newelement.wrap(f.wrapperElement);
            var l = this.element.attr("tabindex");
            if (l) {
                this.newelement.attr("tabindex", l)
            }
            this.newelement.data("selectelement", this.element);
            this.selectmenuIcon = a('<span class="' + this.widgetBaseClass + '-icon ui-icon"></span>').prependTo(this.newelement).addClass((f.style == "popup") ? "ui-icon-triangle-2-n-s" : "ui-icon-triangle-1-s");
            a("label[for=" + this.element.attr("id") + "]").attr("for", this.ids[0]).bind("click", function () {
                r.newelement[0].focus();
                return false
            });
            this.newelement.bind("mousedown", function (j) {
                r._toggle(j, true);
                if (f.style == "popup") {
                    r._safemouseup = false;
                    setTimeout(function () {
                        r._safemouseup = true
                    }, 300)
                }
                return false
            }).bind("click", function () {
                return false
            }).keydown(function (o) {
                var j = true;
                switch (o.keyCode) {
                    case a.ui.keyCode.ENTER:
                        j = true;
                        break;
                    case a.ui.keyCode.SPACE:
                        j = false;
                        r._toggle(o);
                        break;
                    case a.ui.keyCode.UP:
                    case a.ui.keyCode.LEFT:
                        j = false;
                        r._moveSelection(-1);
                        break;
                    case a.ui.keyCode.DOWN:
                    case a.ui.keyCode.RIGHT:
                        j = false;
                        r._moveSelection(1);
                        break;
                    case a.ui.keyCode.TAB:
                        j = true;
                        break;
                    default:
                        j = true;
                        r._typeAhead(o.keyCode, "mouseup");
                        break
                }
                return j
            }).bind("mouseover focus", function () {
                if (!f.disabled) {
                    a(this).addClass(r.widgetBaseClass + "-focus ui-state-hover")
                }
            }).bind("mouseout blur", function () {
                if (!f.disabled) {
                    a(this).removeClass(r.widgetBaseClass + "-focus ui-state-hover")
                }
            });
            a(document).mousedown(function (j) {
                r.close(j)
            });
            this.element.click(function () {
                this._refreshValue()
            }).focus(function () {
                if (this.newelement) {
                    this.newelement[0].focus()
                }
            });
            var d = (f.style == "dropdown") ? " ui-corner-bottom" : " ui-corner-all";
            this.list = a('<ul class="' + r.widgetBaseClass + "-menu ui-widget ui-widget-content" + d + '" aria-hidden="true" role="listbox" aria-labelledby="' + this.ids[0] + '" id="' + this.ids[1] + '"></ul>').appendTo("body");
            this.list.wrap(f.wrapperElement);
            var b = [];
            this.element.find("option").each(function () {
                b.push({
                    value: a(this).attr("value"),
                    text: r._formatText(jQuery(this).text()),
                    selected: a(this).attr("selected"),
                    classes: a(this).attr("class"),
                    parentOptGroup: a(this).parent("optgroup").attr("label"),
                    bgImage: f.bgImage.call(a(this))
                })
            });
            var p = (r.options.style == "popup") ? " ui-state-active" : "";
            for (var m = 0; m < b.length; m++) {
                var e = a('<li role="presentation"><a href="#" tabindex="-1" role="option" aria-selected="false">' + b[m].text + "</a></li>").data("index", m).addClass(b[m].classes).data("optionClasses", b[m].classes || "").mouseup(function (j) {
                    if (r._safemouseup) {
                        var o = a(this).data("index") != r._selectedIndex();
                        r.index(a(this).data("index"));
                        r.select(j);
                        if (o) {
                            r.change(j)
                        }
                        r.close(j, true)
                    }
                    return false
                }).click(function () {
                    return false
                }).bind("mouseover focus", function () {
                    r._selectedOptionLi().addClass(p);
                    r._focusedOptionLi().removeClass(r.widgetBaseClass + "-item-focus ui-state-hover");
                    a(this).removeClass("ui-state-active").addClass(r.widgetBaseClass + "-item-focus ui-state-hover")
                }).bind("mouseout blur", function () {
                    if (a(this).is(r._selectedOptionLi().selector)) {
                        a(this).addClass(p)
                    }
                    a(this).removeClass(r.widgetBaseClass + "-item-focus ui-state-hover")
                });
                if (b[m].parentOptGroup) {
                    var n = r.widgetBaseClass + "-group-" + b[m].parentOptGroup.replace(/[^a-zA-Z0-9]/g, "");
                    if (this.list.find("li." + n).size()) {
                        this.list.find("li." + n + ":last ul").append(e)
                    } else {
                        a('<li role="presentation" class="' + r.widgetBaseClass + "-group " + n + '"><span class="' + r.widgetBaseClass + '-group-label">' + b[m].parentOptGroup + "</span><ul></ul></li>").appendTo(this.list).find("ul").append(e)
                    }
                } else {
                    e.appendTo(this.list)
                }
                this.list.bind("mousedown mouseup", function () {
                    return false
                });
                if (f.icons) {
                    for (var k in f.icons) {
                        if (e.is(f.icons[k].find)) {
                            e.data("optionClasses", b[m].classes + " " + r.widgetBaseClass + "-hasIcon").addClass(r.widgetBaseClass + "-hasIcon");
                            var q = f.icons[k].icon || "";
                            e.find("a:eq(0)").prepend('<span class="' + r.widgetBaseClass + "-item-icon ui-icon " + q + '"></span>');
                            if (b[m].bgImage) {
                                e.find("span").css("background-image", b[m].bgImage)
                            }
                        }
                    }
                }
            }
            this.list.find("li:last").addClass("ui-corner-bottom");
            if (f.style == "popup") {
                this.list.find("li:first").addClass("ui-corner-top")
            }
            if (f.transferClasses) {
                var s = this.element.attr("class") || "";
                this.newelement.add(this.list).addClass(s)
            }
            var g = this.element.width();
            this.newelement.width((f.width) ? f.width : g);
            if (f.style == "dropdown") {
                this.list.width((f.menuWidth) ? f.menuWidth : ((f.width) ? f.width : g))
            } else {
                this.list.width((f.menuWidth) ? f.menuWidth : ((f.width) ? f.width - f.handleWidth : g - f.handleWidth))
            }
            if (f.maxHeight) {
                if (f.maxHeight < this.list.height()) {
                    this.list.height(f.maxHeight)
                }
            } else {
                if (!f.format && (a(window).height() / 3) < this.list.height()) {
                    f.maxHeight = a(window).height() / 3;
                    this.list.height(f.maxHeight)
                }
            }
            this._optionLis = this.list.find("li:not(." + r.widgetBaseClass + "-group)");
            this.list.keydown(function (o) {
                var j = true;
                switch (o.keyCode) {
                    case a.ui.keyCode.UP:
                    case a.ui.keyCode.LEFT:
                        j = false;
                        r._moveFocus(-1);
                        break;
                    case a.ui.keyCode.DOWN:
                    case a.ui.keyCode.RIGHT:
                        j = false;
                        r._moveFocus(1);
                        break;
                    case a.ui.keyCode.HOME:
                        j = false;
                        r._moveFocus(":first");
                        break;
                    case a.ui.keyCode.PAGE_UP:
                        j = false;
                        r._scrollPage("up");
                        break;
                    case a.ui.keyCode.PAGE_DOWN:
                        j = false;
                        r._scrollPage("down");
                        break;
                    case a.ui.keyCode.END:
                        j = false;
                        r._moveFocus(":last");
                        break;
                    case a.ui.keyCode.ENTER:
                    case a.ui.keyCode.SPACE:
                        j = false;
                        r.close(o, true);
                        a(o.target).parents("li:eq(0)").trigger("mouseup");
                        break;
                    case a.ui.keyCode.TAB:
                        j = true;
                        r.close(o, true);
                        break;
                    case a.ui.keyCode.ESCAPE:
                        j = false;
                        r.close(o, true);
                        break
                }
                return j
            });
            if (f.style == "dropdown") {
                this.newelement.addClass(r.widgetBaseClass + "-dropdown");
                this.list.addClass(r.widgetBaseClass + "-menu-dropdown")
            } else {
                this.newelement.addClass(r.widgetBaseClass + "-popup");
                this.list.addClass(r.widgetBaseClass + "-menu-popup")
            }
            this.newelement.prepend('<span class="' + r.widgetBaseClass + '-status">' + b[this._selectedIndex()].text + "</span>");
            this.element.hide();
            if (this.element.attr("disabled") == true) {
                this.disable()
            }
            this.index(this._selectedIndex());
            window.setTimeout(function () {
                r._refreshPosition()
            }, 200);
            a(window).resize(function () {
                r._refreshPosition()
            })
        },
        destroy: function () {
            this.element.removeData(this.widgetName).removeClass(this.widgetBaseClass + "-disabled " + this.namespace + "-state-disabled").removeAttr("aria-disabled").unbind("click");
            a("label[for=" + this.newelement.attr("id") + "]").attr("for", this.element.attr("id")).unbind("click");
            this.newelement.remove();
            this.list.remove();
            this.element.show();
            a.Widget.prototype.destroy.apply(this, arguments)
        },
        _typeAhead: function (f, e) {
            var b = this;
            if (!b._prevChar) {
                b._prevChar = ["", 0]
            }
            var h = String.fromCharCode(f);
            c = h.toLowerCase();
            var d = false;
            function g(j, k) {
                d = true;
                a(j).trigger(e);
                b._prevChar[1] = k
            }
            this.list.find("li a").each(function (j) {
                if (!d) {
                    var k = a(this).text();
                    if (k.indexOf(h) == 0 || k.indexOf(c) == 0) {
                        if (b._prevChar[0] == h) {
                            if (b._prevChar[1] < j) {
                                g(this, j)
                            }
                        } else {
                            g(this, j)
                        }
                    }
                }
            });
            this._prevChar[0] = h
        },
        _uiHash: function () {
            var b = this.index();
            return {
                index: b,
                option: a("option", this.element).get(b),
                value: this.element[0].value
            }
        },
        open: function (e) {
            var d = this;
            var b = this.newelement.attr("aria-disabled");
            if (b != "true") {
                this._refreshPosition();
                this._closeOthers(e);
                this.newelement.addClass("ui-state-active");
                if (d.options.wrapperElement) {
                    this.list.parent().appendTo("body")
                } else {
                    this.list.appendTo("body")
                }
                this.list.addClass(d.widgetBaseClass + "-open").attr("aria-hidden", false).find("li:not(." + d.widgetBaseClass + "-group):eq(" + this._selectedIndex() + ") a")[0].focus();
                if (this.options.style == "dropdown") {
                    this.newelement.removeClass("ui-corner-all").addClass("ui-corner-top")
                }
                this._refreshPosition();
                this._trigger("open", e, this._uiHash())
            }
        },
        close: function (d, b) {
            if (this.newelement.is(".ui-state-active")) {
                this.newelement.removeClass("ui-state-active");
                this.list.attr("aria-hidden", true).removeClass(this.widgetBaseClass + "-open");
                if (this.options.style == "dropdown") {
                    this.newelement.removeClass("ui-corner-top").addClass("ui-corner-all")
                }
                if (b) {
                    this.newelement.focus()
                }
                this._trigger("close", d, this._uiHash())
            }
        },
        change: function (b) {
            this.element.trigger("change");
            this._trigger("change", b, this._uiHash())
        },
        select: function (b) {
            this._trigger("select", b, this._uiHash())
        },
        _closeOthers: function (b) {
            a("." + this.widgetBaseClass + ".ui-state-active").not(this.newelement).each(function () {
                a(this).data("selectelement").selectmenu("close", b)
            });
            a("." + this.widgetBaseClass + ".ui-state-hover").trigger("mouseout")
        },
        _toggle: function (d, b) {
            if (this.list.is("." + this.widgetBaseClass + "-open")) {
                this.close(d, b)
            } else {
                this.open(d)
            }
        },
        _formatText: function (b) {
            return this.options.format ? this.options.format(b) : b
        },
        _selectedIndex: function () {
            return this.element[0].selectedIndex
        },
        _selectedOptionLi: function () {
            return this._optionLis.eq(this._selectedIndex())
        },
        _focusedOptionLi: function () {
            return this.list.find("." + this.widgetBaseClass + "-item-focus")
        },
        _moveSelection: function (e) {
            var d = parseInt(this._selectedOptionLi().data("index"), 10);
            var b = d + e;
            return this._optionLis.eq(b).trigger("mouseup")
        },
        _moveFocus: function (f) {
            if (!isNaN(f)) {
                var e = parseInt(this._focusedOptionLi().data("index") || 0, 10);
                var d = e + f
            } else {
                var d = parseInt(this._optionLis.filter(f).data("index"), 10)
            }
            if (d < 0) {
                d = 0
            }
            if (d > this._optionLis.size() - 1) {
                d = this._optionLis.size() - 1
            }
            var b = this.widgetBaseClass + "-item-" + Math.round(Math.random() * 1000);
            this._focusedOptionLi().find("a:eq(0)").attr("id", "");
            this._optionLis.eq(d).find("a:eq(0)").attr("id", b).focus();
            this.list.attr("aria-activedescendant", b)
        },
        _scrollPage: function (d) {
            var b = Math.floor(this.list.outerHeight() / this.list.find("li:first").outerHeight());
            b = (d == "up") ? -b : b;
            this._moveFocus(b)
        },
        _setOption: function (b, d) {
            this.options[b] = d;
            if (b == "disabled") {
                this.close();
                this.element.add(this.newelement).add(this.list)[d ? "addClass" : "removeClass"](this.widgetBaseClass + "-disabled " + this.namespace + "-state-disabled").attr("aria-disabled", d)
            }
        },
        index: function (b) {
            if (arguments.length) {
                this.element[0].selectedIndex = b;
                this._refreshValue()
            } else {
                return this._selectedIndex()
            }
        },
        value: function (b) {
            if (arguments.length) {
                if (typeof b == "number") {
                    this.index(b)
                } else {
                    if (typeof b == "string") {
                        this.element[0].value = b;
                        this._refreshValue()
                    }
                }
            } else {
                return this.element[0].value
            }
        },
        _refreshValue: function () {
            var e = (this.options.style == "popup") ? " ui-state-active" : "";
            var d = this.widgetBaseClass + "-item-" + Math.round(Math.random() * 1000);
            this.list.find("." + this.widgetBaseClass + "-item-selected").removeClass(this.widgetBaseClass + "-item-selected" + e).find("a").attr("aria-selected", "false").attr("id", "");
            this._selectedOptionLi().addClass(this.widgetBaseClass + "-item-selected" + e).find("a").attr("aria-selected", "true").attr("id", d);
            var b = this.newelement.data("optionClasses") ? this.newelement.data("optionClasses") : "";
            var f = this._selectedOptionLi().data("optionClasses") ? this._selectedOptionLi().data("optionClasses") : "";
            this.newelement.removeClass(b).data("optionClasses", f).addClass(f).find("." + this.widgetBaseClass + "-status").html(this._selectedOptionLi().find("a:eq(0)").html());
            this.list.attr("aria-activedescendant", d)
        },
        _refreshPosition: function () {
            var e = this.options;
            if (e.style == "popup" && !e.positionOptions.offset) {
                var d = this.list.find("li:not(.ui-selectmenu-group):eq(" + this._selectedIndex() + ")");
                var b = "0 -" + (d.outerHeight() + d.offset().top - this.list.offset().top)
            }
            this.list.css({
                zIndex: this.element.zIndex()
            }).position({
                of: e.positionOptions.of || this.newelement,
                my: e.positionOptions.my,
                at: e.positionOptions.at,
                offset: e.positionOptions.offset || b
            })
        }
    })
})(jQuery); (function (a) {
    a.fn.expander = function (e) {
        var g = a.extend({}, a.fn.expander.defaults, e);
        var d;
        return this.each(function () {
            var t = a(this);
            var l = a.meta ? a.extend({}, g, t.data()) : g;
            var v,
            z,
            n;
            var r = t.html();
            var w = r.slice(0, l.slicePoint).replace(/\w+$/, "");
            z = w.match(/<\w[^>]*>/g);
            if (z) {
                w = r.slice(0, l.slicePoint + z.join("").length).replace(/\w+$/, "")
            }
            if (w.lastIndexOf("<") > w.lastIndexOf(">")) {
                w = w.slice(0, w.lastIndexOf("<"))
            }
            var m = r.slice(w.length);
            if (!a("span.details", this).length) {
                if (m.replace(/\s+$/, "").split(" ").length < l.widow) {
                    return
                }
                if (m.indexOf("</") > -1) {
                    n = m.match(/<(\/)?[^>]*>/g);
                    for (var q = 0; q < n.length; q++) {
                        if (n[q].indexOf("</") > -1) {
                            var y,
                            u = false;
                            for (var p = 0; p < q; p++) {
                                y = n[p].slice(0, n[p].indexOf(" ")).replace(/(\w)$/, "$1>");
                                if (y == h(n[q])) {
                                    u = true
                                }
                            }
                            if (!u) {
                                w = w + n[q];
                                var k = false;
                                for (var B = z.length - 1; B >= 0; B--) {
                                    if (z[B].slice(0, z[B].indexOf(" ")).replace(/(\w)$/, "$1>") == h(n[q]) && k == false) {
                                        v = v ? z[B] + v : z[B];
                                        k = true
                                    }
                                }
                            }
                        }
                    }
                    m = v && v + m || m
                }
                t.html([w, '<span class="read-more">', l.expandPrefix, '<a href="#">', l.expandText, "</a>", "</span>", '<span class="details">', m, "</span>"].join(""))
            }
            var x = a("span.details", this),
            A = a("span.read-more", this);
            x.hide();
            A.find("a").click(function () {
                A.hide();
                if (l.expandEffect === "show" && !l.expandSpeed) {
                    l.beforeExpand(t);
                    x.show();
                    l.afterExpand(t);
                    f(l, x)
                } else {
                    l.beforeExpand(t);
                    x[l.expandEffect](l.expandSpeed, function () {
                        x.css({
                            zoom: ""
                        });
                        l.afterExpand(t);
                        f(l, x)
                    })
                }
                return false
            });
            if (l.userCollapse) {
                t.find("span.details").append('<span class="re-collapse">' + l.userCollapsePrefix + '<a href="#">' + l.userCollapseText + "</a></span>");
                t.find("span.re-collapse a").click(function () {
                    clearTimeout(d);
                    var j = a(this).parents("span.details");
                    b(j);
                    l.onCollapse(t, true);
                    return false
                })
            }
        });
        function b(j) {
            j.hide().prev("span.read-more").show()
        }
        function f(k, j) {
            if (k.collapseTimer) {
                d = setTimeout(function () {
                    b(j);
                    k.onCollapse(j.parent(), false)
                }, k.collapseTimer)
            }
        }
        function h(j) {
            return j.replace(/\//, "")
        }
    };
    a.fn.expander.defaults = {
        slicePoint: 100,
        widow: 4,
        expandText: "read more",
        expandPrefix: "&hellip; ",
        collapseTimer: 0,
        expandEffect: "fadeIn",
        expandSpeed: "",
        userCollapse: true,
        userCollapseText: "[collapse expanded text]",
        userCollapsePrefix: " ",
        beforeExpand: function (b) { },
        afterExpand: function (b) { },
        onCollapse: function (d, b) { }
    }
})(jQuery);
/*
* jquery.qtip. The jQuery tooltip plugin
*/
(function (g) {
    g.fn.qtip = function (C, v) {
        var z,
        u,
        B,
        t,
        y,
        x,
        w,
        A;
        if (typeof C == "string") {
            if (g.isPlainObject(g(this).data("qtip"))) {
                g.fn.qtip.log.error.call(self, 1, g.fn.qtip.constants.NO_TOOLTIP_PRESENT, false)
            }
            if (C == "api") {
                return g(this).data("qtip").interfaces[g(this).data("qtip").current]
            } else {
                if (C == "interfaces") {
                    return g(this).data("qtip").interfaces
                }
            }
        } else {
            if (!C) {
                C = {}
            }
            if (typeof C.content !== "object" || (C.content.jquery && C.content.length > 0)) {
                C.content = {
                    text: C.content
                }
            }
            if (typeof C.content.title !== "object") {
                C.content.title = {
                    text: C.content.title
                }
            }
            if (typeof C.position !== "object") {
                C.position = {
                    corner: C.position
                }
            }
            if (typeof C.position.corner !== "object") {
                C.position.corner = {
                    target: C.position.corner,
                    tooltip: C.position.corner
                }
            }
            if (typeof C.show !== "object") {
                C.show = {
                    when: C.show
                }
            }
            if (typeof C.show.when !== "object") {
                C.show.when = {
                    event: C.show.when
                }
            }
            if (typeof C.show.effect !== "object") {
                C.show.effect = {
                    type: C.show.effect
                }
            }
            if (typeof C.hide !== "object") {
                C.hide = {
                    when: C.hide
                }
            }
            if (typeof C.hide.when !== "object") {
                C.hide.when = {
                    event: C.hide.when
                }
            }
            if (typeof C.hide.effect !== "object") {
                C.hide.effect = {
                    type: C.hide.effect
                }
            }
            if (typeof C.style !== "object") {
                C.style = {
                    name: C.style
                }
            }
            C.style = d(C.style);
            t = g.extend(true, {}, g.fn.qtip.defaults, C);
            t.style = a.call({
                options: t
            }, t.style);
            t.user = g.extend(true, {}, C)
        }
        return g(this).each(function () {
            if (typeof C == "string") {
                x = C.toLowerCase();
                B = g(this).qtip("interfaces");
                if (typeof B == "object") {
                    if (v === true && x == "destroy") {
                        while (B.length > 0) {
                            B[B.length - 1].destroy()
                        }
                    } else {
                        if (v !== true) {
                            B = [g(this).qtip("api")]
                        }
                        for (z = 0; z < B.length; z++) {
                            if (x == "destroy") {
                                B[z].destroy()
                            } else {
                                if (B[z].status.rendered === true) {
                                    if (x == "show") {
                                        B[z].show()
                                    } else {
                                        if (x == "hide") {
                                            B[z].hide()
                                        } else {
                                            if (x == "focus") {
                                                B[z].focus()
                                            } else {
                                                if (x == "disable") {
                                                    B[z].disable(true)
                                                } else {
                                                    if (x == "enable") {
                                                        B[z].disable(false)
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            } else {
                w = g.extend(true, {}, t);
                w.hide.effect.length = t.hide.effect.length;
                w.show.effect.length = t.show.effect.length;
                if (w.position.container === false) {
                    w.position.container = g(document.body)
                }
                if (w.position.target === false) {
                    w.position.target = g(this)
                }
                if (w.show.when.target === false) {
                    w.show.when.target = g(this)
                }
                if (w.hide.when.target === false) {
                    w.hide.when.target = g(this)
                }
                u = g.fn.qtip.interfaces.length;
                for (z = 0; z < u; z++) {
                    if (typeof g.fn.qtip.interfaces[z] == "undefined") {
                        u = z;
                        break
                    }
                }
                y = new e(g(this), w, u);
                g.fn.qtip.interfaces[u] = y;
                if (g.isPlainObject(g(this).data("qtip"))) {
                    if (typeof g(this).attr("qtip") === "undefined") {
                        g(this).data("qtip").current = g(this).data("qtip").interfaces.length
                    }
                    g(this).data("qtip").interfaces.push(y)
                } else {
                    g(this).data("qtip", {
                        current: 0,
                        interfaces: [y]
                    })
                }
                if (w.content.prerender === false && w.show.when.event !== false && w.show.ready !== true) {
                    w.show.when.target.bind(w.show.when.event + ".qtip-" + u + "-create", {
                        qtip: u
                    }, function (D) {
                        A = g.fn.qtip.interfaces[D.data.qtip];
                        A.options.show.when.target.unbind(A.options.show.when.event + ".qtip-" + D.data.qtip + "-create");
                        A.cache.mouse = {
                            x: D.pageX,
                            y: D.pageY
                        };
                        q.call(A);
                        A.options.show.when.target.trigger(A.options.show.when.event)
                    })
                } else {
                    y.cache.mouse = {
                        x: w.show.when.target.offset().left,
                        y: w.show.when.target.offset().top
                    };
                    q.call(y)
                }
            }
        })
    };
    function e(v, u, w) {
        var t = this;
        t.id = w;
        t.options = u;
        t.status = {
            animated: false,
            rendered: false,
            disabled: false,
            focused: false
        };
        t.elements = {
            target: v.addClass(t.options.style.classes.target),
            tooltip: null,
            wrapper: null,
            content: null,
            contentWrapper: null,
            title: null,
            button: null,
            tip: null,
            bgiframe: null
        };
        t.cache = {
            mouse: {},
            position: {},
            toggle: 0
        };
        t.timers = {};
        g.extend(t, t.options.api, {
            show: function (z) {
                var y,
                A;
                if (!t.status.rendered) {
                    return g.fn.qtip.log.error.call(t, 2, g.fn.qtip.constants.TOOLTIP_NOT_RENDERED, "show")
                }
                if (t.elements.tooltip.css("display") !== "none") {
                    return t
                }
                t.elements.tooltip.stop(true, false);
                y = t.beforeShow.call(t, z);
                if (y === false) {
                    return t
                }
                function x() {
                    g(this).css({
                        opacity: ""
                    });
                    if (t.options.position.type !== "static") {
                        t.focus()
                    }
                    t.onShow.call(t, z);
                    if (g.browser.msie) {
                        t.elements.tooltip.get(0).style.removeAttribute("filter")
                    }
                }
                t.cache.toggle = 1;
                if (t.options.position.type !== "static") {
                    t.updatePosition(z, (t.options.show.effect.length > 0))
                }
                if (typeof t.options.show.solo == "object") {
                    A = g(t.options.show.solo)
                } else {
                    if (t.options.show.solo === true) {
                        A = g("div.qtip").not(t.elements.tooltip)
                    }
                }
                if (A) {
                    A.each(function () {
                        if (g(this).qtip("api").status.rendered === true) {
                            g(this).qtip("api").hide()
                        }
                    })
                }
                if (typeof t.options.show.effect.type == "function") {
                    t.options.show.effect.type.call(t.elements.tooltip, t.options.show.effect.length);
                    t.elements.tooltip.queue(function () {
                        x();
                        g(this).dequeue()
                    })
                } else {
                    switch (t.options.show.effect.type.toLowerCase()) {
                        case "fade":
                            t.elements.tooltip.fadeIn(t.options.show.effect.length, x);
                            break;
                        case "slide":
                            t.elements.tooltip.slideDown(t.options.show.effect.length, function () {
                                x();
                                if (t.options.position.type !== "static") {
                                    t.updatePosition(z, true)
                                }
                            });
                            break;
                        case "grow":
                            t.elements.tooltip.show(t.options.show.effect.length, x);
                            break;
                        default:
                            t.elements.tooltip.show(null, x);
                            t.elements.tooltip.css({
                                opacity: ""
                            });
                            break
                    }
                    t.elements.tooltip.addClass(t.options.style.classes.active)
                }
                return g.fn.qtip.log.error.call(t, 1, g.fn.qtip.constants.EVENT_SHOWN, "show")
            },
            hide: function (z) {
                var y;
                if (!t.status.rendered) {
                    return g.fn.qtip.log.error.call(t, 2, g.fn.qtip.constants.TOOLTIP_NOT_RENDERED, "hide")
                } else {
                    if (t.elements.tooltip.css("display") === "none") {
                        return t
                    }
                }
                clearTimeout(t.timers.show);
                t.elements.tooltip.stop(true, false);
                y = t.beforeHide.call(t, z);
                if (y === false) {
                    return t
                }
                function x() {
                    t.onHide.call(t, z)
                }
                t.cache.toggle = 0;
                if (typeof t.options.hide.effect.type == "function") {
                    t.options.hide.effect.type.call(t.elements.tooltip, t.options.hide.effect.length);
                    t.elements.tooltip.queue(function () {
                        x();
                        g(this).dequeue()
                    })
                } else {
                    switch (t.options.hide.effect.type.toLowerCase()) {
                        case "fade":
                            t.elements.tooltip.fadeOut(t.options.hide.effect.length, x);
                            break;
                        case "slide":
                            t.elements.tooltip.slideUp(t.options.hide.effect.length, x);
                            break;
                        case "grow":
                            t.elements.tooltip.hide(t.options.hide.effect.length, x);
                            break;
                        default:
                            t.elements.tooltip.hide(null, x);
                            break
                    }
                    t.elements.tooltip.removeClass(t.options.style.classes.active)
                }
                return g.fn.qtip.log.error.call(t, 1, g.fn.qtip.constants.EVENT_HIDDEN, "hide")
            },
            updatePosition: function (x, y) {
                var D,
                H,
                M,
                K,
                I,
                F,
                z,
                J,
                C,
                E,
                L,
                B,
                G,
                A;
                if (!t.status.rendered) {
                    return g.fn.qtip.log.error.call(t, 2, g.fn.qtip.constants.TOOLTIP_NOT_RENDERED, "updatePosition")
                } else {
                    if (t.options.position.type == "static") {
                        return g.fn.qtip.log.error.call(t, 1, g.fn.qtip.constants.CANNOT_POSITION_STATIC, "updatePosition")
                    }
                }
                H = {
                    position: {
                        left: 0,
                        top: 0
                    },
                    dimensions: {
                        height: 0,
                        width: 0
                    },
                    corner: t.options.position.corner.target
                };
                M = {
                    position: t.getPosition(),
                    dimensions: t.getDimensions(),
                    corner: t.options.position.corner.tooltip
                };
                if (t.options.position.target !== "mouse") {
                    if (t.options.position.target.get(0).nodeName.toLowerCase() == "area") {
                        K = t.options.position.target.attr("coords").split(",");
                        for (D = 0; D < K.length; D++) {
                            K[D] = parseInt(K[D])
                        }
                        I = t.options.position.target.parent("map").attr("name");
                        F = g('img[usemap="#' + I + '"]:first').offset();
                        H.position = {
                            left: Math.floor(F.left + K[0]),
                            top: Math.floor(F.top + K[1])
                        };
                        switch (t.options.position.target.attr("shape").toLowerCase()) {
                            case "rect":
                                H.dimensions = {
                                    width: Math.ceil(Math.abs(K[2] - K[0])),
                                    height: Math.ceil(Math.abs(K[3] - K[1]))
                                };
                                break;
                            case "circle":
                                H.dimensions = {
                                    width: K[2] + 1,
                                    height: K[2] + 1
                                };
                                break;
                            case "poly":
                                H.dimensions = {
                                    width: K[0],
                                    height: K[1]
                                };
                                for (D = 0; D < K.length; D++) {
                                    if (D % 2 == 0) {
                                        if (K[D] > H.dimensions.width) {
                                            H.dimensions.width = K[D]
                                        }
                                        if (K[D] < K[0]) {
                                            H.position.left = Math.floor(F.left + K[D])
                                        }
                                    } else {
                                        if (K[D] > H.dimensions.height) {
                                            H.dimensions.height = K[D]
                                        }
                                        if (K[D] < K[1]) {
                                            H.position.top = Math.floor(F.top + K[D])
                                        }
                                    }
                                }
                                H.dimensions.width = H.dimensions.width - (H.position.left - F.left);
                                H.dimensions.height = H.dimensions.height - (H.position.top - F.top);
                                break;
                            default:
                                return g.fn.qtip.log.error.call(t, 4, g.fn.qtip.constants.INVALID_AREA_SHAPE, "updatePosition");
                                break
                        }
                        H.dimensions.width -= 2;
                        H.dimensions.height -= 2
                    } else {
                        if (t.options.position.target.add(document.body).length === 1) {
                            H.position = {
                                left: g(document).scrollLeft(),
                                top: g(document).scrollTop()
                            };
                            H.dimensions = {
                                height: g(window).height(),
                                width: g(window).width()
                            }
                        } else {
                            if (typeof t.options.position.target.attr("qtip") !== "undefined") {
                                H.position = t.options.position.target.qtip("api").cache.position
                            } else {
                                H.position = t.options.position.target.offset()
                            }
                            H.dimensions = {
                                height: t.options.position.target.outerHeight(),
                                width: t.options.position.target.outerWidth()
                            }
                        }
                    }
                    z = g.extend({}, H.position);
                    if ((/right/i).test(H.corner)) {
                        z.left += H.dimensions.width
                    }
                    if ((/bottom/i).test(H.corner)) {
                        z.top += H.dimensions.height
                    }
                    if ((/((top|bottom)Middle)|center/).test(H.corner)) {
                        z.left += (H.dimensions.width / 2)
                    }
                    if ((/((left|right)Middle)|center/).test(H.corner)) {
                        z.top += (H.dimensions.height / 2)
                    }
                } else {
                    H.position = z = {
                        left: t.cache.mouse.x,
                        top: t.cache.mouse.y
                    };
                    H.dimensions = {
                        height: 1,
                        width: 1
                    }
                }
                if ((/right/i).test(M.corner)) {
                    z.left -= M.dimensions.width
                }
                if ((/bottom/i).test(M.corner)) {
                    z.top -= M.dimensions.height
                }
                if ((/((top|bottom)Middle)|center/).test(M.corner)) {
                    z.left -= (M.dimensions.width / 2)
                }
                if ((/((left|right)Middle)|center/).test(M.corner)) {
                    z.top -= (M.dimensions.height / 2)
                }
                J = (g.browser.msie) ? 1 : 0;
                C = (g.browser.msie && parseInt(g.browser.version.charAt(0)) === 6) ? 1 : 0;
                if (t.options.style.border.radius > 0) {
                    if ((/Left/i).test(M.corner)) {
                        z.left -= t.options.style.border.radius
                    } else {
                        if ((/Right/i).test(M.corner)) {
                            z.left += t.options.style.border.radius
                        }
                    }
                    if ((/Top/i).test(M.corner)) {
                        z.top -= t.options.style.border.radius
                    } else {
                        if ((/Bottom/i).test(M.corner)) {
                            z.top += t.options.style.border.radius
                        }
                    }
                }
                if (J) {
                    if ((/top/i).test(M.corner)) {
                        z.top -= J
                    } else {
                        if ((/bottom/i).test(M.corner)) {
                            z.top += J
                        }
                    }
                    if ((/left/i).test(M.corner)) {
                        z.left -= J
                    } else {
                        if ((/right/i).test(M.corner)) {
                            z.left += J
                        }
                    }
                    if ((/leftMiddle|rightMiddle/).test(M.corner)) {
                        z.top -= 1
                    }
                }
                if (t.options.position.adjust.screen === true) {
                    z = p.call(t, z, H, M)
                }
                if (t.options.position.target === "mouse" && t.options.position.adjust.mouse === true) {
                    if (t.options.position.adjust.screen === true && t.elements.tip) {
                        L = t.elements.tip.attr("rel")
                    } else {
                        L = t.options.position.corner.tooltip
                    }
                    z.left += ((/right/i).test(L)) ? -6 : 6;
                    z.top += ((/bottom/i).test(L)) ? -6 : 6
                }
                if (!t.elements.bgiframe && g.browser.msie && parseInt(g.browser.version.charAt(0)) == 6) {
                    g("select, object").each(function () {
                        B = g(this).offset();
                        B.bottom = B.top + g(this).height();
                        B.right = B.left + g(this).width();
                        if (z.top + M.dimensions.height >= B.top && z.left + M.dimensions.width >= B.left) {
                            l.call(t)
                        }
                    })
                }
                z.left += t.options.position.adjust.x;
                z.top += t.options.position.adjust.y;
                G = t.getPosition();
                if (z.left != G.left || z.top != G.top) {
                    A = t.beforePositionUpdate.call(t, x);
                    if (A === false) {
                        return t
                    }
                    t.cache.position = z;
                    if (y === true) {
                        t.status.animated = true;
                        t.elements.tooltip.animate(z, 200, "swing", function () {
                            t.status.animated = false
                        })
                    } else {
                        t.elements.tooltip.css(z)
                    }
                    t.onPositionUpdate.call(t, x);
                    if (typeof x !== "undefined" && x.type && x.type !== "mousemove") {
                        g.fn.qtip.log.error.call(t, 1, g.fn.qtip.constants.EVENT_POSITION_UPDATED, "updatePosition")
                    }
                }
                return t
            },
            updateWidth: function (A) {
                if (!t.status.rendered) {
                    return g.fn.qtip.log.error.call(t, 2, g.fn.qtip.constants.TOOLTIP_NOT_RENDERED, "updateWidth")
                } else {
                    if (A != undefined && typeof A !== "number") {
                        return g.fn.qtip.log.error.call(t, 2, "newWidth must be of type number", "updateWidth")
                    }
                }
                var C = t.elements.contentWrapper.siblings().add(t.elements.tip).add(t.elements.button),
                z = t.elements.wrapper.add(t.elements.contentWrapper.children()),
                B = t.elements.tooltip,
                x = t.options.style.width.max,
                y = t.options.style.width.min;
                if (!A) {
                    if (typeof t.options.style.width.value === "number") {
                        A = t.options.style.width.value
                    } else {
                        t.elements.tooltip.css({
                            width: "auto"
                        });
                        C.hide();
                        if (g.browser.msie) {
                            z.css({
                                zoom: ""
                            })
                        }
                        A = t.getDimensions().width;
                        if (!t.options.style.width.value) {
                            A = Math.min(Math.max(A, y), x)
                        }
                    }
                }
                if (A % 2) {
                    A -= 1
                }
                t.elements.tooltip.width(A);
                C.show();
                if (t.options.style.border.radius) {
                    t.elements.tooltip.find(".qtip-betweenCorners").each(function (D) {
                        g(this).width(A - (t.options.style.border.radius * 2))
                    })
                }
                if (g.browser.msie) {
                    z.css({
                        zoom: 1
                    });
                    if (t.elements.bgiframe) {
                        t.elements.bgiframe.width(A).height(t.getDimensions.height)
                    }
                }
                return g.fn.qtip.log.error.call(t, 1, g.fn.qtip.constants.EVENT_WIDTH_UPDATED, "updateWidth")
            },
            updateStyle: function (x) {
                var A,
                B,
                y,
                z,
                C;
                if (!t.status.rendered) {
                    return g.fn.qtip.log.error.call(t, 2, g.fn.qtip.constants.TOOLTIP_NOT_RENDERED, "updateStyle")
                } else {
                    if (typeof x !== "string" || !g.fn.qtip.styles[x]) {
                        return g.fn.qtip.log.error.call(t, 2, g.fn.qtip.constants.STYLE_NOT_DEFINED, "updateStyle")
                    }
                }
                t.options.style = a.call(t, g.fn.qtip.styles[x], t.options.user.style);
                t.elements.content.css(r(t.options.style));
                if (t.options.content.title.text !== false) {
                    t.elements.title.css(r(t.options.style.title, true))
                }
                t.elements.contentWrapper.css({
                    borderColor: t.options.style.border.color
                });
                if (t.options.style.tip.corner !== false) {
                    if (g("<canvas>").get(0).getContext) {
                        A = t.elements.tooltip.find(".qtip-tip canvas:first");
                        y = A.get(0).getContext("2d");
                        y.clearRect(0, 0, 300, 300);
                        z = A.parent("div[rel]:first").attr("rel");
                        C = b(z, t.options.style.tip.size.width, t.options.style.tip.size.height);
                        j.call(t, A, C, t.options.style.tip.color || t.options.style.border.color)
                    } else {
                        if (g.browser.msie) {
                            A = t.elements.tooltip.find('.qtip-tip [nodeName="shape"]');
                            A.attr("fillcolor", t.options.style.tip.color || t.options.style.border.color)
                        }
                    }
                }
                if (t.options.style.border.radius > 0) {
                    t.elements.tooltip.find(".qtip-betweenCorners").css({
                        backgroundColor: t.options.style.border.color
                    });
                    if (g("<canvas>").get(0).getContext) {
                        B = h(t.options.style.border.radius);
                        t.elements.tooltip.find(".qtip-wrapper canvas").each(function () {
                            y = g(this).get(0).getContext("2d");
                            y.clearRect(0, 0, 300, 300);
                            z = g(this).parent("div[rel]:first").attr("rel");
                            s.call(t, g(this), B[z], t.options.style.border.radius, t.options.style.border.color)
                        })
                    } else {
                        if (g.browser.msie) {
                            t.elements.tooltip.find('.qtip-wrapper [nodeName="arc"]').each(function () {
                                g(this).attr("fillcolor", t.options.style.border.color)
                            })
                        }
                    }
                }
                return g.fn.qtip.log.error.call(t, 1, g.fn.qtip.constants.EVENT_STYLE_UPDATED, "updateStyle")
            },
            updateContent: function (B, z) {
                var A,
                y,
                x;
                if (!t.status.rendered) {
                    return g.fn.qtip.log.error.call(t, 2, g.fn.qtip.constants.TOOLTIP_NOT_RENDERED, "updateContent")
                } else {
                    if (!B) {
                        return g.fn.qtip.log.error.call(t, 2, g.fn.qtip.constants.NO_CONTENT_PROVIDED, "updateContent")
                    }
                }
                A = t.beforeContentUpdate.call(t, B);
                if (typeof A == "string") {
                    B = A
                } else {
                    if (A === false) {
                        return
                    }
                }
                if (g.browser.msie) {
                    t.elements.contentWrapper.children().css({
                        zoom: "normal"
                    })
                }
                if (B.jquery && B.length > 0) {
                    B.clone(true).appendTo(t.elements.content).show()
                } else {
                    t.elements.content.html(B)
                }
                x = 0;
                y = t.elements.content.find("img");
                if (y.length) {
                    if (g.fn.qtip.preload) {
                        y.each(function () {
                            preloaded = g('body > img[src="' + g(this).attr("src") + '"]:first');
                            if (preloaded.length > 0) {
                                g(this).attr("width", preloaded.innerWidth()).attr("height", preloaded.innerHeight())
                            }
                        });
                        C()
                    } else {
                        y.bind("load error", function () {
                            if (++x === y.length) {
                                C()
                            }
                        })
                    }
                } else {
                    C()
                }
                function C() {
                    t.updateWidth();
                    if (z !== false) {
                        if (t.options.position.type !== "static") {
                            t.updatePosition(t.elements.tooltip.is(":visible"), true)
                        }
                        if (t.options.style.tip.corner !== false) {
                            o.call(t)
                        }
                    }
                }
                t.updateWidth();
                if (z !== false) {
                    if (t.options.position.type !== "static") {
                        t.updatePosition(t.elements.tooltip.is(":visible"), true)
                    }
                    if (t.options.style.tip.corner !== false) {
                        o.call(t)
                    }
                }
                t.onContentUpdate.call(t);
                return g.fn.qtip.log.error.call(t, 1, g.fn.qtip.constants.EVENT_CONTENT_UPDATED, "loadContent")
            },
            loadContent: function (x, A, B) {
                var z;
                if (!t.status.rendered) {
                    return g.fn.qtip.log.error.call(t, 2, g.fn.qtip.constants.TOOLTIP_NOT_RENDERED, "loadContent")
                }
                z = t.beforeContentLoad.call(t);
                if (z === false) {
                    return t
                }
                if (B == "post") {
                    g.post(x, A, y)
                } else {
                    g.get(x, A, y)
                }
                function y(C) {
                    t.onContentLoad.call(t);
                    g.fn.qtip.log.error.call(t, 1, g.fn.qtip.constants.EVENT_CONTENT_LOADED, "loadContent");
                    t.updateContent(C)
                }
                return t
            },
            updateTitle: function (x) {
                if (!t.status.rendered) {
                    return g.fn.qtip.log.error.call(t, 2, g.fn.qtip.constants.TOOLTIP_NOT_RENDERED, "updateTitle")
                } else {
                    if (!x) {
                        return g.fn.qtip.log.error.call(t, 2, g.fn.qtip.constants.NO_CONTENT_PROVIDED, "updateTitle")
                    }
                }
                returned = t.beforeTitleUpdate.call(t);
                if (returned === false) {
                    return t
                }
                if (t.elements.button) {
                    t.elements.button = t.elements.button.clone(true)
                }
                t.elements.title.html(x);
                if (t.elements.button) {
                    t.elements.title.prepend(t.elements.button)
                }
                t.onTitleUpdate.call(t);
                return g.fn.qtip.log.error.call(t, 1, g.fn.qtip.constants.EVENT_TITLE_UPDATED, "updateTitle")
            },
            focus: function (B) {
                var z,
                y,
                x,
                A;
                if (!t.status.rendered) {
                    return g.fn.qtip.log.error.call(t, 2, g.fn.qtip.constants.TOOLTIP_NOT_RENDERED, "focus")
                } else {
                    if (t.options.position.type == "static") {
                        return g.fn.qtip.log.error.call(t, 1, g.fn.qtip.constants.CANNOT_FOCUS_STATIC, "focus")
                    }
                }
                z = parseInt(t.elements.tooltip.css("z-index"));
                y = 32001 + g("div.qtip[qtip]").length - 1;
                if (!t.status.focused && z !== y) {
                    A = t.beforeFocus.call(t, B);
                    if (A === false) {
                        return t
                    }
                    g("div.qtip[qtip]").not(t.elements.tooltip).each(function () {
                        if (g(this).qtip("api").status.rendered === true) {
                            x = parseInt(g(this).css("z-index"));
                            if (typeof x == "number" && x > -1) {
                                g(this).css({
                                    zIndex: parseInt(g(this).css("z-index")) - 1
                                })
                            }
                            g(this).qtip("api").status.focused = false
                        }
                    });
                    t.elements.tooltip.css({
                        zIndex: y
                    });
                    t.status.focused = true;
                    t.onFocus.call(t, B);
                    g.fn.qtip.log.error.call(t, 1, g.fn.qtip.constants.EVENT_FOCUSED, "focus")
                }
                return t
            },
            disable: function (x) {
                if (!t.status.rendered) {
                    return g.fn.qtip.log.error.call(t, 2, g.fn.qtip.constants.TOOLTIP_NOT_RENDERED, "disable")
                }
                if (x) {
                    if (!t.status.disabled) {
                        t.status.disabled = true;
                        g.fn.qtip.log.error.call(t, 1, g.fn.qtip.constants.EVENT_DISABLED, "disable")
                    } else {
                        g.fn.qtip.log.error.call(t, 1, g.fn.qtip.constants.TOOLTIP_ALREADY_DISABLED, "disable")
                    }
                } else {
                    if (t.status.disabled) {
                        t.status.disabled = false;
                        g.fn.qtip.log.error.call(t, 1, g.fn.qtip.constants.EVENT_ENABLED, "disable")
                    } else {
                        g.fn.qtip.log.error.call(t, 1, g.fn.qtip.constants.TOOLTIP_ALREADY_ENABLED, "disable")
                    }
                }
                return t
            },
            destroy: function () {
                var x,
                y,
                z;
                y = t.beforeDestroy.call(t);
                if (y === false) {
                    return t
                }
                if (t.status.rendered) {
                    t.options.show.when.target.unbind("mousemove.qtip", t.updatePosition);
                    t.options.show.when.target.unbind("mouseout.qtip", t.hide);
                    t.options.show.when.target.unbind(t.options.show.when.event + ".qtip");
                    t.options.hide.when.target.unbind(t.options.hide.when.event + ".qtip");
                    t.elements.tooltip.unbind(t.options.hide.when.event + ".qtip");
                    t.elements.tooltip.unbind("mouseover.qtip", t.focus);
                    t.elements.tooltip.remove()
                } else {
                    t.options.show.when.target.unbind(t.options.show.when.event + ".qtip-create")
                }
                if (typeof t.elements.target.data("qtip") == "object") {
                    z = t.elements.target.data("qtip").interfaces;
                    if (typeof z == "object" && z.length > 0) {
                        for (x = 0; x < z.length - 1; x++) {
                            if (z[x].id == t.id) {
                                z.splice(x, 1)
                            }
                        }
                    }
                }
                g.fn.qtip.interfaces.splice(t.id, 1);
                if (typeof z == "object" && z.length > 0) {
                    t.elements.target.data("qtip").current = z.length - 1
                } else {
                    t.elements.target.removeData("qtip")
                }
                t.onDestroy.call(t);
                g.fn.qtip.log.error.call(t, 1, g.fn.qtip.constants.EVENT_DESTROYED, "destroy");
                return t.elements.target
            },
            getPosition: function () {
                var x,
                y;
                if (!t.status.rendered) {
                    return g.fn.qtip.log.error.call(t, 2, g.fn.qtip.constants.TOOLTIP_NOT_RENDERED, "getPosition")
                }
                x = (t.elements.tooltip.css("display") !== "none") ? false : true;
                if (x) {
                    t.elements.tooltip.css({
                        visiblity: "hidden"
                    }).show()
                }
                y = t.elements.tooltip.offset();
                if (x) {
                    t.elements.tooltip.css({
                        visiblity: "visible"
                    }).hide()
                }
                return y
            },
            getDimensions: function () {
                var x,
                y;
                if (!t.status.rendered) {
                    return g.fn.qtip.log.error.call(t, 2, g.fn.qtip.constants.TOOLTIP_NOT_RENDERED, "getDimensions")
                }
                x = (!t.elements.tooltip.is(":visible")) ? true : false;
                if (x) {
                    t.elements.tooltip.css({
                        visiblity: "hidden"
                    }).show()
                }
                y = {
                    height: t.elements.tooltip.outerHeight(),
                    width: t.elements.tooltip.outerWidth()
                };
                if (x) {
                    t.elements.tooltip.css({
                        visiblity: "visible"
                    }).hide()
                }
                return y
            }
        })
    }
    function q() {
        var t,
        x,
        v,
        u,
        w,
        z,
        y;
        t = this;
        t.beforeRender.call(t);
        t.status.rendered = true;
        t.elements.tooltip = '<div qtip="' + t.id + '" class="qtip ' + (t.options.style.classes.tooltip || t.options.style) + '"style="display:none; -moz-border-radius:0; -webkit-border-radius:0; border-radius:0;position:' + t.options.position.type + ';">  <div class="qtip-wrapper" style="position:relative; overflow:hidden; text-align:left;">    <div class="qtip-contentWrapper" style="overflow:hidden;">       <div class="qtip-content ' + t.options.style.classes.content + '"></div></div></div></div>';
        t.elements.tooltip = g(t.elements.tooltip);
        t.elements.tooltip.appendTo(t.options.position.container);
        t.elements.tooltip.data("qtip", {
            current: 0,
            interfaces: [t]
        });
        t.elements.wrapper = t.elements.tooltip.children("div:first");
        t.elements.contentWrapper = t.elements.wrapper.children("div:first").css({
            background: t.options.style.background
        });
        t.elements.content = t.elements.contentWrapper.children("div:first").css(r(t.options.style));
        if (g.browser.msie) {
            t.elements.wrapper.add(t.elements.content).css({
                zoom: 1
            })
        }
        if ((/unfocus/i).test(t.options.hide.when.event)) {
            t.elements.tooltip.attr("unfocus", true)
        }
        if (typeof t.options.style.width.value == "number") {
            t.updateWidth()
        }
        if (g("<canvas>").get(0).getContext || g.browser.msie) {
            if (t.options.style.border.radius > 0) {
                n.call(t)
            } else {
                t.elements.contentWrapper.css({
                    border: t.options.style.border.width + "px solid " + t.options.style.border.color
                })
            }
            if (t.options.style.tip.corner !== false) {
                f.call(t)
            }
        } else {
            t.elements.contentWrapper.css({
                border: t.options.style.border.width + "px solid " + t.options.style.border.color
            });
            t.options.style.border.radius = 0;
            t.options.style.tip.corner = false;
            g.fn.qtip.log.error.call(t, 2, g.fn.qtip.constants.CANVAS_VML_NOT_SUPPORTED, "render")
        }
        if ((typeof t.options.content.text == "string" && t.options.content.text.length > 0) || (t.options.content.text.jquery && t.options.content.text.length > 0)) {
            v = t.options.content.text
        } else {
            if (typeof t.elements.target.attr("title") == "string" && t.elements.target.attr("title").length > 0) {
                v = t.elements.target.attr("title").replace("\\n", "<br />");
                t.elements.target.attr("title", "")
            } else {
                if (typeof t.elements.target.attr("alt") == "string" && t.elements.target.attr("alt").length > 0) {
                    v = t.elements.target.attr("alt").replace("\\n", "<br />");
                    t.elements.target.attr("alt", "")
                } else {
                    v = " ";
                    g.fn.qtip.log.error.call(t, 1, g.fn.qtip.constants.NO_VALID_CONTENT, "render")
                }
            }
        }
        if (t.options.content.title.text !== false) {
            k.call(t)
        }
        t.updateContent(v);
        m.call(t);
        if (t.options.show.ready === true) {
            t.show()
        }
        if (t.options.content.url !== false) {
            u = t.options.content.url;
            w = t.options.content.data;
            z = t.options.content.method || "get";
            t.loadContent(u, w, z)
        }
        t.onRender.call(t);
        g.fn.qtip.log.error.call(t, 1, g.fn.qtip.constants.EVENT_RENDERED, "render")
    }
    function n() {
        var G,
        A,
        u,
        C,
        y,
        F,
        v,
        H,
        E,
        z,
        x,
        D,
        B,
        t,
        w;
        G = this;
        G.elements.wrapper.find(".qtip-borderBottom, .qtip-borderTop").remove();
        u = G.options.style.border.width;
        C = G.options.style.border.radius;
        y = G.options.style.border.color || G.options.style.tip.color;
        F = h(C);
        v = {};
        for (A in F) {
            v[A] = '<div rel="' + A + '" style="' + ((/Left/).test(A) ? "left" : "right") + ":0; position:absolute; height:" + C + "px; width:" + C + 'px; overflow:hidden; line-height:0.1px; font-size:1px">';
            if (g("<canvas>").get(0).getContext) {
                v[A] += '<canvas height="' + C + '" width="' + C + '" style="vertical-align: top"></canvas>'
            } else {
                if (g.browser.msie) {
                    H = C * 2 + 3;
                    v[A] += '<v:arc stroked="false" fillcolor="' + y + '" startangle="' + F[A][0] + '" endangle="' + F[A][1] + '" style="width:' + H + "px; height:" + H + "px; margin-top:" + ((/bottom/).test(A) ? -2 : -1) + "px; margin-left:" + ((/Right/).test(A) ? F[A][2] - 3.5 : -1) + 'px; vertical-align:top; display:inline-block; behavior:url(#default#VML)"></v:arc>'
                }
            }
            v[A] += "</div>"
        }
        E = G.getDimensions().width - (Math.max(u, C) * 2);
        z = '<div class="qtip-betweenCorners" style="height:' + C + "px; width:" + E + "px; overflow:hidden; background-color:" + y + '; line-height:0.1px; font-size:1px;">';
        x = '<div class="qtip-borderTop" dir="ltr" style="height:' + C + "px; margin-left:" + C + 'px; line-height:0.1px; font-size:1px; padding:0;">' + v.topLeft + v.topRight + z;
        G.elements.wrapper.prepend(x);
        D = '<div class="qtip-borderBottom" dir="ltr" style="height:' + C + "px; margin-left:" + C + 'px; line-height:0.1px; font-size:1px; padding:0;">' + v.bottomLeft + v.bottomRight + z;
        G.elements.wrapper.append(D);
        if (g("<canvas>").get(0).getContext) {
            G.elements.wrapper.find("canvas").each(function () {
                B = F[g(this).parent("[rel]:first").attr("rel")];
                s.call(G, g(this), B, C, y)
            })
        } else {
            if (g.browser.msie) {
                G.elements.tooltip.append('<v:image style="behavior:url(#default#VML);"></v:image>')
            }
        }
        t = Math.max(C, (C + (u - C)));
        w = Math.max(u - C, 0);
        G.elements.contentWrapper.css({
            border: "0px solid " + y,
            borderWidth: w + "px " + t + "px"
        })
    }
    function s(v, x, t, u) {
        var w = v.get(0).getContext("2d");
        w.fillStyle = u;
        w.beginPath();
        w.arc(x[0], x[1], t, 0, Math.PI * 2, false);
        w.fill()
    }
    function f(w) {
        var u,
        t,
        z,
        v,
        y,
        x;
        u = this;
        if (u.elements.tip !== null) {
            u.elements.tip.remove()
        }
        t = u.options.style.tip.color || u.options.style.border.color;
        if (u.options.style.tip.corner === false) {
            return
        } else {
            if (!w) {
                w = u.options.style.tip.corner
            }
        }
        z = b(w, u.options.style.tip.size.width, u.options.style.tip.size.height);
        u.elements.tip = '<div class="' + u.options.style.classes.tip + '" dir="ltr" rel="' + w + '" style="position:absolute; height:' + u.options.style.tip.size.height + "px; width:" + u.options.style.tip.size.width + 'px; margin:0 auto; line-height:0.1px; font-size:1px;"></div>';
        u.elements.tooltip.prepend(u.elements.tip);
        if (g("<canvas>").get(0).getContext) {
            x = '<canvas height="' + u.options.style.tip.size.height + '" width="' + u.options.style.tip.size.width + '"></canvas>'
        } else {
            if (g.browser.msie) {
                v = u.options.style.tip.size.width + "," + u.options.style.tip.size.height;
                y = "m" + z[0][0] + "," + z[0][1];
                y += " l" + z[1][0] + "," + z[1][1];
                y += " " + z[2][0] + "," + z[2][1];
                y += " xe";
                x = '<v:shape fillcolor="' + t + '" stroked="false" filled="true" path="' + y + '" coordsize="' + v + '" style="width:' + u.options.style.tip.size.width + "px; height:" + u.options.style.tip.size.height + "px; line-height:0.1px; display:inline-block; behavior:url(#default#VML); vertical-align:" + ((/top/).test(w) ? "bottom" : "top") + '"></v:shape>';
                x += '<v:image style="behavior:url(#default#VML);"></v:image>';
                u.elements.contentWrapper.css("position", "relative")
            }
        }
        u.elements.tip = u.elements.tooltip.find("." + u.options.style.classes.tip).eq(0);
        u.elements.tip.html(x);
        if (g("<canvas>").get(0).getContext) {
            j.call(u, u.elements.tip.find("canvas:first"), z, t)
        }
        if ((/top/).test(w) && g.browser.msie && parseInt(g.browser.version.charAt(0)) === 6) {
            u.elements.tip.css({
                marginTop: -4
            })
        }
        o.call(u, w)
    }
    function j(u, w, t) {
        var v = u.get(0).getContext("2d");
        v.fillStyle = t;
        v.beginPath();
        v.moveTo(w[0][0], w[0][1]);
        v.lineTo(w[1][0], w[1][1]);
        v.lineTo(w[2][0], w[2][1]);
        v.fill()
    }
    function o(v) {
        var u,
        x,
        t,
        y,
        w;
        u = this;
        if (u.options.style.tip.corner === false || !u.elements.tip) {
            return
        }
        if (!v) {
            v = u.elements.tip.attr("rel")
        }
        x = positionAdjust = (g.browser.msie) ? 1 : 0;
        u.elements.tip.css(v.match(/left|right|top|bottom/)[0], 0);
        if ((/top|bottom/).test(v)) {
            if (g.browser.msie) {
                if (parseInt(g.browser.version.charAt(0)) === 6) {
                    positionAdjust = ((/top/).test(v)) ? -3 : 1
                } else {
                    positionAdjust = ((/top/).test(v)) ? 1 : 2
                }
            }
            if ((/Middle/).test(v)) {
                u.elements.tip.css({
                    left: "50%",
                    marginLeft: -(u.options.style.tip.size.width / 2)
                })
            } else {
                if ((/Left/).test(v)) {
                    u.elements.tip.css({
                        left: u.options.style.border.radius - x
                    })
                } else {
                    if ((/Right/).test(v)) {
                        u.elements.tip.css({
                            right: u.options.style.border.radius + x
                        })
                    }
                }
            }
            if ((/top/).test(v)) {
                u.elements.tip.css({
                    top: -positionAdjust
                })
            } else {
                u.elements.tip.css({
                    bottom: positionAdjust
                })
            }
        } else {
            if ((/left|right/).test(v)) {
                if (g.browser.msie) {
                    positionAdjust = (parseInt(g.browser.version.charAt(0)) === 6) ? 1 : ((/left/).test(v) ? 1 : 2)
                }
                if ((/Middle/).test(v)) {
                    u.elements.tip.css({
                        top: "50%",
                        marginTop: -(u.options.style.tip.size.height / 2)
                    })
                } else {
                    if ((/Top/).test(v)) {
                        u.elements.tip.css({
                            top: u.options.style.border.radius - x
                        })
                    } else {
                        if ((/Bottom/).test(v)) {
                            u.elements.tip.css({
                                bottom: u.options.style.border.radius + x
                            })
                        }
                    }
                }
                if ((/left/).test(v)) {
                    u.elements.tip.css({
                        left: -positionAdjust
                    })
                } else {
                    u.elements.tip.css({
                        right: positionAdjust
                    })
                }
            }
        }
        t = "padding-" + v.match(/left|right|top|bottom/)[0];
        y = u.options.style.tip.size[(/left|right/).test(t) ? "width" : "height"];
        u.elements.tooltip.css("padding", 0);
        u.elements.tooltip.css(t, y);
        if (g.browser.msie && parseInt(g.browser.version.charAt(0)) == 6) {
            w = parseInt(u.elements.tip.css("margin-top")) || 0;
            w += parseInt(u.elements.content.css("margin-top")) || 0;
            u.elements.tip.css({
                marginTop: w
            })
        }
    }
    function k() {
        var t = this;
        if (t.elements.title !== null) {
            t.elements.title.remove()
        }
        t.elements.title = g('<div class="' + t.options.style.classes.title + '">').css(r(t.options.style.title, true)).css({
            zoom: (g.browser.msie) ? 1 : 0
        }).prependTo(t.elements.contentWrapper);
        if (t.options.content.title.text) {
            t.updateTitle.call(t, t.options.content.title.text)
        }
        if (t.options.content.title.button !== false && typeof t.options.content.title.button == "string") {
            t.elements.button = g('<a class="' + t.options.style.classes.button + '" style="float:right; position: relative"></a>').css(r(t.options.style.button, true)).html(t.options.content.title.button).prependTo(t.elements.title).click(function (u) {
                if (!t.status.disabled) {
                    t.hide(u)
                }
            })
        }
    }
    function m() {
        var u,
        w,
        v,
        t;
        u = this;
        w = u.options.show.when.target;
        v = u.options.hide.when.target;
        if (u.options.hide.fixed) {
            v = v.add(u.elements.tooltip)
        }
        if (u.options.hide.when.event == "inactive") {
            t = ["click", "dblclick", "mousedown", "mouseup", "mousemove", "mouseout", "mouseenter", "mouseleave", "mouseover"];
            function z(A) {
                if (u.status.disabled === true) {
                    return
                }
                clearTimeout(u.timers.inactive);
                u.timers.inactive = setTimeout(function () {
                    g(t).each(function () {
                        v.unbind(this + ".qtip-inactive");
                        u.elements.content.unbind(this + ".qtip-inactive")
                    });
                    u.hide(A)
                }, u.options.hide.delay)
            }
        } else {
            if (u.options.hide.fixed === true) {
                u.elements.tooltip.bind("mouseover.qtip", function () {
                    if (u.status.disabled === true) {
                        return
                    }
                    clearTimeout(u.timers.hide)
                })
            }
        }
        function y(A) {
            if (u.status.disabled === true) {
                return
            }
            if (u.options.hide.when.event == "inactive") {
                g(t).each(function () {
                    v.bind(this + ".qtip-inactive", z);
                    u.elements.content.bind(this + ".qtip-inactive", z)
                });
                z()
            }
            clearTimeout(u.timers.show);
            clearTimeout(u.timers.hide);
            if (u.options.show.delay > 0) {
                u.timers.show = setTimeout(function () {
                    u.show(A)
                }, u.options.show.delay)
            } else {
                u.show(A)
            }
        }
        function x(A) {
            if (u.status.disabled === true) {
                return
            }
            if (u.options.hide.fixed === true && (/mouse(out|leave)/i).test(u.options.hide.when.event) && g(A.relatedTarget).parents("div.qtip[qtip]").length > 0) {
                A.stopPropagation();
                A.preventDefault();
                clearTimeout(u.timers.hide);
                return false
            }
            clearTimeout(u.timers.show);
            clearTimeout(u.timers.hide);
            u.elements.tooltip.stop(true, true);
            u.timers.hide = setTimeout(function () {
                u.hide(A)
            }, u.options.hide.delay)
        }
        if ((u.options.show.when.target.add(u.options.hide.when.target).length === 1 && u.options.show.when.event == u.options.hide.when.event && u.options.hide.when.event !== "inactive") || u.options.hide.when.event == "unfocus") {
            u.cache.toggle = 0;
            w.bind(u.options.show.when.event + ".qtip", function (A) {
                if (u.cache.toggle == 0) {
                    y(A)
                } else {
                    x(A)
                }
            })
        } else {
            w.bind(u.options.show.when.event + ".qtip", y);
            if (u.options.hide.when.event !== "inactive") {
                v.bind(u.options.hide.when.event + ".qtip", x)
            }
        }
        if ((/(fixed|absolute)/).test(u.options.position.type)) {
            u.elements.tooltip.bind("mouseover.qtip", u.focus)
        }
        if (u.options.position.target === "mouse" && u.options.position.type !== "static") {
            w.bind("mousemove.qtip", function (A) {
                u.cache.mouse = {
                    x: A.pageX,
                    y: A.pageY
                };
                if (u.status.disabled === false && u.options.position.adjust.mouse === true && u.options.position.type !== "static" && u.elements.tooltip.css("display") !== "none") {
                    u.updatePosition(A)
                }
            })
        }
    }
    function p(v, w, B) {
        var A,
        t,
        y,
        z,
        u,
        x;
        A = this;
        if (B.corner == "center") {
            return w.position
        }
        t = g.extend({}, v);
        z = {
            x: false,
            y: false
        };
        u = {
            left: (t.left < g.fn.qtip.cache.screen.scroll.left),
            right: (t.left + B.dimensions.width + 2 >= g.fn.qtip.cache.screen.width + g.fn.qtip.cache.screen.scroll.left),
            top: (t.top < g.fn.qtip.cache.screen.scroll.top),
            bottom: (t.top + B.dimensions.height + 2 >= g.fn.qtip.cache.screen.height + g.fn.qtip.cache.screen.scroll.top)
        };
        y = {
            left: (u.left && ((/right/i).test(B.corner) || !u.right)),
            right: (u.right && ((/left/i).test(B.corner) || !u.left)),
            top: (u.top && !(/top/i).test(B.corner)),
            bottom: (u.bottom && !(/bottom/i).test(B.corner))
        };
        if (y.left) {
            if (A.options.position.target !== "mouse") {
                t.left = w.position.left + w.dimensions.width
            } else {
                t.left = A.cache.mouse.x
            }
            z.x = "Left"
        } else {
            if (y.right) {
                if (A.options.position.target !== "mouse") {
                    t.left = w.position.left - B.dimensions.width
                } else {
                    t.left = A.cache.mouse.x - B.dimensions.width
                }
                z.x = "Right"
            }
        }
        if (y.top) {
            if (A.options.position.target !== "mouse") {
                t.top = w.position.top + w.dimensions.height
            } else {
                t.top = A.cache.mouse.y
            }
            z.y = "top"
        } else {
            if (y.bottom) {
                if (A.options.position.target !== "mouse") {
                    t.top = w.position.top - B.dimensions.height
                } else {
                    t.top = A.cache.mouse.y - B.dimensions.height
                }
                z.y = "bottom"
            }
        }
        if (t.left < 0) {
            t.left = v.left;
            z.x = false
        }
        if (t.top < 0) {
            t.top = v.top;
            z.y = false
        }
        if (A.options.style.tip.corner !== false) {
            t.corner = new String(B.corner);
            if (t.corner.match(/^(right|left)/)) {
                if (z.x !== false) {
                    t.corner = t.corner.replace(/(left|right)/, z.x.toLowerCase())
                }
            } else {
                if (z.x !== false) {
                    t.corner = t.corner.replace(/Left|Right|Middle/, z.x)
                }
                if (z.y !== false) {
                    t.corner = t.corner.replace(/top|bottom/, z.y)
                }
            }
            if (t.corner !== A.elements.tip.attr("rel")) {
                f.call(A, t.corner)
            }
        }
        return t
    }
    function r(v, u) {
        var w,
        t;
        w = g.extend(true, {}, v);
        for (t in w) {
            if (u === true && (/(tip|classes)/i).test(t)) {
                delete w[t]
            } else {
                if (!u && (/(width|border|tip|title|classes|user)/i).test(t)) {
                    delete w[t]
                }
            }
        }
        return w
    }
    function d(t) {
        if (typeof t.tip !== "object") {
            t.tip = {
                corner: t.tip
            }
        }
        if (typeof t.tip.size !== "object") {
            t.tip.size = {
                width: t.tip.size,
                height: t.tip.size
            }
        }
        if (typeof t.border !== "object") {
            t.border = {
                width: t.border
            }
        }
        if (typeof t.width !== "object") {
            t.width = {
                value: t.width
            }
        }
        if (typeof t.width.max == "string") {
            t.width.max = parseInt(t.width.max.replace(/([0-9]+)/i, "$1"))
        }
        if (typeof t.width.min == "string") {
            t.width.min = parseInt(t.width.min.replace(/([0-9]+)/i, "$1"))
        }
        if (typeof t.tip.size.x == "number") {
            t.tip.size.width = t.tip.size.x;
            delete t.tip.size.x
        }
        if (typeof t.tip.size.y == "number") {
            t.tip.size.height = t.tip.size.y;
            delete t.tip.size.y
        }
        return t
    }
    function a() {
        var t,
        u,
        v,
        z,
        w,
        y;
        t = this;
        v = [true, {}];
        for (u = 0; u < arguments.length; u++) {
            v.push(arguments[u])
        }
        z = [g.extend.apply(g, v)];
        while (typeof z[0].name == "string") {
            var x = g.fn.qtip.styles[z[0].name];
            if (x == undefined) {
                break
            }
            z.unshift(d(x))
        }
        z.unshift(true, {
            classes: {
                tooltip: "qtip-" + (arguments[0].name || "defaults")
            }
        }, g.fn.qtip.styles.defaults);
        w = g.extend.apply(g, z);
        y = (g.browser.msie) ? 1 : 0;
        w.tip.size.width += y;
        w.tip.size.height += y;
        if (w.tip.size.width % 2 > 0) {
            w.tip.size.width += 1
        }
        if (w.tip.size.height % 2 > 0) {
            w.tip.size.height += 1
        }
        if (w.tip.corner === true) {
            w.tip.corner = (t.options.position.corner.tooltip === "center") ? false : t.options.position.corner.tooltip
        }
        return w
    }
    function b(w, v, u) {
        var t = {
            bottomRight: [[0, 0], [v, u], [v, 0]],
            bottomLeft: [[0, 0], [v, 0], [0, u]],
            topRight: [[0, u], [v, 0], [v, u]],
            topLeft: [[0, 0], [0, u], [v, u]],
            topMiddle: [[0, u], [v / 2, 0], [v, u]],
            bottomMiddle: [[0, 0], [v, 0], [v / 2, u]],
            rightMiddle: [[0, 0], [v, u / 2], [0, u]],
            leftMiddle: [[v, 0], [v, u], [0, u / 2]]
        };
        t.leftTop = t.bottomRight;
        t.rightTop = t.bottomLeft;
        t.leftBottom = t.topRight;
        t.rightBottom = t.topLeft;
        return t[w]
    }
    function h(t) {
        var u;
        if (g("<canvas>").get(0).getContext) {
            u = {
                topLeft: [t, t],
                topRight: [0, t],
                bottomLeft: [t, 0],
                bottomRight: [0, 0]
            }
        } else {
            if (g.browser.msie) {
                u = {
                    topLeft: [-90, 90, 0],
                    topRight: [-90, 90, -t],
                    bottomLeft: [90, 270, 0],
                    bottomRight: [90, 270, -t]
                }
            }
        }
        return u
    }
    function l() {
        var t,
        u,
        v;
        t = this;
        v = t.getDimensions();
        u = '<iframe class="qtip-bgiframe" frameborder="0" tabindex="-1" src="javascript:false" style="display:block; position:absolute; z-index:-1; filter:alpha(opacity=\'0\'); border: 1px solid red; height:' + v.height + "px; width:" + v.width + 'px" />';
        t.elements.bgiframe = t.elements.wrapper.prepend(u).children(".qtip-bgiframe:first")
    }
    g(document).ready(function () {
        g.fn.qtip.cache = {
            screen: {
                scroll: {
                    left: g(window).scrollLeft(),
                    top: g(window).scrollTop()
                },
                width: g(window).width(),
                height: g(window).height()
            }
        };
        var t;
        g(window).bind("resize scroll", function (u) {
            clearTimeout(t);
            t = setTimeout(function () {
                if (u.type === "scroll") {
                    g.fn.qtip.cache.screen.scroll = {
                        left: g(window).scrollLeft(),
                        top: g(window).scrollTop()
                    }
                } else {
                    g.fn.qtip.cache.screen.width = g(window).width();
                    g.fn.qtip.cache.screen.height = g(window).height()
                }
                for (i = 0; i < g.fn.qtip.interfaces.length; i++) {
                    var v = g.fn.qtip.interfaces[i];
                    if (v.status.rendered === true && (v.options.position.adjust.scroll && u.type === "scroll" || v.options.position.adjust.resize && u.type === "resize")) {
                        v.updatePosition(u, true)
                    }
                }
            }, 100)
        });
        g(document).bind("mousedown.qtip", function (u) {
            if (g(u.target).parents("div.qtip").length === 0) {
                g(".qtip[unfocus]").each(function () {
                    var v = g(this).qtip("api");
                    if (g(this).is(":visible") && !v.status.disabled && g(u.target).add(v.elements.target).length > 1) {
                        v.hide(u)
                    }
                })
            }
        })
    });
    g.fn.qtip.interfaces = [];
    g.fn.qtip.log = {
        error: function () {
            return this
        }
    };
    g.fn.qtip.constants = {};
    g.fn.qtip.defaults = {
        content: {
            prerender: false,
            text: false,
            url: false,
            data: null,
            title: {
                text: false,
                button: false
            }
        },
        position: {
            target: false,
            corner: {
                target: "bottomRight",
                tooltip: "topLeft"
            },
            adjust: {
                x: 0,
                y: 0,
                mouse: true,
                screen: false,
                scroll: true,
                resize: true
            },
            type: "absolute",
            container: false
        },
        show: {
            when: {
                target: false,
                event: "mouseover"
            },
            effect: {
                type: "fade",
                length: 100
            },
            delay: 140,
            solo: false,
            ready: false
        },
        hide: {
            when: {
                target: false,
                event: "mouseout"
            },
            effect: {
                type: "fade",
                length: 100
            },
            delay: 0,
            fixed: false
        },
        api: {
            beforeRender: function () { },
            onRender: function () { },
            beforePositionUpdate: function () { },
            onPositionUpdate: function () { },
            beforeShow: function () { },
            onShow: function () { },
            beforeHide: function () { },
            onHide: function () { },
            beforeContentUpdate: function () { },
            onContentUpdate: function () { },
            beforeContentLoad: function () { },
            onContentLoad: function () { },
            beforeTitleUpdate: function () { },
            onTitleUpdate: function () { },
            beforeDestroy: function () { },
            onDestroy: function () { },
            beforeFocus: function () { },
            onFocus: function () { }
        }
    };
    g.fn.qtip.styles = {
        defaults: {
            background: "white",
            color: "#111",
            overflow: "hidden",
            textAlign: "left",
            width: {
                min: 0,
                max: 250
            },
            padding: "5px 9px",
            border: {
                width: 1,
                radius: 0,
                color: "#d3d3d3"
            },
            tip: {
                corner: false,
                color: false,
                size: {
                    width: 13,
                    height: 13
                },
                opacity: 1
            },
            title: {
                background: "#e1e1e1",
                fontWeight: "bold",
                padding: "7px 12px"
            },
            button: {
                cursor: "pointer"
            },
            classes: {
                target: "",
                tip: "qtip-tip",
                title: "qtip-title",
                button: "qtip-button",
                content: "qtip-content",
                active: "qtip-active"
            }
        }
    }
})(jQuery);
(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);
                // check for empty string in single property
                if (!settings.single.length)
                    settings.single = 'metadata';

                var data = $.data(elem, settings.single);
                // returned cached data if it already exists
                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;
            }
        }
    });

    /**
    * Returns the metadata object for the first member of the jQuery object.
    *
    * @name metadata
    * @descr Returns element's metadata object
    * @param Object opts An object contianing settings to override the defaults
    * @type jQuery
    * @cat Plugins/Metadata
    */
    $.fn.metadata = function (opts) {
        return $.metadata.get(this[0], opts);
    };

})(jQuery);

function isScrolledIntoView(elem)
{
    var docViewTop = $(window).scrollTop();
    var docViewBottom = docViewTop + $(window).height();

    var elemTop = $(elem).offset().top;
    var elemBottom = elemTop + $(elem).height();

    return ((elemBottom >= docViewTop) && (elemTop <= docViewBottom));
}
function addCommas(nStr) {
    nStr += '';
    x = nStr.split('.');
    x1 = x[0];
    x2 = x.length > 1 ? '.' + x[1] : '';
    var rgx = /(\d+)(\d{3})/;
    while (rgx.test(x1)) {
        x1 = x1.replace(rgx, '$1' + ',' + '$2');
    }
    return x1 + x2;
}

