<!--

var layer;
var layerOpac = 0;
var layerMax = 80;
var globalImage = "";
var globalImageWidth;
var globalImageHeight;
var sliding;
var slideStep = 12;

var fadeInterupt = false;

var hotelSelectionVisible = false;

// initially determine the currently used browser
var ie = (navigator.appName == "Microsoft Internet Explorer");
var apple = (navigator.vendor && (navigator.vendor == "Apple Computer, Inc."));

function click (e) {
  if (!e)
    e = window.event;
  if ((e.type && e.type == "contextmenu") || (e.button && e.button == 2) || (e.which && e.which == 3)) {
    if (window.opera)
      window.alert("Sorry: Diese Funktion ist deaktiviert.");
    return false;
  }
}
if (document.layers)
  document.captureEvents(Event.MOUSEDOWN);
document.onmousedown = click;
document.oncontextmenu = click;

function getCurrentYPos() 
{
  if (document.body && document.body.scrollTop)
  {
    return document.body.scrollTop;
  }
  
  if (document.documentElement && document.documentElement.scrollTop)
  {
    return document.documentElement.scrollTop;
  }
  if (window.pageYOffset)
  {
    return window.pageYOffset;
  }
  return 0;
}

var scrollInterval;
function scrollSmoothly(destination)
{
  var anchor = window.document.getElementById(destination);
  var destX = anchor.offsetLeft;  
  var destY = anchor.offsetTop;
  var thisNode = anchor;
  while (thisNode.offsetParent &&  
    (thisNode.offsetParent != document.body))
  {
    thisNode = thisNode.offsetParent;
    destX += thisNode.offsetLeft;
    destY += thisNode.offsetTop;
    
  }
  
  
  clearInterval(scrollInterval);
  var stepSize = 25;
  
  var currentYPos = getCurrentYPos();
  
  if (currentYPos == destY) return;
  if (currentYPos > destY)
  {
    stepSize *= -1;
  }
  scrollInterval = setInterval('performScroll('+stepSize+','+destY+',"'+destination+'")',10);
}

function performScroll(stepSize, destY, destination)
{
  currentYPos = getCurrentYPos();
  isAbove = (currentYPos < destY);
  isAboveLater = ((currentYPos + stepSize) < destY);
  
  //if (!isAbove && !isAboveLater)
  window.scrollTo(0, currentYPos + stepSize);
  
  iscypos = getCurrentYPos();
  isAboveNow = (iscypos < destY);
  if ((isAbove != isAboveNow) || (currentYPos == iscypos))
  {
    window.scrollTo(0, destY);
   
    clearInterval(scrollInterval);
    
    location.hash = destination;
  }
}

function adjustLayer()
{
        layer = window.document.getElementById('layer');
        if (parseInt(layer.style.width) > 0)
        {
          if (ie)
          {
            layer.style.top = document.documentElement.scrollTop + "px";
          }
          else
          {
            layer.style.top = window.pageYOffset + "px";
          }
        }
}

function fadeInLayer()
{
        if (fadeInterupt) 
        {
          return;
        }
        
        if (layerOpac == 0)
        {
          layer = window.document.getElementById('layer');
          if (ie)
          {
            layer.style.width = window.document.documentElement.clientWidth + "px";
            layer.style.height = window.document.documentElement.clientHeight + "px";
            layer.style.top = document.documentElement.scrollTop + "px";
            layer.style.filter = "Alpha(Style=0, Opacity=0)";
          }
          else
          {
            layer.style.width = "100%";
            layer.style.height = "100%";
            layer.style.top = window.pageYOffset + "px";
          }
        }
        document.body.appendChild(layer);
        
        if (layerOpac < layerMax)
        {
          layerOpac += 5;
          if (ie)
          {
            layer.style.filter = "Alpha(Style=0, Opacity=" + layerOpac + ")";
          }
          else
          {
            document.getElementById('layer').style.opacity = layerOpac/100;
          }
          window.setTimeout('fadeInLayer()', 1);
        }
}

