var messages={  
  'keineangebotegefunden':{
    'de':'Es wurden keine Angebote gefunden',
    'it':'Nessuna offerta presente ',
    'en':'No offers found'
  }
}

var proxyurl="ahAjaxProxy.php";

var preisspanne=  Array(20,170);
var sternespanne= Array(1,5);
var heightspanne= Array(0,2100);
var hotelart=Array();
var themenhotels=Array();
var hotelausstattung=Array();
var zimmertyp=Array();
var zimmerausstattung=Array();

var score1=0;
var score2=0;
var score3=0;

var preissteps=false;
var heightsteps=false

var mappinimage='ah.png';
var gmapview='NORMAL'; //NORMAL, SATELLITE oder HYBRID
var giconsize=Array(21,37)
var giconanchor=Array(10,35);
var gmapballoonmaxheight=200;
var gmapballoonmaxwidth=false;

var sumdivsum=0;
var sumdiv5stars=0;
var sumdiv4stars=0;
var sumdiv3stars=0;

var sumdivreal5stars=0;
var sumdivreal4sstars=0;
var sumdivreal4stars=0;
var sumdivreal3sstars=0;
var sumdivreal3stars=0;
var limit=30;
var sortparam=false;
var preistypurlaubtxt='Gesamtpreis';
var preistyphoteltxt='pro Person im DZ';

var detmaps=Array();

var thumbnailpath=""; //"http://www.suedtirol-information.com/img/";
var filterdata;

var locationcode=false;
var zeitspanne=false;
var anzahlerw=false;
var alterkind1=false;
var alterkind2=false;
var alterkind3=false;

var verpflegung=false;
var hotelart=Array();
var themenhotels=Array();
var hotelausstattung=Array();
var zimmertyp=Array();
var zimmerausstattung=Array();

var rememberlist=Array();

String.prototype.get = function(p){
    return (match = this.match(new RegExp("[?|&]?" + p + "=([^&]*)"))) ? match[1] : false;
}

//Cookiemanagement:
var Cookie = {
  data: {},
  options: {domain: "", path: "", secure: false},  
  init: function(options, data) {
    Cookie.options = Object.extend(Cookie.options, options || {});
    var payload = Cookie.retrieve();
    if(payload) {
      Cookie.data = payload.evalJSON();
    }
    else {
      Cookie.data = data || {};
    }
    Cookie.store();
  },
  getData: function(key) {
    return Cookie.data[key];
  },
  setData: function(key, value) {
    Cookie.data[key] = value;
    Cookie.store();
  },
  removeData: function(key) {
    delete Cookie.data[key];
    Cookie.store();
  },
  retrieve: function() {
    var start = document.cookie.indexOf(Cookie.options.name + "=");
    if(start == -1) {
      return null;
    }
    if(Cookie.options.name != document.cookie.substr(start, Cookie.options.name.length)) {
      return null;
    }
    var len = start + Cookie.options.name.length + 1;   
    var end = document.cookie.indexOf(';', len);
    if(end == -1) {
      end = document.cookie.length;
    } 
    return unescape(document.cookie.substring(len, end));
  },
  store: function() {
    var expires = '';
    if (Cookie.options.expires) {
      var today = new Date();
      expires = Cookie.options.expires * 86400000;
      expires = ';expires=' + new Date(today.getTime() + expires);
    }
    document.cookie = Cookie.options.name + '=' + escape(Object.toJSON(Cookie.data)) + Cookie.getOptions() + expires;
  },
  erase: function() {
    document.cookie = Cookie.options.name + '=' + Cookie.getOptions() + ';expires=Thu, 01-Jan-1970 00:00:01 GMT';
  },
  getOptions: function() {
    return (Cookie.options.path ? ';path=' + Cookie.options.path : '') + (Cookie.options.domain ? ';domain=' + Cookie.options.domain : '') + (Cookie.options.secure ? ';secure' : '');      
  }
};

Cookie.init({name: 'sliderdata', path: '/'});




// horizontal slider control

function $N(name, doc) {
  return $A((doc || document).getElementsByName(name));
}

function convsterne(value) {

	// alert(value);
	
	switch (value) {
	
		case '1': 
			return '*';
		case '2':
			return '**';
		case '3':
			return '***';			
		case '14':
			return '***<sup>s</sup>';
		case '4':
			return '****';			
		case '5':
			return '****<sup>s</sup>';
		case '6':
			return '*****';
	}
}

/*
var locationcode=false;
if (window.location.search.get('locationcode')){
  locationcode=window.location.search.get('locationcode');
}

var zeitspanne=false;
if (window.location.search.get('zeitspanne')){
  zeitspanne=window.location.search.get('zeitspanne');
}
if (window.location.search.get('anreisedatum') && window.location.search.get('abreisedatum')){
  zeitspanne=window.location.search.get('anreisedatum')+","+window.location.search.get('abreisedatum');
}

var anzahlerw=false;
if (window.location.search.get('anzahlerw')){
  anzahlerw=window.location.search.get('anzahlerw');
}
var alterkind1=false;
if (window.location.search.get('alterkind1')){
  alterkind1=window.location.search.get('alterkind1');
}
var alterkind2=false;
if (window.location.search.get('alterkind2')){
  alterkind2=window.location.search.get('alterkind2');
}
var alterkind3=false;
if (window.location.search.get('alterkind3')){
  alterkind3=window.location.search.get('alterkind3');
}
*/

function setHotelSuche(dercode,thema){
  locationcode=dercode;
  zeitspanne=false;
  anzahlerw=false;
  alterkind1=false;
  alterkind2=false;
  alterkind3=false;
  hotelidsparam=false;
  var thekeys=Object.keys(filterdata.themenhotels);
  if (thema!=undefined){
    for (var i=0; i< thekeys.length; i++){
      if($('searchfilterthemenhotels_'+thekeys[i]).value==thema){
        $('searchfilterthemenhotels_'+thekeys[i]).checked=true;
      }else{
        $('searchfilterthemenhotels_'+thekeys[i]).checked=false;
      }    
    }	
  }
  
  loaddata();
}
//javascript:setUrlaubSuche(%20document.getElementById('anzahlerw3').value,%20document.getElementById('alterkind1').value,%20document.getElementById('alterkind2').value,%20document.getElementById('alterkind3').value);
function setUrlaubSuche(dercode,datumvon,datumbis,paramanzahlerw,paramalterkind1,paramalterkind2,paramalterkind3){
  locationcode=dercode;
  zeitspanne=datumvon+","+datumbis;
  anzahlerw=paramanzahlerw;
  alterkind1=paramalterkind1;
  alterkind2=paramalterkind2;
  alterkind3=paramalterkind3;
  hotelidsparam=false;
  loaddata();
}


