// ============================================================================
// The following javascript is executed after the page has been loaded.
// It creates the map, toolbar and reference map
// ============================================================================
//debuglevel = 3;

var MICADO = Class.create();
MICADO.prototype = {

// ----------------------------------------------------------------------------
//  initialise the application
// ----------------------------------------------------------------------------
initialize: function(maptag,refmaptag,toolbartag,mapurl) {

    // define version
    this.version = "2.1";

    // ---------------------------------------------
    // CGI analysis
    // ---------------------------------------------
    
    // define CGI query string
    var props = location.href.toQueryParams();
    
    // GENERAL SETTINGS
    
    // flag for hiding toolbar
    var noTb = (props.tb=="no");
    // flag for select button
    var noSelect = (props.select=="no");
    // map width
    var mapwidth = props.mapwidth || 550;

    // MAP LAYOUT
    
    // background
    var mapbackground = props.mapbackground || "topo_sommer";
    // content
    var mapcontent = props.mapcontent || "hotel";
    // gps track type
    this.tracktype = props.tracktype || "-1";
    this.tracktypeTitle = props.tracktypeTitle || "";
    
    // CONTENT
    
    // region to be zoomed to
    var region = props.region || "KAM";

    // hotel ID's to zoom to
    var hotelIds = props.showHotels;
    var forceRegion = props.forceRegion || "";
    
    // GPS Track ID to zoom to
    var trackId = props.showGpstrack;

    // set map background
    if (mapbackground=="sat_summer") {
        this.backgroundlayers = "sommerortho,strassen,strassen_anno,eisenbahn,topo,ortho_anno";
        this.season = "summer";
    } else if (mapbackground=="sat_winter") {
        this.backgroundlayers = "winterortho,strassen,strassen_anno,eisenbahn,topo,ortho_anno";
        this.season = "winter";
    } else if (mapbackground=="topo_winter") {
        this.backgroundlayers = "topo_winter,ortsplan";
        this.season = "winter";
    } else {
        this.backgroundlayers = "topo_summer,ortsplan";
        this.season = "summer";
    }
    
    // set region code
    this.regio = "all";

    // ---------------------------------------------
    // Define MAP component
    // ---------------------------------------------

    this.map1 = new grid_Map( maptag ,{});
    //this.map1.setFullExtent(-85000,254600,-81000);
    this.map1.setFullExtent(-105000,237000,-52000);

    this.map1.setCgi(mapurl);
    //this.map1.setLayers("bg_ortsplan,ortsplan,gesamt");
    //this.map1.setBgHexColor("#e7ead9");
    this.map1.setMaxScale(200000);
    this.map1.setMinScale(1000);
    this.map1.setScalebar(true);

    // ---------------------------------------------
    // Define TOOLBAR component
    // ---------------------------------------------

    this.tb = new grid_Toolbar(toolbartag, "vertical", false);
    //this.tb.addButton(new grid_ZoomBoxCmd( this.map1 ), "img/mapcontrol/zoombox.png", true);
    //this.tb.addButton(new grid_PanCmd( this.map1 ), "img/mapcontrol/pan.png", true);
    //this.tb.addButton(new grid_FullExtentCmd( this.map1 ), "img/full_extent.png", false);
    //$(toolbartag).setStyle({background: "#DDDDDD", opacity: 0.8});
    
    this.ss = new grid_ScaleSetter(this.tb, this.map1);
    this.ss.addScaleMinus( {icon: "img/mapcontrol/zoomer/_.gif", title: "zoom out"});
    this.ss.addScale({scale: 200000,  iconon: "img/mapcontrol/zoomer/1_on.gif", iconoff: "img/mapcontrol/zoomer/1_off.gif", title: "zoom level 1"});
    this.ss.addScale({scale: 150000,  iconon: "img/mapcontrol/zoomer/2_on.gif", iconoff: "img/mapcontrol/zoomer/2_off.gif", title: "zoom level 2"});
    this.ss.addScale({scale: 100000,  iconon: "img/mapcontrol/zoomer/3_on.gif", iconoff: "img/mapcontrol/zoomer/3_off.gif", title: "zoom level 3"});
    this.ss.addScale({scale: 70000,  iconon: "img/mapcontrol/zoomer/4_on.gif", iconoff: "img/mapcontrol/zoomer/4_off.gif", title: "zoom level 4"});
    this.ss.addScale({scale: 40000,  iconon: "img/mapcontrol/zoomer/5_on.gif", iconoff: "img/mapcontrol/zoomer/5_off.gif", title: "zoom level 5"});
    this.ss.addScale({scale: 30000,  iconon: "img/mapcontrol/zoomer/6_on.gif", iconoff: "img/mapcontrol/zoomer/6_off.gif", title: "zoom level 6"});
    this.ss.addScale({scale: 20000,  iconon: "img/mapcontrol/zoomer/7_on.gif", iconoff: "img/mapcontrol/zoomer/7_off.gif", title: "zoom level 7"});
    this.ss.addScale({scale: 10000,  iconon: "img/mapcontrol/zoomer/8_on.gif", iconoff: "img/mapcontrol/zoomer/8_off.gif", title: "zoom level 8"});
    this.ss.addScale({scale: 5000,  iconon: "img/mapcontrol/zoomer/9_on.gif", iconoff: "img/mapcontrol/zoomer/9_off.gif", title: "zoom level 9"});
    this.ss.addScale({scale: 2000,   iconon:  "img/mapcontrol/zoomer/10_on.gif", iconoff: "img/mapcontrol/zoomer/10_off.gif", title: "zoom level 10"});
    this.ss.addScalePlus({icon: "img/mapcontrol/zoomer/+.gif", title: "zoom in"});
    this.ss.setScale(50000);
    this.ss.setStyle({
        background: "#dddddd",
        padding: "3px",
        opacity: 0.8,
        border: "1px solid #2F507A",
        zindex: 50
    });

    // Define REFERENCE MAP component
    // ------------------------------
    this.mapref = new grid_Map( refmaptag ,{});
    this.mapref.setFullExtent(-93000,250000,-61000);
    this.mapref.setCgi(mapurl);
    this.mapref.setLayers("shade, bg, siedlungsraum, overview");
    this.mapref.setParentMap(this.map1);
    this.mapref.setState("ref");

    // Define overlay service for hotels
    // ---------------------------------
    this.osHotel = new grid_OverlayService("hotel", this.map1, "overlay",
       {service: "hotel",
        title:   "",
        typ:     ""},
       {icon:    "img/pin.gif",
        iconDim: { width: 24, height: 24 },
        iconOffset: { x: 0, y: -22 },
        selIcon: "img/roterkreis.gif",
        selIconDim: { width: 27, height: 27 },
        boxwidth: "150",
        boxheight: "170",
        showtype: "infobox",
        zindex:500 }
    );
    
    this.osHotel.setZoomBuffer({factor: 1.1, buffer: 200});
    this.osHotel.setBoxSize(150,170);
    this.osHotel.setVisible(false);

    // Define overlay service for Waypoints
    // ------------------------------------
    this.osWaypoint = new grid_OverlayService("waypoint", this.map1, "overlay",
       {service: "trac",
        typ:     "",
        id:      "-1"},
       {icon:    "img/transparent24.gif",
        iconDim: { width: 24, height: 24 },
        selIcon: "img/roterkreis.gif",
        selIconDim: { width: 27, height: 27 },
        showtype: "infobox",
        zindex:500 }
    );
    this.osWaypoint.setVisible(false);

    
    // Buttons for MAP and SAT view
    // ----------------------------
    this.buttonMap = new grid_MapButton( this.map1, "Karte", setMapTopo, {
        background: "#dddddd",
        width: "38px",
        height: "14px",
        top: "2px",
        left: (mapwidth-108)+"px",
        padding: "5px",
        fontSize: "12px",
        fontWeight: "bold",
        border: "1px solid #2F507A",
        opacity: 0.8
    });
    this.buttonSat = new grid_MapButton( this.map1, "Satellit", setMapSat, {
        background: "#dddddd",
        width: "38px",
        height: "14px",
        top: "2px",
        left: (mapwidth-55)+"px",
        padding: "5px",
        fontSize: "12px",
        fontWeight: "bold",
        border: "1px solid #2F507A",
        opacity: 0.8
    });


    // Additional intialisation
    // ------------------------
    
    this.zoomToRegion(region);
    this.setContent(mapcontent,region,noSelect);
    
    $("search_tag").show();

    // now draw the map
    this.mapref.redraw();

    if (trackId) {
        this.osWaypoint.setVisible(true);
        showTrackInfo(trackId, this);
    } else if (hotelIds) {
        this.osHotel.setParams({
           lang: "de",
           ids:  hotelIds,
           forceregion: forceRegion
        });
        this.osHotel.show(true);
    } else {
        this.map1.redraw();
    }

}, // end of MICADO.initialise


// ----------------------------------------------------------------------------
// redraw the map
// ----------------------------------------------------------------------------
redraw: function() {
    this.map1.redraw();
},


// ----------------------------------------------------------------------------
// Set backgroup map to "sat" -> orthophoto or "topo" -> Topogr.Map
// Flag 'redraw' activates a redraw
// ----------------------------------------------------------------------------
setMap: function(maptype, redraw) {

    this.map1.removeLayers(this.backgroundlayers);
    if (maptype=="sat") {
      if (this.season=="winter") {
        this.backgroundlayers = "winterortho,strassen,strassen_anno,eisenbahn,topo,ortho_anno";
      } else {
        this.backgroundlayers = "sommerortho,strassen,strassen_anno,eisenbahn,topo,ortho_anno";
      }
    } else {
      if (this.season=="winter") {
        this.backgroundlayers = "topo_winter,ortsplan";
      } else {
        this.backgroundlayers = "topo_summer,ortsplan";
      }
    }
    if (redraw) {
        this.map1.addLayers(this.backgroundlayers);
        this.map1.redraw();
    }
},


// ----------------------------------------------------------------------------
//  Set mapextent for the given region
// ----------------------------------------------------------------------------
zoomToRegion: function (region) {
    switch( region ) {
        case "Brixental" : 
            this.map1.setFullExtent(-84820, 256000, -75600); 
            this.map1.setExtent(-84820, 256000, -75600, 256500); 
            this.regio = "brixen"; 
            break;
        case "Westendorf" :  
            this.map1.setFullExtent(-85000, 254900, -83000); 
            this.map1.setExtent(-85000, 254900, -83000, 257000); 
            this.regio = "brixen"; 
            break;
        case "Kirchberg" :  
            this.map1.setFullExtent(-78000, 255800, -75000); 
            this.map1.setExtent(-78000, 255800, -75000, 258000); 
            this.regio = "brixen"; 
            break;
        case "Brixen" :  
            this.map1.setFullExtent(-82000, 257000, -80000); 
            this.map1.setExtent(-82000, 257000, -80000, 258000); 
            this.regio = "brixen"; 
            break;
        case "Kitzbuehel" :  
            this.map1.setExtent(-72553, 255651, -68769, 259000); 
            this.regio = "kitz"; 
            break;
        case "Aurach" :  
            this.map1.setExtent(-69187, 253255, -67435, 254000); 
            this.regio = "kitz"; 
            break;
        case "Jochberg" :  
            this.map1.setExtent(-69000, 248300, -67500, 251600); 
            this.regio = "kitz"; 
            break;
        case "Kitz" :  
            this.map1.setExtent(-77430, 253500, -61757, 254500); 
            this.regio = "kitz"; 
            break;
        case "Reith" : 
            this.map1.setExtent(-76810, 258272, -72098, 261699); 
            this.regio = "kitz"; 
            break;
        case "Oberndorf" :  
            this.map1.setFullExtent(-72200, 262000, -70200); 
            this.map1.setExtent(-71672, 261609, -70448, 263298); 
            this.regio = "stjohann"; 
            break;
        case "StJohann" :  
            this.map1.setFullExtent(-69292, 264512, -67278); 
            this.map1.setExtent(-69292, 264512, -67278, 265977); 
            this.regio = "stjohann"; 
            break;
        case "Kirchdorf" :  
            this.map1.setFullExtent(-67470, 268260, -65640); 
            this.map1.setExtent(-67470, 268260, -65640, 270000); 
            this.regio = "stjohann"; 
            break;
        case "Erpfendorf" :  
            this.map1.setFullExtent(-64800, 271000, -62400); 
            this.map1.setExtent(-64800, 271000, -62400, 272000); 
            this.regio = "stjohann"; 
            break;
        case "Sainihons" :  
            this.map1.setFullExtent(-76300, 262270, -60300, 272000); 
            this.map1.setExtent(-76300, 262270, -60300, 272000); 
            this.regio = "stjohann"; 
            break;
        case "KAM" :  
            this.map1.setExtent(-83700, 250000, -73000, 270000); 
            this.regio = "all"; 
            break;
        default :  
            this.map1.setExtent(-84820, 240000, -75600, 270000); 
            this.regio = "all"; 
            break;
    }
},



// ----------------------------------------------------------------------------
//  Set menu type
// ----------------------------------------------------------------------------
setContent: function(type,region,noSelect) {

    var layers = this.backgroundlayers;

    
    //  Hotel-Suche
    // -----------------------------
    if (type=="hotel") {
        
        this.osHotel.setVisible(true);

        $("menu_option1").innerHTML="Hotels";
        $("menu_option2").innerHTML="Appartments";
        $("menu_option3").setStyle({display: "none"});
        
        new Ajax.Autocompleter("autocomplete", "autocomplete_choices", "quicksearch?service=searchHotel", 
            { paramName: "chars", afterUpdateElement: zoomToHotelByTitle, parameters: "region="+region });
    
        new Ajax.Request( "quicksearch?service=menuHotel&kategorie=HO&region="+region, {
            method: "get",
            onComplete: function(transport) {
                var ziel = "menu_category1";
                new Insertion.Top(ziel, transport.responseText);
            }
        });
        new Ajax.Request( "quicksearch?service=menuHotel&kategorie=AP&region="+region, {
            method: "get",
            onComplete: function(transport) {
                var ziel = $("menu_category2");
                new Insertion.Top(ziel, transport.responseText);
            }
        });
        $("menu_category3").innerHTML="";
        
    //  GPS Track Suche
    // -----------------------------------------------------------------------
    } else if (type=="gpstrack") {

        this.osWaypoint.setVisible(true);
        this.osWaypoint.setParam("typ", this.tracktype);
        layers += ",gpstrack";
        var arg = "map_layer[gpstrack]=DATA+%22line FROM (SELECT idgpstrack, line, type, difficulty AS sw FROM tdtaGpsTrack WHERE type = "+this.tracktype+") AS view USING UNIQUE idgpstrack USING SRID=90001%22";
        this.map1.setArgs(arg);

        $("menu_option1").innerHTML="leicht";
        $("menu_option2").innerHTML="mittel";
        $("menu_option3").innerHTML="schwer";

        new Ajax.Autocompleter("autocomplete", "autocomplete_choices", "quicksearch?service=searchTrac", 
            { paramName: "chars", afterUpdateElement: this.zoomToTrackByTitle, parameters: "typ="+this.tracktype });

        new Ajax.Request( "quicksearch?service=menuTrac&typ="+this.tracktype+"&schwierigkeit=1", {
            method: "get",
            onComplete: function(transport) {
                var ziel = "menu_category1";
                new Insertion.Top(ziel, transport.responseText);
            }
        });
        new Ajax.Request( "quicksearch?service=menuTrac&typ="+this.tracktype+"&schwierigkeit=2", {
            method: "get",
            onComplete: function(transport) {
                var ziel = "menu_category2";
                new Insertion.Top(ziel, transport.responseText);
            }
        });
        new Ajax.Request( "quicksearch?service=menuTrac&typ="+this.tracktype+"&schwierigkeit>=3", {
            method: "get",
            onComplete: function(transport) {
                var ziel = "menu_category3";
                new Insertion.Top(ziel, transport.responseText);
            }
        });
    }
    
    showMenu1();
    this.map1.setLayers(layers);
    //$("menubarTitle").innerHTML = this.tracktypeTitle;
    
},


version: function () {
    alert(this.version);
}

} // end of MICADO