function fadeOutLayer()
{
        fadeInterupt = true;
        if (layerOpac > 0)
        {
          layerOpac -= 5;
          if (ie)
          {
            layer.style.filter = "Alpha(Style=0, Opacity=" + layerOpac + ")";
          }
          else
          {
            document.getElementById('layer').style.opacity = layerOpac/100;
          }
          window.setTimeout('fadeOutLayer()', 1);
        }
        
        if (layerOpac == 0)
        {
          fadeInterupt = false;
          layer = window.document.getElementById('layer');
          layer.style.width = "0px";
          layer.style.height = "0px";
          layer.style.top = "0px";
          layer.style.filter = "Alpha(Style=0, Opacity=0)";
        }
}

function changeRaceAsync(serverPage)
{
	var request = null;
	
	// Mozilla.
	if (window.XMLHttpRequest)
	{
		request = new XMLHttpRequest();
	}
	
	// Microsoft.
	else if (window.ActiveXObject)
	{
		request = new ActiveXObject("Microsoft.XMLHTTP"); 
	}
	
        var id = window.document.getElementById('race')[window.document.getElementById('race').selectedIndex].value;
	request.open("GET", serverPage + "?id=" + id, true);
	request.onreadystatechange = function() 
	{
        if ((request.readyState == 4) && (request.status == 200)) 
        {
            // Fill the text boxes with content.
            race = eval("(" + request.responseText + ")");
            
            window.document.getElementById("caption").innerHTML = race.str;
        }
    }
    
    request.send(null);
}
 
function checkForm()
{
        var error = 0;
        var msg = "";
        
        if (window.document.getElementById("lastname").value == "")
        {
              msg += "Pflichtfeld 'Name' nicht ausgef" + String.fromCharCode(252) + "llt\n";
              error++;
        }
        
        if (window.document.getElementById("firstname").value == "")
        {
              msg += "Pflichtfeld 'Vorname' nicht ausgef" + String.fromCharCode(252) + "llt\n";
              error++;
        }
        
        if (window.document.getElementById("street").value == "")
        {
              msg += "Pflichtfeld 'Stra" + String.fromCharCode(223) + "e' nicht ausgef" + String.fromCharCode(252) + "llt\n";
              error++;
        }
        
        if (window.document.getElementById("zipcode").value == "")
        {
              msg += "Pflichtfeld 'Plz.' nicht ausgef" + String.fromCharCode(252) + "llt\n";
              error++;
        }
        
        if (window.document.getElementById("city").value == "")
        {
              msg += "Pflichtfeld 'Ort' nicht ausgef" + String.fromCharCode(252) + "llt\n";
              error++;
        }
        
        if (window.document.getElementById("email").value == "")
        {
              msg += "Pflichtfeld 'Email' nicht ausgef" + String.fromCharCode(252) + "llt\n";
              error++;
        }
        
        if (window.document.getElementById("phone").value == "")
        {
              msg += "Pflichtfeld 'Telefon' nicht ausgef" + String.fromCharCode(252) + "llt\n";
              error++;
        }
        
        if (window.document.getElementById("race").selectedIndex < 1)
        {
              msg += "Kein Rennen ausgew" + String.fromCharCode(228) + "hlt\n";
              error++;
        }
        
        if (window.document.getElementById("grandStand").selectedIndex < 1)
        {
              msg += "Keine Trib" + String.fromCharCode(252) + "ne ausgew" + String.fromCharCode(228) + "hlt\n";
              error++;
        }
        
        if (window.document.getElementById("amount").value == "")
        {
              msg += "Pflichtfeld 'Anzahl Personen' nicht ausgef" + String.fromCharCode(252) + "llt\n";
              error++;
        }
        else
        {
              var tmp = parseInt(window.document.getElementById("amount").value);
              if (isNaN(tmp))
              {
                      msg += "In das Feld 'Anzahl Personen' d" + String.fromCharCode(252) + "rfen nur Ziffern (0..9) eingetragen werden\n";
                      error++;
              }
        }
        
        if (window.document.getElementById("ticketType").selectedIndex < 1)
        {
              msg += "Option 'Renntage' nicht ausgew" + String.fromCharCode(228) + "hlt\n";
              error++;
        }
        
        if ((window.document.getElementById("ticketType")[window.document.getElementById("ticketType").selectedIndex].text == "Paket")
            && (window.document.getElementById("hotel").selectedIndex < 1))
        {
              msg += "Option 'Paket' ohne Hotel ausgew" + String.fromCharCode(228) + "hlt\n";
              error++;
        }
        
        if (!window.document.getElementById("agb").checked)
        {
              msg += "Allgemeine Gesch" + String.fromCharCode(228) + "ftsbedingungen nicht best" + String.fromCharCode(228) + "tigt\n";
              error++;
        }
        
        if (error > 1)
        {
              alert("Folgende Fehler sind aufgetreten:\n\n" + msg);
              return false;
        }
        else
        {
              if (error > 0)
              {
                    alert(msg);
                    return false;
              }
              return true;
        }
}

