//onError=null

// Abfrage des Browsers (Internet Explorer oder Netscape?)
var nn = !!document.layers;
var ie = !!document.all;

// Vorbereitung der Zwischenablage für Netscape (deaktiviert)
//if (nn)
//{
//  netscape.security.PrivilegeManager.enablePrivilege("UniversalSystemClipboardAccess");
//  var fr=new java.awt.Frame();
//  var Zwischenablage = fr.getToolkit().getSystemClipboard();
//}

//Kopieren des Textes in die Zwischenablage, nur für Internet Explorer
function copytext(text)
{
 if (ie)
  {
// Text in Textarea aus dem versteckten Layer (div1)
    hiddenform.txtarea.value=text;
// Text in Textarea auswählen
    hiddenform.txtarea.select();
// Erstellen eines Range-Objektes
    cbBuffer=hiddenform.txtarea.createTextRange();
// Kopieren des Objektes in die Zwischenablage
    cbBuffer.execCommand('Copy');
  }
  else
  {
// Info, wenn kein Internet Explorer
   alert ("Kopieren in die Zwischenablage ist nur mit dem Internet Explorer möglich!")

// Text in die Zwischenablage für Netscape (deaktiviert)
//   if (nn)
//    {
//    Zwischenablage.setContents(new java.awt.datatransfer.StringSelection(text), null);
//    }
  }
}

function select_change(intStart, feld, element, strTrenn, elementZiel, strTrennZiel, boolErsterEintragDefault, strOptionAlleFelder)
{
 var i, j=0
 var eintrag = element.options[element.options.selectedIndex].value

 if (eintrag=="" || eintrag==cKeinElement )
 {
  intStart = loesche_select(intStart, elementZiel)
  return
 }

 var anzeige
 var inhalt = feld.value
 var inhalt_save = inhalt

 i=inhalt.indexOf(strTrenn + eintrag + strTrenn, 0)
 if (i!=-1 && inhalt.length>i)
 {
  inhalt = inhalt.substr(i + 1, inhalt.length - (i + 1))
  i=inhalt.indexOf(cFeldTrenn, 0)
  if (i!=-1 && inhalt.length>i)
  {
   inhalt = inhalt.substr(i + 1, inhalt.length - (i + 1))
   i=inhalt.indexOf(strTrenn, 0)
   if (i!=-1 && inhalt.length>i)
   {
    inhalt = inhalt.substr(0, i)
   }
   feld.value=inhalt
   lade_select(intStart, feld, elementZiel, strTrennZiel, boolErsterEintragDefault, strOptionAlleFelder)
   feld.value=inhalt_save
  }
 }
}

function lade_select(intStart, feld, element, strTrenn, boolErsterEintragDefault, strOptionAlleFelder)
{
 var i, j, k=0
 var boolStringZuEnde=false
 var objEintrag
 var eintrag
 var anzeige
//alert (feld.value)
 var inhalt = feld.value

 intStart = loesche_select(intStart, element)

 j=intStart
 while (!boolStringZuEnde)
 {
  i=inhalt.indexOf(strTrenn, 0)
  if (i!=-1 && inhalt.length>i)
  {
   inhalt = inhalt.substr(i + 1, inhalt.length - (i + 1))
   i=inhalt.indexOf(strTrenn, 0)
   if (i!=-1 && inhalt.length>i)
   {
    eintrag = inhalt.substr(0, i)
    inhalt = inhalt.substr(i + 1, inhalt.length - (i + 1))
    i=inhalt.indexOf(cFeldTrenn, 0)
    if (i!=-1 && inhalt.length>i)
    {
     anzeige = inhalt.substr(0, i)
     inhalt = inhalt.substr(i + 1, inhalt.length - (i + 1))
     objEintrag = new Option(anzeige, eintrag)
     element.options[j]=objEintrag
     j++
	 k++
	 if(k==2 && strOptionAlleFelder!="")
	 {
      objEintrag = new Option(element.options[j - 1].text, element.options[j - 1].value)
	  element.options[j] = objEintrag
	  element.options[j - 1].text = element.options[j - 2].text
	  element.options[j - 1].value = element.options[j - 2].value
	  element.options[j - 2].text = strOptionAlleFelder
	  element.options[j - 2].value = "0"
      j++
	 }
    }
    else
    {
     boolStringZuEnde=true
    }
   }
   else
   {
    boolStringZuEnde=true
   }
  }
  else
  {
   boolStringZuEnde=true
  }
 }
 if (element.options.selectedIndex<0 && boolErsterEintragDefault)
 {
  element.options[0].selected=true
 }
}