// ============================================================================
// Additional global functions
// ============================================================================

// ----------------------------------------------------------------------------
//  Configure INDEX.HTML
// ----------------------------------------------------------------------------

function hideMenus ()  {
  $("menu_category1").setStyle({display: "none"});
  $("menu_category2").setStyle({display: "none"});
  $("menu_category3").setStyle({display: "none"});
}
function showMenu1 () {
  hideMenus();
  $("menu_category1").setStyle({display: ""});
}
function showMenu2 () {
  hideMenus();
  $("menu_category2").setStyle({display: ""});
}
function showMenu3 () {
  hideMenus();
  $("menu_category3").setStyle({display: ""});
}


// ----------------------------------------------------------------------------
//  Set map background
// ----------------------------------------------------------------------------

function setMapSat () {
    micado.setMap("sat",true);
}

function setMapTopo () {    
    micado.setMap("topo",true);
}


// ----------------------------------------------------------------------------
//  Manage Tracks
// ----------------------------------------------------------------------------

function hideTrackInfo (obj) {
    $("tract").hide();
    $("search_tag").show();
    $("runner").hide();
    // update map
    var obj = obj || micado;
    obj.map1.removeLayers("gpstracksel,waypoint,gpstrackmarker");
    var arg = "";
    if (obj.tracktype) {
      arg = "map_layer[gpstrack]=DATA+%22line FROM (SELECT idgpstrack, line, type, difficulty AS sw FROM tdtaGpsTrack WHERE type = "+obj.tracktype+") AS view USING UNIQUE idgpstrack USING SRID=90001%22";
    }
    micado.map1.setArgs(arg);
    micado.map1.redraw();
}