function checkHotelsEnabled()
{
        var select = window.document.getElementById('ticketType');
        
        if (select.options[select.selectedIndex].text == "Paket")
        {
              window.document.getElementById('hotel').disabled = false;
              window.document.getElementById('extraNight').disabled = false;
              window.document.getElementById('singleRoom').disabled = false;
              window.document.getElementById('hotelTD1').className = "enabled";
              window.document.getElementById('hotelTD2').className = "enabled";
              window.document.getElementById('extraNightTD1').className = "enabled";
              window.document.getElementById('extraNightTD2').className = "enabled";
              window.document.getElementById('singleRoomTD1').className = "enabled";
              window.document.getElementById('singleRoomTD2').className = "enabled";
        }
        else
        {
              window.document.getElementById('hotel').disabled = true;
              window.document.getElementById('extraNight').disabled = true;
              window.document.getElementById('singleRoom').disabled = true;
              window.document.getElementById('hotelTD1').className = "disabled";
              window.document.getElementById('hotelTD2').className = "disabled";
              window.document.getElementById('extraNightTD1').className = "disabled";
              window.document.getElementById('extraNightTD2').className = "disabled";
              window.document.getElementById('singleRoomTD1').className = "disabled";
              window.document.getElementById('singleRoomTD2').className = "disabled";
        }
}

function loadGrandStandsAsync(serverPage)
{
	var request = null;
	
	// Mozilla.
	if (window.XMLHttpRequest)
	{
		request = new XMLHttpRequest();
	}
	
	// Microsoft.
	else if (window.ActiveXObject)
	{
		request = new ActiveXObject("Microsoft.XMLHTTP"); 
	}
	
        var id = window.document.getElementById('race')[window.document.getElementById('race').selectedIndex].value;
	request.open("GET", serverPage + "?id=" + id, true);
	request.onreadystatechange = function() 
	{
        if ((request.readyState == 4) && (request.status == 200)) 
        {
            // Fill the text boxes with content.
            grandStands = eval("(" + request.responseText + ")");
            
            var grandStandSelect = window.document.getElementById('grandStand');
            while (grandStandSelect.hasChildNodes())
            {
              grandStandSelect.removeChild(grandStandSelect.firstChild);
            }
            
            var option = document.createElement("option");
            option.setAttribute("value", "0");
            option.setAttribute("selected", "selected");
            option.appendChild(document.createTextNode("Bitte ausw" + String.fromCharCode(228) + "hlen"));
            grandStandSelect.appendChild(option);
            
            option = document.createElement("option");
            option.setAttribute("disabled", "disabled");
            var tildes = "";
            for (var j=0; j<13; j++)
            {
              tildes += String.fromCharCode(126);
            }
            option.appendChild(document.createTextNode(tildes));
            grandStandSelect.appendChild(option);
            
            var i=0;
            while (grandStands[i])
            {
              option = document.createElement("option");
              option.setAttribute("value", grandStands[i].id);
              option.appendChild(document.createTextNode(replaceHtmlSpecialChars(grandStands[i].name)));
              grandStandSelect.appendChild(option);
              i++;
            }
        }
    }
    
    request.send(null);
}