function loesche_select(intStart, element)
{
 if (element.length>0)
 {
  if (element.length>=intStart)
  {
   element.length=intStart
  }
  else
  {
   element.length=0
   intStart = 0
  }
 }
 return intStart
}


function frame_left_to_main(framenr, taste)
{
 if (parent.frames.length<=(framenr + 1)) 
 {
  return
 }
 if (parent.frames[framenr].document.form01.frmTasteVirtual==null) 
 {
  return
 }
 if (document.form01.frmLogik[0].checked==true)
 {
  parent.frames[framenr].document.form01.frmLogik.value="and"
 }
 if (document.form01.frmLogik[1].checked==true)
 {
  parent.frames[framenr].document.form01.frmLogik.value="or"
 }
 if (document.form01.frmDatumSuch[0].checked==true)
 {
  parent.frames[framenr].document.form01.frmDatumSuch.value=""
 }
 if (document.form01.frmDatumSuch[1].checked==true)
 {
  parent.frames[framenr].document.form01.frmDatumSuch.value="6"
 }
 if (document.form01.frmDatumSuch[2].checked==true)
 {
  parent.frames[framenr].document.form01.frmDatumSuch.value="3"
 }
 if (document.form01.frmDatumSuch[3].checked==true)
 {
  parent.frames[framenr].document.form01.frmDatumSuch.value="1"
 }
 parent.frames[framenr].document.form01.frmFreiSuch.value=document.form01.frmFreiSuch.value
 parent.frames[framenr].document.form01.frmTasteVirtual.value=taste 
// document.form01.submit()
 parent.frames[framenr].document.form01.submit()
}

function frame_left_to_main2(framenr, taste)
{
 if (parent.frames.length<=(framenr + 1)) 
 {
  return
 }
 if (parent.frames[framenr].document.form01.frmTasteVirtual==null) 
 {
  return
 }
 if (document.form01.frmOnlineshopSuch.checked==true)
 {
  parent.frames[framenr].document.form01.frmOnlineshopSuch.value="1"
 }
 else
 {
  parent.frames[framenr].document.form01.frmOnlineshopSuch.value="0"
 }
 parent.frames[framenr].document.form01.frmPlzSuch.value=document.form01.frmPlzSuch.value
 parent.frames[framenr].document.form01.frmOrtSuch.value=document.form01.frmOrtSuch.value
 parent.frames[framenr].document.form01.frmNameSuch.value=document.form01.frmNameSuch.value
 parent.frames[framenr].document.form01.frmTasteVirtual.value=taste 
// document.form01.submit()
 parent.frames[framenr].document.form01.submit()
}


var PopupFenster=null
var strUrlSave=""

function popupfenster_vorhanden()
{
 var fenster_vorhanden=false
 if (PopupFenster != null)
 {
  if (!PopupFenster.closed)
  {
    fenster_vorhanden = true
  }
 }
 return fenster_vorhanden
}

//Prüfen, ob kein PopupFenster geöffnet wurde, wenn ja - schliessen

function popupfenster_schliessen()
{
 if (popupfenster_vorhanden())
 {
  PopupFenster.close()
 }
}

