LGS_COOKIE="LANG_SWITCHER_PREFERED_LANG";LGS_COOKIE_EXPIRE=100000;if(!Array.indexOf){Array.prototype.indexOf=function(obj){for(var i=0;i<this.length;i++){if(this[i]==obj){return i}}return-1}}function replace_rec(node,search,replace){if(node.nodeValue!=null){try{node.nodeValue=node.nodeValue.replace(search,replace)}catch(e){}}var nodes=node.childNodes;if(nodes)for(var i=0;i<nodes.length;i++){replace_rec(nodes[i],search,replace)}if(node.nodeType==1){var nodes=node.attributes;if(nodes)for(var i=0;i<nodes.length;i++){replace_rec(nodes[i],search,replace)}}}jQuery.fn.replace=function(search,replace){return jQuery(this).each(function(){replace_rec(this,search,replace)})};gLangButtons=new Array;gLangButtonId=0;function install_switch(placeholder,targets,template){var nodes=jQuery("[lang]",targets);var list=jQuery.map(nodes,function(node){return jQuery(node).attr('lang')});uniques=new Object;for(var i=0;i<list.length;i++){uniques[list[i]]=list[i]}list=new Array;for(var val in uniques){list.push(val)}if(list.length<=1)return;var buttons=new Array;jQuery.map(list,function(lang){var button=jQuery(template).clone().replace('jQuerylang',lang);button.attr("id","lang-"+gLangButtonId+"-"+lang);jQuery(button).click(function(){var ids=jQuery(this).attr('id').split('-');var lang_id=ids[1];var lang=ids[2];switch_to(lang_id,lang);if(jQuery.cookie){jQuery.cookie(LGS_COOKIE,lang,{expires:LGS_COOKIE_EXPIRE})}return false});buttons.push(button)});jQuery(buttons).each(function(){jQuery(placeholder).prepend(this)});gLangButtons[gLangButtonId]={buttons:buttons,targets:targets};var lang;if((jQuery.cookie)&&(lang=jQuery.cookie(LGS_COOKIE))&&(list.indexOf(lang)!=-1)){switch_to(gLangButtonId,lang)}else{switch_to(gLangButtonId,list[0])}gLangButtonId++}function switch_to(id,lang){var targets=gLangButtons[id].targets;var buttons=gLangButtons[id].buttons;jQuery("[lang]",targets).each(function(){if(lang==jQuery(this).attr("lang")){jQuery(this).show()}else{jQuery(this).hide()}});jQuery(buttons).each(function(){var butLang=jQuery(this).attr("id").split("-")[2];if(lang==butLang){jQuery(this).removeClass("off").addClass("on")}else{jQuery(this).removeClass("on").addClass("off")}})}