function loadHotelsAsync()
{
        var request = null;
	
	// Mozilla.
	if (window.XMLHttpRequest)
	{
		request = new XMLHttpRequest();
	}
	
	// Microsoft.
	else if (window.ActiveXObject)
	{
		request = new ActiveXObject("Microsoft.XMLHTTP"); 
	}
	
        var raceId = window.document.getElementById('race')[window.document.getElementById('race').selectedIndex].value;
        
        request.open("GET", "scripts/gethotelsasync.php?id=" + raceId, true);
	request.onreadystatechange = function() 
	{
        if ((request.readyState == 4) && (request.status == 200)) 
        {
            // Fill the text boxes with content.
            hotels = eval("(" + request.responseText + ")");
           
            var hotelSelect = window.document.getElementById("hotel");
            while (hotelSelect.hasChildNodes())
            {
              hotelSelect.removeChild(hotelSelect.firstChild);
            }
            
            var option = document.createElement("option");
            option.setAttribute("value", "0");
            option.setAttribute("selected", "selected");
            option.appendChild(document.createTextNode("Bitte ausw" + String.fromCharCode(228) + "hlen"));
            hotelSelect.appendChild(option);
            
            option = document.createElement("option");
            option.setAttribute("disabled", "disabled");
            var tildes = "";
            for (var j=0; j<13; j++)
            {
              tildes += String.fromCharCode(126);
            }
            option.appendChild(document.createTextNode(tildes));
            window.document.getElementById('hotel').appendChild(option);
            
            var i=0;
            while (hotels[i])
            {
              option = document.createElement("option");
              option.appendChild(document.createTextNode(replaceHtmlSpecialChars(hotels[i].name)));
              option.setAttribute("value", hotels[i].id);
              hotelSelect.appendChild(option);
              i++;
            }
        }
    }
    request.send(null);
}

function loadTicketTypesAsync(serverPage)
{
	var request = null;
	
	// Mozilla.
	if (window.XMLHttpRequest)
	{
		request = new XMLHttpRequest();
	}
	
	// Microsoft.
	else if (window.ActiveXObject)
	{
		request = new ActiveXObject("Microsoft.XMLHTTP"); 
	}
	
        var race = window.document.getElementById('race')[window.document.getElementById('race').selectedIndex].value;
        var grandStand = window.document.getElementById('grandStand')[window.document.getElementById('grandStand').selectedIndex].value;
         
	request.open("GET", serverPage + "?race=" + race + "&grandStand=" + grandStand, true);
	request.onreadystatechange = function() 
	{
        if ((request.readyState == 4) && (request.status == 200)) 
        {
            // Fill the text boxes with content.
            ticketTypes = eval("(" + request.responseText + ")");
            
            var ticketTypeSelect = window.document.getElementById('ticketType');
            while (ticketTypeSelect.hasChildNodes())
            {
              ticketTypeSelect.removeChild(ticketTypeSelect.firstChild);
            }
            
            var option = document.createElement("option");
            option.setAttribute("value", "0");
            option.setAttribute("selected", "selected");
            option.appendChild(document.createTextNode("Bitte ausw" + String.fromCharCode(228) + "hlen"));
            ticketTypeSelect.appendChild(option);
            
            option = document.createElement("option");
            option.setAttribute("disabled", "disabled");
            var tildes = "";
            for (var j=0; j<13; j++)
            {
              tildes += String.fromCharCode(126);
            }
            option.appendChild(document.createTextNode(tildes));
            ticketTypeSelect.appendChild(option);
            
            var i=0;
            while (ticketTypes[i])
            {
              option = document.createElement("option");
              option.setAttribute("value", ticketTypes[i].id);
              option.appendChild(document.createTextNode(ticketTypes[i].name));
              ticketTypeSelect.appendChild(option);
              i++;
            }
        }
    }
    
    request.send(null);
}

function naviMouseOver(id)
{
  window.document.getElementById(id).src = "res/images/" + id + "_OVER.jpg";
}

function naviMouseOut(id)
{
  window.document.getElementById(id).src = "res/images/" + id + ".jpg";
}

function naviMouseOverPng(id)
{
  window.document.getElementById(id).src = "res/images/" + id + "_OVER.png";
}

function naviMouseOutPng(id)
{
  window.document.getElementById(id).src = "res/images/" + id + ".png";
}