function showTrackInfo (id, obj) {
    
    var obj = obj || micado;
    
    var qstring = "query?service=trac&";
    var pos = obj.map1.mapselect;
    if (id) {
        qstring += "id="+id;
    } else if (pos) {
        var x = 0;
        var y = 0;
        try {
            x = pos.split(" ")[0];
            y = pos.split(" ")[1];
            qstring += "x="+x+"&y="+y;
            if (obj.tracktype) {
              qstring+="&typ=" + obj.tracktype;
            }

        } catch (e) {
        }
    } else {
        alert("Kann Track nicht anzeigen (keine ID und keine Position)");
        return;
    }
    // add layer
    obj.map1.addLayers("sel,waypoint");

    var tracReq = new Ajax.Request( qstring, {
        method: "get",
        onComplete: function(transport) {
            var eles = $A(transport.responseXML.getElementsByTagName("item"));
            var item = new Hash();
            if (eles.length>0) {
                var atts = $A(eles[0].attributes);
                for (var jj=0, jjl=atts.length; jj<jjl; jj=jj+1) {
                    var att = atts[jj];
                    item[att.nodeName] = att.nodeValue;
                }
                
                //res = res.evalJSON(true);
                $("search_tag").hide();
                var pHTML = $("profilimg");
                $("profilimg_img").src = "gps?service=profile&id="+item["id"]+"&width=530&height=120";
                //pHTML.innerHTML = pHTML.profTemp.evaluate(item);
                //pHTML.idTrac = res.id;                                
                $('tract').show();
                zoomToTrackById(item["id"],false);
                obj.osWaypoint.setParam("id",item["id"]);
                obj.osWaypoint.show();

                // create runner
                var runner = $("runner");
                if (runner==null) {
                  runner = $(document.createElement("div"));
                  runner.id = "runner";
                  runner.hide();
                  runner.setStyle({
                      position: "absolute",
                      zIndex: "15",
                      width: "10px",
                      height: "10px",
                      left: "0px",
                      top: "0px",
                      border: "2px solid black",
                      background: "white"
                  });
                  obj.map1.containerTag.appendChild(runner);                   
                }
                
                // create slider
                var sliderReq = new Ajax.Request( "gps?service=slider&id=" + item["id"], {
                    method: "get",
                    cursor: "move",
                    onComplete: function( transport) {
                      // prepare
                      var eles = $A(transport.responseXML.getElementsByTagName("item"));
                      obj.profilPositions = new Hash();
                      // loop all items
                      for (var ii = 0, iil = eles.length; ii < iil; ++ii) {
                          
                          var ele = new Hash();
                          var atts = $A(eles[ii].attributes);
                          var dist0;

                          for (var jj=0, jjl=atts.length; jj<jjl; jj=jj+1) {
                            var att = atts[jj];
                            if (att.nodeName=="dist") {
                                dist0 = att.nodeValue;
                            } else {
                                ele.set(att.nodeName,att.nodeValue);
                            }
                          }
                          obj.profilPositions.set(dist0,ele);
                          
                      }
                      
                      obj.profilDistance = obj.profilPositions.keys().collect(function(n) { return parseFloat(n); });
                      
                      var sl = new Control.Slider("handlet", "slidert", {
                        axis: "horizontal",
                        range: $R(0, obj.profilDistance.max()),
                        values: obj.profilDistance,
                        onSlide: function(v) {
                            try {
                            var x_map = obj.map1.real2X(obj.profilPositions.get(v).get("x"));
                            var y_map = obj.map1.real2Y(obj.profilPositions.get(v).get("y"));
                            $("profil_dist").innerHTML = "Distanz: " + (v/1000.0).toFixed(2) + " km";
                            $("profil_height").innerHTML = "H&ouml;he: " + parseInt(obj.profilPositions.get(v).get("z")) + " m";
                            runner = $("runner");
                            runner.setStyle({
                                left: x_map - 5 + "px",
                                top:  y_map - 5 + "px"
                            });
                            } catch (e) {}
                        }
                      });

                      // initial position
                      var x_map = obj.map1.real2X(obj.profilPositions.get("0").get("x"));
                      var y_map = obj.map1.real2Y(obj.profilPositions.get("0").get("y"));
                      runner = $("runner");
                      runner.setStyle({
                          left: x_map - 5 + "px",
                          top:  y_map - 5 + "px"
                      });
                      runner.show();
                      
                   }
                });
                
                // update map
                var args = 'map_layer[gpstracksel]=DATA+%22line FROM (SELECT idgpstrack AS id, line FROM tdtaGpsTrack WHERE idgpstrack=' + item["id"] + ') as view using unique id using SRID=90001%22';
                args += '&map_layer[gpstrack]=DATA+%22line FROM (SELECT idgpstrack AS id, line, type, difficulty AS sw FROM tdtaGpsTrack WHERE idgpstrack=' + item["id"] + ') as view using unique id using SRID=90001%22';
                args += '&map_layer[waypoint]=DATA+%22point FROM (SELECT idgpswaypoint,number,point FROM tdtagpswaypoint WHERE idgpstrack=' + item["id"] + ') AS view USING UNIQUE idgpswaypoint USING SRID=90001%22';
                args += '&map_layer[gpstrackmarker]=DATA+%22point FROM (SELECT * FROM qselgpstrackmarker WHERE id=' + item["id"] + ') AS view USING UNIQUE idpoint USING SRID=90001%22';
                
                obj.map1.addLayers("gpstracksel,gpstrackmarker");
                obj.map1.setArgs(args);
                obj.map1.redraw();
                
            // eles.length = 0
            } else {
                alert ("Kein Track mit gegebener ID oder Position");
            }
        }
    });
}