function loaddata(){  
  sumdivsum=0;
  sumdiv5stars=0;
  sumdiv4stars=0;
  sumdiv3stars=0;
  sumdivreal5stars=0;
  sumdivreal4sstars=0;
  sumdivreal4stars=0;
  sumdivreal3sstars=0;
  sumdivreal3stars=0;
  $('sucheausgabeloading').style.display='block';
  var locationcodegetparam =""
  if (locationcode!=false) locationcodegetparam='&locationcode='+locationcode;
  var urlaubsparams='';
  if (zeitspanne!=false){ //urlaubsuche:
    urlaubsparams+='&anzahlerw='+anzahlerw;
    urlaubsparams+='&alterkind1='+alterkind1;
    urlaubsparams+='&alterkind2='+alterkind2;
    urlaubsparams+='&alterkind3='+alterkind3;  
  }
  var scoregetparam='';
  if (score1>0) scoregetparam+="&score1="+score1;
  if (score2>0) scoregetparam+="&score2="+score2;
  if (score3>0) scoregetparam+="&score3="+score3;
  var aj = new Ajax.Request(
		proxyurl+'?ah_path=gethotelsearchresults.php&culture='+culture+sparam+'&preisspanne='+preisspanne+'&sternespanne='+sternespanne+'&heightspanne='+heightspanne+'&hotelart='+hotelart+'&themenhotels='+themenhotels+'&hotelausstattung='+hotelausstattung+'&zimmertyp='+zimmertyp+'&zimmerausstattung='+zimmerausstattung+(verpflegung!=false ? '&verpflegung='+verpflegung : '')+'&limit='+limit+(sortparam!=false ? '&sort='+sortparam : '')+(zeitspanne == false ? '' : '&zeitspanne='+zeitspanne)+(hotelidsparam == false ? '' : '&hotelids='+hotelidsparam)+urlaubsparams+locationcodegetparam+scoregetparam, {
			method:'post',
			evalJSON: 'force',
			//parameter: {path: 'gethotelsearchfilterdata.php', culture: 'de'},
			onComplete: showresults
		}
	); 

}

function convertdata(thedata,thenummer){
  var subkathtml="";
  var tdata=thedata[11];
  if(typeof filterdata!='undefined'){
    for (var i=0; i<tdata.length; i++){
      if (typeof (filterdata.hotelart) != 'undefined' && typeof (filterdata.hotelart[tdata[i]]) != 'undefined'){
        subkathtml+='<li>'+filterdata.hotelart[tdata[i]]+'</li>';
      }else if (typeof (filterdata.themenhotels) != 'undefined' && typeof (filterdata.themenhotels[tdata[i]]) != 'undefined'){
        subkathtml+='<li>'+filterdata.themenhotels[tdata[i]]+'</li>';	      
      }
    }
  }  
  var convdata = {
    id:thedata[0], 
    title:thedata[1], 
    bild:thumbnailpath+thedata[2], 
    sterne:convsterne(thedata[3]), 
    land:thedata[4], 
    region:thedata[5], 
    ferienregion:thedata[6], 
    ort:thedata[7], 
    minpreis:preisoutputtemplatefunction(thedata[8]), 
    hoehenmeter:thedata[9], 
    klasse:thedata[10],
    subkat:subkathtml,
    hotelausstattung:thedata[12],
    zimmertyp:thedata[13],
    zimmerausstattung:thedata[14],
    nummer:thenummer,
    excerptline1:thedata[15],
    excerptline2:thedata[16],
    excerptline3:thedata[17],
    excerptline1empty: (thedata[15]=='' || thedata[15] == null ? 1 : 0),
    excerptline2empty: (thedata[16]=='' || thedata[16] == null ? 1 : 0),
    excerptline3empty: (thedata[17]=='' || thedata[17] == null ? 1 : 0),
    www:thedata[20],
    strasse:thedata[21],
    preistyp:(zeitspanne!=false) ? preistypurlaubtxt : preistyphoteltxt,
    email:thedata[25],
    tel:thedata[26],
    fax:thedata[27],
    odd:(thenummer % 2),
    land_id:thedata[29],
    region_id:thedata[30],
    ferienregion_id:thedata[31],
    ort_id:thedata[32]  
  }  
  if (typeof (thedata[24].length)!='number' && Object.values(thedata[24]).length>0){
    var dynfields=thedata[24];
    var dynfieldnames=Object.keys(dynfields);
    var dynfieldvalues=Object.values(dynfields);
    for(var i=0; i<dynfieldnames.length; i++){
      if (dynfieldvalues[i]==null || typeof(dynfieldvalues[i])=='undefined') dynfieldvalues[i]='';      
      if (typeof (window[dynfieldnames[i]+"Outputfunction"]) == 'function'){        
        var newvalue=window[dynfieldnames[i]+"Outputfunction"](dynfieldvalues[i]);
        eval("convdata."+dynfieldnames[i]+"='"+newvalue+"'");
      }else{
        eval("convdata."+dynfieldnames[i]+"='"+dynfieldvalues[i]+"'");
      }
      
      
      
      //eval("convdata."+dynfieldnames[i]+"='fjkdla lkdfsajkfdas'");
      
      //convdata.extend(convdata, { dynfieldnames[i] : dynfieldvalues[i] });
    }
  }
  return convdata;
}

function makeoutput(thedata,thenummer){
  var thetemplate1 = theboxdetailtemplate1;
  var thetemplate2 = theboxdetailtemplate2;
  var thetemplate3 = theboxdetailtemplate3;
  
  sumdivsum++;
  switch (thedata[3]) {					
		case '3':
			sumdiv3stars++;
			sumdivreal3stars++;
			break;
		case '14':
			sumdiv3stars++;
			sumdivreal3sstars++;
			break;
		case '4':
			sumdiv4stars++;	
			sumdivreal4stars++;
			break;
		case '5':
			sumdiv4stars++;
			sumdivreal4sstars++;
			break;
		case '6':
			sumdiv5stars++;
			sumdivreal5stars++;
			break;
	}
	
	var convdata=convertdata(thedata,thenummer);
	if (thedata[23]==1){
    return thetemplate1.evaluate(convdata);	
  }else if (thedata[23]==2){
    return thetemplate2.evaluate(convdata);	
  }else{
    return thetemplate3.evaluate(convdata);	
  } 
 
}



function makebaloon(thedata,thenummer){
	var convdata=convertdata(thedata,thenummer);	
  //alert(thetemplate1.evaluate(convdata));
  if (thedata[23]==1){
    if (maptemplate1!=false) addmarker(thenummer,maptemplate1.evaluate(convdata),thedata[18],thedata[19]);
  }else if (thedata[23]==2){
    if (maptemplate1!=false) addmarker(thenummer,maptemplate2.evaluate(convdata),thedata[18],thedata[19]);
  }else{
    if (maptemplate1!=false) addmarker(thenummer,maptemplate3.evaluate(convdata),thedata[18],thedata[19]);
  } 
}




var data;
function showresults(resp){ 
  data = resp.responseJSON; 
  makeresultshtml();
}
function makeresultshtml(){
  sumdivsum=0;
  if (hotelsmap) hotelsmap.clearOverlays();
  var resulthtml=""; 
  if (mastertemplatefile!=false) {
	var ids='';
	for (var i=0; i<data.length; i++){
		if (ids!='') ids += ',';
		ids += data[i][0];
	}
    new Ajax.Request(mastertemplatefile+'?hotelids='+ids, {
      onSuccess: function (transport){
		  resulthtml = transport.responseText;
		  if (resulthtml.length>0){
			if ($('nothingfounddiv')) $('nothingfounddiv').hide();
		  }else{
			if ($('nothingfounddiv')) $('nothingfounddiv').show();
		  }
		  resulthtml+='<div id="sucheausgabeloading" style="display:none;" class="loading"><div class="loadingimage">&nbsp;</div></div>';  
		  $('sucheausgabediv').update(resulthtml); 
		  if (typeof updatesumdiv != 'undefined') updatesumdiv();  
		  if (hotelsmap!=false) maploaded();  
		  if (typeof onresultsloaded != 'undefined'){ //function wird aufgerufen sobald alles fertig ist:
			onresultsloaded();
		  } 
	  }
    });
  } else { 
	  if (data.length>0){
		if ($('nothingfounddiv')) $('nothingfounddiv').hide();
	  }else{
		if ($('nothingfounddiv')) $('nothingfounddiv').show();
	  }   
	  for (var i=0; i<data.length; i++){
		var entrhtml=makeoutput(data[i],i+1);
		resulthtml+=entrhtml;
		if (window.location.search.get('test')) alert('showresult:'+i+" - "+entrhtml);
	  }
	  
	  resulthtml+='<div id="sucheausgabeloading" style="display:none;" class="loading"><div class="loadingimage">&nbsp;</div></div>';  
	  $('sucheausgabediv').update(resulthtml); 
	  if (typeof updatesumdiv != 'undefined') updatesumdiv();  
	  if (hotelsmap!=false) maploaded();  
	  if (typeof onresultsloaded != 'undefined'){ //function wird aufgerufen sobald alles fertig ist:
		onresultsloaded();
	  } 
  }	  

}


