function addbookmark(bookmarkurl, bookmarktitle){ 
if (document.all) 
window.external.AddFavorite(bookmarkurl,bookmarktitle) 
}

function focussetzen() {
  document.formular.nachricht.focus();
}
ACblur=true;
function setanswer(id, sort)
	{
	    vote_radio = document.getElementById("vote_radio");
	    selected = document.getElementById("selected_answer");
	    checkboxes = document.getElementsByName("pollanswer");
	    img = checkboxes[id];
	
	    for(i = 0; i < checkboxes.length; i++)
	        checkboxes[i].src = 'gfx/icons/poll_checkbox.gif';
	
	    vote_radio.value = sort;
	    selected.value = id;
	    img.src = 'gfx/icons/poll_checkbox_checked.gif';
	}
function AConblur()
  {
  	if (ACblur==true)
		{
      	this.AUSGABE.style.visibility = "hidden";
  		}
  }
function ACmove()
  {
  		this.className = "autocomplete_highlightedListItem";
  }
function ACout()
  {
  		this.className = "autocomplete_listItem";
  }
 function textsetzen(text)
 	{
	document.formular.EINGABE.value=text;
	this.AUSGABE.style.visibility = "hidden";
	}
function doAC(eingabe) 
	{
	var req;
	var url="sys/complete.php?query="+escape(eingabe);
	if (eingabe.length>0)
		{
		this.AUSGABE.style.visibility = "visible";
		}
	// branch for native XMLHttpRequest object
	if (window.XMLHttpRequest) 
		{
		req = new XMLHttpRequest();
		req.onreadystatechange=function()
			{
			if(req.readyState==4 && req.responseText)
				{
				if(req.responseText.charAt(0)=="<")
					{
					}else{
					eval(req.responseText)
					}
				}
			}
		req.open("GET", url, true);
		req.send(null);
		// branch for IE/Windows ActiveX version
		} else if (window.ActiveXObject) {
		req = new ActiveXObject("Microsoft.XMLHTTP");
		if (req) 
			{
			req.onreadystatechange=function()
				{
				if (req.readyState==4 && req.responseText)
					{
					if(req.responseText.charAt(0)=="<")
						{
						}else{
						eval(req.responseText);
						}
					}
				}
			req.open("GET", url, true);
			req.send();
			}
		}
	}

doAC.prototype.onTextBlur = function()
  {
      this.AutoComplete.onblur();
  }

doAC.prototype.onblur = function()
  {
      this.oDiv.style.visibility = "hidden";
  }

doAC.prototype.onTextChange = function()
  {
      this.AutoComplete.onchange();
  }

doAC.prototype.onchange = function()
  {
  var txt = this.oText.value;

  // count the number of strings that match the text-box value.
  var nCount = this.db.getCount(txt);

  // if a suitable number then show the popup-div
  if ( (this.nMaxSize == -1 ) || ((nCount < this.nMaxSize) && (nCount > 0)) )
  {
      // clear the popup div.
      while ( this.oDiv.hasChildNodes() )
      this.oDiv.removeChild(this.oDiv.firstChild);

      // get all the matching strings from the AutoCompleteDB
      var aStr = new Array();
      this.db.getStrings(txt, "", aStr);

      // add each string to the popup-div
      var i, n = aStr.length;
      for ( i = 0; i < n; i++ )
      {
          var oDiv = document.createElement('div');
          this.oDiv.appendChild(oDiv);
          oDiv.innerHTML = aStr[i];
          oDiv.onmousedown = AutoComplete.prototype.onDivMouseDown;
          oDiv.onmouseover = AutoComplete.prototype.onDivMouseOver;
          oDiv.onmouseout = AutoComplete.prototype.onDivMouseOut;
          oDiv.AutoComplete = this; 
      }
          this.oDiv.style.visibility = "visible";
      }
      else // hide the popup-div
     {
          this.oDiv.innerHTML = "";
          this.oDiv.style.visibility = "hidden";
      }
  }
doAC.prototype.onDivMouseDown = function()
    {
        // set the text-box value to the word
        this.AutoComplete.oText.value = this.innerHTML;
    }

doAC.prototype.onDivMouseOver = function()
    {
        // assumes the existence of a CSS style called AutoCompleteHighlight
        this.className = "AutoCompleteHighlight";
    }

doAC.prototype.onDivMouseOut = function()
    {
        // assumes the existence of a CSS style called AutoCompleteBackground
        this.className = "AutoCompleteBackground";
    } 

