/* jQuery Translate plugin and related components
 * http://code.google.com/p/jquery-translate/
 * Copyright (c) 2009 Balazs Endresz (balazs.endresz@gmail.com)
 * Dual licensed under the MIT and GPL licenses.
 * Involved core,NCT,NCT-adapter
 */
/* 
 * jQuery nodesContainingText plugin 
 * Version: 1.1.2
 */
(function(d){function e(){}e.prototype={init:function(a,b){this.textArray=[];this.elements=[];this.options=b;this.jquery=a;this.n=-1;if(b.async===true){b.async=2}if(b.not){a=a.not(b.not);a=a.add(a.find("*").not(b.not)).not(d(b.not).find("*"))}else{a=a.add(a.find("*"))}this.jq=a;this.jql=this.jq.length;return this.process()},process:function(){this.n++;var s=this,w=this.options,a="",t=false,u=false,v=this.jq[this.n],q,c,r;if(this.n===this.jql){r=this.jquery.pushStack(this.elements,"nodesContainingText");w.complete.call(r,r,this.textArray);if(w.returnAll===false&&w.walk===false){return this.jquery}return r}if(!v){return this.process()}q=d(v);var b=v.nodeName.toUpperCase(),o=b==="INPUT"&&d.attr(v,"type").toLowerCase();if(({SCRIPT:1,NOSCRIPT:1,STYLE:1,OBJECT:1,IFRAME:1})[b]){return this.process()}if(typeof w.subject==="string"){a=q.attr(w.subject)}else{if(w.altAndVal&&(b==="IMG"||o==="image")){a=q.attr("alt")}else{if(w.altAndVal&&({text:1,button:1,submit:1})[o]){a=q.val()}else{if(b==="TEXTAREA"){a=q.val()}else{c=v.firstChild;if(w.walk!==true){u=true}else{while(c){if(c.nodeType==1){u=true;break}c=c.nextSibling}}if(!u){a=q.text()}else{if(w.walk!==true){t=true}c=v.firstChild;while(c){if(c.nodeType==3&&c.nodeValue.match(/\S/)!==null){if(c.nodeValue.match(/<![ \r\n\t]*(--([^\-]|[\r\n]|-[^\-])*--[ \r\n\t]*)>/)!==null){if(c.nodeValue.match(/(\S+(?=.*<))|(>(?=.*\S+))/)!==null){t=true;break}}else{t=true;break}}c=c.nextSibling}if(t){a=q.html();a=w.stripScripts?a.replace(/<script[^>]*>([\s\S]*?)<\/script>/gi,""):a;this.jq=this.jq.not(q.find("*"))}}}}}}if(!a){return this.process()}this.elements.push(v);this.textArray.push(a);w.each.call(v,this.elements.length-1,v,a);if(w.async){setTimeout(function(){s.process()},w.async);return this.jquery}else{return this.process()}}};var f={not:"",async:false,each:function(){},complete:function(){},comments:false,returnAll:true,walk:true,altAndVal:false,subject:true,stripScripts:true};d.fn.nodesContainingText=function(a){a=d.extend({},f,d.fn.nodesContainingText.defaults,a);return new e().init(this,a)};d.fn.nodesContainingText.defaults=f})(jQuery);
/* 
 * jQuery Translate plugin 
 * Version: 1.4.7
 */
