/******************************************************************************
 * jquery.i18n.properties
 * 
 * Dual licensed under the GPL (http://dev.jquery.com/browser/trunk/jquery/GPL-LICENSE.txt) and 
 * MIT (http://dev.jquery.com/browser/trunk/jquery/MIT-LICENSE.txt) licenses.
 * 
 * @version     1.0.x
 * @author      Nuno Fernandes
 * @url         www.codingwithcoffee.com
 * @inspiration Localisation assistance for jQuery (http://keith-wood.name/localisation.html)
 *              by Keith Wood (kbwood{at}iinet.com.au) June 2007
 * 
 *****************************************************************************/(function($){function loadAndParseFile(e,t){$.ajax({url:e,async:!1,cache:t.cache,contentType:"text/plain;charset="+t.encoding,dataType:"text",success:function(e,n){parseData(e,t.mode)}})}function parseData(data,mode){var parsed="",parameters=data.split(/\n/),regPlaceHolder=/(\{\d+\})/g,regRepPlaceHolder=/\{(\d+)\}/g,unicodeRE=/(\\u.{4})/ig;for(var i=0;i<parameters.length;i++){parameters[i]=parameters[i].replace(/^\s\s*/,"").replace(/\s\s*$/,"");if(parameters[i].length>0&&parameters[i].match("^#")!="#"){var pair=parameters[i].split("=");if(pair.length>0){var name=unescape(pair[0]).replace(/^\s\s*/,"").replace(/\s\s*$/,""),value=pair.length==1?"":pair[1];while(value.match(/\\$/)=="\\")value=value.substring(0,value.length-1),value+=parameters[++i].replace(/\s\s*$/,"");for(var s=2;s<pair.length;s++)value+="="+pair[s];value=value.replace(/^\s\s*/,"").replace(/\s\s*$/,"");if(mode=="map"||mode=="both"){var unicodeMatches=value.match(unicodeRE);if(unicodeMatches)for(var u=0;u<unicodeMatches.length;u++)value=value.replace(unicodeMatches[u],unescapeUnicode(unicodeMatches[u]));$.i18n.map[name]=value}if(mode=="vars"||mode=="both"){value=value.replace(/"/g,'\\"'),checkKeyNamespace(name);if(regPlaceHolder.test(value)){var parts=value.split(regPlaceHolder),first=!0,fnArgs="",usedArgs=[];for(var p=0;p<parts.length;p++)regPlaceHolder.test(parts[p])&&(usedArgs.length==0||usedArgs.indexOf(parts[p])==-1)&&(first||(fnArgs+=","),fnArgs+=parts[p].replace(regRepPlaceHolder,"v$1"),usedArgs.push(parts[p]),first=!1);parsed+=name+"=function("+fnArgs+"){";var fnExpr='"'+value.replace(regRepPlaceHolder,'"+v$1+"')+'"';parsed+="return "+fnExpr+";"+"};"}else parsed+=name+'="'+value+'";'}}}}eval(parsed)}function checkKeyNamespace(key){var regDot=/\./;if(regDot.test(key)){var fullname="",names=key.split(/\./);for(var i=0;i<names.length;i++)i>0&&(fullname+="."),fullname+=names[i],eval("typeof "+fullname+' == "undefined"')&&eval(fullname+"={};")}}function getFiles(e){return e&&e.constructor==Array?e:[e]}function normaliseLanguageCode(e){return e=e.toLowerCase(),e.length>3&&(e=e.substring(0,3)+e.substring(3).toUpperCase()),e}function unescapeUnicode(e){var t=[],n=parseInt(e.substr(2),16);n>=0&&n<Math.pow(2,16)&&t.push(n);var r="";for(var i=0;i<t.length;++i)r+=String.fromCharCode(t[i]);return r}$.i18n={},$.i18n.map={},$.i18n.properties=function(e){var t={name:"Messages",language:"",path:"",mode:"vars",cache:!1,encoding:"UTF-8",callback:null};e=$.extend(t,e);if(e.language===null||e.language=="")e.language=$.i18n.browserLang();e.language===null&&(e.language="");var n=getFiles(e.name);for(i=0;i<n.length;i++)loadAndParseFile(e.path+n[i]+".properties",e),e.language!=="en-US"&&e.language.length>=2&&loadAndParseFile(e.path+n[i]+"_"+e.language.substring(0,2)+".properties",e);e.callback&&e.callback()},$.i18n.prop=function(e){var t=$.i18n.map[e];if(t==null)return"["+e+"]";var n;if(typeof t=="string"){n=0;while((n=t.indexOf("\\",n))!=-1)t[n+1]=="t"?t=t.substring(0,n)+"	"+t.substring(n++ +2):t[n+1]=="r"?t=t.substring(0,n)+"\r"+t.substring(n++ +2):t[n+1]=="n"?t=t.substring(0,n)+"\n"+t.substring(n++ +2):t[n+1]=="f"?t=t.substring(0,n)+"\f"+t.substring(n++ +2):t[n+1]=="\\"?t=t.substring(0,n)+"\\"+t.substring(n++ +2):t=t.substring(0,n)+t.substring(n+1);var r=[],i,s;n=0;while(n<t.length)if(t[n]=="'")if(n==t.length-1)t=t.substring(0,n);else if(t[n+1]=="'")t=t.substring(0,n)+t.substring(++n);else{i=n+2;while((i=t.indexOf("'",i))!=-1){if(i==t.length-1||t[i+1]!="'"){t=t.substring(0,n)+t.substring(n+1,i)+t.substring(i+1),n=i-1;break}t=t.substring(0,i)+t.substring(++i)}i==-1&&(t=t.substring(0,n)+t.substring(n+1))}else if(t[n]=="{"){i=t.indexOf("}",n+1);if(i==-1)n++;else{s=parseInt(t.substring(n+1,i));if(!isNaN(s)&&s>=0){var o=t.substring(0,n);o!=""&&r.push(o),r.push(s),n=0,t=t.substring(i+1)}else n=i+1}}else n++;t!=""&&r.push(t),t=r,$.i18n.map[e]=r}if(t.length==0)return"";if(t.lengh==1&&typeof t[0]=="string")return t[0];var o="";for(n=0;n<t.length;n++)typeof t[n]=="string"?o+=t[n]:t[n]+1<arguments.length?o+=arguments[t[n]+1]:o+="{"+t[n]+"}";return o},$.i18n.browserLang=function(){return normaliseLanguageCode(navigator.language||navigator.userLanguage)};var cbSplit;cbSplit||(cbSplit=function(e,t,n){if(Object.prototype.toString.call(t)!=="[object RegExp]")return typeof cbSplit._nativeSplit=="undefined"?e.split(t,n):cbSplit._nativeSplit.call(e,t,n);var r=[],i=0,s=(t.ignoreCase?"i":"")+(t.multiline?"m":"")+(t.sticky?"y":""),t=RegExp(t.source,s+"g"),o,u,a,f;e+="",cbSplit._compliantExecNpcg||(o=RegExp("^"+t.source+"$(?!\\s)",s));if(n===undefined||+n<0)n=Infinity;else{n=Math.floor(+n);if(!n)return[]}while(u=t.exec(e)){a=u.index+u[0].length;if(a>i){r.push(e.slice(i,u.index)),!cbSplit._compliantExecNpcg&&u.length>1&&u[0].replace(o,function(){for(var e=1;e<arguments.length-2;e++)arguments[e]===undefined&&(u[e]=undefined)}),u.length>1&&u.index<e.length&&Array.prototype.push.apply(r,u.slice(1)),f=u[0].length,i=a;if(r.length>=n)break}t.lastIndex===u.index&&t.lastIndex++}return i===e.length?(f||!t.test(""))&&r.push(""):r.push(e.slice(i)),r.length>n?r.slice(0,n):r},cbSplit._compliantExecNpcg=/()??/.exec("")[1]===undefined,cbSplit._nativeSplit=String.prototype.split),String.prototype.split=function(e,t){return cbSplit(this,e,t)}})(jQuery);