function adjustGallerySize(stepW, stepH, targetW, targetH, maxW, maxH)
{
        window.document.getElementById("img").style.visibility = "hidden";
        var width = parseInt(document.getElementById('gallery').style.width);
        var height = parseInt(document.getElementById('gallery').style.height);
        
        if (stepW < 0)
        {
          if (width > targetW)
          {
            width += stepW;
          }
          else
          {
            width = targetW;
          }
        }
        else
        {
          if (width < targetW)
          {
            width += stepW;
          }
          else
          {
            width = targetW;
          }
        }
        
        if (stepH < 0)
        {
          if (height > targetH)
          {
            height += stepH;
          }
          else
          {
            height = targetH;
          }
        }
        else
        {
          if (height < targetH)
          {
            height += stepH;
          }
          else
          {
            height = targetH;
          }
        }
        
        if (ie)
        {
		document.getElementById('gallery').style.left = (document.documentElement.clientWidth/2)-(width/2) + "px";
		document.getElementById('gallery').style.top = (document.documentElement.clientHeight/2)-(height/2) + document.documentElement.scrollTop + "px";
	} 
        else 
        {
		document.getElementById('gallery').style.left = (window.innerWidth/2)-(width/2) + "px";
		document.getElementById('gallery').style.top = (window.innerHeight/2)-(height/2) + window.pageYOffset + "px";
	}
        
        document.getElementById('gallery').style.width = width + "px";
        document.getElementById('gallery').style.height = height + "px";
        document.getElementById('divClose').style.left = (width-90) + "px";
        document.getElementById('divLogo').style.left = (width/2-64) + "px";
        document.getElementById('divNext').style.left = (width-110) + "px";
        document.getElementById('divNext').style.top = (height-22) + "px";
        document.getElementById('divPrevious').style.top = (height-22) + "px";
        if ((width != targetW) || (height != targetH))
        {
          window.setTimeout('adjustGallerySize(' + stepW + ', ' + stepH + ', ' + targetW + ', ' + targetH + ')', 1);
        }
        else
        {
          window.document.getElementById("img").style.visibility = "visible";
        }
}