function getActiveText(selectedtext) { 
	commenttext = (document.all) ? document.selection.createRange().text : document.getSelection();
	if (selectedtext.createTextRange) {	
    	selectedtext.caretPos = document.selection.createRange().duplicate();	
	}
}
function zeichensetzen(aTag, eTag, formular, textfeld) 
	{
	var input = document.forms[''+formular+''].elements[''+textfeld+''];
  input.focus();
  
  /* für Internet Explorer */
  if(typeof document.selection != 'undefined') {
    /* Einfügen des Formatierungscodes */
    var range = document.selection.createRange();
    var insText = range.text;
    range.text = aTag + insText + eTag;
    /* Anpassen der Cursorposition */
    range = document.selection.createRange();
    if (insText.length == 0) {
      range.move('character', -eTag.length);
    } else {
      range.moveStart('character', aTag.length + insText.length + eTag.length);      
    }
    range.select();
  }
  /* für neuere auf Gecko basierende Browser */
  else if(typeof input.selectionStart != 'undefined')
  {
    /* Einfügen des Formatierungscodes */
    var start = input.selectionStart;
    var end = input.selectionEnd;
    var insText = input.value.substring(start, end);
    input.value = input.value.substr(0, start) + aTag + insText + eTag + input.value.substr(end);
    /* Anpassen der Cursorposition */
    var pos;
    if (insText.length == 0) {
      pos = start + aTag.length;
    } else {
      pos = start + aTag.length + insText.length + eTag.length;
    }
    input.selectionStart = pos;
    input.selectionEnd = pos;
  }
  /* für die übrigen Browser */
  else
  {
    /* Abfrage der Einfügeposition */
    var pos;
    var re = new RegExp('^[0-9]{0,3}$');
    while(!re.test(pos)) {
      pos = prompt("Einfügen an Position (0.." + input.value.length + "):", "0");
    }
    if(pos > input.value.length) {
      pos = input.value.length;
    }
    /* Einfügen des Formatierungscodes */
    var insText = prompt("Bitte geben Sie den zu formatierenden Text ein:");
    input.value = input.value.substr(0, pos) + aTag + insText + eTag + input.value.substr(pos);
  }
}
function dynvorschau(datum, inhalt)
	{
	document.getElementById('vorschau').innerHTML = '<tr><td class="contenttxt">&nbsp;</td>\n</tr>\n<tr>\n<td class="contenttxt">\n<h1>'+document.formular.ueberschrift.value+'</h1>\n<span class="infotxt">Vom '+datum+' in Kategorie Feuerwehrlexikon</span><hr>\n</td>\n</tr>\n<tr>\n<td align="left" class="contenttxt2">'+document.formular.artikel.value+'<br><br><span class="infotxt">Autor: &raquo;'+document.formular.username.value+'&laquo;<br>Dieser Artikel wurde 1 mal gelesen.</span></td>\n</tr>\n';
	}
//scrollen der news - startseite
var wartezeit=5000;
var position=1;
timer=setTimeout('rotieren(position)', wartezeit);

function removeClassName (elem) {
    elem.className ='seitennavi';
}
function addClassName (elem) {
    elem.className ='seitennavi_a';
}
function hidediv (elem) {
    elem.style.display = 'none';
}
function showdiv (elem) {
    elem.style.display = 'block';
}
function rotationstoppen() {
			window.document.getElementById('rotierenpic').innerHTML='&nbsp;';
			clearTimeout(timer);
		}
function rotationstarten() {
			clearTimeout(timer);
			timer=setTimeout('rotieren(position)', wartezeit)
			window.document.getElementById('rotierenpic').innerHTML='<img src=gfx/main/rotate.gif width=20 height=20 border=0>';
		}
function rotieren(index) {
	if (window.document.getElementById('rotierenpic'))
			{
				window.document.getElementById('rotierenpic').innerHTML='<img src=gfx/main/rotate.gif width=20 height=20 border=0>';
				links = window.document.getElementById('themenseitennav').getElementsByTagName('A');
				position = index+1;
				if(position <= links.length){
					switchNews(position);
				}else{
					switchNews(1);
				}
				rotationstarten();
			}
		}
function switchNews(index) {
			links = window.document.getElementById('themenseitennav').getElementsByTagName('A');
			news = window.document.getElementById('themenbanner').getElementsByTagName('div');
			for(i = 0; i < links.length; i++) {
				removeClassName(links[i]);
			}
			addClassName(links[index-1]);
			for(i = 0; i < (news.length-1); i++) {
				hidediv(news[i]);
			}
			showdiv(news[(index-1)]);
			rotationstoppen();
			position = index;
		}