/* TranslateThis Button v1.0 - http://translateTH.IS
Copyright (c)2008-2009 Jon Raasch. All rights reserved */
(function(){function a(g){var f={opts:{},langs:{},theFlags:[],theDD:[],theAll:[],input:[],results:[],busy:0,ol:0,all:0,tr:0,undo:0,prev:function(i){if(i&&i.preventDefault){i.preventDefault()}else{if(window.event&&window.event.returnValue){window.eventReturnValue=false}}},trans:function(p){function m(v){function r(y,x,w){f.input.push({node:y,html:x,x:w})}switch(v.nodeType){case 1:if(!v.innerHTML||v.tagName=="SCRIPT"||v.tagName=="STYLE"||v.tagName=="OBJECT"){return}if(v.innerHTML.length<f.o.maxLength){r(v,v.innerHTML,0)}else{var s=v.childNodes;for(var t=0;t<s.length;t++){m(s[t])}}break;case 3:if(v.nodeValue.length<f.o.maxLength){r(v,v.nodeValue,0)}else{var q=v.nodeValue,u=0;while(q.length){r(v,q.substr(0,f.o.maxLength),u?1:0);q=q.substr(f.o.maxLength);u++}}break}}function o(q){google.language.translate(f.input[q].html,f.o.fromLang,p,function(r){if(f.cancel){return}if(!r.error){j(f.input[q].node,r.translation,f.input[q].x)}if(q+1>=f.input.length){l(0)}})}function l(q){function u(){function w(){v--;if(v>-25){f.undo.style.top=v+"px";setTimeout(w,12)}else{n()}}if(f.undo){var v=0;w()}}f.busy=0;f.wrap=document.getElementById(f.o.wrapper);var r=f.findCTA();f.buildCTA(r);f.tr.style.display="none";f.hideOL();if(!q){if(f.o.cookie){f.setCookie(p,30)}if(typeof f.o.onComplete=="function"){f.o.onComplete(p)}var s=document.createElement("div"),t=document.createElement("a");s.className="ttb-undo";s.innerHTML=f.o.doneText+" TranslateThis Button &nbsp;|&nbsp; ";t.innerHTML=f.o.undoText;try{t.href="#"}catch(err){};t.onclick=function(v){f.prev(v);u();f.trans(0)};s.appendChild(t);document.body.appendChild(s);f.undo=s;setTimeout(u,4000)}}function j(r,s,q){if(!s.length){return}if(typeof r.innerHTML!="undefined"){r.innerHTML=s}else{if(typeof r.nodeValue!="undefined"){r.nodeValue=q?r.nodeValue+s:s}}}function k(){var r=document.createElement("div"),q=document.createElement("a");r.className="ttb-translating";r.innerHTML=f.o.busyText+"<br />";q.innerHTML=f.o.cancelText;q.href="#cancel";q.onclick=function(s){f.prev(s);f.trans(0)};r.appendChild(q);document.body.appendChild(r);return r}function n(){f.remove(f.undo);f.undo=0}if(f.busy&&p){return}else{f.busy=1}f.showOL();if(f.tr){f.remove(f.tr)}f.tr=k();f.centerXY(f.tr,100,25);f.tr.style.display="block";if(f.dd){f.remove(f.dd);f.dd=0;f.theDD=[]}if(f.all){f.remove(f.all);f.all=0;f.theAll=[]}if(p&&f.undo){n()}if(!f.input.length||f.o.reparse){f.input=[];m(f.o.scope?document.getElementById(f.o.scope):document.body)}if(p){f.cancel=0;for(var i=0;i<f.input.length;i++){o(i)}f.report(p);if(typeof f.o.onClick=="function"){f.o.onClick()}}else{if(!f.cancel){f.cancel=1;for(index in f.input){j(f.input[index].node,f.input[index].html,f.input[index].x)}f.setCookie("",-1);f.report(0);l(1)}}},build:function(){function i(){var m=document.createElement("style"),o="display:block;overflow:hidden;text-indent:-2000px;",n="background:#FFF;border:1px solid #BBB;font-family:Arial;color:#555;",l=".ttb-panel{display:none;position:absolute;z-index:999;font-size:12px;text-align:left;"+n+"} .ttb-panel .ttb-column{width:117px;float:left;margin:0 3px 0 0;} .ttb-panel a{color:#555}";if(!f.o.noBtn){l+=" #"+f.o.wrapper+" .translate-this-button{background:url('"+f.o.btnImg+"') no-repeat;visibility:visible;position:relative;width:"+f.o.btnWidth+"px;height:"+f.o.btnHeight+"px;float:left;"+o+"}"}l+=" .ttb-more{float:right;padding:4px;} .ttb-close{display:block;position:absolute;top:3px;right:3px;height:16px;width:16px;}";l+=" .ttb-cta{display:block;padding:4px 5px;text-decoration:none;cursor:pointer;} .ttb-cta:hover{background:#EEE;outline:1px solid #DDD;text-decoration:underline;}";l+=" .translate-flag{background:url('"+f.o.bgImg+"') no-repeat;height:"+f.o.imgHeight+"px;width:"+f.o.imgWidth+"px;margin:0 6px 0 0;float:left;"+o+"}";l+=" .ttb-overlay{position:absolute;top:0;left:0;background:#222;filter:alpha(opacity=80);opacity:.8;} .ttb-translating{position:absolute;height:80px;width:200px;font-size:16px;text-align:center;line-height:40px;"+n+"} .ttb-translating a{font-size:.8em;}";l+=" .ttb-undo{position:absolute;width:100%;z-index:2000;top:0;left:0;padding:5px 0;filter:alpha(opacity=95);opacity:.95;text-align:center;font-size:12px;"+n+"border:0;border-bottom:1px solid #BBB;}";m.type="text/css";if(m.styleSheet){m.styleSheet.cssText=l}else{m.appendChild(document.createTextNode(l))}document.getElementsByTagName("head")[0].appendChild(m)}f.wrap=document.getElementById(f.o.wrapper);if(!f.wrap){return}var j=f.findCTA();if(!j){return}try{j.href="#translate"}catch(err){};if(f.o.cookie&&!f.busy){var k=f.getCookie();if(k){f.trans(k)}}i();f.wrap.style.height=f.o.btnHeight+"px";f.buildCTA(j);f.appendClear(f.wrap,1);if(typeof f.o.onLoad=="function"){f.o.onLoad()}},buildFlag:function(m){var j=document.createElement("a");j.className="translate-"+m+" ttb-cta";j.title="Translate into "+f.langs[m];j.href="#translate-"+m;var i=document.createElement("span");i.className="translate-label";i.innerHTML=f.langs[m];if(f.o.noImg){j.appendChild(i);return j}var k=document.createElement("span");k.className="translate-flag";k.style.backgroundPosition="0 "+(f.o.imgMap[m]*f.o.imgHeight*-1)+"px";j.appendChild(k);j.appendChild(i);return j},findCTA:function(){var j=f.wrap.childNodes;for(var k=0;k<j.length;k++){if(j[k].className=="translate-this-button"){return j[k]}}return false},buildCTA:function(l){function m(){f.dd=f.buildPanel(1);f.dd.style.width="250px";f.dd.onmouseover=i;f.dd.onmouseout=j}function i(){if(k){clearTimeout(k);return}if(!f.dd){m()}var o=f.getPos(l);f.dd.style.top=(Math.max(f.wHeight(),document.body.offsetHeight)-o[1]>248?o[1]+l.offsetHeight:o[1]-248)+"px";f.dd.style.left=(document.body.offsetWidth-o[0]>250-l.offsetWidth?o[0]:o[0]-250+l.offsetWidth)+"px";f.dd.style.display="block"}function j(){k=setTimeout(n,500)}function n(){k=0;f.dd.style.display="none"}var k=0;l.onclick=f.showAll;l.onmouseover=i;l.onmouseout=j},buildPanel:function(w){function s(p,z,i){var A=document.createElement("a");A.href="http://translateTH.IS/";A.title=z;A.target="_blank";A.innerHTML=p;if(i){A.style.cssFloat="right";A.style.styleFloat="right"}k.appendChild(A)}var t='<a href="http://translateTH.IS/" title="';if(w){var x=f.theDD,l=f.o.ddLangs,u=2,m=0}else{var x=f.theAll,l=f.o.allLangs,u=4,m="5px"}var j=document.createElement("div");j.className="ttb-panel";j.innerHTML='<div style="background:#EEE;border-bottom:1px solid #DDD;padding:4px 5px;">'+f.o.panelText+'</div><div style="padding:5px 0 '+m+' 5px;"></div><div style="background:#EEE;border-top:1px solid #DDD;font-size:10px;padding:1px 5px;"></div>';document.body.appendChild(j);var o=j.childNodes[1],r=[],k=j.childNodes[2];for(var n=0;n<u;n++){r[n]=document.createElement("div");r[n].className="ttb-column";o.appendChild(r[n])}var y=0;for(var n=0;n<l.length;n++){var q=f.buildFlag(l[n]);if(n>=l.length/u*(y+1)){y++}r[y].appendChild(q);if(w){f.theDD.push(q)}else{f.theAll.push(q)}q.onclick=function(p){f.prev(p);var i=f.getTar(this);f.flagClick(p,i,x,l)}}s("TranslateThis Button","Get your own TranslateThis Button",!w);if(!w){s("What's This?","What is the TranslateThis Button?",0)}var v=document.createElement("a");v.style.cursor="pointer";if(w){v.className="ttb-more";v.innerHTML=f.o.moreText;v.onclick=f.showAll}else{v.className="ttb-close";if(f.o.noImg){v.innerHTML="X"}else{v.style.backgroundImage='url("'+f.o.bgImg+'")';v.style.backgroundPosition="0 -624px"}v.title="Close";v.onclick=f.hideAll}o.appendChild(v);f.appendClear(o,0);return j},appendClear:function(k,j){var i=document.createElement("div");i.style.margin="0";i.style.padding="0";if(j){i.style.width="100%";i.style.height="1px"}else{i.style.clear="both"}k.appendChild(i)},getStyle:function(j,i){if(j.currentStyle){var k=j.currentStyle[i]}else{if(window.getComputedStyle){var k=document.defaultView.getComputedStyle(j,null).getPropertyValue(i)}}return k},getPos:function(i){var j=curtop=0;if(i.offsetParent){do{j+=i.offsetLeft;curtop+=i.offsetTop}while(i=i.offsetParent);return[j,curtop]}},getTar:function(i){if(i.tagName!="A"){i=i.parentNode}return i},flagClick:function(n,j,l,m){function o(r,q){for(var p=0;p<q.length;p++){if(r==q[p]){return p}}}f.hideAll(n);var k=o(j,l);f.trans(m[k])},showOL:function(){function j(){var k=document.createElement("div");k.className="ttb-overlay";document.body.appendChild(k);k.onclick=function(l){f.hideAll(l);f.hideOL();if(f.busy){f.tr.style.display="none"}};window.onresize=function(l){f.resize=setTimeout(i,80)};return k}function i(){if(!f.olShow){return}var m=document,l=Math.max(Math.max(m.body.scrollWidth,m.documentElement.scrollWidth),Math.max(m.body.offsetWidth,m.documentElement.offsetWidth),Math.max(m.body.clientWidth,m.documentElement.clientWidth)),k=Math.max(Math.max(m.body.scrollHeight,m.documentElement.scrollHeight),Math.max(m.body.offsetHeight,m.documentElement.offsetHeight),Math.max(m.body.clientHeight,m.documentElement.clientHeight));f.ol.style.width=l+"px";f.ol.style.height=k+"px"}f.olShow=1;if(!f.ol){f.ol=j()}i();f.ol.style.display="block";if(f.dd){f.dd.style.display="none"}},hideOL:function(){f.ol.style.display="none";f.olShow=0},showAll:function(j){function i(){var k=f.buildPanel(0);k.style.width="488px";return k}f.prev(j);f.showOL();if(!f.all){f.all=i()}f.centerXY(f.all,244,190);f.all.style.display="block"},hideAll:function(i){f.prev(i);if(!f.all){return}f.all.style.display="none";f.hideOL()},centerXY:function(l,k,j){var i=0,m=0;if(typeof(window.pageYOffset)=="number"){m=window.pageYOffset;i=window.pageXOffset}else{if(document.body&&(document.body.scrollLeft||document.body.scrollTop)){m=document.body.scrollTop;i=document.body.scrollLeft}else{if(document.documentElement&&(document.documentElement.scrollLeft||document.documentElement.scrollTop)){m=document.documentElement.scrollTop;i=document.documentElement.scrollLeft}}}i+=(f.wWidth()/2)-k;m+=(f.wHeight()/2)-j;l.style.top=m+"px";l.style.left=i+"px"},wHeight:function(){return window.innerHeight?window.innerHeight:document.documentElement.clientHeight?document.documentElement.clientHeight:document.body.clientHeight},wWidth:function(){return window.innerWidth?window.innerWidth:document.documentElement.clientWidth?document.documentElement.clientWidth:document.body.clientWidth},remove:function(i){i.parentNode.removeChild(i)},setCookie:function(j,k){var i=new Date();i.setTime(i.getTime()+k*8640000);document.cookie=f.o.cookie+"="+j+"; expires="+i.toGMTString()+"; path=/"},getCookie:function(){var l=f.o.cookie+"=",j=document.cookie.split(";");for(var k=0;k<j.length;k++){var m=j[k];while(m.charAt(0)==" "){m=m.substring(1,m.length)}if(m.indexOf(l)==0){return m.substring(l.length,m.length)}}return null},report:function(k){if(f.o.GA&&k!="init"&&typeof pageTracker!="undefined"){pageTracker._trackPageview("TranslateThis-"+k)}if("https:"==document.location.protocol){return}var i=new Image();i.src="http://translateth.is/translate.gif?x="+k;document.body.appendChild(i);var j=setInterval(function(){if(i.complete){clearInterval(j);f.remove(i)}},90)}};var g=g||[];g.wrapper=g.wrapper||"translate-this";g.scope=g.scope||false;g.bgImg=g.bgImg||"http://x.translateth.is/tt-sprite2.png";g.fromLang=g.fromLang||"";g.flags=g.flags||[];g.ddLangs=g.ddLangs||["fr","es","ar","zh-CN","ko","it","cs","iw","de","pt-PT","ru","ja","vi","el","hi","tr"];g.imgMap=g.imgMap||{af:10,sq:11,ar:6,be:12,bg:13,ca:50,"zh-CN":7,"zh-TW":14,hr:15,cs:16,da:17,nl:18,en:19,et:21,fi:22,fr:0,gl:51,de:1,el:23,iw:24,hi:25,hu:26,is:27,id:28,ga:29,it:4,ja:8,ko:9,lv:30,lt:31,mk:32,ms:33,mt:34,no:35,fa:36,pl:37,"pt-PT":3,ro:38,ru:5,sr:39,sk:40,sl:41,es:2,sw:42,sv:43,tl:44,th:45,tr:46,uk:47,vi:48,cy:49,yi:24};if(typeof g.allLangs=="undefined"){g.allLangs=[];for(var d in g.imgMap){g.allLangs.push(d)}}g.noBtn=g.noBtn||false;g.btnImg=g.btnImg||"http://x.translateth.is/tt-btn1.png";g.btnWidth=g.btnWidth||180;g.btnHeight=g.btnHeight||18;g.noImg=g.noImg||false;g.imgHeight=g.imgHeight||12;g.imgWidth=g.imgWidth||18;g.maxLength=g.maxLength||1000;g.reparse=g.reparse||false;g.onLoad=g.onLoad||null;g.onClick=g.onClick||null;g.onComplete=g.onComplete||null;g.GA=g.GA||false;g.cookie=typeof g.cookie!="undefined"?g.cookie:"tt-lang";g.undoText=g.undoText||"Undo &raquo;";g.panelText=g.panelText||"Translate Into:";g.moreText=g.moreText||"36 More Languages &raquo;";g.busyText=g.busyText||"Translating page...";g.cancelText=g.cancelText||"cancel";g.doneText=g.doneText||"This page translated by the";f.o=g;var b=google.language.Languages;for(d in b){var e=b[d],h=d.replace("_"," ").toLowerCase();h=h.charAt(0).toUpperCase()+h.substr(1,h.length);f.langs[e]=h}f.langs["zh-CN"]="Chinese";f.langs["zh-TW"]="Chinese (trad.)";var c=(window.onload)?window.onload:function(){};window.onload=function(){c();new f.build()}}google.load("language","1");window.TranslateThis=a})();