function showGallery(folder, image, width, height)
{
        globalImage = image;
        globalImageWidth = width;
        globalImageHeight = height;
        
        // Room for the controls.
        width += 40;
        height += 92;
        
        if (ie)
        {
		document.getElementById('gallery').style.left = (document.documentElement.clientWidth/2)-(width/2) + "px";
		document.getElementById('gallery').style.top = (document.documentElement.clientHeight/2)-(height/2) + document.documentElement.scrollTop + "px";
	} 
        else 
        {
		document.getElementById('gallery').style.left = (window.innerWidth/2)-(width/2) + "px";
		document.getElementById('gallery').style.top = (window.innerHeight/2)-(height/2) + window.pageYOffset + "px";
	}
        
        document.getElementById('gallery').style.width = width + "px";
        document.getElementById('gallery').style.height = height + "px";
        document.getElementById('gallery').style.visibility = "visible";
        
        // Clear the former content.
        while (document.getElementById('gallery').hasChildNodes())
        {
          document.getElementById('gallery').removeChild(document.getElementById('gallery').firstChild);
        }
        
        var table = document.createElement("table");
        var tbody = document.createElement("tbody");
        
        var tr1 = document.createElement("tr");
        var td11 = document.createElement("td");
        
        var tr2 = document.createElement("tr");
        var td21 = document.createElement("td");
        
        var tr3 = document.createElement("tr");
        var td31 = document.createElement("td");
        
        var divSlide = document.createElement("div");
        var aSlide = document.createElement("a");
        divSlide.appendChild(aSlide);
        imgSlide = document.createElement("img");
        imgSlide.src = "res/images/slideshow/slides.png";
        imgSlide.width = "16";
        imgSlide.height = "14";
        imgSlide.style.paddingRight = "4px";
        aSlide.appendChild(imgSlide);
        aSlide.className = "hrefgallery";
        aSlide.appendChild(document.createTextNode("Slideshow starten"));
        aSlide.id = "aSlide";
        
        var divLogo = document.createElement("div");
        imgLogo = document.createElement("img");
        imgLogo.src = "res/images/slideshow/logo_small.png";
        imgLogo.width = "128";
        imgLogo.height = "35";
        divLogo.appendChild(imgLogo);
        divLogo.id = "divLogo";
        
        var divClose = document.createElement("div");
        var aClose = document.createElement("a");
        divClose.appendChild(aClose);
        imgClose = document.createElement("img");
        imgClose.src = "res/images/slideshow/close.png";
        imgClose.width = "11";
        imgClose.height = "10";
        imgClose.style.paddingRight = "4px";
        aClose.appendChild(imgClose);
        aClose.className = "hrefgallery";
        aClose.appendChild(document.createTextNode("schlie" + String.fromCharCode(223) + "en"));
        
        var divPrevious = document.createElement("div");
        var aPrevious = document.createElement("a");
        divPrevious.appendChild(aPrevious);
        imgPrevious = document.createElement("img");
        imgPrevious.src = "res/images/slideshow/back.png";
        imgPrevious.width = "11";
        imgPrevious.height = "15";
        imgPrevious.style.paddingRight = "4px";
        aPrevious.className = "hrefgallery";
        aPrevious.appendChild(imgPrevious);
        aPrevious.appendChild(document.createTextNode("vorheriges Bild"));
        
        var divNext = document.createElement("div");
        var aNext = document.createElement("a");
        divNext.appendChild(aNext);
        imgNext = document.createElement("img");
        imgNext.src = "res/images/slideshow/forth.png";
        imgNext.width = "11";
        imgNext.height = "15";
        imgNext.style.paddingLeft = "4px";
        aNext.className = "hrefgallery";
        aNext.appendChild(document.createTextNode("n" + String.fromCharCode(228) + "chstes Bild"));
        aNext.appendChild(imgNext);
        
        var img = document.createElement("img");
        img.src = folder + image;
        img.width = globalImageWidth;
        img.height = globalImageHeight;
      
        td11.appendChild(divSlide);
        td11.appendChild(divLogo);
        td11.appendChild(divClose);
        tr1.appendChild(td11);
        tbody.appendChild(tr1);
        
        td21.appendChild(img);
        tr2.appendChild(td21);
        tbody.appendChild(tr2);
        
        td31.appendChild(divPrevious);
        td31.appendChild(divNext);
        tr3.appendChild(td31);
        tbody.appendChild(tr3);
        
        table.appendChild(tbody);
        document.getElementById('gallery').appendChild(table);
        
        if (ie)
        {
          divSlide.style.position = "absolute";
          divSlide.style.top = "42px";
          divSlide.style.left = "20px";
          divSlide.id = "divSlide";
          divLogo.style.position = "absolute";
          divLogo.style.top = "8px";
          divLogo.style.left = (parseInt(width)/2-64) + "px";
          divLogo.id = "divLogo";
          divClose.style.position = "absolute";
          divClose.style.top = "44px";
          divClose.style.left = (parseInt(width)-90) + "px";
          divClose.id = "divClose";
          divNext.style.position = "absolute";
          divNext.style.top = (parseInt(height)-22) +"px";
          divNext.style.left = (parseInt(width)-110) +"px";
          divNext.id = "divNext";
          divPrevious.style.position = "absolute";
          divPrevious.style.top = (parseInt(height)-22) +"px";
          divPrevious.style.left = "20px";
          divPrevious.id = "divPrevious";
          td11.style.textAlign = "right";
          td11.style.width = "100%";
          td11.style.height = "64px";
          td21.style.paddingBottom = "0px";
          td21.style.paddingLeft = "20px";
          td21.style.paddingRight = "20px";
          td21.style.paddingTop = "0px";
          td31.style.padding = "10px";
          td31.style.height = "28px";
          table.style.width = "100%";
          table.style.fontSize = "12px";
          aSlide.onclick = function(){startSlideshow(folder);};
          aSlide.setAttribute("class", "hrefgallery");
          aSlide.style.cursor = "pointer";
          aClose.onclick = function(){hideGallery();fadeOutLayer();};
          aClose.style.cursor = "pointer";
          aPrevious.onclick = function(){galleryNext(folder, 0, false);};
          aPrevious.style.cursor = "pointer";
          aNext.onclick = function(){galleryNext(folder, 1, false);};
          aNext.style.cursor = "pointer";
          img.id = "img";
        }
        else
        {
          divSlide.setAttribute("id", "divSlide");
          divSlide.setAttribute("style", "position: absolute; top: 42px; left: 20px");
          divClose.setAttribute("id", "divClose");
          divClose.setAttribute("style", "position: absolute; top: 44px; left: " + (parseInt(width)-90) + "px");
          divLogo.setAttribute("id", "divLogo");
          divLogo.setAttribute("style", "position: absolute; top: 8px; left: " + (parseInt(width)/2-64) + "px");
          divNext.setAttribute("id", "divNext");
          divNext.setAttribute("style", "position: absolute; top: 0px; left: " + (parseInt(width)-110) + "px; top: " + (parseInt(height)-22) +"px");
          divPrevious.setAttribute("id", "divPrevious");
          divPrevious.setAttribute("style", "position: absolute; top: 0px; left: 20px; top: " + (parseInt(height)-22) +"px");
          td11.setAttribute("style", "text-align: right; width: 100%; height: 64px");
          td21.setAttribute("style", "padding-bottom: 0px; padding-left: 20px; padding-right: 20px; padding-top: 0px; font-weight: bold");
          td31.setAttribute("style", "height: 28px;");
          table.setAttribute("style", "width: 100%; font-size: 12px");
          table.setAttribute("cellpadding", "0");
          table.setAttribute("cellspacing", "0");
          aSlide.setAttribute("onclick", "startSlideshow('" + folder + "')");
          aSlide.setAttribute("style", "cursor: pointer;");
          aClose.setAttribute("onclick", "hideGallery();fadeOutLayer()");
          aClose.setAttribute("style", "cursor: pointer;");
          aNext.setAttribute("onclick", "galleryNext('" + folder + "', 1, false);");
          aNext.setAttribute("style", "cursor: pointer;");
          aPrevious.setAttribute("onclick", "galleryNext('" + folder + "', 0, false);");
          aPrevious.setAttribute("style", "cursor: pointer;");
          img.setAttribute("id", "img");
        }
}

