if(navigator.userAgent.search(/Firefox/)>=0){
// "wbr"-edition of Nasty kludgy Soft-hyphen hack
// by chris@cvogt.org, 13/07/05
// largely based on v0.1 by yoz@yoz.com, 17/01/05

// abstract:

// Nasty kludgy Soft-hyphen hack is a little javascript that provides a 
// simple workaround for mozilla firefox' lack of support for the &shy;-entities


// note on the "wbr"-edition":

// The "wbr"-edition claims to be more accurate than the v0.1 by yoz in
// detecting if a word break is needed. v0.1 by yoz detect's needed word 
// breaks by putting "- " inside the word with the space character causing
// firefox to make a linebreak if needed (which is afterwards checked out in
// javascript). In certain cases this linebreak may be caused by "- " which also
// use up space as they are additional characters. So the "wbr"-edition puts 
// "<wbr />" inside the word instead which also causes a wordbreak if needed
// without the space overhead of the two chars "- ".
// The disadvantage of using <wbr /> is, that it's not a valid tag in xhtml 1.0
// strict, though this error won't be detected by actual validators because
// the tag is generated in the javascript.
// Remember that the "wbr"-edition is just a quickly created fix for making v0.1
// more accurate what can probably be solved in a better way. Please send 
// suggestions on how to get rid of the "wbr"-tag but keeping the accuracy to 
// chris@cvogt.org


// inclusion/usage:

// For easy and xhtml 1.0 strict compatible usage of the script put
// <script src="shy-wbr.js" type="text/javascript">
// </script>
// <script type="text/javascript">
//	window.onresize = shyreflow;
// </script>
// into your html-head and add the onload event to your body-tag:
// <body onload="doShyTags();shyreflow();">
// If needed you can add more events on which shyreflow should be executed for
// recalculating the needed word-breaks. Please send me suggestions on how to
// execute shyreflow in case the user changes zoom of the page (either via menu
// or via strg+mouse-wheel) to chris@cvogt.org.


// notice:

// At present, soft hyphens are only dealt with when surrounded by
// characters matched by the "\w" regexp character class.
// If you'd like to fix this, please edit the regexp at the start
// of doShyTags() and send your edits to yoz@yoz.com.


var doneshytags = false; // set to true once we've rebuilt the HTML
var counter = 0; // used for generating numeric IDs
var shys = new Array(); // used for storing refs to our Shy objects
var shyids = new Array(); // used for storing num IDs to Shy elements

// replacer() is called by the replace call in doShyTags()
// it takes words that use &shy; and breaks them into a number of SPAN
// elements, while storing the IDs of the shy elements
function replacer(s, n, full) {

	// split on &shy;
	var splitword = s.split(/\xAD/i);
	
	// now wrap everything in new SPAN elements, keeping track of 
	// used IDs
	var newword = "";
	for (i=0;i<splitword.length;i++)
	{
		if (newword != "") // if we're in the middle of a word
		{
			// add a shy element
			newword += '<span id="shy'+(++counter)+'">- </span>';
			shyids.push(counter);
		}
		
		newword += '<span id="shy'+ (++counter) + '">' + splitword[i] + '</span>';
	}

	return newword;	
	
}

// doShyTags() locates all &shy; entities and breaks the surrounding word into
// a set of separated referenceable elements 
// then creates and stores Shy objects for each &shy; element

function doShyTags() {
	
	// NOTE: ANY ADDED SUPPORT FOR FOREIGN CHARACTERS SHOULD GO
	// IN THE REGEXP BELOW, ADDED TO BOTH "[..]" CLASSES
	var wordre = /[\w]+\xAD[\w\xAD]+/gi; // RE to match words with &shy;
	
	// replace all words using &shy; with munged equivalents
	
	document.body.innerHTML = document.body.innerHTML.replace(wordre,replacer);
	
	// create Shy objects for each shy element we created
	for(i=0;i<shyids.length;i++)
	{
		shys.push(new Shy(shyids[i]));
	}
	
	doneshytags = true;
	
	// and we're done
	
}

// constructor for Shy object.
// Is given a numeric ID $n, looks for shy element named "shy$x" in the document
// then creates an object referencing that element's style object and the
// style objects of the text elements on either side

function Shy(n) {
	this.id = n;
	this.style = document.getElementById("shy"+n).style;
	this.next = document.getElementById("shy"+(n+1));
	this.prev = document.getElementById("shy"+(n-1));
	return this;
}

// shyreflow() - goes through the document checking and setting visibilities
// on shy elements. It does this by checking whether the text nodes before and
// after are on the same line; if so, the shy should not be visible

function shyreflow() {
	
	// to start: make all Shy objects visible and replace the content by <wbr />
	for (i=0;i<shys.length;i++)
	{
		shys[i].style.display = "inline";
		document.getElementById("shy"+shys[i].id).innerHTML = '<wbr />';
	}
	// now check heights of text elements on either side. If the same,
	// make the shy invisible
	for (i=0;i<shys.length;i++)
	{
		
		//alert("Left: "+ shys[i].prev.offsetTop +
		//			", right:" + shys[i].next.offsetTop);
		
		// word parts on same height
		if (shys[i].next.offsetTop == shys[i].prev.offsetTop) 
		{
			// thus hide Shy object
			shys[i].style.display = "none";
		}
		// word parts are on different hide <=> word break is needed
		else
		{
			// make the Shy object be "- "
			document.getElementById("shy"+shys[i].id).innerHTML = '- ';
			
			//if the appended "- " makes the first word part break in front of the second
			if (shys[i].next.offsetTop == shys[i].prev.offsetTop)
			{
				// then hide the Shy object thus the whole word is broken to the new line
				shys[i].style.display = "none";
			}
		}
	}
}


}