function zoomToTrackByTitle (title) {
    var title = $("autocomplete").value;
    new Ajax.Request("quicksearch?service=bboxTrac&title="+title, {
        method: "get",
        onComplete: function(transport) {
            var c = $w(transport.responseText);
            c =  c.collect( function(s) {
                return parseFloat(s);
            });
            if( c.size() == 4 ) {
                micado.map1.setExtent(c[0], c[1], c[2], c[3]);
                micado.map1.redraw();
            }
        }
    });
}


function zoomToTrackById (id,nodraw) {   
    new Ajax.Request("quicksearch?service=bboxTrac&id="+id, {
        method: "get",
        onComplete: function(transport) {
            var c = $w(transport.responseText);
            c =  c.collect( function(s) {
                return parseFloat(s);
            });
            if( c.size() == 4 ) {
                micado.map1.setExtent(c[0], c[1], c[2], c[3]);
                if (!nodraw) {
                  micado.map1.redraw();
                }
            }
        }
    });
}


// ----------------------------------------------------------------------------
//  Manage Hotel display
// ----------------------------------------------------------------------------


// to be replaced later
function sel_typ_kat( typ, kat, t ) {
    micado.osHotel.setParams({
        title :     "",
        ids:        "",
        ferateltyp: typ,
        feratelkat: kat,
        typ:        t,
        lang:       "de"
    });
    micado.osHotel.show();
}


function showOverlayHotel () {
    micado.osHotel.setParams({
        lang:  "de",
        typ:   "hotel",
        title: $("autocomplete").value
    });
    micado.osHotel.show();
}

function zoomToHotelByTitle () {
//alert($("autocomplete").value);
var title = $("autocomplete").value;
//alert(title);
//alert(encodeURIComponent(title));
//alert(Url.encode(title));
//window.open("http://localhost:8084/micado2/overlay?service=hotel&title="+title);
    micado.osHotel.setParams({
        lang:  "de",
        typ:   "hotel",
        title: title
    });
    micado.osHotel.execute(true);
}

