function setToTopLink() {
  if(document.all) {
    bh = document.body.offsetHeight;
    dd = document.getElementById('seitenende').offsetTop;
    if (document.body.offsetHeight>(document.getElementById('seitenende').offsetTop + document.getElementById('seitenende').offsetHeight)) {
       writeHTMLinElement('toTop', '');
    }
  } else {
    bh = window.innerHeight;
    dd = document.body.offsetHeight;
    if (document.body.offsetHeight<window.innerHeight) {
      writeHTMLinElement('toTop', '');
    }
  }
}

function resizeWindow(w, h) {
  // resize current window...
  window.resizeTo(w,h);
  if(document.all){
    
  } else {
   // window.innerHeight = h;
   // window.innerWidth = w;
  }
}

function popup(urll,name,width,height) {
 var a = window.open(urll, name, 'width='+width+',height='+height+',left=0,top=0,status=no,scrollbars=no,toolbar=no');
}

function popupScroll(urll,name,width,height) {
 var a = window.open(urll, name, 'width='+width+',height='+height+',left=0,top=0,status=no,scrollbars=yes,toolbar=no');
}

function getScreenParam(windowWidth,windowHeight){
  if (screen.width >= windowWidth) {
    windowLeft = (screen.width-windowWidth)/4*3;
  } else {
    windowLeft = 0;
  }
  if (screen.height >= windowHeight) {
    windowTop = (screen.height-windowHeight)/2;
  } else {
    windowTop = 0;
  }
  var ret = new Array(windowLeft,windowTop);
  return ret;
}

function popupParam(url,param,name,width,height) {
 var a = window.open(url+'?'+param, name, 'width='+width+',height='+height+',left=0,top=0,status=no,scrollbars=yes,toolbar=no');
}

function setFlashFocus () {
 //document.flashFilm.focus();
 el = document.getElementById('test');
 alert(el.name);
 el.style.setAttribute("visibility","hidden");
}

function get_my_stat_write(sitename, installdir, trackname) {
  var winref=self.document.referrer;
  var sPath = window.location.pathname;
  var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);
  if (self!=top) {
    var wintref=top.location.href;
    if(wintref==winref) {
      winref=top.document.referrer;
    }
  }
  var bsuniquevid=_my_stat_getCookie("bsuniquevid");
  if(bsuniquevid == null) {
    _my_stat_setCookie("bsuniquevid",0,0,"/","",0);
    bsuniquevid=_my_stat_getCookie("bsuniquevid");
    if(bsuniquevid == null){
      bsuniquevid = "";
    }
  }
  var randnum=Math.random()*1000000000000000;
  var final_query =   installdir + "/connector.php?pn="+ escape(sPage)+
  "&fp="+escape(self.location.href)+
  "&ref="+escape(winref)+
  "&websitename="+escape(sitename)+
  "&logitmode=ALWAYS&trackname="+((trackname!= null) ? escape(trackname) : "DETECT")+"&trackmode=DYNAMIC&bsuniquevid="+
  escape(bsuniquevid)+"&randnum="+randnum+
  "&mode=JSMODE"+_my_stat_getData(sitename, installdir);
  while(final_query.match(/&/)){
    final_query = final_query.replace(/&/, "__u__");
  }
  while(final_query.match(/=/)){
    final_query = final_query.replace(/=/, "__g__");
  }
  while(final_query.match(/\?/)){
    final_query = final_query.replace(/\?/, "__f__");
  }
  return final_query;
  // document.write("<img width='1' height='1' alt='"+randnum+"' border='0' src='"+final_query+"'>");
}

function writeHTMLinElement(id, html) {
  // writes an HTML-String in an HTML-Element (fetched by ID)...
  var e = document.getElementById(id);
  if(e){
    e.innerHTML = html;
  }
}

var my_window = null;

function newWindow(url, windowName, w, h) {
  // open microsite 
  var x = 20; // defaults
  var y = 15;
  
  if(my_window != null && !my_window.closed) my_window.close();
    
    // center horizontal and vertical
    if (window.screen) {
    x =  Math.round((screen.width - w) / 2);
    y =  Math.round((screen.height - h) / 2);
  }
  my_window = window.open(url,windowName,"width=" + w + ",height=" + h + ",left=" + x + ",top=" + y + ",personalbar=no,locationbar=no,toolbar=no,scrollbars=no,menubar=no,status=no,resizable=no");
}