//Erstellen eines Popup-Fensters
function popupfenster_oeffnen(strUrl, breite, hoehe, PosX, PosY)
{
 var boolNetscape = false
 if(document.layers) 
 { 
  boolNetscape = true
 }

 if (popupfenster_vorhanden())
 {
  var strSearch
  if (strUrlSave != strUrl)
  {
   strSearch=hole_parameter(strUrl)
   if (strSearch != "")
   {
    PopupFenster.window.location.search=strSearch 
   }
   PopupFenster.document.form01.frmTasteVirtual.value=""
   PopupFenster.document.form01.submit
  }
  PopupFenster.focus()
 }
 else
 {
// Popupfenster öffnen
  if(boolNetscape) 
  { 
//   PopupFenster = window.open(strUrl, "", "scrollbars=no, tollbar=no, menubar=no, location=no, resizeable=no, directories=no marginwidth=5")
   PopupFenster = window.open(strUrl, "", "scrollbars=yes")
  }
  else
  {
//   PopupFenster = window.open(strUrl, "", "scrollbars=no, tollbar=no, menubar=no, location=no, resizeable=no, directories=no marginwidth=5")
   PopupFenster = window.open(strUrl, "", "scrollbars=yes")
  }
 PopupFenster.resizeTo(breite, hoehe)
 PopupFenster.moveTo(PosX, PosY)
 PopupFenster.focus()
 }
 strUrlSave = strUrl
}

//Erstellen eines Popup-Fensters
function popupfenster_neu(strUrl, breite, hoehe, PosX, PosY)
{
 var boolNetscape = false
 if(document.layers) 
 { 
  boolNetscape = true
 }

 if (popupfenster_vorhanden())
 {
  var strSearch
  if (strUrlSave != strUrl)
  {
   strSearch=hole_parameter(strUrl)
   if (strSearch != "")
   {
    PopupFenster.window.location.search=strSearch 
   }
//   PopupFenster.document.form02.frmTasteVirtual.value=""
//   PopupFenster.document.form02.submit
  }
  PopupFenster.focus()
 }
 else
 {
// Popupfenster öffnen
  if(boolNetscape) 
  { 
//   PopupFenster = window.open(strUrl, "", "scrollbars=no, tollbar=no, menubar=no, location=no, resizeable=no, directories=no marginwidth=5")
   PopupFenster = window.open(strUrl, "", "scrollbars=yes")
  }
  else
  {
//   PopupFenster = window.open(strUrl, "", "scrollbars=no, tollbar=no, menubar=no, location=no, resizeable=no, directories=no marginwidth=5")
   PopupFenster = window.open(strUrl, "", "scrollbars=yes")
  }
 PopupFenster.resizeTo(breite, hoehe)
 PopupFenster.moveTo(PosX, PosY)
 PopupFenster.focus()
 }
 strUrlSave = strUrl
}


function hole_parameter(strUrl)
{
 var i=0
 parameter=""
 i=strUrl.indexOf("?")
 if (i!=-1)
 {
  parameter=trim(strUrl.substring(i + 1))
 }
 return parameter
}

function trim(text)
{
 var i
 var text_gefunden
 var text_trim = ""
 var text_tmp = ""
 if (text.length<=0)
 {
  return text_trim
 }

 text_tmp=text

 for (i=0, text_gefunden=false; i<text_tmp.length; i++)
 {
  if (text_gefunden)
  {
   text_trim = text_trim + text_tmp.charAt(i)
  }
  else
  {
   if (text_tmp.charAt(i)!=" ")
   {
    text_trim = text_trim + text_tmp.charAt(i)
    text_gefunden=true
   }
  }
 }

 text_tmp=text_trim
 text_trim=""

 for (i=text_tmp.length - 1, text_gefunden=false; i>=0; i--)
 {
  if (text_gefunden)
  {
   text_trim = text_tmp.charAt(i) + text_trim
  }
  else
  {
   if (text_tmp.charAt(i)!=" ")
   {
    text_trim = text_tmp.charAt(i) + text_trim
    text_gefunden=true
   }
  }
 }

 return text_trim

}

