
function handleError()
{
	return true;
}
window.onerror = handleError;

function hasFlash()
{
  return true;
  /*var agt=navigator.userAgent.toLowerCase();
  var ie  = (agt.indexOf("msie") != -1);
  var ns  = (navigator.appName.indexOf("Netscape") != -1);
  var win = ((agt.indexOf("win")!=-1) || (agt.indexOf("32bit")!=-1));
  var mac = (agt.indexOf("mac")!=-1);
  
  if (ie && win) {	pluginlist = detectIE("Adobe.SVGCtl","SVG Viewer") + detectIE("SWCtl.SWCtl.1","Shockwave Director") + detectIE("ShockwaveFlash.ShockwaveFlash.1","Shockwave Flash") + detectIE("rmocx.RealPlayer G2 Control.1","RealPlayer") + detectIE("QuickTimeCheckObject.QuickTimeCheck.1","QuickTime") + detectIE("MediaPlayer.MediaPlayer.1","Windows Media Player") + detectIE("PDF.PdfCtrl.5","Acrobat Reader"); }
  if (ns || !win) {
  		nse = ""; for (var i=0;i<navigator.mimeTypes.length;i++) nse += navigator.mimeTypes[i].type.toLowerCase();
  		pluginlist = detectNS("image/svg-xml","SVG Viewer") + detectNS("application/x-director","Shockwave Director") + detectNS("application/x-shockwave-flash","Shockwave Flash") + detectNS("audio/x-pn-realaudio-plugin","RealPlayer") + detectNS("video/quicktime","QuickTime") + detectNS("application/x-mplayer2","Windows Media Player") + detectNS("application/pdf","Acrobat Reader");
  }
  
  function detectIE(ClassID,name) { result = false; document.write('<SCRIPT LANGUAGE=VBScript>\n on error resume next \n result = IsObject(CreateObject("' + ClassID + '"))</SCR'+'IPT>\n'); if (result) return name+','; else return ''; }
  function detectNS(ClassID,name) { n = ""; if (nse.indexOf(ClassID) != -1) if (navigator.mimeTypes[ClassID].enabledPlugin != null) n = name+","; return n; }
  
  pluginlist += navigator.javaEnabled() ? "Java," : "";
  if (pluginlist.length > 0) pluginlist = pluginlist.substring(0,pluginlist.length-1);
  
  //Beispiel - "Flash"
  if (pluginlist.indexOf("Flash")!=-1)
    return true;
    
  return false;*/
}


function replace(string,text,by) {
// Replaces text with by in string
    var strLength = string.length, txtLength = text.length;
    if ((strLength == 0) || (txtLength == 0)) return string;

    var i = string.indexOf(text);
    if ((!i) && (text != string.substring(0,txtLength))) return string;
    if (i == -1) return string;

    var newstr = string.substring(0,i) + by;

    if (i+txtLength < strLength)
        newstr += replace(string.substring(i+txtLength,strLength),text,by);

    return newstr;
}


function convert2(text) {
    text = replace(text,'%C4','&Auml;');	
    text = replace(text,'%D6','&Ouml;');
    text = replace(text,'%DC','&Uuml;');	
    text = replace(text,'%DF','&szlig;');	
    text = replace(text,'%E4','&auml;');	
    text = replace(text,'%E9','&eacute;');
    text = replace(text,'%F6','&ouml;');
    text = replace(text,'%FC','&uuml;');		
	return text;
}

function getLineCount(str,htmltag){
  switch(htmltag){
    case "h1":
      return 1;
    break;
    case "h2":
      //zeilenumbruch nach etwa 20 zeichen
      zeichen = 20;
      len = str.length;
      if(len <= zeichen){
        return 1;
      }
      
      rest = len % zeichen;
      return ((len - rest) / zeichen) + 1;
    break;
    case "h3":
      zeichen = 23;
      len = str.length;
      if(len <= zeichen){
        return 1;
      }
      
      rest = len % zeichen;
      zahl = ((len - rest) / zeichen);
      return zahl + 1;
    break;
  }
  return 1;
}

function getInnerHTML(obj){
  delete(str);
  str = "";
  
  kinder = obj.childNodes[0].childNodes;
  for(var i=0;i<kinder.length;i++){
    
    typ = kinder[i].nodeType;
    nam = kinder[i].nodeName;
    inn = kinder[i].innerHTML;
    val = kinder[i].nodeValue;

//    alert(i+":"+typ+", "+nam+","+val);
    
    switch(typ){
      case 1:
        in1 = kinder[i].innerHTML;
        if(nam == "FONT"){
          att = kinder[i].getAttribute("color");
          tmp ='<font color="'+att+'">'+in1+'</font>';
          
          stil = kinder[i].style.color;
          if(stil){
            if(stil.indexOf("rgb") != -1){
              //Firefox: liegt vor im format rgb(255,255,0)
              tmp = stil.split("(");
              tmp2 = tmp[1].split(")");
              werte = tmp2[0].split(",");
              stil = "#"+RGBtoHex(werte[0],werte[1],werte[2]);
            }
            tmp = '<font color="'+stil+'">'+in1+'</font>';
          }
          str+=tmp;
        }
        else
          str+="<"+nam+">"+in1+"</"+nam+">";
      break; 
      
      case 2:
      
      break;

      case 3:
        str+=val;
      break;

    }
  }
  return str;
}
//<P>DAS <FONT COLOR="#FF9900">SONNEN</FONT>REICH <FONT COLOR="#CC99FF">HEHEHE</FONT></P>

