/*
 * shopp.js - Shopp behavioral utility library
 * Copyright ?? 2008-2010 by Ingenesis Limited
 * Licensed under the GPLv3 {@see license.txt}
 */
function jqnc(){return jQuery.noConflict()}function copyOf(c){var b=new Object(),a;for(a in c){b[a]=c[a]}return b}if(!Array.indexOf){Array.prototype.indexOf=function(b){for(var a=0;a<this.length;a++){if(this[a]==b){return a}}return -1}}function getCurrencyFormat(b){var a=ShoppSettings;if(b&&b.currency){return b}if(a&&a.c){return{indian:(a.india),cpos:a.cp,currency:a.c,precision:parseInt(a.p),decimals:a.d,thousands:a.t}}return{cpos:true,currency:"$",precision:2,decimals:".",thousands:","}}function asMoney(b,a){a=getCurrencyFormat(a);b=formatNumber(b,a);if(a.cpos){return a.currency+b}return b+a.currency}function asPercent(c,a,b){a=getCurrencyFormat(a);a.precision=b?b:1;return formatNumber(c,a)+"%"}function formatNumber(g,c){c=getCurrencyFormat(c);g=asNumber(g);var b,a,e=g.toFixed(c.precision).toString().split(".");g="";if(c.indian){b=e[0].slice(0,-3);g=e[0].slice(-3,e[0].length)+((g.length>0)?c.thousands+g:g);for(a=0;a<(b.length/2);a++){g=b.slice(-2*(a+1),b.length+(-2*a))+((g.length>0)?c.thousands+g:g)}}else{for(a=0;a<(e[0].length/3);a++){g=e[0].slice(-3*(a+1),e[0].length+(-3*a))+((g.length>0)?c.thousands+g:g)}}if(c.precision>0){g+=c.decimals+e[1]}return g}function asNumber(b,a){if(!b){return 0}a=getCurrencyFormat(a);if(b instanceof Number){return new Number(b.toFixed(a.precision))}b=b.toString().replace(a.currency,"");b=b.toString().replace(new RegExp(/(\D\.|[^\d\,\.])/g),"");b=b.toString().replace(new RegExp("\\"+a.thousands,"g"),"");if(a.precision>0){b=b.toString().replace(new RegExp("\\"+a.decimals,"g"),".")}if(isNaN(new Number(b))){b=b.replace(new RegExp(/\./g),"").replace(new RegExp(/\,/),".")}return new Number(b)}function CallbackRegistry(){this.callbacks=new Array();this.register=function(a,b){this.callbacks[a]=b};this.call=function(d,c,b,a){this.callbacks[d](c,b,a)};this.get=function(a){return this.callbacks[a]}}if(!Number.prototype.roundFixed){Number.prototype.roundFixed=function(a){var b=Math.pow(10,a||0);return String(Math.round(this*b)/b)}}function quickSelects(a){jQuery("input.selectall").mouseup(function(){this.select()})}function htmlentities(a){if(!a){return""}a=a.replace(new RegExp(/&#(\d+);/g),function(){return String.fromCharCode(RegExp.$1)});return a}jQuery.parseJSON=function(data){if(typeof(JSON)!=="undefined"&&typeof(JSON.parse)==="function"){try{return JSON.parse(data)}catch(e){return false}}else{return eval("("+data+")")}};jQuery(document).ready(function(){var a=jqnc();a("input.currency, input.money").change(function(){this.value=asMoney(this.value)}).change();quickSelects()});