var newWindow = null;

function closeWin(){
	if (newWindow != null){
		if(!newWindow.closed)
			newWindow.close();
	}
}

// use:
// <a href="link" title="title" target="popUpWin" onclick="popUpWin(this.href,'console',640,480);return false;">link</a>
function popUpWin(url, type, strWidth, strHeight)
{
	closeWin();
	
	if (type == "fullScreen"){
		strWidth = screen.availWidth - 10;
		strHeight = screen.availHeight - 160;
	}
	
	var tools="";
	if (type == "standard" || type == "fullScreen") tools = "resizable,toolbar=yes,location=yes,scrollbars=yes,menubar=yes,width="+strWidth+",height="+strHeight+",top=0,left=0";
	if (type == "console") tools = "resizable,toolbar=no,location=no,scrollbars=no,width="+strWidth+",height="+strHeight+",left=100,top=100";
	newWindow = window.open(url, 'newWin', tools);
	newWindow.focus();
}

function vis(layID) {
	var who = document.getElementById(layID);
	if (who.style.display=="none") {who.style.display="";} else {who.style.display="none";}
}

function jah(url,target) {
    // native XMLHttpRequest object
    document.getElementById(target).innerHTML = 'sending...';
    if (window.XMLHttpRequest) {
        req = new XMLHttpRequest();
        req.onreadystatechange = function() {jahDone(target);};
        req.open("GET", url, true);
        req.send(null);
    // IE/Windows ActiveX version
    } else if (window.ActiveXObject) {
        req = new ActiveXObject("Microsoft.XMLHTTP");
        if (req) {
            req.onreadystatechange = function() {jahDone(target);};
            req.open("GET", url, true);
            req.send();
        }
    }
}    

function jahDone(target) {
    // only if req is "loaded"
    if (req.readyState == 4) {
        // only if "OK"
        if (req.status == 200) {
            results = req.responseText;
            document.getElementById(target).innerHTML = results;
        } else {
            document.getElementById(target).innerHTML="jah error:\n" +
                req.statusText;
        }
    }
}
// Thumbnail expansion and reduction animation
// Developed by Jan Goyvaerts, 2006
// Copyright (c) 2006 Jan Goyvaerts. All rights reserved.
// Do not copy or link to this script.

expandingid = 0;
expandingstep = 0;
expandingwidth = 0;
expandingheight = 0;
expandingtop = 0;
expandingleft = 0;
expandingtimeout = 0;
expandingtotalsteps = 15;

function expandthumb(thumbid, fullwidth, fullheight) {
  if (expandingtimeout != 0) {
    clearTimeout(expandingtimeout);
  }
  if (expandingid > 0 && expandingid != thumbid) {
    restorethumb();
  }
  if (expandingid != thumbid) {
    img = document.getElementById("screen" + thumbid);
    img.style.display = 'block';
    expandingid = thumbid;
    expandingstep = 1;
    expandingwidth = fullwidth;
    expandingheight = fullheight;
    expandingtop = img.offsetTop;
    expandingleft = img.offsetLeft;
  } else if (expandingstep < 1) {
    expandingstep = 1;
  }
  expandstep();
}

function doexpand() {
  img = document.getElementById("screen" + expandingid);
  thumb = document.getElementById("thumb" + expandingid);
  myscroll = getScroll();
  if (expandingtop + thumb.height > myscroll.top + myscroll.height) {
    finaltop = myscroll.top + myscroll.height - expandingheight;
  } else {
    finaltop = expandingtop + thumb.height - expandingheight;
  }
  if (finaltop < myscroll.top) { finaltop = myscroll.top; }
  img.style.top = finaltop + ((expandingtop - finaltop) * (expandingtotalsteps - expandingstep) / expandingtotalsteps) + 'px';

  if (expandingleft + thumb.width > myscroll.left + myscroll.width) {
    finalleft = myscroll.left + myscroll.width - expandingwidth;
  } else {
    finalleft = expandingleft + thumb.width - expandingwidth;
  }
  if (finalleft < myscroll.left) { finalleft = myscroll.left; }
  img.style.left = finalleft + ((expandingleft - finalleft) * (expandingtotalsteps - expandingstep) / expandingtotalsteps) + 'px';

  img.width = thumb.width + ((expandingwidth - thumb.width) * expandingstep / expandingtotalsteps);
  img.height = thumb.height + ((expandingheight - thumb.height) * expandingstep / expandingtotalsteps);
}

