
function createCookie(name,value,days){
  if (days){
     var date=new Date();
     date.setTime(date.getTime()+(days*24*60*60*1000));
     var expires="";
     expires=";expires="+date.toGMTString();
   } else {
      expires = "";
   }
   document.cookie = name+"="+escape(value)+expires+";path=/;domain="+domain+";";
}
function readCookie(name){
  var nameEQ=name+"=";
  var ca=document.cookie;
  if ((!ca)||(ca.length<1)){return "";}
  var str=ca.indexOf(nameEQ);
  if (str==-1){return "";}
  str=str + name.length + 1;
  var end=ca.indexOf(';', str);
  if (end==-1){end=ca.length;}
  var val=ca.substring(str,end);
  return unescape(val);
}
function langChd(){
   var chd = false;
   var cl=new String(readCookie(cookiename));
   if (cl.length>0){
      chd=(curlang.toLowerCase() != cl.toLowerCase());
      curlang=cl;
      cookiefnd = true;
   } else {
      curlang=deflang;
   }
   createCookie(cookiename,curlang,30);
   return chd;
}

function Initialize(){
  if (!pname){return;}
  if (pname.length<1){return;}

  // Make sure the page is not opened within a frame
  if (window != top) top.location.href = location.href;
  
  var redir=true;
  var lch=false;
  var cl=deflang;
  bbt="";
  lch=langChd();
  redir=lch;
  cl=curlang;

  if (redir){
     var nw = "/html_" + cl + "/";
     if (lch){pname = new String(pname.replace("/html_" + deflang + "/", nw));}
     window.location=pname;
     var hsh=(hash.length > 1)?hash.substring(1):"";
  }
  else{
     document.title = this.document.title;
     pname = "";
     hash  = "";
  }
}

function withinDateRange(y1,m1,d1,y2,m2,d2)
{
   var ddc = today.getDate();
   var mmc = today.getMonth()+1;
   var yyc = today.getFullYear();
   var del = 0;
   if (m1<1) { m1 = mmc; } if (d1<1) { d1 = 1; }
   if (m2<1) { m2 = mmc; } if (d2<1) { m2++; d2 = 1; del=-86400000; y2 += ( (m2 / 11) - (m2 % 11) ); m2 %= 11; }
   if (y1<1) { 
      if ( ((m1*100)+d1) > ((mmc*100)+ddc) ) { y1 = yyc-1; } else { y1 = yyc; }
   }
   if (y2<1) {
      if ( ((m2*100)+d2)<((m1*100)+d1) ) { y2 = y1+1; } else { y2 = y1; }
   }
   var dx = new Date(y1,m1-1,d1,0,0,0,0);
   var dy = new Date(y2,m2-1,d2,0,0,0,0); dy.setTime(dy.getTime()+del);
   var dc; 
   if (dx>dy) { dc=dx; dx=dy; dy=dc; }
   dc = new Date(yyc,mmc-1,ddc,0,0,0,0);
   return ( (dx.valueOf()<=dc.valueOf()) && (dy.valueOf()>=dc.valueOf()) );
}

function notOutdated(y,m,d)
{
   var dx = new Date(y,m-1,d,0,0,0,0);
   var dy = new Date(today.getFullYear(),today.getMonth(),today.getDate(),0,0,0,0);
   return (dx.valueOf()>=dy.valueOf());
}

function setbbtext(txt){
    var wb=document.getElementById("bltnbrd");
    if(wb){
       wb.innerHTML=wb.innerHTML + txt;
       if (txt.length>0) { 
          wb.style.display=""; 
          wb.style.visibility="visible";
       }
    }
}

function changeLanguage(nxtl){
  var pth=new String(this.document.location.pathname);
  var loc=new String(pth.replace(eval("/htm_"+curlang+"/i"), "html_"+lcd[nxtl]));
  var hsh=new String((this.document.location.hash.length > 1)?this.document.location.hash:"");
  return loc+hsh;
}

function genlanguages(){
  if (!multilanguage) {return;}
  var m=0;
  for (var n=0;(n<lng.length);n++){
    if(!(deflang.toUpperCase()==lng[n])){
       var pth= new String( changeLanguage(n) );
       var a1=new String( "<a onclick=\"createCookie(\'"+cookiename+"\','"+lcd[n]+"',30); window.location=\'"+pth+"\'; void 0;\" title=\""+lnm[n]+"\" class=\"button1\" target=\"_top\" alt=\'" + lnm[n] + "\' onmouseover=\"status=\'"+lnm[n]+"\'; return true;\" onmouseout=\"status=\'\';\">" );
       var a2=new String((m>0 ? "&nbsp;" : "")+a1+"<b>"+lng[n]+"</b></a>" );
        this.document.write( a2 );
       m++;
    }
  }
}

