var imagepfad="http://www.suedtirol-information.com/img/img_120x90/"
function writeempfehlung(id,title,h2row,url,images,thetext,infolink,region,sterne){
	var empfehlungenbox=document.createElement("div");
	var thehtml='<div class="empfehlungenboxcontent">';
  if ( typeof images == 'array'){
    for (var i=0; i<images.length; i++){
      thehtml+='<img src="'+imagepfad+images[i]+'" alt="'+title+'" width="120" height="90" align="left" />';
    }
  }else{
    thehtml+='<img src="'+imagepfad+images+'" alt="'+title+'" width="120" height="90" align="left" />';
  }
  thehtml+='<span><div class="empfehlungenboxtitel">'+title+'</div>'+sterne+'</span>';
  //thehtml+='<div style="clear:left"></div>';
  thehtml+='<h2>'+h2row;
  if (url!="") {
    var ganzeurl=url;
    if(ganzeurl.substr(0,7)!='http://') ganzeurl='http://'+ganzeurl;
    thehtml+=' - <a href="'+ganzeurl+'" target="_blank" onclick="javascript: pageTracker._trackPageview(\'/empfohlenehotels/'+title+'\')" titel="'+url+'">'+url+'</a>';
  }
  thehtml+='</h2>';
  thehtml+='<p style="overflow: hidden; height: 39px;">';
  
  thehtml+=thetext+'</p>';
  thehtml+='<div style="clear:left"></div></div>';  
  //thehtml+='<div class="empfehlungenboxfooter">';
  //thehtml+='<div class="empfehlungenboxfooterright">&nbsp;</div>';
  //thehtml+='<div class="empfehlungenboxfootercenter"><a href="'+infolink+'">weitere Infos</a></div>';
  //thehtml+='<div class="empfehlungenboxfooterleft">&nbsp;</div>';
  //thehtml+='</div>';
  empfehlungenbox.innerHTML=thehtml;
  empfehlungenbox.className="empfehlungenbox";
  empfehlungenbox.setAttribute('style','display:none;');
  document.getElementById("empfehlungen").appendChild(empfehlungenbox);
  new Effect.Appear(empfehlungenbox, { queue: 'end' });
}
function initempfehlungen(fregion,lang,headertext,proxyurl,subkats,count,dontshowids){
  var jetzt = new Date();
  var subkatstxt="";
  if (typeof subkats != 'undefined'){
    subkatstxt='&subkats='+subkats;
  }
  if (typeof count == 'undefined'){
    count=100;
  }
  var fregiontxt="";
  if (fregion!=""){
    fregiontxt='&fregion='+fregion;
  }
  var dontshowidstxt="";
  if (typeof dontshowids != 'undefined'){
    dontshowidstxt='&dontshowids='+dontshowids;
  }
  new Ajax.Request(proxyurl+'?lang='+lang+fregiontxt+subkatstxt+dontshowidstxt+'&count='+count+'&t='+jetzt.getTime(), {
    method:'get',
    //requestHeaders: {Accept: 'application/json'},
    onSuccess: function(transport){
      var json = transport.responseText.evalJSON(true);
        var empfehlungen=json.objRegion;
        document.getElementById("empfehlungen").innerHTML='<h1>'+headertext+'</h1>';
        for (var i=0; i<empfehlungen.length; i++){
          writeempfehlung(empfehlungen[i][0],empfehlungen[i][1],empfehlungen[i][2],empfehlungen[i][3],empfehlungen[i][4],empfehlungen[i][5],empfehlungen[i][6],empfehlungen[i][7],empfehlungen[i][8]);
        }
        //clearen:
        /*var empfehlungenboxcleardiv=document.createElement("div");
        empfehlungenboxcleardiv.innerHTML="&nbsp";
        empfehlungenboxcleardiv.setAttribute('style','');
        document.getElementById("empfehlungen").appendChild(empfehlungenboxcleardiv);
        */
    }
  });
}
function initempfehlungenort(ort,lang,headertextort,headertextregion,proxyurl,count,showregionhotels,dontshowids){
  var jetzt = new Date();
  
  if (typeof count == 'undefined'){
    count=100;
  }
  if (typeof showregionhotels == 'undefined'){
    showregionhotels=true;
  }
  var dontshowidstxt="";
  if (typeof dontshowids != 'undefined'){
    dontshowidstxt='&dontshowids='+dontshowids;
  }
  var showbundlemsparam='';
  if (typeof showbundlems != 'undefined'){
    showbundlemsparam='&showbundlems=true';
  }
  new Ajax.Request(proxyurl+'?ort='+ort+'&lang='+lang+showbundlemsparam+'&count='+count+dontshowidstxt+'&t='+jetzt.getTime(), {
    method:'get',
    //requestHeaders: {Accept: 'application/json'},
    onSuccess: function(transport){
      var json = transport.responseText.evalJSON(true);
        var empfehlungen=json.objOrt;
        document.getElementById("empfehlungen").innerHTML='<h1>'+headertextort+'</h1>';
        for (var i=0; i<empfehlungen.length; i++){
          writeempfehlung(empfehlungen[i][0],empfehlungen[i][1],empfehlungen[i][2],empfehlungen[i][3],empfehlungen[i][4],empfehlungen[i][5],empfehlungen[i][6],empfehlungen[i][7],empfehlungen[i][8]);
        }
        empfehlungen=json.objRegion;
        if(showregionhotels!=false && empfehlungen.length>0){
          var h1tag=document.createElement("h1");
          h1tag.innerHTML=headertextregion;
          document.getElementById("empfehlungen").appendChild(h1tag);
          //document.getElementById("empfehlungen").innerHTML+='<h1>'+headertextregion+'</h1>';
          for (var i=0; i<empfehlungen.length; i++){
            writeempfehlung(empfehlungen[i][0],empfehlungen[i][1],empfehlungen[i][2],empfehlungen[i][3],empfehlungen[i][4],empfehlungen[i][5],empfehlungen[i][6],empfehlungen[i][7],empfehlungen[i][8]);
          }
        }
        //clearen:
        /*var empfehlungenboxcleardiv=document.createElement("div");
        empfehlungenboxcleardiv.innerHTML="&nbsp";
        empfehlungenboxcleardiv.setAttribute('style','');
        document.getElementById("empfehlungen").appendChild(empfehlungenboxcleardiv);
        */
    }
  });
}


function initempfehlungensubkat(subkat,lang,headertext,proxyurl,count,dontshowids){
  var jetzt = new Date();
  
  if (typeof count == 'undefined'){
    count=100;
  }
  if (typeof showregionhotels == 'undefined'){
    showregionhotels=true;
  }
  var dontshowidstxt="";
  if (typeof dontshowids != 'undefined'){
    dontshowidstxt='&dontshowids='+dontshowids;
  }
  new Ajax.Request(proxyurl+'?subkats='+subkat+'&lang='+lang+'&count='+count+dontshowidstxt+'&t='+jetzt.getTime(), {
    method:'get',
    //requestHeaders: {Accept: 'application/json'},
    onSuccess: function(transport){
      var json = transport.responseText.evalJSON(true);
      var empfehlungen=json.objRegion;
      document.getElementById("empfehlungen").innerHTML='<h1>'+headertext+'</h1>';
      for (var i=0; i<empfehlungen.length; i++){
        writeempfehlung(empfehlungen[i][0],empfehlungen[i][1],empfehlungen[i][2],empfehlungen[i][3],empfehlungen[i][4],empfehlungen[i][5],empfehlungen[i][6],empfehlungen[i][7],empfehlungen[i][8]);
      } 
    }
  });
}