function createMarker(point,html) {
	var marker = new GMarker(point);
	
	GEvent.addListener(marker, 'click', function() {
	  marker.openInfoWindowHtml(html);
	});
	
	return marker;
}

function calculateCenter(points) {
	
	var lats = 0;
	var lngs = 0;
	
	points.each(function(point) {
		lats += Number(point.lat());
		lngs += Number(point.lng());
	});
	
	var lat = lats/points.length;
	var lng = lngs/points.length;
	
	var center = new GLatLng(lat,lng)
	return center;
}
 function writeTips(tips) {
 	
	for (t in tips) {
		
		if ($(t)) {
			var el = $(t);
			el.addClass('hasTip');
			el.setProperty('title', tips[t]);
		}
		
	}
	
	
 }

function getArticleIdFromSession(updateField, sessionId, formname, type) {
	var url = 'index.php?option=com_destinations&c=destination&task=getArticleId&format=raw&session_id='+sessionId;
	new Ajax(url, {
		method: 'get',
		onSuccess: function(response) {
			updateField.setProperty('value', response);
			window.parent.$('sbox-window').close();
			var url = window.parent.location;

			if (type == 19) {
				url += "&post_id="+response;
			}
			
			var form = window.parent.$(formname);
			form.ret.setProperty('value', url);
			form.submit();
			
		}
	}).request();

}