var ignorecookie=false;
var resetcookie=false;

var mastertemplatefile=false;
var templatefile1=false;
var templatefile2=false;
var templatefile3=false;
var maptemplatefile1=false;
var maptemplatefile2=false;
var maptemplatefile3=false;
var sparam='';
var hotelidsparam=false;

var galeriesubtemplatebigimgcode='<img alt="#{imagetxt}" src="http://service.alpine-hotels.com/ah/web/getthumbnail.php?img=img/#{imageurl}&maxx=300&maxy=300&mode=normal" />';
var galeriesubtemplatesmallimgcode='<li><a href="#" onclick="return showimage(#{theid},\'#{p2}\',\'#{p1}\')"><img src="http://service.alpine-hotels.com/ah/web/getthumbnail.php?img=img/#{p2}&maxx=64&maxy=64&mode=crop" /></a></li>';
var portalgalerie=false;
var sterneoutputfunction=function(a,b){
  return(a<b) ? a+" - "+b+" Sterne" : b+" - "+a+" Sterne";
}
var preisoutputtemplatefunction=function(a){
  return a;
}


function initsearch(params){

  if (typeof params.mastertemplatefile !='undefined'){
    mastertemplatefile=params.mastertemplatefile;
  }
  if (typeof params.templatefile1 !='undefined'){
    templatefile1=params.templatefile1;
  }
  if (typeof params.templatefile2 !='undefined'){
    templatefile2=params.templatefile2;
  }
  if (typeof params.templatefile3 !='undefined'){
    templatefile3=params.templatefile3;
  }
  
  if (typeof params.maptemplatefile1 !='undefined'){
    maptemplatefile1=params.maptemplatefile1;
  }
  if (typeof params.maptemplatefile2 !='undefined'){
    maptemplatefile2=params.maptemplatefile2;
  }
  if (typeof params.maptemplatefile3 !='undefined'){
    maptemplatefile3=params.maptemplatefile3;
  }
  
  if (typeof params.infotemplatefile !='undefined'){
    infotemplatefile=params.infotemplatefile;
  }
  if (typeof params.umgebungtemplatefile !='undefined'){
    umgebungtemplatefile=params.umgebungtemplatefile;
  }
  if (typeof params.galerietemplatefile !='undefined'){
    galerietemplatefile=params.galerietemplatefile;
  }
  if (typeof params.ausstattungtemplatefile !='undefined'){
    ausstattungtemplatefile=params.ausstattungtemplatefile;
  }
  if (typeof params.zimmertemplatefile !='undefined'){
    zimmertemplatefile=params.zimmertemplatefile;
  }
  if (typeof params.bookingstep2file !='undefined'){
    bookingstep2file=params.bookingstep2file;
  }
  if (typeof params.bookingstep1file !='undefined'){
    bookingstep1file=params.bookingstep1file;
  }  
  if (typeof params.bookingstep3file !='undefined'){
    bookingstep3file=params.bookingstep3file;
  } 
  
  if (typeof params.bookingstep3_namenalterfile !='undefined'){
    bookingstep3_namenalterfile=params.bookingstep3_namenalterfile;
  } 
  if (typeof params.danketemplatefile !='undefined'){
    danketemplatefile=params.danketemplatefile;
  } 
  if (typeof params.anfragefile !='undefined'){
    anfragefile=params.anfragefile;
  }
  if (typeof params.anfragedanketemplatefile !='undefined'){
    anfragedanketemplatefile=params.anfragedanketemplatefile;
  }
  
  if (typeof params.angebotetemplatefile !='undefined'){
    angebotetemplatefile=params.angebotetemplatefile;
  }
  
  
  if (typeof params.preistypurlaubtxt !='undefined'){
    preistypurlaubtxt=params.preistypurlaubtxt;
  }
  if (typeof params.preistyphoteltxt !='undefined'){
    preistyphoteltxt=params.preistyphoteltxt;
  }
  
  if (typeof params.galeriesubtemplatebigimgcode !='undefined'){
    galeriesubtemplatebigimgcode=params.galeriesubtemplatebigimgcode;
  }
  if (typeof params.galeriesubtemplatesmallimgcode !='undefined'){
    galeriesubtemplatesmallimgcode=params.galeriesubtemplatesmallimgcode;
  }  
  if (typeof params.portalgalerie !='undefined'){
    portalgalerie=params.portalgalerie;
  }  
  
  if (typeof params.proxyurl !='undefined'){
    proxyurl=params.proxyurl;
  }
  if (typeof params.culture !='undefined'){
    culture=params.culture;
  }
  if (typeof params.sparam !='undefined'){
    sparam=params.sparam;
  }
  if (typeof params.mappinimage !='undefined'){
    mappinimage=params.mappinimage;
  }
  
  if (typeof params.sterneoutputfunction !='undefined'){
    sterneoutputfunction=params.sterneoutputfunction;
  }
  
  if (typeof params.preisoutputtemplatefunction !='undefined'){
    preisoutputtemplatefunction=params.preisoutputtemplatefunction;
  }
  
  if (typeof params.gmapview !='undefined'){
    gmapview=params.gmapview;
  }
  
  if (typeof params.gmapview !='undefined'){
    gmapview=params.gmapview;
  }
  if (typeof params.giconsize !='undefined'){
    giconsize=params.giconsize;
  }
  if (typeof params.giconanchor !='undefined'){
    giconanchor=params.giconanchor;
  }
  
  if (typeof params.resetcookie !='undefined'){
    resetcookie=params.resetcookie;
    if (resetcookie){
      Cookie.erase();
      Cookie.init({name: 'sliderdata', path: '/'});
    }
  }
  
  if (typeof params.ignorecookie !='undefined'){
    ignorecookie=params.ignorecookie; 
  }
  
  //übergabeparams:
  
  
  if (typeof params.locationcode !='undefined' && params.locationcode!=''){
    locationcode=params.locationcode;
  } /*else if (Cookie.getData('locationcode')){
    locationcode=Cookie.getData('locationcode');
  }*/
  
  if (typeof params.zeitspanne !='undefined' && params.zeitspanne!=''){
    zeitspanne=params.zeitspanne;
  }
  if (typeof params.anreisedatum !='undefined' && params.anreisedatum!='' && typeof params.abreisedatum !='undefined' && params.abreisedatum!=''){
    zeitspanne=params.anreisedatum+","+params.abreisedatum;
  }  
  
  if (typeof params.anzahlerw !='undefined' && params.anzahlerw!=''){
    anzahlerw=params.anzahlerw;
  }
  
  if (typeof params.alterkind1 !='undefined' && params.alterkind1!=''){
    alterkind1=params.alterkind1;
  }
  
  if (typeof params.alterkind2 !='undefined' && params.alterkind2!=''){
    alterkind2=params.alterkind2;
  }
  
  if (typeof params.alterkind3 !='undefined' && params.alterkind3!=''){
    alterkind3=params.alterkind3;
  }
  
  if (typeof params.hotelids !='undefined' && params.hotelids!=''){
    hotelidsparam=params.hotelids;
  }
  
  if (typeof params.sort !='undefined' && params.sort!=''){
    sortparam=params.sort;
  }
  if (typeof params.limit !='undefined' && params.limit!=''){
    limit=params.limit;
  }   
  
  if (typeof params.gmapballoonmaxheight !='undefined' && params.gmapballoonmaxheight!=''){
    gmapballoonmaxheight=params.gmapballoonmaxheight;
  }  
  if (typeof params.gmapballoonmaxwidth !='undefined' && params.gmapballoonmaxwidth!=''){
    gmapballoonmaxwidth=params.gmapballoonmaxwidth;
  }
  
  preisspanne=Array(0,50000);
  if (typeof params.preisspanne !='undefined' && params.preisspanne!=''){
    preisspanne=params.preisspanne.split(',');
    preisspanne[0]=Math.floor(preisspanne[0]);
    preisspanne[1]=Math.floor(preisspanne[1]);
  }else if (Cookie.getData('preisspanne') && !ignorecookie){
    preisspanne=Cookie.getData('preisspanne');    
  }
  
  sternespanne=Array(1,5);
  if (typeof params.sternespanne !='undefined' && params.sternespanne!=''){
    sternespanne=params.sternespanne.split(',');
    sternespanne[0]=Math.floor(sternespanne[0]);
    sternespanne[1]=Math.floor(sternespanne[1]);
  }else if (Cookie.getData('sternespanne') && !ignorecookie){
    sternespanne=Cookie.getData('sternespanne');
    /*sternespanne=sternespanne.split(',');
    sternespanne[0]=Math.floor(sternespanne[0]);
    sternespanne[1]=Math.floor(sternespanne[1]);*/
  }
  //if (window.location.href.indexOf('test=true')!=-1) alert (Cookie.getData('sternespanne'));
  
	
  heightspanne=Array(0,2100);
  if (typeof params.heightspanne !='undefined' && params.heightspanne!=''){
    heightspanne=params.heightspanne.split(',');
    heightspanne[0]=Math.floor(heightspanne[0]);
    heightspanne[1]=Math.floor(heightspanne[1]);
  }else if (Cookie.getData('heightspanne') && !ignorecookie){
    heightspanne=Cookie.getData('heightspanne');    
  }
  

  hotelart=Array();
  if (typeof params.hotelart !='undefined' && params.hotelart!=''){
    hotelart=params.hotelart.split(',');    
  }else if (Cookie.getData('hotelart') && !ignorecookie){
    hotelart=Cookie.getData('hotelart');    
  }
	
  themenhotels=Array();
  if (typeof params.themenhotels !='undefined' && params.themenhotels!=''){
    themenhotels=params.themenhotels.split(',');    
  }else if (Cookie.getData('themenhotels') && !ignorecookie){
    themenhotels=Cookie.getData('themenhotels');    
  }	 

  hotelausstattung=Array();    
	if (typeof params.hotelausstattung !='undefined' && params.hotelausstattung!=''){
    hotelausstattung=params.hotelausstattung.split(',');    
  }else if (Cookie.getData('hotelausstattung') && !ignorecookie){
    hotelausstattung=Cookie.getData('hotelausstattung');    
  }

  zimmertyp=Array();    
	if (typeof params.zimmertyp !='undefined' && params.zimmertyp!=''){
    zimmertyp=params.zimmertyp.split(',');    
  }else if (Cookie.getData('zimmertyp') && !ignorecookie){
    zimmertyp=Cookie.getData('zimmertyp');    
  }

  zimmerausstattung=Array();    
	if (typeof params.zimmerausstattung !='undefined' && params.zimmerausstattung!=''){
    zimmerausstattung=params.zimmerausstattung.split(',');    
  }else if (Cookie.getData('zimmerausstattung') && !ignorecookie){
    zimmerausstattung=Cookie.getData('zimmerausstattung');    
  }
  
  verpflegung=false;
  if (typeof params.verpflegung !='undefined' && params.verpflegung!=''){
    verpflegung=params.verpflegung;
  }  
  
  if (typeof params.score1 !='undefined' && params.score1!=''){
    score1=params.score1;    
  }
  if (typeof params.score2 !='undefined' && params.score2!=''){
    score2=params.score2;    
  }
  if (typeof params.score3 !='undefined' && params.score3!=''){
    score3=params.score3;    
  }
  
  if (typeof params.preissteps !='undefined' && params.preissteps!=''){
    preissteps=params.preissteps;
  }
  if (typeof params.heightsteps !='undefined' && params.heightsteps!=''){
    heightsteps=params.heightsteps;
  }
      
  var resulthtml='<div id="sucheausgabeloading" class="loading"><div class="loadingimage">&nbsp;</div></div>';  
  $('sucheausgabediv').update(resulthtml);
  
    
  
  //load template:
  if (templatefile3!=false){
    new Ajax.Request(templatefile3, {
      onSuccess: loadedtemplatefile3
    });
  }else{
    loadedtemplatefile3(false);
  }
  
  detmaps=Array();
  
}

