function selectAll(array_id)
{
	for (var i=0; i < array_id.length; i++)
	{
		var element = document.getElementById(array_id[i]);
		if (element)
		{
			if (element.checked)
			{
				element.checked='';
			}
			else
			{
				element.checked='checked';	
			}
		}
	}
}

function roadbookEnablePoint()
{
	var roadbook_point_list = document.getElementById('roadbook_point_list');
	var roadbook_point_options_print = document.getElementById('roadbook_point_options_print');
	var roadbook_hosting_data_print = document.getElementById('roadbook_hosting_data_print');
	if (roadbook_point_list && roadbook_point_options_print && roadbook_hosting_data_print)
	{
		if (roadbook_point_list.checked)
		{
			new Effect.Appear(roadbook_point_options_print, { duration: 2.0 });
			new Effect.Appear(roadbook_hosting_data_print, { duration: 2.0 });
		}
		else
		{
			new Effect.Fade(roadbook_point_options_print, { duration: 1.0 });
			new Effect.Fade(roadbook_hosting_data_print, { duration: 1.0 });
		}
	}
}

function frontMapSwitchTrail(id_trail, id_widget)
{
	var trail = document.getElementById(id_trail);
	var widget = document.getElementById(id_widget);
	if (trail && widget)
	{
		if (widget.style.color == "rgb(255, 255, 255)")
		{
			widget.style.color = "rgb(0, 0, 0)";
			//trail.style.visibility = "hidden";
			new Effect.Fade(trail, { duration: 1.0 });
		}
		else
		{
			widget.style.color = "rgb(255, 255, 255)";
			//trail.style.visibility = "visible";
			new Effect.Appear(trail, { duration: 1.0 });
		}
	}
}



function filenameExtract(url)
{
	wholeurl = url;
	x = wholeurl.length;
	while((wholeurl.substring(x,x-1))!= "/")
	{ 
		x--; 
	} 
	clipstart = x;
	return wholeurl.substring(wholeurl.length,clipstart);
} 

function basepathExtract(url)
{
	wholeurl = url;
	x = wholeurl.length;
	while((wholeurl.substring(x,x-1))!= "/")
	{ 
		x--; 
	} 
	clipstart = x;
	return wholeurl.substring(0, clipstart);
} 

function changeTrailLegendFixed()
{
	var legend = document.getElementById('trail_legend_left');
	var postit = document.getElementById('trail_legend_left_postit');
	
	if (legend && postit)
	{
		var current = legend.style.position;
		if (current=='fixed')
		{
			legend.style.position = '';
			postit.src = basepathExtract(postit.src) + 'unpostit.gif';
		}
		else
		{
			legend.style.position = 'fixed';
			postit.src = basepathExtract(postit.src) + 'postit.gif';
		}
		
		
	}
}

function toggleIcon(icon_id)
{
	var icon = document.getElementById(icon_id);
	
	if (icon)
	{
		icon_src = filenameExtract(icon.src);
		if (icon_src=='plus.gif')	
		{
			icon.src = basepathExtract(icon.src) + 'minus.gif';	
		}
		else
		{
			icon.src = basepathExtract(icon.src) + 'plus.gif';
		}
	}
}