function RGBtoHex(R,G,B){
  return toHex(R)+toHex(G)+toHex(B);
}
function toHex(N) {
 if (N==null) return "00";
 N=parseInt(N); if (N==0 || isNaN(N)) return "00";
 N=Math.max(0,N); N=Math.min(N,255); N=Math.round(N);
 return "0123456789ABCDEF".charAt((N-N%16)/16)
      + "0123456789ABCDEF".charAt(N%16);
}


function getInnerHTML2(obj){
  delete(stringi);
  delete(kinder1);
  delete(j);
  stringi = "";
  kinder1 = obj.childNodes;
  for(j=0;j<kinder1.length;j++){
    kind = kinder1[i];
    tmp = "";
    typ1 = kind.nodeType;
    alert("typ:"+typ1);
    nam1 = kind.nodeName;
    val1 = kind.nodeValue;
    if(typ1 == 1){
      texto = "";
      if(kinder1[i+1].nodeType == 3){
        texto = kinder1[i+1].nodeValue;
        i++;
      }
      tmp="<"+nam1+">"+texto+"</"+nam1+">";
    }
    else if(typ1 == 3){
      tmp = val1;
    }
    stringi+=tmp;
  }
  return stringi;
}




function replaceHeading(htmltag, datei) {

	for(var i = 0; i < document.getElementsByTagName(htmltag).length; i++) {

	  usedatei = datei;
	  css = "";
		//alert(document.getElementsByTagName("H2")[i].outerHTML);
		//alert(document.getElementsByTagName("H2")[i].childNodes.length);
		myValue = document.getElementsByTagName(htmltag)[i].innerHTML;
	  myTag = document.getElementsByTagName(htmltag)[i];
	  f = document.getElementsByTagName(htmltag)[i].innerHTML.toUpperCase();
	  if(htmltag=="h1" && document.getElementsByTagName(htmltag)[i].className.indexOf("flash") != -1 && f.indexOf("FONT") != -1){
  	  myValue = getInnerHTML(myTag);
  	}

		var myLinki = document.getElementsByTagName(htmltag)[i].id;

		if (myValue != undefined) {
      //return;
      if(htmltag=="h1" && document.getElementsByTagName(htmltag)[i].className.indexOf("flash") == -1)
        return;
      if(htmltag=="h2" && document.getElementsByTagName(htmltag)[i].className.indexOf("flash") == -1)
        return;

			//if (htmltag=="h1" || document.getElementsByTagName(htmltag)[i].className.indexOf("flash") != -1) {
			
				myObj = document.getElementsByTagName(htmltag)[i];
				
				myValue = myValue.replace(/<p>/gi,"");
				myValue = myValue.replace(/<br>/gi,"");
				myValue = myValue.replace(/<\/p>/gi,"");
				myValue = myValue.replace(/<i>/gi,"");
				myValue = myValue.replace(/<\/i>/gi,"");
				myValue = myValue.replace(/&amp;/gi,"+%26+");

				myParent = myObj.parentNode;
				myValue = myValue.replace(/"/gi,"'");
				
				myValue= convert2(myValue);
				//alert(myValue);
			  count = getLineCount(myValue,htmltag);
				width = myObj.offsetWidth + 10;
				height = (myObj.offsetHeight);
				theHeight = height;

				// FLASH AUSGABE
				
				var pfad = basepath+"media/";
				var stil = "";
				var myLinki= "";
				var addValues = "";
				var js_stuff = "";
				myLinki = 'javascript:void(0)';
				myFlash = ('<object '+js_stuff+' style="'+css+'" classid="clsid:d27cdb6e-ae6d'
				 +'-11cf-96b8-444553540000" codebase="https://fpdownlo'
				 +'ad.macromedia.com/pub/shockwave/cabs/flash/swflash'
				 +'.cab#version=6,0,0,0" width="' + width + '" height="' + height + '" id="'
				 +'boxtitle" align="middle"> <param name="allowScrip'
				 +'tAccess" value="sameDomain" /> <param name="wmode" value="transparent" /> <param name="movie'
				 +'" value="'+pfad+usedatei+'" /><param name="FlashVars" value="title=' + myValue + addValues + '" /> <param name="quality" v'
				 +'alue="high" /> <param name="scale" value="noscale' 
				 +'" /> <param name="salign" value="lt" /> <param n'
				 +'ame="bgcolor" value="#FFFFFF" /> <embed src="'+pfad+usedatei
				 +'" FlashVars="title=' + myValue + addValues + '" quality="high" wmode="transparent" scale="noscale" salign="l'
				 +'t" bgcolor="#FFFFFF" width="' + width + '" height="' + height + '" name='
				 +'"boxtitle" align="middle" allowScriptAccess="sameD'
				 +'omain" type="application/x-shockwave-flash" plugin'
				 +'spage="http://www.macromedia.com/go/getflashplayer'
				 +'" /> </object>');
				// FLASH AUSGABE
				replaceDiv = document.createElement('div');
				replaceDiv.innerHTML = myFlash;
				replaceDiv.style.margin = "0px 0px 0px 0px";
				replaceDiv.style.padding = "0px 0px 0px 0px";
				
				myParent.replaceChild(replaceDiv, myObj);
				
				if(htmltag == "h3"){
				  myParent.style.height = theHeight+"px";
				}
				
				i--;
				
			//}
		}
	
	}
	
}

if (hasFlash() && document.getElementsByTagName) {
	replaceHeading("h1", "header.swf");
	replaceHeading("h2", "header2.swf");
	//replaceHeading("h3", "gedicht.swf");
}