function startSlideshow(folder)
{
          sliding=true;
          document.getElementById('aSlide').removeChild(document.getElementById('aSlide').lastChild);
          document.getElementById('aSlide').appendChild(document.createTextNode("Slideshow stoppen"));
          if (ie)
          {
            document.getElementById('aSlide').onclick = function(){stopSlideshow(folder);};
          }
          else
          {
            document.getElementById('aSlide').setAttribute("onclick", "stopSlideshow('" + folder + "')");
          }
          slideshow(folder);
}

function stopSlideshow(folder)
{
          sliding = false;
          document.getElementById('aSlide').removeChild(document.getElementById('aSlide').lastChild);
          document.getElementById('aSlide').appendChild(document.createTextNode("Slideshow starten"));
          if (ie)
          {
            document.getElementById('aSlide').onclick = function(){startSlideshow(folder);};
          }
          else
          {
            document.getElementById('aSlide').setAttribute("onclick", "startSlideshow('" + folder + "')");
          }
          galleryNext(folder, 1, false);
}

function slideshow(folder)
{
        if (sliding)
        {
          window.setTimeout("slideshow('" + folder + "')", 5000);
          galleryNext(folder, 1, true);
        }
}

function hideGallery()
{
        sliding = false;
        document.getElementById('img').style.visibility = "hidden";
        document.getElementById('gallery').style.visibility = "hidden";
}

function galleryNext(folder, goNext, slideshow)
{
        var request = null;
        var width;
        var height;
        
    
	// Mozilla.
	if (window.XMLHttpRequest)
	{
		request = new XMLHttpRequest();
	}
	
	// Microsoft.
	else if (window.ActiveXObject)
	{
		request = new ActiveXObject("Microsoft.XMLHTTP"); 
	}
        
        if (goNext == 1)
        {
          request.open("GET", "scripts/getnextimageasync.php?galleryFolder=" + folder + "&previous=" + globalImage, true);
        }
        else
        {
          request.open("GET", "scripts/getpreviousimageasync.php?galleryFolder=" + folder + "&previous=" + globalImage, true);
        }
	request.onreadystatechange = function() 
	{
        if ((request.readyState == 4) && (request.status == 200)) 
        {
            // Fill the text boxes with content.
            next = eval("(" + request.responseText + ")");
            globalImage = next.image;
            width = next.width;
            height = next.height;
            
            var realWidth = parseInt(document.getElementById('gallery').style.width);
            var realHeight = parseInt(document.getElementById('gallery').style.height);
            if ((parseInt(document.getElementById('gallery').style.width) != width) 
              && (parseInt(document.getElementById('gallery').style.height) != height))
            {
              if (false)
              {
                // Resize at once if the difference is marginal.
                document.getElementById('gallery').style.width = (parseInt(width)+56) + "px";
                document.getElementById('gallery').style.height = (parseInt(height)+40) + "px";
              }
              else
              {
                var stepW;
                if (parseInt(document.getElementById('gallery').style.width) < width)
                {
                  stepW = slideStep;
                }
                else
                {
                  stepW = -slideStep;
                }
                
                var stepH;
                if (parseInt(document.getElementById('gallery').style.height) < height)
                {
                  stepH = slideStep;
                }
                else
                {
                  stepH = -slideStep;
                }
               
                if ((width != globalImageWidth) || (height != globalImageHeight))
                {
                  adjustGallerySize(stepW, stepH, parseInt(width)+40, parseInt(height)+92);
                }
              }
              
              var img = window.document.getElementById("img");
              
              img.style.visibility = "hidden";
              img.src = folder + globalImage;
              if ((!slideshow || (slideshow && sliding)) && window.document.getElementById('gallery').style.visibility == "visible")
              {
                img.style.visibility = "visible";
              }
              
              img.width = width;
              img.height = height;
              globalImageWidth = width;
              globalImageHeight = height;
            }
        }
    }    
   
    request.send(null);
}