function loadmap(){
  //load template:
  if (maptemplatefile3!=false){
    new Ajax.Request(maptemplatefile3, {
      onSuccess: loadedmaptemplatefile3
    });
  }else{
    loadedmaptemplatefile3(false);
  }
}

function loadedmaptemplatefile3(transport){
  if (transport!=false) maptemplate3 = new Template(transport.responseText);   
  if (maptemplatefile2!=false){
    new Ajax.Request(maptemplatefile2, {
      onSuccess: loadedmaptemplatefile2
    });
  }else{
    loadedmaptemplatefile2(false);
  }
}

function loadedmaptemplatefile2(transport){
  if (transport!=false) maptemplate2 = new Template(transport.responseText);   
  if (maptemplatefile1!=false){
    new Ajax.Request(maptemplatefile1, {
      onSuccess: loadedmaptemplatefile1
    });
  }else{
    loadedmaptemplatefile1(false);
  }
}

function loadedmaptemplatefile1(transport){
  if (transport!=false) {
    maptemplate1 = new Template(transport.responseText);   
    maploaded();
  }
}

function loadedtemplatefile3(transport){
  if (transport!=false) theboxdetailtemplate3 = new Template(transport.responseText);   
  if (templatefile2!=false){
    new Ajax.Request(templatefile2, {
      onSuccess: loadedtemplatefile2
    });
  }else{
    loadedtemplatefile2(false);
  }
}

function loadedtemplatefile2(transport){
  if (transport!=false) theboxdetailtemplate2 = new Template(transport.responseText);   
  if (templatefile1!=false){
    new Ajax.Request(templatefile1, {
      onSuccess: loadedtemplatefile1
    });
  }else{
    loadedtemplatefile1(false);
  }
}
function loadedtemplatefile1(transport){
  if (transport!=false) theboxdetailtemplate1 = new Template(transport.responseText);   
  
  if (typeof generatesearchfilter != 'undefined'){ //regler generieren:
    generatesearchfilter();                            
	}else{
	  loaddata();
	}
  
}


function updatesumdiv(){
  
  if (sumdivsum==30) sumdivsum="> 30";
  if (sumdiv5stars==30) sumdiv5stars="> 30";
  if (sumdiv4stars==30) sumdiv4stars="> 30";
  if (sumdiv3stars==30) sumdiv3stars="> 30";
  
  if (sumdivreal5stars==30) sumdivreal5stars="> 30";
  if (sumdivreal4sstars==30) sumdivreal4sstars="> 30";
  if (sumdivreal4stars==30) sumdivreal4stars="> 30";
  if (sumdivreal3sstars==30) sumdivreal3sstars="> 30";  
  if (sumdivreal3stars==30) sumdivreal3stars="> 30";
  
  if($('sumdivsum')) $('sumdivsum').update(sumdivsum);
  if($('sumdiv5stars')) $('sumdiv5stars').update(sumdiv5stars);
  if($('sumdiv4stars')) $('sumdiv4stars').update(sumdiv4stars);
  if($('sumdiv3stars')) $('sumdiv3stars').update(sumdiv3stars);
  
  if($('sumdivreal5stars')) $('sumdivreal5stars').update(sumdivreal5stars);
  if($('sumdivreal4sstars')) $('sumdivreal4sstars').update(sumdivreal4sstars);
  if($('sumdivreal4stars')) $('sumdivreal4stars').update(sumdivreal4stars);
  if($('sumdivreal3sstars')) $('sumdivreal3sstars').update(sumdivreal3sstars);
  if($('sumdivreal3stars')) $('sumdivreal3stars').update(sumdivreal3stars);
}


