

function do_logoff()
{
	var oAjax = new WBE_AjaxClass();
	oAjax.clear();
	oAjax.throwEventXML("user_logoff"); 
	document.location.href = 'inicio.html';
}


function breadcrumb_read(div_id)
{
	var bread_xml = ajax_call('breadcrumb_get', [], []);

	var html = '';
	
	var items = bread_xml.getElementsByTagName("b");
	if (items)
	{
		html = /*'<div id="bread_crumb">' +*/ ' <ul>';		
		
		var start = items.length - 6;
		if (start < 0) start = 0;
		
		for (var i = start; i < items.length; i++)
		{
			var item = items[i];

			/*var link = item.getElementsByTagName('a')[0].firstChild.nodeValue;
			var title = item.getElementsByTagName('t')[0].firstChild.nodeValue;*/
			var link = xml_get(item, 'a');
			var title = xml_get(item, 't');
			
			if (html != '')
				html = html + ' > ';
		
			html = html + '<a class="bread" href="' + link + '"  title="' + title + '" >' + breadcrumb_shorten(title) + '</a>';/**/
			
			//html = html + '<li ' + ((i == items.length-1) ? 'class="home"' :'') + ((i == items.length-1) ? 'class="last"' :'') + ' title="' + title + '" ><a href="' + link + '">' + breadcrumb_shorten(title) + '</a></li>';				
		}
		
		'</ul>' /*+ '</div>'*/;
	}
	
	var div = document.getElementById(div_id);
	if (div)
	{
		div.innerHTML = html;
	}
}	





/*
	Google Maps
	-----------
*/
var locs = new Array;
var map;
var marker;
var map_loaded = false;
var geocoder;
//Posición por defecto
var currentLat = 39.46991972331721;
var currentLon = -0.3814101219177246;
var x_input = 'gmaps_x';
var y_input = 'gmaps_y';
var map_size_x = 220;
var map_size_y = 220;
var map_zoom = 15;
var div_Gmaps = 'g_map';

function initialize()
{
	if (GBrowserIsCompatible()) {

		var auxLat = document.getElementById(x_input).value;
		var auxLon = document.getElementById(y_input).value;
		if (auxLat != '') currentLat = parseFloat(auxLat);
		if (auxLon != '') currentLon = parseFloat(auxLon);

		//geocoder = new GClientGeocoder();
		map = new GMap2(document.getElementById(div_Gmaps), { size: new GSize(map_size_x, map_size_y) } );

		map.setCenter(new GLatLng(currentLat, currentLon), map_zoom);
		map.addControl(new GSmallMapControl());
		map.addControl(new GMapTypeControl());

		/*GEvent.addListener(map, "click", function(marker, point)
		{
		if(point != null)
		{
		addPoint(point.lat(), point.lng());
		}
		});*/

		map_loaded = true;
	}
}


function addPoint(lat, lon)
{
	if (marker)	map.removeOverlay(marker);

	var point 	= new GLatLng(lat, lon);
	marker 		= new GMarker(point);

	map.addOverlay(marker);

	document.getElementById(x_input).value = lat;
	document.getElementById(y_input).value = lon;
}