function restorethumb() {
  img = document.getElementById("screen" + expandingid);
  img.style.top = '';
  img.style.left = '';
  img.style.display = 'none';
  expandingid = 0;
}

function expandstep() {
  expandingtimeout = 0;
  doexpand();
  if (expandingstep < expandingtotalsteps) {
    expandingstep++;
    expandingtimeout = setTimeout("expandstep()", 20);
  }
}

function reducestep() {
  expandingtimeout = 0;
  doexpand();
  if (expandingstep > 0) {
    expandingstep--;
    expandingtimeout = setTimeout("reducestep()", 20);
  } else {
    restorethumb();
  }
}

function reducethumb(thumbid) {
  if (expandingtimeout != 0) {
    clearTimeout(expandingtimeout);
  }
  if (expandingstep > 0) {
    reducestep();
  }
}

// returns the scroll position and size of the browser
function getScroll() {
  if (document.all && typeof document.body.scrollTop != "undefined") {  
    // IE model
    var ieBox = document.compatMode != "CSS1Compat";
    var cont = ieBox ? document.body : document.documentElement;
    return {
      left:   cont.scrollLeft,
      top:    cont.scrollTop,
      width:  cont.clientWidth,
      height: cont.clientHeight
    };
  } else {
    return {
      left:   window.pageXOffset,
      top:    window.pageYOffset,
      width:  window.innerWidth,
      height: window.innerHeight
    };
  }
}
function over(image){
	ti = new Array();
	ti['b0'] = '/tpl/img/wintergarten.jpg';
	ti['b1'] = '/tpl/img/einzelzimmer.jpg';
	ti['b2'] = '/tpl/img/doppelzimmer_neu.jpg';
	ti['b3'] = '/tpl/img/tresen.jpg';
	ti['b4'] = '/tpl/img/garten.jpg';
	ti['b5'] = '/tpl/img/terasse.jpg';
	ti['b6'] = '/tpl/img/restaurant.jpg';
	ti['b7'] = '/tpl/img/rathaus.jpg';
	ti['b8'] = '/tpl/img/alter-markt.jpg';
	ti['b9'] = '/tpl/img/theater.jpg';
	ti['b10'] = '/tpl/img/hafen.jpg';
	ti['b11'] = '/tpl/img/gorch-fock.jpg';
	ti['b12'] = '/tpl/img/nikolaikirche.jpg';
	ti['b13'] = '/tpl/img/kueche.jpg';
	ti['b15'] = '/tpl/img/kamin.jpg';
	ti['b14'] = '/tpl/img/bad.jpg';
	ti['b16'] = '/tpl/img/schlafbereich.jpg';
	var im = document.getElementById('tbild');
	im.src = ti[image];
}
function out(){ 
var im = document.getElementById('tbild');
im.src = "/tpl/img/blank.gif";

var namen=new Array("begin.gif","up.gif","prev.gif","next.gif","down.gif");
  /* Array aller Bildernamen */
var bilder=new Array();
  /* Definition des Bilder-Arrays */

function lade()
  /* Laedt die Bilder */
{
  var i;                     /* lokale Variablendeklaration */
  for (i=0;i<5;i++)          /* Schleife: i=0..4 */
  {
    bilder[i]=new Image();   /* neues Image-Objekt erzeugen */
    bilder[i].src=namen[i];  /* Quelldateiname des Bildes setzen */
  }
}

function zeige(nr)
  /* zeigt ein Bild an */
{
  document.images[0].src=bilder[nr].src;
    /* Bild austauschen */
}