var hotelsmap=false;
var image = new Array("/images/gmapper/143.png",32,32); 

function initmap(){
  
  if (document.getElementById("hotels_map")){
    if (GBrowserIsCompatible()) {
      G_NORMAL_MAP.getMinimumResolution = function(){return minZoomLevel};
      G_NORMAL_MAP.getMaximumResolution = function(){return maxZoomLevel}; 
      G_SATELLITE_MAP.getMinimumResolution = function(){return minZoomLevel};
      G_SATELLITE_MAP.getMaximumResolution = function(){return maxZoomLevel};
      G_HYBRID_MAP.getMinimumResolution = function(){return minZoomLevel};
      G_HYBRID_MAP.getMaximumResolution = function(){return maxZoomLevel};
      hotelsmap = new GMap2(document.getElementById("hotels_map"));      
      hotelsmap.setCenter(new GLatLng( 46.67,11.4),9);
      
      var bounds = hotelsmap.getBounds();
      var southWest = bounds.getSouthWest();
      var northEast = bounds.getNorthEast();
      var lngSpan = northEast.lng() - southWest.lng();
      var latSpan = northEast.lat() - southWest.lat();  
      
  		new GKeyboardHandler(hotelsmap);  
  		hotelsmap.enableDoubleClickZoom();  
  		hotelsmap.enableContinuousZoom(); 
  		var themaptype= G_NORMAL_MAP;
  		switch (gmapview) {
        case 'NORMAL': themaptype= G_NORMAL_MAP;
          break;     
        case 'SATELLITE': themaptype= G_SATELLITE_MAP;
          break;
        case 'HYBRID': themaptype= G_HYBRID_MAP;
          break;     
        default: themaptype= G_NORMAL_MAP;
      }
  		
  		hotelsmap.setMapType(themaptype);
  		
  		
  		if (document.getElementById('hotelsmapzoomslider')){
        ghotelsmapZoom = new Control.Slider('hotelsmapzoomslider', 'ghotelsmapleiste', {
          axis:'vertical',
          //increment: pixelIncrement,
          range: $R(-maxZoomLevel,-minZoomLevel),
          sliderValue: -ghotelsmapSliderValue,
          alignY: trackAlignY
        });
  
        ghotelsmapZoom.options.onChange = function(value) {
          setHotelsmapZoom(value);        
        }; 
      }
          
      
    }
  }
}
//var markerlist=Array();

var ghotelsmapSliderValue = 9;

function setHotelsmapZoom(zoomlevel){
  hotelsmap.setZoom(Math.round(-zoomlevel));  
  //alert(-zoomlevel);
  //gmapZoom[mapid].setValue(detmaps[mapid].getZoom());
}
function hotelsmapZoomin(){
  //detmaps[mapid].zoomIn();
  var newzoom=hotelsmap.getZoom();
  newzoom=newzoom+1;
  ghotelsmapZoom.setValue(Math.round(-newzoom));
}
function hotelsmapZoomout(){
  //detmaps[mapid].zoomOut();
  var newzoom=hotelsmap.getZoom();
  newzoom=newzoom-1;
  ghotelsmapZoom.setValue(Math.round(-newzoom));
}




function addmarker(entrycount,hotelname,lat,lng){
 //alert(entrycount,hotelname,lat,lng);

  if (hotelsmap!=false){  
    var letter = String.fromCharCode("A".charCodeAt(0) + entrycount);
    var icon = new GIcon();
    icon.shadow = "http://www.google.com/mapfiles/shadow50.png";
    
    icon.iconSize = new GSize(giconsize[0], giconsize[1]);
    icon.shadowSize = new GSize(37, 34);
    icon.iconAnchor = new GPoint(giconanchor[0], giconanchor[1]);
    icon.infoWindowAnchor = new GPoint(9, 2);
    icon.infoShadowAnchor = new GPoint(18, 25);
    
    icon.image = "http://service.bookingpilot.info/markers/numbered_marker.php?image=pushpins/webhues/"+mappinimage+"&text="+entrycount;
    
    var infoTabs = hotelname;
    var point = new GLatLng(lat,lng);
    var marker = new GMarker(point, icon); 
    //var marker = new GMarker(point); 
    var infowinparams={}
    if (gmapballoonmaxheight!=false) infowinparams.maxHeight=gmapballoonmaxheight;
    if (gmapballoonmaxwidth!=false) infowinparams.maxWidth=gmapballoonmaxwidth;
    GEvent.addListener(marker, "click", function() {
      marker.openInfoWindowHtml(infoTabs,infowinparams);
    }); 
    
    
    hotelsmap.addOverlay(marker);
  }
}
function showhidemap(){
  if ($('hotels_map_container').getStyle('display')=='none'){
    if (!hotelsmap) initmap();
		Effect.BlindDown('hotels_map_container',{ duration: 0.5, queue: 'end', afterFinish: function() { hotelsmap.checkResize(); hotelsmap.setCenter(mapbounds.getCenter());/*hotelsmap.setCenter(new GLatLng( 46.67,11.4),9); */  }});
    loadmap();
  }else{
		Effect.BlindUp('hotels_map_container',{ duration: 0.5, queue: 'end'});
  }
	return false;
}
var mapbounds = new GLatLngBounds();
function maploaded(){
  //baloons generieren:
  hotelsmap.clearOverlays();

  mapbounds = new GLatLngBounds();
  for (var i=0; i<data.length; i++){
    if (rememberlist.length==0 || (rememberlist.indexOf(parseInt(data[i][0]))>-1))makebaloon(data[i],i+1);    
    if (data[i][18]!=0 && data[i][19]!=0) mapbounds.extend(new GLatLng(data[i][18], data[i][19]));

  }
  hotelsmap.setCenter(mapbounds.getCenter());
  //auf marker zoomen:
  if (window.location.search.get('test')){
    //alert(mapbounds.getCenter());
    //hotelsmap.checkResize()
  //hotelsmap.setZoom(hotelsmap.getBoundsZoomLevel(bounds));
    
    //alert(hotelsmap.getCenter());
  }
}

