/**************** Preamble ****************/
// This script is licensed under the creative commons license
// Attribution-Share Alike 2.5 Switzerland
// You are free to share and to remix this work under the 
// following conditions: Attribution and Share-Alike
// See http://creativecommons.org/licenses/by-sa/2.5/ch/deed.en
// Thus you are free to use it  commercial purposes.
//
// Dieses Script steht unter der Creative Commons-Lizenz
// Attribution-Share Alike 2.5 Switzerland
// Sie dürfen das Werk vervielfältigen, verbreiten und öffentlich zugänglich machen,
// sowie Bearbeitungen des Werkes anfertigen
// Zu den folgenden Bedingungen:
// Namensnennung und Weitergabe unter gleichen Bedingungen.
// Siehe http://creativecommons.org/licenses/by-sa/2.5/ch/
// Somit sind sie frei, das Script für kommerzielle Zwecke zu nutzen
//
// Mathias Nater, Zürich, 2008
// mnater at mac dot com
/**************** Preamble ****************/
var Hyphenator=(function(){var SUPPORTEDLANG={'de':true,'en':true,'fr':true,'nl':true};var LANGUAGEHINT='Deutsch: de\tEnglish: en\tFran%E7ais: fr\tNederlands: nl';var PROMPTERSTRINGS={'de':'Die Sprache dieser Webseite konnte nicht automatisch bestimmt werden. Bitte Sprache angeben: \n\n'+LANGUAGEHINT,'en':'The language of this website could not be determined automatically. Please indicate main language: \n\n'+LANGUAGEHINT,'fr':'La langue de cette site ne pouvait pas %EAtre d%E9termin%E9e automatiquement. Veuillez indiquer une langue: \n\n'+LANGUAGEHINT,'nl':'De taal van deze website kan niet automatisch worden bepaald. Geef de hoofdtaal op: \n\n'+LANGUAGEHINT};var BASEPATH=function(){var s=document.getElementsByTagName('script'),i=0,p,t;while(t=s[i++].src){p=t.indexOf('Hyphenator.js');if(p!=-1){return t.substring(0,p)}}return'http://hyphenator.googlecode.com/svn/trunk/'}();var DONTHYPHENATE={'script':true,'code':true,'pre':true,'img':true,'br':true,'samp':true,'kbd':true,'var':true,'abbr':true,'acronym':true,'sub':true,'sup':true,'button':true,'option':true,'label':true};var hyphenation={};var enableRemoteLoading=true;var hyphenateclass='hyphenate';var hyphen=String.fromCharCode(173);var urlhyphen=_createZeroWidthSpace();var min=6;var bookmarklet=false;var patternsloaded={};var preparestate=0;var mainlanguage=null;var url='(\\w*:\/\/)((\\w*:)?(\\w*)@)?([\\w\.]*)?(:\\d*)?(\/[\\w#!:.?+=&%@!\-]*)*';var mail='[\\w-\\.]+@[\\w\\.]+';var urlRE=new RegExp(url,'i');var mailRE=new RegExp(mail,'i');var zerowidthspace='';function _createZeroWidthSpace(){var ua=navigator.userAgent.toLowerCase();if(ua.indexOf('firefox')!=-1||ua.indexOf('msie 7')!=-1){zerowidthspace=String.fromCharCode(8203)}return zerowidthspace}function _checkIfBookmarklet(){var loc=null;var jsArray=document.getElementsByTagName('script');for(var i=0,l=jsArray.length;i<l;i++){if(!!jsArray[i].getAttribute('src')){loc=jsArray[i].getAttribute('src')}if(!loc){continue}else if(loc.indexOf('Hyphenator.js?bm=true')!=-1){bookmarklet=true}}};function _log(msg){if(window.console){window.console.log(msg)}else if(window.opera){window.opera.postError(msg)}else{}}function _autoSetMainLanguage(){var el=document.getElementsByTagName('html')[0];mainlanguage=_getLang(el);if(!mainlanguage){var m=document.getElementsByTagName('meta');for(var i=0;i<m.length;i++){if(!!m[i].getAttribute('http-equiv')&&(m[i].getAttribute('http-equiv')=='content-language')){mainlanguage=m[i].getAttribute('content').substring(0,2)}if(!!m[i].getAttribute('name')&&(m[i].getAttribute('name')=='DC.Language')){mainlanguage=m[i].getAttribute('content').substring(0,2)}if(!!m[i].getAttribute('name')&&(m[i].getAttribute('name')=='language')){mainlanguage=m[i].getAttribute('content').substring(0,2)}}}if(!mainlanguage){var text='';var ul=(navigator.language)?navigator.language:navigator.userLanguage;ul=ul.substring(0,2);if(SUPPORTEDLANG[ul]){text=PROMPTERSTRINGS[ul]}else{text=PROMPTERSTRINGS.en}var lang=window.prompt(unescape(text),ul);if(SUPPORTEDLANG[lang]){mainlanguage=lang}}};function _getLang(el){if(!!el.getAttribute('lang')){return el.getAttribute('lang').substring(0,2)}try{if(!!el.getAttribute('xml:lang')){return el.getAttribute('xml:lang').substring(0,2)}}catch(ex){}if(mainlanguage){return mainlanguage}return null};function _loadPatterns(lang){if(SUPPORTEDLANG[lang]&&!patternsloaded[lang]){var url=BASEPATH+'patterns/'+lang+'.js';if(lang=="de"){url=BASEPATH+'patterns/newpatterns/de.js'}}else{return}if(document.createElement){var head=document.getElementsByTagName('head').item(0);var script=document.createElement('script');script.src=url;script.type='text/javascript';head.appendChild(script)}};function _runHyphenation(){var body=document.getElementsByTagName('body')[0];if(Hyphenator.isBookmarklet()){Hyphenator.hyphenateElement(body)}else{if(document.getElementsByClassName){var elements=document.getElementsByClassName(hyphenateclass);for(var i=0,l=elements.length;i<l;i++){Hyphenator.hyphenateElement(elements[i])}}else{var elements=body.getElementsByTagName('*');for(var i=0,l=elements.length;i<l;i++){if(elements[i].className.indexOf(hyphenateclass)!=-1){Hyphenator.hyphenateElement(elements[i])}}}}};function _runOnContentLoaded(){(function(i){var u=navigator.userAgent;var e=/*@cc_on!@*/false;var st=setTimeout;if(/webkit/i.test(u)){st(function(){var dr=document.readyState;if(dr=="loaded"||dr=="complete"){i()}else{st(arguments.callee,10)}},10)}else if((/mozilla/i.test(u)&&!/(compati)/.test(u))||(/opera/i.test(u))){document.addEventListener("DOMContentLoaded",i,false)}else if(e){(function(){var t=document.createElement('doc:rdy');try{t.doScroll('left');i();t=null}catch(e){st(arguments.callee,0)}})()}else{window.onload=i}})(Hyphenator.hyphenateDocument)};function _autoinit(){for(var lang in SUPPORTEDLANG){patternsloaded[lang]=false}_autoSetMainLanguage();_createZeroWidthSpace();_checkIfBookmarklet()};_autoinit();return{leftmin:{},rightmin:{},shortestPattern:{},longestPattern:{},specialChars:{},patterns:{},run:function(){_runOnContentLoaded()},addExceptions:function(words){var w=words.split(',');for(var i=0,l=w.length;i<l;i++){var key=w[i].replace(/-/g,'');if(!hyphenation[key]){hyphenation[key]=w[i]}}},setClassName:function(str){hyphenateclass=str||'hyphenate'},setMinWordLength:function(mymin){min=mymin||6},setHyphenChar:function(str){hyphen=str||String.fromCharCode(173)},setUrlHyphenChar:function(str){urlhyphen=str||_createZeroWidthSpace()},setRemoteLoading:function(bool){enableRemoteLoading=bool},isPatternLoaded:function(lang){return patternsloaded[lang]},updatePatternsLoadState:function(lang,bool){patternsloaded[lang]=bool},isBookmarklet:function(){return bookmarklet},prepare:function(){preparestate=1;var doclanguages={};doclanguages[mainlanguage]=true;var elements=document.getElementsByTagName('body')[0].getElementsByTagName('*');var lang=null;for(var i=0,l=elements.length;i<l;i++){if(lang=_getLang(elements[i])){if(SUPPORTEDLANG[lang]){doclanguages[lang]=true}else{}}}for(lang in doclanguages){_loadPatterns(lang)}interval=window.setInterval(function(){finishedLoading=false;for(lang in doclanguages){if(!patternsloaded[lang]){finishedLoading=false;break}else{finishedLoading=true}}if(finishedLoading){window.clearInterval(interval);preparestate=2}},100)},hyphenateDocument:function(){if(preparestate!=2&&enableRemoteLoading){if(preparestate==0){Hyphenator.prepare()}var interval=window.setInterval(function(){if(preparestate==2){window.clearInterval(interval);_runHyphenation()}},10)}else{_runHyphenation()}},hyphenateElement:function(el,lang){if(el.className.indexOf("donthyphenate")!=-1){return}if(!lang){var lang=_getLang(el)}else{var newlang=_getLang(el);if(newlang!=lang){var lang=newlang}}var wrd='[\\w'+Hyphenator.specialChars[lang]+'@­-]{'+min+',}';var wrdRE=new RegExp(wrd,'i');function __hyphenate(word){if(urlRE.test(word)||mailRE.test(word)){return Hyphenator.hyphenateURL(word)}else{return Hyphenator.hyphenateWord(lang,word)}}var genRegExp=new RegExp('('+url+')|('+mail+')|('+wrd+')','gi');for(var i=0;(n=el.childNodes[i]);i++){if(n.nodeType==3&&n.data.length>=min){n.data=n.data.replace(genRegExp,__hyphenate)}else if(n.nodeType==1&&!DONTHYPHENATE[n.nodeName.toLowerCase()]){Hyphenator.hyphenateElement(n,lang)}}el.style.visibility='visible'},hyphenateWord:function(lang,word){if(word==''){return''}if(word.indexOf('­')!=-1){return word}if(hyphen=='&shy;'){hyphen=String.fromCharCode(173)}if(hyphenation[word]){return hyphenation[word].replace(/-/g,hyphen)}if(word.indexOf('-')!=-1){var parts=word.split('-');for(var i=0,l=parts.length;i<l;i++){parts[i]=Hyphenator.hyphenateWord(lang,parts[i])}return parts.join('-'+zerowidthspace)}var positions=[];var result=[];var w='_'+word.toLowerCase()+'_';var wl=w.length;var i=wl-2;do{positions[i]=0}while(i--);var s=wl-1;do{var maxl=wl-s;var window=w.substring(s);for(var l=Hyphenator.shortestPattern[lang];l<=maxl&&l<=Hyphenator.longestPattern[lang];l++){var part=window.substring(0,l);var values=null;if(Hyphenator.patterns[lang][part]!==undefined){values=Hyphenator.patterns[lang][part];var i=s-1;var v;for(var p=0,le=values.length;p<le;p++,i++){v=parseInt(values.charAt(p));if(v>positions[i]){positions[i]=v}}}}}while(s--)wl=word.length;for(i=1;i<wl;i++){if(!!(positions[i]&1)&&i>=Hyphenator.leftmin[lang]&&i<=word.length-Hyphenator.rightmin[lang]){result.push(word.substring(result.join('').length,i))}}result.push(word.substring(result.join('').length,i));return result.join(hyphen)},hyphenateURL:function(url){return url.replace(/([:\/\.\?#&_,;!@]+)/gi,'$&'+urlhyphen)}}})();if(Hyphenator.isBookmarklet()){Hyphenator.hyphenateDocument()}