ccf={
   // add as many as you want here
//   engines:[
//      "http://www.google.de/search?q=",
//      "http://www.google.com/search?q=",
//      "http://alltheweb.com/search?q=",
//      "http://search.yahoo.com/search?p=",
//      "http://www.altavista.com/web/results?q="
//   ],
   engines:[websrchengine],

   init:function(){
      if (opt[oASrch]==1) {
        ccf.addEvent(document,"dblclick",ccf.readSelection);
      }
   }, // init

   readSelection:function(e){
      var text="";
      if(window.getSelection){
         text=window.getSelection();
      }
      if(document.selection){
         text=document.selection.createRange().text;
      }
      if(text==""){
         alert("Es wurde kein Text ausgewählt!");
      }else{
         ccf.processQuery(text);
      }
   },// readSelection

   processQuery:function(query){
//   window.location.href=this.engines[0]+query;
      window.open(this.engines[0]+query);
   }, // processQuery

   addEvent:function(obj, evType, fn){
      /*
      adds an eventListener for browsers which support it.
      Written by Scott Andrew: www.scottandrew.com
      */
      if (obj.addEventListener){
         obj.addEventListener(evType, fn, true);
         return true;
      } else if (obj.attachEvent){
         var r = obj.attachEvent("on"+evType, fn);
         return r;
      } else {
         return false;
      } // if
   } // addEvent
} // ccf

var px = document.layers ? "" : "px";

function getAbsPosition(obj) {
   var posi = new Object;
   posi.x = 0;
   posi.y = 0;
   if (obj) {
      posi.x = obj.offsetLeft;
      posi.y = obj.offsetTop;
      if (obj.offsetParent) {
         var pposi = getAbsPosition(obj.offsetParent);
         posi.x += pposi.x;
         posi.y += pposi.y;
      }
   }
   return posi;
}

function getElt(id) 
{
   return document.getElementById ? document.getElementById(id) : document.all ? document.all(id) : document.layers[id];
}

var fboxes=[];
var px = document.layers ? "" : "px";


function adjustBoxes() 
{
  var lg = fboxes.length;
  if (lg>0) {
    for (var n=0;(n<fboxes.length);n++) {
      setfBoxPos(n);
    }
    setTimeout("adjustBoxes()", 250);
  }
}

function floatingBox(id,ox,oy) {
  this.name = id;
  this.theBox = getElt(id);
  if (this.theBox) { 
    if (oy) { this.theBox.y = oy; } else { this.theBox.y = Number(this.theBox.style.top.replace(/px/, "")); }
    if (ox) { this.theBox.x = ox; } else { this.theBox.x = Number(this.theBox.style.left.replace(/px/, "")); }
    this.theBox.style.position = "absolute";
    this.theBox.style.visibility = "visible";
    this.boxTop = this.theBox.y;
    this.boxLeft= this.theBox.x;
    this.boxLocationY=0;
    this.boxLocationX=0;
    fboxes.push(this);
    if (fboxes.length==1) {
      setTimeout("adjustBoxes()", 250); 
    }
  }
}

function setfBoxPos(n) {
  var fb = fboxes[n];
  var pY = ( ns ? window.pageYOffset : 
                   document.documentElement && document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop             );
  if (fb.boxLocationY == pY) {
//     var dY = (pY > fb.boxTop-4) ? pY+4 : fb.boxTop;
     var dY = (pY > fb.boxTop) ? pY : fb.boxTop;
     fb.theBox.y += (dY - fb.theBox.y);
     fb.theBox.style.top = "" + fb.theBox.y + px;
//   fb.theBox.style.left = "" + fb.theBox.x + px;
  }
   fb.boxLocationY = pY;
} // setfBoxPos

function adjustBoxPos(id1,mobj,id2) {
   this.refBox = getElt(id1+"bbar_0");
   this.adjBox = getElt(id2);
   var y =  Number(this.refBox.style.top.replace(/px/, ""));
   if (y==0) {y = mobj.fromTop;}
   var dy = Number(this.refBox.style.height.replace(/px/, ""));
   var py = y + dy + 3;
   if (!ie) { py += 2; }
   this.adjBox.style.top = "" + py + px;
   if (!ie) {
     var x = Number(this.adjBox.style.left.replace(/px/, "")) - 2;
     var w = Number(this.adjBox.style.width.replace(/px/, "")) - 2;
     this.adjBox.style.left = "" + x + px;
     this.adjBox.style.width = "" + w + px;
   }
//   var x_bb = new floatingBox(id2);
}