function rememberThis(mid,theelement){
  mid=parseFloat(mid);
  if(rememberlist.indexOf(mid)==-1){
    if (theelement.checked==true) rememberlist.push(mid);
  }else{
    if (theelement.checked==false) rememberlist=rememberlist.without(mid);
  }
  if (hotelsmap!=false){
    hotelsmap.clearOverlays();
    var bounds = new GLatLngBounds();
    for (var i=0; i<data.length; i++){
      if (rememberlist.indexOf(parseInt(data[i][0]))>-1){  
        
        var thedata=data[i];
        
        var subkathtml="";
        var tdata=thedata[11];
        if (typeof(filterdata)!='undefined'){
          for (var ii=0; ii<tdata.length; ii++){
            if (typeof(filterdata.hotelart)!='undefined' && filterdata.hotelart[tdata[ii]]){
              if (typeof(filterdata.hotelart[tdata[ii]])!='undefined') subkathtml+='<li>'+filterdata.hotelart[tdata[ii]]+'</li>';
            }else if (typeof(filterdata.themenhotels)!='undefined' && typeof(filterdata.themenhotels[tdata[ii]])!='undefined'){
              subkathtml+='<li>'+filterdata.themenhotels[tdata[ii]]+'</li>';	      
            }
          }
        }
        sumdivsum++;
        switch (thedata[3]) {					
      		case '3':
      			sumdiv3stars++;
      			break;
      		case '14':
      			sumdiv3stars++;
      			break;
      		case '4':
      			sumdiv4stars++;	
      			break;
      		case '5':
      			sumdiv4stars++;
      			break;
      		case '6':
      			sumdiv5stars++;
      			break;
      	}
      	thenummer=i+1;
        var convdata = {
          id:thedata[0], 
          title:thedata[1], 
          bild:thumbnailpath+thedata[2], 
          sterne:convsterne(thedata[3]), 
          land:thedata[4], 
          region:thedata[5], 
          ferienregion:thedata[6], 
          ort:thedata[7], 
          minpreis:preisoutputtemplatefunction(thedata[8]), 
          hoehenmeter:thedata[9], 
          klasse:thedata[10],
          subkat:subkathtml,
          hotelausstattung:thedata[12],
          zimmertyp:thedata[13],
          zimmerausstattung:thedata[14],
          nummer:thenummer,
          excerptline1:thedata[15],
          excerptline2:thedata[16],
          excerptline3:thedata[17],
          www:thedata[20],
          strasse:thedata[21],
          preistyp:(zeitspanne!=false) ? preistypurlaubtxt : preistyphoteltxt
        }
        var renderedtemplate='';
        if (thedata[23]==1){
          renderedtemplate=maptemplate1.evaluate(convdata);
        }else if (thedata[23]==2){
          renderedtemplate=maptemplate2.evaluate(convdata);
        }else{
          renderedtemplate=maptemplate3.evaluate(convdata);
        }
        if (thedata[18]!=0 && thedata[19]!=0){        
          addmarker(thenummer,renderedtemplate,thedata[18],thedata[19]);
          bounds.extend(new GLatLng(thedata[18], thedata[19]));
        }
        if (window.location.search.get('test')) alert(thedata[18]+" - "+thedata[19]);
      }
    }
    if(rememberlist.length==0){
      hotelsmap.setCenter(new GLatLng( 46.67,11.4),9);
    }else{
      //auf marker zoomen:
      //hotelsmap.checkResize()
      hotelsmap.setZoom(hotelsmap.getBoundsZoomLevel(bounds));
      hotelsmap.setCenter(bounds.getCenter()); 
    }

  }
  
}





//map einstellungen
var zoomLevel = 9;
var minZoomLevel = 6;
var maxZoomLevel = 15;
var trackLength = 114;
var sliderLength = 12;
var gmapZoom=new Array();
var trackAlignY = Math.round((trackLength-sliderLength)/2*-1);
var realTrackLength = trackLength-sliderLength;
var pixelIncrement = Math.round(realTrackLength/(maxZoomLevel-minZoomLevel));
var gmapSliderValue = zoomLevel;

function setMapZoom(mapid,zoomlevel){
  detmaps[mapid].setZoom(Math.round(-zoomlevel));  
  //alert(-zoomlevel);
  //gmapZoom[mapid].setValue(detmaps[mapid].getZoom());
}
function mapZoomin(mapid){
  //detmaps[mapid].zoomIn();
  var newzoom=detmaps[mapid].getZoom();
  newzoom=newzoom+1;
  gmapZoom[mapid].setValue(Math.round(-newzoom));
}
function mapZoomout(mapid){
  //detmaps[mapid].zoomOut();
  var newzoom=detmaps[mapid].getZoom();
  newzoom=newzoom-1;
  gmapZoom[mapid].setValue(Math.round(-newzoom));
}

function initdetmap(theid){
  if (GBrowserIsCompatible()) {
    if (document.getElementById("ahsearchresultdetail_"+theid+"_tabContent4_map")){
      if (document.getElementById("ahsearchresultdetail_"+theid+"_tabContent4")){
        if (typeof (detmaps[theid]) == 'undefined'){
          detmaps[theid] = new GMap2(document.getElementById("ahsearchresultdetail_"+theid+"_tabContent4_map"));      
          detmaps[theid].setCenter(new GLatLng( 46.67,11.4),9);    
          var bounds = detmaps[theid].getBounds();
          var southWest = bounds.getSouthWest();
          var northEast = bounds.getNorthEast();
          var lngSpan = northEast.lng() - southWest.lng();
          var latSpan = northEast.lat() - southWest.lat();      
      		new GKeyboardHandler(detmaps[theid]);  
      		detmaps[theid].enableDoubleClickZoom();  
      		detmaps[theid].enableContinuousZoom();  
      		var themaptype= G_NORMAL_MAP;
      		switch (gmapview) {
            case 'NORMAL': themaptype= G_NORMAL_MAP;
              break;     
            case 'SATELLITE': themaptype= G_SATELLITE_MAP;
              break;
            case 'HYBRID': themaptype= G_HYBRID_MAP;
              break;     
            default: themaptype= G_NORMAL_MAP;
          }
      		
      		detmaps[theid].setMapType(themaptype);      		
      		//marker setzen:
      		for (var i=0; i<data.length; i++){
            if (data[i][0]==theid){       
              var point = new GLatLng(data[i][18],data[i][19]);
              detmaps[theid].setCenter(point,9);  
              
              
              
              var icon = new GIcon();
              icon.shadow = "http://www.google.com/mapfiles/shadow50.png";
              
              icon.iconSize = new GSize(giconsize[0], giconsize[1]);
              icon.shadowSize = new GSize(37, 34);
              icon.iconAnchor = new GPoint(giconanchor[0], giconanchor[1]);
              icon.infoWindowAnchor = new GPoint(9, 2);
              icon.infoShadowAnchor = new GPoint(18, 25);
              
              icon.image = "http://service.bookingpilot.info/markers/numbered_marker.php?image=pushpins/webhues/"+mappinimage+"&text=";
              
              var marker = new GMarker(point, icon); 
              
              
              
                      
              detmaps[theid].addOverlay(marker);
      
            }
          }
          gmapZoom[theid] = new Control.Slider('zoomslider'+theid, 'gmapleiste'+theid, {
            axis:'vertical',
            //increment: pixelIncrement,
            range: $R(-maxZoomLevel,-minZoomLevel),
            sliderValue: -gmapSliderValue,
            alignY: trackAlignY,
            mapid: theid
          });
  
        gmapZoom[theid].options.onChange = function(value) {
          
            setMapZoom(this.mapid,value);
          
        }; 
        }else{
          adjustdetmap(theid);
        }
  		}
		}
  }
}
function adjustdetmap(theid){
  if (typeof detmaps[theid] != 'undefined'){
    detmaps[theid].checkResize();
    for (var i=0; i<data.length; i++){
      if (data[i][0]==theid){       
        var point = new GLatLng(data[i][18],data[i][19]);
        detmaps[theid].setCenter(point,9);  
      }
    } 
  }
}

function formatentfernung(meter){
  if (meter>1000){
    nmeter=String(Math.round(meter/10));
    return nmeter.substr(0,nmeter.length-2)+","+nmeter.substr(nmeter.length-2)+" km";
  }else{
    return meter+" m";
  }
}