(function(R){function E(){}var Q=true,N=false,P,z="".replace,y=String,J=Function,A=Object,G,I,O,D={},S,K=[],M={from:"",to:"",start:E,error:E,each:E,complete:E,onTimeout:E,timeout:0,stripComments:Q,stripWhitespace:Q,stripScripts:Q,separators:/\.\?\!;:/,limit:1750,walk:Q,returnAll:N,replace:Q,rebind:Q,data:Q,setLangAttr:N,subject:Q,not:"",altAndVal:Q,async:N,toggle:N,fromOriginal:Q,parallel:false,trim:true,alwaysReplace:false};function B(){R.translate.GL=G=google.language;R.translate.GLL=I=G.Languages;O=R.translate.toLanguageCode;R.each(I,function(c,b){D[b.toUpperCase()]=c});R.translate.isReady=Q;var a;while((a=K.shift())){a()}}function L(b,c){var a={};R.each(b,function(d,e){if(c(e,d)===Q){a[d]=e}});return a}function x(c,b,a){return function(){return c.apply(b===Q?arguments[0]:b,a||arguments)}}function C(a){return a!==P}function F(f,e,b){var a,d={},c=R.grep(f,C);R.each(e,function(i,h){var g=R.grep(h[0],function(j,k){return C(c[k])&&c[k].constructor===j}).length;if(g===c.length&&g===h[0].length&&(a=Q)){R.each(h[1],function(k,j){d[j]=c[k]});return N}});if(!a){throw b}return d}function H(b,c){var a=F(b,R.translate.overload,"jQuery.translate: Invalid arguments"),d=a.options||{};delete a.options;d=R.extend({},M,c,R.extend(d,a));if(d.fromOriginal){d.toggle=Q}if(d.toggle){d.data=Q}if(d.async===Q){d.async=2}return d}function T(){this.extend(R.translate);delete this.defaults;delete this.fn}T.prototype={version:"1.4.7",_init:function(d,c){var f=c.separators.source||c.separators,e=this.isString=typeof d==="string",b=0,a;R.each(["stripComments","stripScripts","stripWhitespace"],function(h,i){var g=R.translate[i];if(c[i]){d=e?g(d):R.map(d,g)}});this.rawSource="<div>"+(e?d:d.join("</div><div>"))+"</div>";this._m3=new RegExp("["+f+"](?![^"+f+"]*["+f+"])");this.options=c;this.from=c.from=O(c.from)||"";this.to=c.to=O(c.to)||"";this.source=d;this.rawTranslation="";this.translation=[];this.i=0;this.stopped=N;this.elements=c.nodes;this._i=-1;this.rawSources=[];while(Q){a=this.truncate(this.rawSource.substr(b),c.limit);if(!a){break}this.rawSources.push(a);b+=a.length}this.queue=new Array(this.rawSources.length);this.done=0;c.start.call(this,d,c.from,c.to,c);if(c.timeout){this.timeout=setTimeout(x(c.onTimeout,this,[d,c.from,c.to,c]),c.timeout)}(c.toggle&&c.nodes)?(c.textNodes?this._toggleTextNodes():this._toggle()):this._process()},_process:function(){if(this.stopped){return}var i=this.options,n=this.rawTranslation.length,j,h,l,m;var k=this;while((j=this.rawTranslation.lastIndexOf("</div>",n))>-1){n=j-1;h=this.rawTranslation.substr(0,n+1);l=h.match(/<div[> ]/gi);m=h.match(/<\/div>/gi);l=l?l.length:0;m=m?m.length:0;if(l!==m+1){continue}var d=R(this.rawTranslation.substr(0,n+7)),b=d.length,c=this.i;if(c===b){break}d.slice(c,b).each(x(function(u,r){if(this.stopped){return N}var o=R(r).html(),s=i.trim?R.trim(o):o,t=c+u,q=this.source,p=!this.from&&this.detectedSourceLanguage||this.from;this.translation[t]=s;this.isString?this.translation=s:q=this.source[t];i.each.call(this,t,s,q,p,this.to,i);this.i++},this));break}if(this.rawSources.length-1==this._i){this._complete()}var e=x(this._translate,this);if(i.parallel){if(this._i<0){if(!i.parallel){R.each(this.rawSources,e)}else{var a=0,g=this.rawSources.length;function f(){e();if(a<g){setTimeout(f,i.parallel)}}f()}}}else{e()}},_translate:function(){this._i++;var a=this._i,b=this.rawSourceSub=this.rawSources[a];if(!b){return}G.translate(b,this.from,this.to,x(function(c){if(c.error){return this.options.error.call(this,c.error,this.rawSourceSub,this.from,this.to,this.options)}this.queue[a]=c.translation||this.rawSourceSub;this.detectedSourceLanguage=c.detectedSourceLanguage;this._check()},this))},_check:function(){if(!this.options.parallel){this.rawTranslation+=this.queue[this._i];this._process();return}var a=0;jQuery.each(this.queue,function(d,c){if(c!=P){a=d}else{return false}});if((a>this.done)||(a===this.queue.length-1)){for(var b=0;b<=a;b++){this.rawTranslation+=this.queue[b]}this._process()}this.done=a},_complete:function(){clearTimeout(this.timeout);this.options.complete.call(this,this.translation,this.source,!this.from&&this.detectedSourceLanguage||this.from,this.to,this.options)},stop:function(){if(this.stopped){return this}this.stopped=Q;this.options.error.call(this,{message:"stopped"});return this}};R.translate=function(c,b){if(c==P){return new T()}if(R.isFunction(c)){return R.translate.ready(c,b)}var a=new T();var d=[].slice.call(arguments,0);d.shift();return R.translate.ready(x(a._init,a,[c,H(d,R.translate.defaults)]),N,a)};R.translate.fn=R.translate.prototype=T.prototype;R.translate.fn.extend=R.translate.extend=R.extend;R.translate.extend({_bind:x,_filter:L,_validate:F,_getOpt:H,_defaults:M,defaults:R.extend({},M),capitalize:function(a){return a.charAt(0).toUpperCase()+a.substr(1).toLowerCase()},truncate:function(a,f){var e,h,j,b,c,i,g=encodeURIComponent(a);for(e=0;e<10;e++){try{i=decodeURIComponent(g.substr(0,f-e))}catch(d){continue}if(i){break}}return(!(h=/<(?![^<]*>)/.exec(i)))?((!(j=/>\s*$/.exec(i)))?((b=this._m3.exec(i))?((c=/>(?![^>]*<)/.exec(i))?(b.index>c.index?i.substring(0,b.index+1):i.substring(0,c.index+1)):i.substring(0,b.index+1)):i):i):i.substring(0,h.index)},getLanguages:function(i,a){if(i==P||(a==P&&!i)){return I}var c={},d=typeof i,e=a?R.translate.getLanguages(i):I,h=(d==="object"||d==="function")?i:a;if(h){if(h.call){c=L(e,h)}else{for(var b=0,f=h.length,g;b<f;b++){g=R.translate.toLanguage(h[b]);if(e[g]!=P){c[g]=e[g]}}}}else{c=L(I,G.isTranslatable)}return c},toLanguage:function(d,b){var c=d.toUpperCase();var a=D[c]||(I[c]?c:P)||D[(R.translate.languageCodeMap[d.toLowerCase()]||"").toUpperCase()];return a==P?P:b==="lowercase"?a.toLowerCase():b==="capitalize"?R.translate.capitalize(a):a},toLanguageCode:function(a){return I[a]||I[R.translate.toLanguage(a)]||R.translate.languageCodeMap[a.toLowerCase()]},same:function(b,a){return b===a||O(b)===O(a)},isTranslatable:function(a){return G.isTranslatable(O(a))},languageCodeMap:{pt:"pt-PT","pt-br":"pt-PT",he:"iw",zlm:"ms","zh-hans":"zh-CN","zh-hant":"zh-TW"},isRtl:{ar:Q,iw:Q,fa:Q,ur:Q,yi:Q},getBranding:function(){return R(G.getBranding.apply(G,arguments))},load:function(c,a){S=Q;function b(){google.load("language",a||"1",{callback:B})}if(typeof google!=="undefined"&&google.load){b()}else{R.getScript(((document.location.protocol=="https:")?"https://":"http://")+"www.google.com/jsapi"+(c?"?key="+c:""),b)}return R.translate},ready:function(a,b,c){R.translate.isReady?a():K.push(a);if(!S&&!b){R.translate.load()}return c||R.translate},isReady:N,overload:[[[],[]],[[y,y,A],["from","to","options"]],[[y,A],["to","options"]],[[A],["options"]],[[y,y],["from","to"]],[[y],["to"]],[[y,y,J],["from","to","complete"]],[[y,J],["to","complete"]]],stripScripts:x(z,Q,[/<script[^>]*>([\s\S]*?)<\/script>/gi,""]),stripWhitespace:x(z,Q,[/\s\s+/g," "]),stripComments:x(z,Q,[/<![ \r\n\t]*(--([^\-]|[\r\n]|-[^\-])*--[ \r\n\t]*)>/g,""])})})(jQuery);(function(l){var m=true,j={text:m,button:m,submit:m},i={SCRIPT:m,NOSCRIPT:m,STYLE:m,OBJECT:m,IFRAME:m},n=l([]);n.length=1;function o(a){while(a&&a.nodeType!=9){a=a.parentNode}return a}function p(b,c){var a=b.css("text-align");b.css("direction",c);if(a==="right"){b.css("text-align","left")}if(a==="left"){b.css("text-align","right")}}function k(c,b){var a=c.nodeName.toUpperCase(),d=a==="INPUT"&&l.attr(c,"type").toLowerCase();b=b||{altAndVal:m,subject:m};return typeof b.subject==="string"?b.subject:b.altAndVal&&(a==="IMG"||d==="image")?"alt":b.altAndVal&&j[d]?"$val":a==="TEXTAREA"?"$val":"$html"}l.translate.fn._toggle=function(){var b=this.options,a=b.to,c;this.elements.each(l.translate._bind(function(e,d){this.i=e;var f=l(d),g=l.translate.getData(f,a,b);if(!g){return !(c=m)}this.translation.push(g);b.each.call(this,e,d,g,this.source[e],this.from,a,b)},this));!c?this._complete():this._process()};l.translate.extend({_getType:k,each:function(c,a,d,b,e,f,g){n[0]=a;l.translate.setData(n,f,d,e,b,g);l.translate.replace(n,d,f,g);l.translate.setLangAttr(n,f,g)},getData:function(c,a,b){var e=c[0]||c,d=l.data(e,"translation");return d&&d[a]&&d[a][k(e,b)]},setData:function(f,d,b,c,a,s){if(s&&!s.data){return}var h=f[0]||f,e=k(h,s),g=l.data(h,"translation");g=g||l.data(h,"translation",{});(g[c]=g[c]||{})[e]=a;(g[d]=g[d]||{})[e]=b},replace:function(e,v,w,g){if(g&&!g.replace){return}if(g&&typeof g.subject==="string"){return e.attr(g.subject,v)}var f=e[0]||e,b=f.nodeName.toUpperCase(),c=b==="INPUT"&&l.attr(f,"type").toLowerCase(),d=l.translate.isRtl,h=l.data(f,"lang");if(!g.alwaysReplace){if(h===w){return}}if(d[w]!==d[h||g&&g.from]){if(d[w]){p(e,"rtl")}else{if(e.css("direction")==="rtl"){p(e,"ltr")}}}if((!g||g.altAndVal)&&(b==="IMG"||c==="image")){e.attr("alt",v)}else{if(b==="TEXTAREA"||(!g||g.altAndVal)&&j[c]){e.val(v)}else{if(!g||g.rebind){this.doc=this.doc||o(f);var t=e.find("*").not("script"),a=l(this.doc.createElement("div")).html(v);l.translate.copyEvents(t,a.find("*"));e.html(a.contents())}else{e.html(v)}}}l.data(f,"lang",w)},setLangAttr:function(c,a,b){if(!b||b.setLangAttr){c.attr((!b||b.setLangAttr===m)?"lang":b.setLangAttr,a)}},copyEvents:function(a,b){b.each(function(d,g){var f=a[d];if(!g||!f){return false}if(i[f.nodeName.toUpperCase()]){return m}var e=l.data(f,"events");if(!e){return m}for(var h in e){for(var c in e[h]){l.event.add(g,h,e[h][c],e[h][c].data)}}})}});l.fn.translate=function(d,e,a){var c=l.translate._getOpt(arguments,l.fn.translate.defaults),b=l.extend({},l.translate._defaults,l.fn.translate.defaults,c,{complete:function(f,g){l.translate(function(){var h=l.translate.toLanguageCode(c.from);if(c.fromOriginal){f.each(function(v,r){n[0]=r;var q=l.translate.getData(n,h,c);if(!q){return true}g[v]=q})}var s=c.each;function t(q){return function(){[].unshift.call(arguments,this.elements);q.apply(this,arguments)}}c.nodes=f;c.start=t(c.start);c.onTimeout=t(c.onTimeout);c.complete=t(c.complete);c.each=function(q){var r=arguments;if(arguments.length!==7){[].splice.call(r,1,0,this.elements[q])}this.each.apply(this,r);s.apply(this,r)};l.translate(g,c)})},each:function(){}});if(this.nodesContainingText){return this.nodesContainingText(b)}c.nodes=this;l.translate(l.map(this,function(f){return l(f).html()||l(f).val()}),c);return this};l.fn.translate.defaults=l.extend({},l.translate._defaults)})(jQuery);
