/*
Copyright (c) 2008, Caridy Patino. All rights reserved.
Portions Copyright (c) 2008, Yahoo!, Inc. All rights reserved.
Code licensed under the BSD License:
http://www.bubbling-library.com/eng/licence
version: 2.0
*/
YAHOO.namespace("plugin");(function(){var C=YAHOO.lang,B=YAHOO.util.Connect,A=YAHOO.util.Event;YAHOO.plugin.Translator=function(){var H={},D={},G="/translator.php?",F="eng",E="UTF-8";var I={success:function(M){var K=null,J=D[M.argument.id].modConfig;try{K=C.JSON.parse(M.responseText)}catch(L){J.onError.fire()}if(K){H.set(M.argument.id,K)}},failure:function(K){var J=D[K.argument.id].modConfig;J.onError.fire()}};H.load=function(N,K){var M,J,L;if(C.isString(N)&&(N!=="")){this.reset(N,K);D[N].modConfig.ready=false;M=new String((D[N].modConfig.uri)?D[N].modConfig.uri:G);L=((D[N].modConfig.charset)?D[N].modConfig.charset:E);if(!M.indexOf("?")){M+="?"}else{if(M.indexOf("?")!==M.length-1){M+="&"}}M+="lang="+F+"&module="+N+"&charset="+L;J={success:I.success,failure:I.failure,argument:{id:N,module:K}};D[N].handle=B.asyncRequest("GET",M,J)}};H.set=function(K,J){if(!C.isObject(D[K])){this.reset(K);D[K].modConfig.name=K}D[K].values=J;D[K].modConfig.ready=true;D[K].modConfig.onReady.fire();return D[K].values};H.get=function(L,K,J){J=J||{};J.autoloader=J.autoloader||true;if(C.isObject(D[L])){if(this.isReady(L)){if(C.isString(D[L].values[K])){return D[L].values[K]}else{if(C.isFunction(J.onNull)){J.onNull.apply(D[L],[L,K])}return K}}else{if(C.isFunction(J.onReady)){D[L].modConfig.onReady.subscribe(J.onReady)}if(C.isFunction(J.onError)){D[L].modConfig.onError.subscribe(J.onError)}}}else{if(J.autoloader){this.load(L,J)}}return null};H.find=function(K){var J;for(id in D){if(D.hasOwnProperty(id)){J=this.get(id,K,false);if(J){return J}}}return null};H.add=function(L,K,J){J=(C.isObject(J)?J:{});this.reset(L,J);D[L].modConfig.ready=false;D[L].modConfig.name=L;return this.set(L,K)};H.reload=function(){for(id in D){if(D.hasOwnProperty(id)){this.reset(id,D[id].modConfig);this.load(id,D[id].modConfig)}}};H.reset=function(M,J){var L,K;if(C.isString(M)&&(M!=="")){J=J||{};if(C.isObject(D[M])){J=D[M].modConfig}else{L=new YAHOO.util.CustomEvent("onReady");K=new YAHOO.util.CustomEvent("onError");if(C.isFunction(J.onReady)){L.subscribe(J.onReady)}if(C.isFunction(J.onError)){K.subscribe(J.onError)}J.onReady=L;J.onError=K}D[M]={modConfig:J}}else{for(M in D){if(D.hasOwnProperty(M)){this.reset(M,J)}}}};H.init=function(J){F=J.lang||F;G=J.uri||G;E=J.charset||E;if(!J.silence){this.reload()}};H.getLang=function(){return F};H.isReady=function(J){if(C.isObject(D[J])){return D[J].modConfig.ready}return false};return H}()})();String.prototype.translate=function(A){if(YAHOO.lang.isString(A)&&(A!=="")){return YAHOO.util.Translator.get(A,this)}else{return YAHOO.util.Translator.find(this)||this}};YAHOO.util.Translator=YAHOO.plugin.Translator;YAHOO.register("translator",YAHOO.plugin.Translator,{version:"2.0",build:"208"});