var infotemplate=false;
var umgebungtemplate=false;
var galerietemplate=false;
var ausstattungtemplate=false;
var zimmertemplate=false;
var angebotetemplate=false;
var bookingstep2=false;
var bookingstep1=false;
var bookingstep3=false;
var bookingstep3_namenalter=false;
var anfrage=false;
var anfragedanketemplate=false;
function makeinfodetailoutput(transport,theid){
  var infodata = transport.responseJSON[0];
  $('ahsearchresultdetail_'+theid+'_tabContent1').innerHTML=infotemplate.evaluate(infodata);
  toggleAHTab(theid,1,7);
  var entfernungenlitxt='';
  for(var i=0; i<infodata.entfernungen.length; i++){
    entfernungenlitxt+="<li>"+infodata.entfernungen[i][3]+" "+infodata.entfernungen[i][1]+": "+formatentfernung(infodata.entfernungen[i][2])+"</li>";
  }
  var umgebungsdata={
    infotext:infodata.infotext,
    entfernungen:entfernungenlitxt
  }
  
  
  if (umgebungtemplate==false){
  	//load template:
    new Ajax.Request(umgebungtemplatefile, {
      onSuccess: function(transport) {
        umgebungtemplate = new Template(transport.responseText);   
        $('ahsearchresultdetail_'+theid+'_tabContent6').innerHTML=umgebungtemplate.evaluate(umgebungsdata);        
      }
    });	
	}else{
    $('ahsearchresultdetail_'+theid+'_tabContent6').innerHTML=umgebungtemplate.evaluate(umgebungsdata);	
	}
	
	//evtl. karte ausblenden:
	
	if (infodata.lat=='' || infodata.lng==''){ //galerietab ausblenden
	  $('ahsearchresultdetail_'+theid+'_tabHeader4').hide();
	}else{
	  $('ahsearchresultdetail_'+theid+'_tabHeader4').show();
  }
	
	var galerielitxt='';
	if (infodata.bild_1==''){ //galerietab ausblenden
	  $('ahsearchresultdetail_'+theid+'_tabHeader3').hide();
	}else{
	  $('ahsearchresultdetail_'+theid+'_tabHeader3').show();
	  var galeriesubtemplatesmallimg = new Template(galeriesubtemplatesmallimgcode);
	  if (portalgalerie==false){
      for(var i=0; i<infodata.galerie.length; i++){
        //galerielitxt+='<li><a href="#" onclick="return showimage('+theid+',\''+infodata.galerie[i][2]+'\',\''+infodata.galerie[i][1]+'\')"><img src="http://service.alpine-hotels.com/ah/web/getthumbnail.php?img=img/'+infodata.galerie[i][2]+'&maxx=64&maxy=64&mode=crop" /></a></li>';
        galerielitxt+=galeriesubtemplatesmallimg.evaluate({theid: theid, p2: infodata.galerie[i][2], p1: infodata.galerie[i][1]});
      }
    }else{
      for(var i=1; i<8; i++){
        //galerielitxt+='<li><a href="#" onclick="return showimage('+theid+',\''+infodata.galerie[i][2]+'\',\''+infodata.galerie[i][1]+'\')"><img src="http://service.alpine-hotels.com/ah/web/getthumbnail.php?img=img/'+infodata.galerie[i][2]+'&maxx=64&maxy=64&mode=crop" /></a></li>';
        if (infodata['bild_'+i]!='')galerielitxt+=galeriesubtemplatesmallimg.evaluate({theid: theid, p2: infodata['bild_'+i], p1: infodata['text_'+i]});
      }
    }
    //alert(galerielitxt);
    
    var galeriedata={
      id:theid,
      galerielitxt:galerielitxt
    }
    
  	if (galerietemplate==false){
  	  //alert('galerietemplate ist false '+galerietemplatefile);
    	//load template:
      new Ajax.Request(galerietemplatefile, {
        onSuccess: function(transport) {
          //alert(transport.responseText);  
          galerietemplate = new Template(transport.responseText);  
          
          $('ahsearchresultdetail_'+theid+'_tabContent3').innerHTML=galerietemplate.evaluate(galeriedata);    
          if (portalgalerie==false){
            showimage(theid,infodata.galerie[0][2],infodata.galerie[0][1]); 
          }else{
            if (infodata.bild_1!='')showimage(theid,infodata.bild_1,infodata.text_1); 
          }   
        }
      });	
  	}else{
      $('ahsearchresultdetail_'+theid+'_tabContent3').innerHTML=galerietemplate.evaluate(galeriedata);	      
      if (portalgalerie==false){
        showimage(theid,infodata.galerie[0][2],infodata.galerie[0][1]); 
      }else{
        if (infodata.bild_1!='')showimage(theid,infodata.bild_1,infodata.text_1); 
      } 
  	}
	}
	
	var ausstattunglitxt='';
  for(var i=0; i<infodata.hotelausstattung.length; i++){
    ausstattunglitxt+='<li>'+infodata.hotelausstattung[i]+'</li>';
  }
  var jetzt = new Date();
  var inktext=infodata.inktext_s;
  if((jetzt.getMonth()+1>10 || jetzt.getMonth()+1<4) && infodata.inktext_w!=''){ //wintertext:
    inktext=infodata.inktext_w;
  }

	var ausstattungdata={
    id:theid,
    ausstattungtxt:ausstattunglitxt,
    inktext:inktext
  }
  
	if (ausstattungtemplate==false){
	  //alert('galerietemplate ist false '+galerietemplatefile);
  	//load template:
    new Ajax.Request(ausstattungtemplatefile, {
      onSuccess: function(transport) {
        //alert(transport.responseText);  
        ausstattungtemplate = new Template(transport.responseText);  
        $('ahsearchresultdetail_'+theid+'_tabContent5').innerHTML=ausstattungtemplate.evaluate(ausstattungdata);        
      }
    });	
	}else{
    $('ahsearchresultdetail_'+theid+'_tabContent5').innerHTML=ausstattungtemplate.evaluate(ausstattungdata);	
	}  
	
	var zimmerdata=Array();
	for(var i=0; i<infodata.zimmer.length; i++){
	  zimmerdata[i]=infodata.zimmer[i];
	  zimmerdata[i].hotelid=theid;
	  zimmerdata[i].lightboxid=infodata.zimmer[i].bild == '' ? 0 : infodata.zimmer[i].zimmerid;
	  zimmerdata[i].lightboxid1=infodata.zimmer[i].bild1 == '' ? 0 : infodata.zimmer[i].zimmerid;
	}
	
	
	if (zimmertemplate==false){
	  //alert('galerietemplate ist false '+galerietemplatefile);
  	//load template:
    new Ajax.Request(zimmertemplatefile, {
      onSuccess: function(transport) {
        //alert(transport.responseText);  
        zimmertemplate = new Template(transport.responseText);  
        var zimmerhtml="";
        for (var i=0; i<zimmerdata.length; i++){
          zimmerhtml+=zimmertemplate.evaluate(zimmerdata[i]); 
        }
        $('ahsearchresultdetail_'+theid+'_tabContent2').innerHTML=zimmerhtml; 
        if (typeof onzimmerloaded != 'undefined'){ //function wird aufgerufen sobald alles fertig ist:
          onzimmerloaded();
        }               
      }
    });	
	}else{
    var zimmerhtml="";
    for (var i=0; i<zimmerdata.length; i++){
      zimmerhtml+=zimmertemplate.evaluate(zimmerdata[i]); 
    }
    $('ahsearchresultdetail_'+theid+'_tabContent2').innerHTML=zimmerhtml;  
    if (typeof onzimmerloaded != 'undefined'){ //function wird aufgerufen sobald alles fertig ist:
      onzimmerloaded();
    }     
	}  
  
  
}
var buchungfromzimmer=false;
function showahsearchresultdetail(theid,buchungfromzimmer){
  if (typeof(buchungfromzimmer)=='undefined') buchungfromzimmer=false;
  
  if ($('ahsearchresultdetail_'+theid).getStyle('display')=='none'){
		//Effect.BlindDown('ahsearchresultdetail_'+theid,{ duration: 0.5,afterFinish: function(){ initdetmap(theid)}});
		$('ahsearchresultdetail_'+theid).show();
		initdetmap(theid);
		if ($('ahsearchresultdetailbutton_'+theid)!= null) $('ahsearchresultdetailbutton_'+theid).className="button aktiv";
		//Effect.BlindUp('ahsearchresultbuchung_'+theid,{ duration: 0.5});		
		if ($('ahsearchresultbuchung_'+theid)!= null) $('ahsearchresultbuchung_'+theid).hide();
		if ($('ahsearchresultbuchungbutton_'+theid)!= null) $('ahsearchresultbuchungbutton_'+theid).className="button";
		if ($('ahsearchresultanfrage_'+theid)!= null) $('ahsearchresultanfrage_'+theid).hide();
		if ($('ahsearchresultanfragebutton_'+theid)!= null) $('ahsearchresultanfragebutton_'+theid).className="button";
	}else{
		//Effect.BlindUp('ahsearchresultdetail_'+theid,{ duration: 0.5});	
    if ($('ahsearchresultdetail_'+theid)!= null) $('ahsearchresultdetail_'+theid).hide();
		if ($('ahsearchresultdetailbutton_'+theid)!= null) $('ahsearchresultdetailbutton_'+theid).className="button";    	
	}	
	
	if (infotemplate==false){
  	//load template:
    new Ajax.Request(infotemplatefile, {
      onSuccess: function(transport) {
        infotemplate = new Template(transport.responseText);   
        var aj = new Ajax.Request(
    			proxyurl+"?ah_path=gethotels.php&type=json&schema=detail&culture="+culture+"&id="+theid, {
    				method:'post',
    				evalJSON: 'force',
    				//parameter: {path: 'gethotelsearchfilterdata.php', culture: 'de'},
    				onComplete: function(transport){ makeinfodetailoutput(transport,theid)}
    			}
    		); 
      }
    });	
	}else{
    var aj = new Ajax.Request(
			proxyurl+"?ah_path=gethotels.php&type=json&schema=detail&culture="+culture+"&id="+theid, {
				method:'post',
				evalJSON: 'force',
				//parameter: {path: 'gethotelsearchfilterdata.php', culture: 'de'},
				onComplete: function(transport){ makeinfodetailoutput(transport,theid)}
			}
		); 
	
	}
	
	//return false;
}