function preloadImage(folder, next)
{
        var request = null;
        var width;
        var height;
        
    
	// Mozilla.
	if (window.XMLHttpRequest)
	{
		request = new XMLHttpRequest();
	}
	
	// Microsoft.
	else if (window.ActiveXObject)
	{
		request = new ActiveXObject("Microsoft.XMLHTTP"); 
	}
         
        if (next == 1)
        {
          request.open("GET", "scripts/getnextimageasync.php?previous=" + globalImage, true);
        }
        else
        {
          request.open("GET", "scripts/getpreviousimageasync.php?previous=" + globalImage, true);
        }
	request.onreadystatechange = function() 
	{
        if ((request.readyState == 4) && (request.status == 200)) 
        {
            // Fill the text boxes with content.
            next = eval("(" + request.responseText + ")");
            var img = document.createElement("img");
            img.src = folder + next.image;
        }
    }    
   
    request.send(null);
}

function showHotelPicker()
{
        var td = window.document.getElementById('ticketProperties');
        if ((window.document.getElementById('ticketType')[window.document.getElementById('ticketType').selectedIndex].value == "4")
            && (!hotelSelectionVisible))
        {
          
          // 1.: Text.
          td.appendChild(document.createTextNode("Hotel:"));
          
          // 2.: Select.
          var select = document.createElement("select");
          select.setAttribute("name", "hotel");
          select.setAttribute("id", "hotel");
          select.setAttribute("style", "width: 240px");
          
          td.appendChild(select);
          
          // 3.: Text.
          td.appendChild(document.createTextNode("Anzahl EZ:"));
          
          // 4.: Input.
          var singleRoom = document.createElement("input");
          singleRoom.setAttribute("type", "text");
          singleRoom.setAttribute("name", "singleRoom");
          singleRoom.setAttribute("style", "width: 40px");
          td.appendChild(singleRoom);
          
          // 5.: Text.
          td.appendChild(document.createTextNode("Anzahl Zusatznaechte:"));
          
          // 6.: Input.
          var extraNight = document.createElement("input");
          extraNight.setAttribute("type", "text");
          extraNight.setAttribute("name", "extraNight");
          extraNight.setAttribute("style", "width: 40px");
          td.appendChild(extraNight);
          
          loadHotelsAsync();
          
          hotelSelectionVisible = true;
        }
        else
        {
          if (hotelSelectionVisible)
          {
            for (var i=0; i<6; i++)
            {
              var item = td.lastChild;
              td.removeChild(item);
            }
            
            hotelSelectionVisible = false;
          }
        }
}

function str_replace(search, replace, subject) 
{
    return subject.split(search).join(replace);
}

function replaceHtmlSpecialChars(text)
{
    text = str_replace("&quot;", String.fromCharCode(34), text);
    text = str_replace("&Auml;", String.fromCharCode(196), text);
    text = str_replace("&Ouml;", String.fromCharCode(214), text);
    text = str_replace("&Uuml;", String.fromCharCode(220), text);
    text = str_replace("&auml;", String.fromCharCode(228), text);
    text = str_replace("&ouml;", String.fromCharCode(246), text);
    text = str_replace("&uuml;", String.fromCharCode(252), text);
    text = str_replace("&szlig;", String.fromCharCode(223), text);
    return text;
}

function ticketRowOver(row)
{
	for (var i=0; i<row.cells.length; i++)
	{
		row.cells[i].style.backgroundColor = "#999999";
		row.cells[i].style.color = "#FFFFFF";
	}
}

function ticketRowOut(row)
{
	for (var i=0; i<row.cells.length; i++)
	{
		row.cells[i].style.backgroundColor = "#CCCCCC";
		row.cells[i].style.color = "#000000";
	}
}
-->
