//Map marker listing
/**
** Google Maps Widget Marker Listing
** Author: 32i from DIMALEX.EU
** Date : 27/11/08
**/
function infoPointClose(){
    $('#maps_listing').hide();   
    $('#map').show();
}
function infoPoint(i,j){
    $('#map').hide();
    $('#maps_listing').show();
    $('#maps_listing').empty();
    $('#maps_listing').append(createInfoPoint(markers_data.markers[i][j]));
}
function createInfoPoint(mrk){
   	    html = '<div><div class="infowindow" style="font-size: 12px;height: auto;" align="left">';
       	if (mrk.event_id != undefined){
    		html += '<h2><a href="/events/id/' + mrk.event_id + '/">' + mrk.title + '</a></h2>';
	    }
    	else if (mrk.point_marker_id != undefined)
    		html += '<h2><a href="/attractions/' + mrk.point_marker_id + '/">' + mrk.title + '</a></h2>';
    	else
    		html += '<h2>' + mrk.title + '</h2>';
    
    	if (mrk.pic != null) {
    		html += '<img src="'+serv+'/' + mrk.pic + '" alt="" class="pic" width="65" height="65" />';
    	}
    	if (mrk.addr) {
    	    addr = mrk.addr.split(',');
    	    if(typeof(addr) != 'string'){
        	    addr[0] = (addr[0])? addr[0] : '';
        	    addr[1] = (addr[1])? addr[1] : '';
        	    addr[2] = (addr[2])? addr[2] : '';
        	    html += '<p width="150">' + addr[0]+'<br />' + addr[1]+''+ addr[2]+'</p>';
    	    }
    	    else{
    	        html += '<p width="150">' +mrk.addr+ '</p>';
    	    }
    	}
    	if (mrk.phone) {
    		html += '<p>Phone: ' +mrk.phone+'</p>';
    	}
    	if (mrk.site_url) {
    		html += '<p><a href="http://' +mrk.site_url.replace('http://','')+'" target="_blank">Website</a></p>';
    	}
    	if (mrk.read_more_active == 1) {
    		html += '<div class="description">' + mrk.read_more + '</div>';
    	}else if(mrk.desc){
    	    html += '<div class="description">' + mrk.desc + '</div>';
    	}
    	html += '<ul><li><a href="javascript:backToGMap('+ mrk.lat + ',' + mrk.lng + ');"><img src="'+serv+'/images/map-icons/center_icon.png" alt="" />Center</a></li>';	
    	html += '<li><a href="http://maps.google.com/maps?f=d&hl=en&daddr='+ mrk.lat+','+ mrk.lng+'&ie=UTF8" target="_blank"><img src="'+serv+'/images/map-icons/directions_icon.png" alt="" />Directions</a></li>';	
    	html += '<li><a href="javascript:infoPointClose();"><img src="'+serv+'/images/map-icons/close_icon.png" alt="" />Close</a></li></ul>';	
    	html += '</div></div>';
    	return html;
}
function backToGMap(lat,lng){
    if(confirm('Do you want to go back to Map and recenter to this point?')){
        $("#maps_listing").hide();
        $("#map").show();
        map.setCenter(new GLatLng(lat,lng));
        
    }
}