function showimage(theid,imageurl,imagetxt){
//http://service.alpine-hotels.com/ah/web/getthumbnail.php?img=2443906524ab9c9f0ab4674.85222182.jpg&maxx=145&maxy=105&mode=crop
  //$('ahgalleryimage_'+theid).innerHTML='<img alt="'+imagetxt+'" src="http://service.alpine-hotels.com/ah/web/getthumbnail.php?img=img/'+imageurl+'&maxx=300&maxy=300&mode=normal" />';
  var galeriesubtemplatebigimg = new Template(galeriesubtemplatebigimgcode);
  $('ahgalleryimage_'+theid).innerHTML=galeriesubtemplatebigimg.evaluate({imagetxt: imagetxt, imageurl: imageurl, theid: theid});
  return false;
}


// TABS:

function toggleDisp() {
	for (var i=0;i<arguments.length;i++){
		var d = $(arguments[i]);
		if (d.style.display == 'none')
			d.style.display = 'block';
		else
			d.style.display = 'none';
	}
}
function toggleAHTab(theid,num,numelems,opennum,animate) {
  animate=false;
	if ($('ahsearchresultdetail_'+theid+'_tabContent'+num).style.display == 'none'){
		for (var i=1;i<=numelems;i++){
			if ((opennum == null) || (opennum != i)){
				var temph = 'ahsearchresultdetail_'+theid+'_tabHeader'+i;
				var h = $(temph);
				
        h.className="";
				var tempc = 'ahsearchresultdetail_'+theid+'_tabContent'+i;
				var c = $(tempc);
				if(c.style.display != 'none'){
					if (animate || typeof animate == 'undefined')
						Effect.toggle(tempc,'blind',{duration:0.5, queue:{scope:'menus', limit: 3}});						
					else
						toggleDisp(tempc);
				}
			}
		}
		var h = $('ahsearchresultdetail_'+theid+'_tabHeader'+num);
		if (h)
			h.className = 'tabHeaderActive';
		h.blur();
		var c = $('ahsearchresultdetail_'+theid+'_tabContent'+num);
		//c.style.marginTop = '2px';
		if (animate || typeof animate == 'undefined'){
		  if (num==4){ //map:
			  Effect.toggle('ahsearchresultdetail_'+theid+'_tabContent'+num,'blind',{duration:0.5, queue:{scope:'menus', position:'end', limit: 3},afterFinish: function(){ adjustdetmap(theid)} });

			}else if (num==7){ //angebote:
			  Effect.toggle('ahsearchresultdetail_'+theid+'_tabContent'+num,'blind',{duration:0.5, queue:{scope:'menus', position:'end', limit: 3},afterFinish: function(){ showangebotetab(theid)} });

			}else{  
			  Effect.toggle('ahsearchresultdetail_'+theid+'_tabContent'+num,'blind',{duration:0.5, queue:{scope:'menus', position:'end', limit: 3}});
      }
		}else{
			toggleDisp('ahsearchresultdetail_'+theid+'_tabContent'+num);
			if (num==4){ //map:
			  adjustdetmap(theid);
			}
			//adjustdetmap(theid)
			if (num==7){ //angebote:
			  showangebotetab(theid)
			}
		}
	}
}


//ANGEBOTETAB:
var angeboteshowtheid=false;
function showangebotetab(theid){
  angeboteshowtheid=theid;
  if (angebotetemplate==false){
    new Ajax.Request(angebotetemplatefile, {
      onSuccess: function(transport) {        
        angebotetemplate = new Template(transport.responseText); 
        var angeboteaj = new Ajax.Request(
    			proxyurl+"?ah_path=getangebote.php&type=json&schema=angebotedetailmitzimmer&hotelid="+theid+"&culture="+culture, {
    				method:'post',
    				evalJSON: 'force',      				
    				onComplete: showangebote
    			}
    		); 
         
      }
    });
  }else{
    var angeboteaj = new Ajax.Request(
			proxyurl+"?ah_path=getangebote.php&type=json&schema=angebotedetailmitzimmer&hotelid="+theid+"&culture="+culture, {
				method:'post',
				evalJSON: 'force',      				
				onComplete: showangebote
			}
		); 
  }   
  		
}
function showangebote(resp){  
  var angebotedata = resp.responseJSON;
  var thekeys=Object.keys(angebotedata);
  var thevalues=Object.values(angebotedata);
  if (thekeys.length>1){ 
    $('ahsearchresultdetail_'+angeboteshowtheid+'_tabContent7').update();
  }else{
    eval('notfoundtext=messages.keineangebotegefunden.'+culture);    
    $('ahsearchresultdetail_'+angeboteshowtheid+'_tabContent7').update('<span class="keinezimmer">'+notfoundtext+'</span>');
  }
  for(var i=0; i<thekeys.length; i++){
    if(thekeys[i]!='totalrows'){
      $('ahsearchresultdetail_'+angeboteshowtheid+'_tabContent7').insert(angebotetemplate.evaluate(thevalues[i]));
    }
  }
  /*angebotedata.each(function(angebot, index){
    alert(index);
    
  });*/
  /*for(var i=0; i<angebotedata.length; i++){
    $('ahsearchresultdetail_'+angeboteshowtheid+'_tabContent7').insert(angebotetemplate.evaluate(angebotedata[i]));
  }*/
}
