/**
 * sIFR injection wrapped by hack to 
 * remove percieved spaces after 
 * line breaks in Mozilla.
 * TODO: Fix with regular expressions!
 */
function sifrfix ( color ) {

	function inject () {
		sIFR.replaceElement( named ({
			sSelector:"body " + name, 
			sFlashSrc:"/Frontend/sIFR/klavika.swf", 
			sWmode:"transparent", 
			sColor:color, 
			sLinkColor:"#000000", 
			sBgColor:"#FFFFFF", 
			sHoverColor:"#CCCCCC", 
			nPaddingTop:0, 
			nPaddingBottom:0, 
			sFlashVars:"textalign=left&amp;offsetTop=0" 
		}));
	}

	function fix () {

		var elements = document.getElementsByTagName ( name );
		var i = 0, element;
		var BR = document.all ? "<BR>" : "<br>";
		
		while ( element = elements [ i++ ]) {
			var markup = element.innerHTML;
			if ( markup.indexOf ( BR ) > 0 ) {
	 			while ( markup.indexOf ( BR + "\n " ) > 0 ) {
	 				markup = markup.replace ( BR + "\n ", BR + "\n" );
	 			}
	 			while ( markup.indexOf ( "\n" ) > 0 ) {
	 				markup = markup.replace ( "\n", "" );
	 			}
				var len = markup.length;
				if ( len >= 4 ) {
					var sub = markup.substring ( len - 4, len );
					if ( sub == BR ) {
						markup = markup.substring ( 0, len - 4 );
					}
					
				}
				element.innerHTML = markup;
			}
		}
	}
	
	var names = [ "h1" ], name = null;
	var j = 0;
	while ( name = names [ j ++ ]) {
		fix ( name );
	}
	j = 0;
	while ( name = names [ j ++ ]) {
		inject ( name );
	}
}

