//Browser detection// /* Removed at JQuery 1.9.1*/ var browser = (function (pub) { var matched, browserObj; uaMatch = function (ua) { ua = ua.toLowerCase(); //This fixes an ie7 bug that causes crashes from incorrect version identification if (/*@cc_on/*@if(@_jscript_version<=5.6)1@else@*/0/*@end@*/) { ua = "msie 6.0"; } var match = /(chrome)[ \/]([\w.]+)/.exec(ua) || /(webkit)[ \/]([\w.]+)/.exec(ua) || /(opera)(?:.*version|)[ \/]([\w.]+)/.exec(ua) || /(msie) ([\w.]+)/.exec(ua) || ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec(ua) || []; return { browserObj: match[1] || "", version: match[2] || "0" }; }; matched = uaMatch(navigator.userAgent); browserObj = {}; if (matched.browserObj) { browserObj[matched.browserObj] = true; browserObj.version = matched.version; } // Chrome is Webkit, but Webkit is also Safari. if (browserObj.chrome) { browserObj.webkit = true; } else if (browserObj.webkit) { browserObj.safari = true; } pub = browserObj; return pub; } (browser || {})); function querystring(name) { name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]"); var regexS = "[\\?&]" + name + "=([^&#]*)"; var regex = new RegExp(regexS); var results = regex.exec(window.location.search); if (results == null) return ""; else return decodeURIComponent(results[1].replace(/\+/g, " ")); } //USAGE: cookie([name],value); cookie([name]); cookie([name],[value],{expires:[value]}) function cookie() { return cookie.params.apply(this, arguments); } cookie.params = function (key, value, options) { if (arguments.length > 1 && String(value) !== "[object Object]") { if (options == undefined) { 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('')); } 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; }; jQuery.IsNumber = function(n) { return typeof(n) != "boolean" && !isNaN(n); }; jQuery.fn.center = function() { this.css("position", "absolute"); this.css("top", ((this.parent().height() - this.outerHeight()) / 2) + this.parent().scrollTop() + "px"); this.css("left", ((this.parent().width() - this.outerWidth()) / 2) + this.parent().scrollLeft() + "px"); return this; }; var getPageName = function () { var n = window.location.pathname; return n.substr(n.lastIndexOf("/") + 1).split(".")[0]; }; jQuery.currency = function (num, settings) { // initialize defaults var defaults = { symbol: '$', positiveFormat: '%s%n', negativeFormat: '(%s%n)', groupDigits: true, decimalSymbol: '.', digitGroupSymbol: ',', roundToDecimalPlace: 2, eventOnDecimalsEntered: false }; settings = $.extend(defaults, settings); // evalutate number input var numParts = String(num).split('.'); var isPositive = (num == Math.abs(num)); var hasDecimals = (numParts.length > 1); var decimals = (hasDecimals ? numParts[1].toString() : '0'); var originalDecimals = decimals; // format number num = Math.abs(numParts[0]); num = isNaN(num) ? 0 : num; if (settings.roundToDecimalPlace >= 0) { decimals = parseFloat('1.' + decimals); // prepend "0."; (IE does NOT round 0.50.toFixed(0) up, but (1+0.50).toFixed(0)-1 decimals = decimals.toFixed(settings.roundToDecimalPlace); // round if (decimals.substring(0, 1) == '2') { num = Number(num) + 1; } decimals = decimals.substring(2); // remove "0." } num = String(num); if (settings.groupDigits) { for (var i = 0; i < Math.floor((num.length - (1 + i)) / 3); i++) { num = num.substring(0, num.length - (4 * i + 3)) + settings.digitGroupSymbol + num.substring(num.length - (4 * i + 3)); } } if ((hasDecimals && settings.roundToDecimalPlace == -1) || settings.roundToDecimalPlace > 0) { num += settings.decimalSymbol + decimals; } // format symbol/negative var format = isPositive ? settings.positiveFormat : settings.negativeFormat; var money = format.replace(/%s/g, settings.symbol); money = money.replace(/%n/g, num); return money; };