/* jQuery Translate plugin and related components */
/* http://code.google.com/p/jquery-translate/
 * Version: 1.2.6
 * License: MIT, GPL  (c) 2009 Balazs Endresz
 */
(function(g){function h(){}function m(r){return typeof r!="undefined"}function b(r){return typeof r=="string"}function o(t,r){return t.toLowerCase()==r.toLowerCase()}function k(r){return g.nodeName(r[0],"input")?!!r.attr("type").match(/text|button|submit/i):false}function n(t,r,y,x){var w="",v,u={};if(typeof t=="object"){u=t}else{if(!r&&!y){v=t}if(!y&&r){if(typeof r=="object"){v=t;u=r}else{w=t;v=r}}if(t&&r&&y){w=t;v=r;u=y}u.from=w||u.from||"";u.to=v||u.to||""}if(u.fromOriginal){u.toggle=true}if(u.toggle){u.data=true}if(u.async===true){u.async=2}return g.extend({},d,(m(x)?g.fn.translate.defaults:g.translate.defaults),u)}function e(){}e.fn=e.prototype={version:"1.2.6",translateInit:function(C,z,y,x){var w=this,A,B,r;this.options=r=n(z,y,x);r.from=this.toLanguageCode(r.from)||"";r.to=this.toLanguageCode(r.to)||"";if(r.fromOriginal&&r.nodes[0]){r.nodes.each(function(t){var D=w.getData(this,r.from);if(!D){return false}C[t]=D})}if(b(C)){if(r.comments===false){C=this.stripComments(C)}this.rawSource="<div>"+C+"</div>";this.isString=true}else{if(r.comments===false){for(var v=0,u=C.length;v<u;v++){C[v]=this.stripComments(C[v])}}this.rawSource="<div>"+C.join("</div><div>")+"</div>";this.isString=false}this.from=r.from;this.to=r.to;this.source=C;this.elements=r.nodes;this.rawTranslation="";this.translation=[];this.startPos=0;this.i=0;this.numberOfCalls=0;this.stopped=false;r.start.call(this,r.nodes[0]?r.nodes:C,r.from,r.to,r);if(r.timeout>0){this.timeout=setTimeout(function(){r.onTimeout.call(w,r.nodes[0]?r.nodes:C,r.from,r.to,r)},r.timeout)}if(r.toggle&&r.nodes[0]){this.toggle()}return this.translate()},translate:function(){if(this.stopped){return}var z=this,r=this.options;this.rawSourceSub=this.truncate(this.rawSource.substring(this.startPos,this.startPos+r.limit));this.startPos+=this.rawSourceSub.length;var w=this.rawTranslation.length;while(this.rawTranslation.lastIndexOf("</div>",w)>-1){w=this.rawTranslation.lastIndexOf("</div>",w)-1;var A=this.rawTranslation.substr(0,w),y=A.match(/<div(>|( style=\";))/gi),x=A.match(/<\/div>/gi);y=y?y.length:0;x=x?x.length:0;if(y!=x+1){continue}var t=g(this.rawTranslation.substr(0,(w+7))),v=t.length,u=this.i;if(u==v){break}t.slice(u,v).each(function(C,D){(function(){if(this.stopped){return false}var F=g(D).html().replace(/^\s/,""),E=u+C,G=this.source,H=this.from.length<2&&this.detectedSourceLanguage||this.from;this.translation[E]=F;if(!r.nodes[0]){if(this.isString){this.translation=F}else{G=this.source[E]}r.each.call(this,E,F,G,H,this.to,r,this.numberOfCalls)}else{this.each(E,this.elements[E],F,this.source[E],H,this.to,r);r.each.call(this,E,this.elements[E],F,this.source[E],H,this.to,r,this.numberOfCalls)}this.i++}).call(z)});break}if(this.rawSourceSub.length>0){s.translate(this.rawSourceSub,this.from,this.to,function(C){(function(){if(C.error){return r.error.call(this,C.error,this.rawSourceSub,this.from,this.to,r,this.numberOfCalls)}this.rawTranslation+=C.translation;this.detectedSourceLanguage=C.detectedSourceLanguage;this.translate()}).call(z)});this.numberOfCalls++;if(!r.nodes[0]){return this}}else{if(!this.rawTranslation){return}var B=this.from.length<2&&this.detectedSourceLanguage||this.from;if(this.timeout){clearTimeout(this.timeout)}if(!r.nodes[0]){r.complete.call(this,this.translation,this.source,B,this.to,r,this.numberOfCalls)}else{r.complete.call(this,this.elements.end(),this.elements,this.translation,this.source,B,this.to,r,this.numberOfCalls)}}},each:function(v,u,B,C,z,A,r){var w=this,x=g(u),y;if(r.data===true){if(b(r.subject)){y=r.subject}else{if(r.altAndVal&&g.nodeName(u,"img")){y="alt"}else{if(r.altAndVal&&k(x)){y="value"}else{if(g.nodeName(u,"textarea")){y="value"}else{y="html"}}}}g.data(u,"translation."+z+"."+y,C);g.data(u,"translation."+A+"."+y,B)}this.setLangAttr(x,A,r);this.replace(x,B,r)},getData:function(r,v,u){var u=u||this.options||{subject:true},t="translation."+v+".";return b(u.subject)&&g.data(r,t+u.subject)||u.subject===true&&g.data(r,t+"html")||u.altAndVal&&g.data(r,t+"value")||u.altAndVal&&g.data(r,t+"alt")},toggle:function(){var u=this,x=[],v=this.options,t=v.nodes,w=v.to,r=false;t.each(function(y){var A=g(this),z=u.getData(this,w);if(m(z)){u.stop()}else{r=true;return false}u.setLangAttr(A,w,v);u.replace(A,z,v);x.push(z);v.each.call(u,y,u.elements[y],z,u.source[y],u.from,w,v)});if(!r){v.complete.call(this,t.end(),t,x,this.source,this.from,this.to,v)}},replace:function(v,u,w){if(w.replace===true){if(b(w.subject)){v.attr(w.subject,u)}else{if(w.from=="ar"||w.to=="ar"){if(w.from=="ar"){v.css("direction","ltr")}if(w.to=="ar"){v.css("direction","rtl")}if(v.css("text-align")=="right"){v.css("text-align","left")}if(v.css("text-align")=="left"){v.css("text-align","right")}}if(w.altAndVal&&g.nodeName(v[0],"img")){v.attr("alt",u)}else{if(w.altAndVal&&k(v)){v.val(u)}else{if(g.nodeName(v[0],"textarea")){v.val(u)}else{if(w.rebind===true){var r=v.find("*").not("script").clone(true);v.html(u);this.copyEvents(r,v.find("*"))}else{v.html(u)}}}}}}},setLangAttr:function(t,r,u){if(u.setLangAttr===true){t.attr("lang",r)}if(b(u.setLangAttr)){t.attr(u.setLangAttr,r)}},stripComments:function(r){return r.replace(/<![ \r\n\t]*(--([^\-]|[\r\n]|-[^\-])*--[ \r\n\t]*)>/g,"")},truncate:function(x){var w=/<(?![^<]*>)/.exec(x);if(!w){var v=/>\s*$/.exec(x);if(!v){var u=/[\.\?\!;:](?![^\.\?\!;:]*[\.\?\!;:])/.exec(x);if(u){var r=/>(?![^>]*<)/.exec(x);if(r){if(u.index>r.index){x=x.substring(0,u.index+1)}else{x=x.substring(0,r.index+1)}}else{x=x.substring(0,u.index+1)}}else{x=x}}else{x=x}}else{x=x.substring(0,w.index)}return x},copyEvents:function(t,r){r.each(function(v){var u=g.data(t[v],"events");if(!u){return false}for(var x in u){for(var w in u[x]){g.event.add(this,x,u[x][w],u[x][w].data)}}})},stop:function(){if(this.stopped){return this}this.stopped=true;this.options.error.call(this,{message:"stopped"});return this},ready:function(r,t){if(i){return r()}q.push(r);if(m(t)){return t}},getLanguages:function(r){if(!m(r)){return j}r={};for(var t in j){if(s.isTranslatable(j[t])){r[t]=j[t]}}return r},toLanguage:function(u,r){var t="UNKNOWN";for(l in j){if(o(j[l],u)||o(l,u)){t=l;break}}if(r=="lowercase"){t=t.toLowerCase()}if(r=="uppercase"){t=t.toUpperCase()}if(r=="capitalize"){t=t.charAt(0).toUpperCase()+t.substring(1).toLowerCase()}return t},toLanguageCode:function(r){for(l in j){if(o(j[l],r)||o(l,r)){return j[l]}}},isTranslatable:function(r){return s.isTranslatable(this.toLanguageCode(r))},getBranding:function(t,r){return g(s.getBranding(t,r))}};g.fn.translate=function(t,r,w){var u=n(t,r,w,true),v=g.extend({},d,g.fn.translate.defaults,u,{complete:function(y,x){u.nodes=y;g.translate(x,u)},each:h});if(m(g.fn.nodesContainingText)){return this.nodesContainingText(v)}u.nodes=this.get();return g.translate(u)};g.translate=function(v,u,r,x){if(g.isFunction(v)){return a(v)}var w=new e();if(!m(v)){return w}return a(function(){return w.translateInit(v,u,r,x)},w)};var d={limit:500,comments:false,start:h,error:h,each:h,complete:h,onTimeout:h,timeout:0,from:"",to:"",nodes:[],walk:true,returnAll:false,replace:true,rebind:true,data:true,setLangAttr:false,subject:true,not:"",altAndVal:true,async:false,toggle:false,fromOriginal:false},s,j,i=false,q=[],a=e.fn.ready;g.translate.defaults=g.fn.translate.defaults=d;g.translate.fn=g.translate.prototype=e.fn;function f(){s=e.prototype.GL=google.language;j=s.Languages;i=true;g.each(q,function(){this()})}function p(){google.load("language","1",{callback:f})}function c(r){if(typeof google!="undefined"&&typeof google.load!="undefined"){return p()}g.getScript("http://www.google.com/jsapi?"+(r?"key="+r:""),p)}c()})(jQuery);(function(b){function a(){}b.fn.language=function(d){d=d||{};var e=b.extend({},c,b.fn.language.defaults,d,{complete:function(g,f){d.nodes=g;b.language(f,d)},each:a,start:a,returnAll:true});if(typeof b.fn.nodesContainingText!="undefined"){return this.nodesContainingText(e)}d.nodes=this;return b.language(that,d)};b.language=function(d,f){f=f||{};var e=new b.translate();if(b.isFunction(d)){return e.ready(d)}if(typeof d=="undefined"){return e}return e.ready(function(){return e.detect(d,f)},e)};var c={start:a,each:a,complete:a,error:a,setLangAttr:true,subject:true,limit:500,walk:true,returnAll:false,not:"",altAndVal:false,async:false,nodes:[]};b.language.defaults=b.fn.language.defaults=c;b.language.fn=b.language.prototype=b.extend(b.translate.fn,{detect:function(n,f){if(typeof n=="undefined"){return this}this.options=f=b.extend({},c,(f.nodes[0]?b.fn.language.defaults:b.language.defaults),f);var m=this,h=0,p=[],g=[],j=[],d=f.nodes,e;if(typeof n=="string"){n=[n];e=true}var k=n.length;this.elements=d;this.text=n;this.stopped=false;this.languageCodes=p;this.languages=g;this.results=j;f.start.call(this,f.nodes[0]?f.nodes:n,f);b.each(n,function(q,o){m.GL.detect(o.substring(0,f.limit*1),function(i){(function(){if(this.stopped){return}if(i.error){if(d[0]){return f.error.call(this,i.error,d[q],o,q,f)}else{return f.error.call(this,i.error,o,q,f)}}var s=i.language,t=this.toLanguage(s);p.push(s);g.push(t);j.push(i);if(d[0]){var r=d[q];this.setLangAttr(b(r),s,f);f.each.call(this,q,r,o,s,t,i,f)}else{f.each.call(this,q,o,s,t,i,f)}if(q==k-1){if(e){return f.complete.call(this,n[0],p[0],g[0],j[0],f)}else{if(d[0]){return f.complete.call(this,d,n,p,g,j,f)}else{return f.complete.call(this,n,p,g,j,f)}}}}).call(m)})});return this}})})(jQuery);(function(a){a.translate.fn.ui=function(f,d,i){var h="",g="",e="";if(i){g="<"+i+">";e="</"+i+">"}a.each(this.getLanguages(true),function(b,c){h+=("<"+d+">"+g+b.charAt(0)+b.substring(1).toLowerCase()+e+"</"+d+">")});return a("<"+f+' class="jq-translate-ui">'+h+"</"+f+">")}})(jQuery);(function(a){a.translate.fn.progress=function(b,d){if(!this.i){this.pr=0}this.pr+=this.source[this.i].length;var c=100*this.pr/(this.rawSource.length-(11*(this.i+1)));if(b){var f=a(b);if(!this.i&&!f.hasClass("ui-progressbar")){f.progressbar(d)}f.progressbar("progress",c)}return c}})(jQuery);(function(d){function c(g,f){return g.nodeName&&g.nodeName.toUpperCase()==f.toUpperCase()}function b(g){if(!c(g[0],"input")){return false}var f=g.attr("type");return f=="text"||f=="button"||f=="submit"}function a(){}a.prototype={init:function(g,f){this.textArray=[];this.elements=[];this.options=f;this.jquery=g;this.n=-1;if(f.async===true){f.async=2}g=g.not("script, "+f.not);g=g.add(g.find("*").not("script, "+f.not));if(f.not){g=g.not(d(f.not).find("*"))}this.jq=g;this.jql=this.jq.length;return this.process()},process:function(){this.n++;var j=this,f=this.options,p="",i=false,h=false,g=this.jq[this.n],m,n,k;if(this.n==this.jql){k=this.jquery.pushStack(this.elements);f.complete.call(k,k,this.textArray);if(f.returnAll===false&&f.walk===false){return this.jquery}return k}if(!g){return this.process()}m=d(g);if(typeof f.subject=="string"){p=m.attr(f.subject)}else{if(f.altAndVal&&c(g,"img")){p=m.attr("alt")}else{if(f.altAndVal&&b(m)){p=m.val()}else{if(c(g,"textarea")){p=m.val()}else{n=g.firstChild;if(f.walk!==true){h=true}else{while(n){if(n.nodeType==1){h=true;break}n=n.nextSibling}}if(!h){p=m.text()}else{if(f.walk!==true){i=true}n=g.firstChild;while(n){if(n.nodeType==3&&n.nodeValue.match(/\S/)!==null){if(n.nodeValue.match(/<![ \r\n\t]*(--([^\-]|[\r\n]|-[^\-])*--[ \r\n\t]*)>/)!==null){if(n.nodeValue.match(/(\S+(?=.*<))|(>(?=.*\S+))/)!==null){i=true;break}}else{i=true;break}}n=n.nextSibling}if(i){p=m.html().replace(/<script[^<]+<[^<]+>/,"");this.jq=this.jq.not(m.find("*"))}}}}}}if(!p){return this.process()}this.elements.push(g);if(f.comments===false){p=this.stripComments(p)}this.textArray.push(p);f.each.call(g,this.elements.length-1,g,p);if(f.async){setTimeout(function(){j.process()},f.async);return this.jquery}else{return this.process()}},stripComments:function(f){return f.replace(/<![ \r\n\t]*(--([^\-]|[\r\n]|-[^\-])*--[ \r\n\t]*)>/g,"")}};d.fn.nodesContainingText=function(f){f=d.extend({},e,d.fn.nodesContainingText.defaults,f);return new a().init(this,f)};var e={not:"",async:false,each:function(){},complete:function(){},comments:false,returnAll:true,walk:true,altAndVal:false,subject:true};d.fn.nodesContainingText.defaults=e})(jQuery);