/**
 * create draggable marker for editing  
 * 
 * @param caption
 * @param description
 * @param fkSpotType
 * @return void
 */
function createDraggableMarker(caption, description, image) {

    spotIcon = new GIcon();

    spotIcon.image = contextPath + 'static/images/regio/cat_icons/' + image + '.gif';
    spotIcon.iconSize = new GSize(32, 32);
    spotIcon.iconAnchor = new GPoint(9, 34);
    spotIcon.infoWindowAnchor = new GPoint(16, 2);

    spotOptions = { icon:spotIcon, draggable:true, title:caption };
    marker = new GMarker(map.getCenter(), spotOptions);

    GEvent.addListener(marker, "dragstart", function() {
        map.closeInfoWindow();
    });
    GEvent.addListener(marker, "dragend", function() {
        marker.openInfoWindowHtml(getHotspotContent(caption, description, null, true), {maxWidth: 350});
    });

    map.addOverlay(marker);
    
    marker.bindInfoWindowHtml(getHotspotContent(caption, description, null, true), {maxWidth: 450});
    marker.openInfoWindowHtml(getHotspotContent(caption, description, null, true), {maxWidth: 450});
}

/**
 * 
 * create html content for hotspot
 * 
 * @param caption
 * @param description
 * @param extended
 * @return the hotspot content
 */
function getHotspotContent(caption, description, id, extended) {

    val = "<div><h3>" + caption + "</h3><br>" + description;
    if (id) {
    	val += '<img src="' + contextPath + id + '.jpg">';
    }
    if (extended) {
    	val += "<br><br><i>Sie können den HotSpot jetzt per Drag&Drop verschieben.<br>Nutzen Sie auch den Zoom, um noch besser platzieren zu können.</i>";
    }
    
    val += "</div>";
    
    return val;
}
/**
 * 
 * create html for makler
 * 
 * @param name
 * @param street
 * @param zip
 * @param city
 * @param id
 * @return the makler content
 */
function getMaklerContent(name, street, zip, city, id) {

    val = "<div><h3>" + name + "</h3>";
    val += street + "<br>";
    val += zip + " " + city + "<br>";
    val += '<br><a href="' + contextPath + 'suche/anbieter_objekte.html?id=' + id + '">Alle Objekte dieses Maklers</a>';
    val += "</div>";
    
    return val;
}

/**
 * create html content for immo object
 * 
 * @param caption
 * @param description
 * @param id
 * @return the immo object content
 */
function getImmoObjectContent(caption, description, id) {

    val = "<div><h3>" + caption + "</h3>"
    val += description + "<br>";
    val += '<br><a href="' + contextPath + 'detail.html?id=' + id + '">Link zum Exposé</a>';
    val += "</div>";
    
    return val;
}

/**
 * shows a hotspot
 * 
 * @param id
 * @return
 */
function showHotspot(id) {

	new Ajax.Request(contextPath + 'ajax/get_hotspot.html?id=' + id,
	{
		method:'get',
		onSuccess: function(transport){
		    spots[id].openInfoWindowHtml(transport.responseText, {maxWidth: 350});
		},
		onFailure: function(transport){
		    alert("Fehler beim Laden des HotSpots!");
		}
	});
	
	
}

/**
 * show area description
 * 
 * @param id
 * @return
 */
function showAreaDescription(id) {

new Ajax.Request(contextPath + 'ajax/get_area_description.html?id=' + id,
{
 method:'get',
 onSuccess: function(transport){
     map.openInfoWindowHtml(center, transport.responseText, {maxWidth: 350});
 },
 onFailure: function(transport){
     alert("Fehler beim Laden der Beschreibung!");
 }
});
}

/**
 * show immo object
 * 
 * @param id
 * @return
 */
function showImmoObject(id) {

	new Ajax.Request(contextPath + 'ajax/get_immoobject.html?id=' + id,
	{
		method:'get',
		onSuccess: function(transport){
		    
		    //map.hideControl();
		
		    immoObjects[id].openInfoWindowHtml(transport.responseText, {maxWidth: 500});
		    
		    var fadeOut = new YAHOO.util.Anim("labelControl", { opacity: { to: 0 } }, 0.5);
		    fadeOut.onComplete.subscribe(function() {document.getElementById("labelControl").style.display = "none";});
		    fadeOut.animate();
		    
		    fadeOut = new YAHOO.util.Anim("areaDescriptions", { opacity: { to: 0 } }, 0.5);
		    fadeOut.onComplete.subscribe(function() {document.getElementById("areaDescriptions").style.display = "none";});
		    fadeOut.animate();
		},
		onFailure: function(transport){
		    alert("Fehler beim Laden des Objektes!");
		}
	});
}

