jQuery.fn.getBox = function() {
  return {
	left: $(this).offset().left,
	top: $(this).offset().top,
	width: $(this).outerWidth(),
	height: $(this).outerHeight()
  };
}

jQuery.jQueryRandom = 0;

jQuery.extend(jQuery.expr[":"], {
		random: function (a, i, m, r) {
			if (i == 0) {
				jQuery.jQueryRandom = Math.floor(Math.random() * r.length)
			};
			return i == jQuery.jQueryRandom;
		}
});

// getPageScroll() by quirksmode.com
function getPageScroll() {
	var xScroll, yScroll;
	if (self.pageYOffset) {
	  yScroll = self.pageYOffset;
	  xScroll = self.pageXOffset;
	} else if (document.documentElement && document.documentElement.scrollTop) {
	  yScroll = document.documentElement.scrollTop;
	  xScroll = document.documentElement.scrollLeft;
	} else if (document.body) {// all other Explorers
	  yScroll = document.body.scrollTop;
	  xScroll = document.body.scrollLeft;
	}
	return new Array(xScroll,yScroll)
}

// Adapted from getPageSize() by quirksmode.com
function getPageHeight() {
	var windowHeight
	if (self.innerHeight) { // all except Explorer
	  windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) {
	  windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
	  windowHeight = document.body.clientHeight;
	}
	return windowHeight
}

$(function() {


});

jQuery.fn.autoShorten = function (length, showTip) {
    if (!length) length = 75;
    if (typeof showTip === "undefined") showTip = true;
    return this.each(function () {
        if ($(this).text().length > length) {
            var words = $(this).text().substring(0, length).split(" ");
            var shortText = words.slice(0, words.length - 1).join(" ") + "...";
            $(this).data('title', $(this).text())
		                .text(shortText);
            if (showTip)
                $(this).css({ cursor: 'pointer' })
                            .tooltip({
                                tip: '.tooltip',
                                effect: 'fade',
                                fadeOutSpeed: 100,
                                predelay: 400,
                                position: 'top center',
                                relative: true
                            });
        }
    });
};


/**
* 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) { 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() : '', options.path ? '; path=' + options.path : '', options.domain ? '; domain=' + options.domain : '', options.secure ? '; secure' : ''].join('')) } 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 };
