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