var selectedButton="none";
var selectedaction="none";

/*
var httpget = new String(location.search.substr(1,location.search.length));
httpget = httpget.toLowerCase();
var firstpos = httpget.indexOf('action=');
if(firstpos>=0) 
{
	firstpos = firstpos + 5;
	var secondpos = httpget.indexOf('&', firstpos);
	if (secondpos > 0) 
	{
		selectedaction = httpget.substr(firstpos, secondpos - firstpos);
	}
	else
	{
		selectedaction = httpget.substr(firstpos);
	}
	
	
	//if(selectedaction=="zoomin")
	//	HighlightImage("im1");
	//else if(selectedaction=="zoomout")
	//	HighlightImage("im2");
	//else if(selectedaction=="info")
	//	HighlightImage("im3");	
	
}
*/

function HighlightImage(butid) 
{	
	if(selectedButton != "none") 
	{
		UnHighlightImage(selectedButton);
	}
	
	// change the button image
	var im = document.getElementById(butid);
	var source = new String(im.src);
	source = source.replace('_up.gif', '_down.gif');
	im.src = source;
	
	//now set the current action
	document.getElementById("action").value=butid;
	
	selectedButton=butid;		
}

function UnHighlightImage(butid) 
{
	// change the button image
	var im = document.getElementById(butid);
	var source = new String(im.src);
	source = source.replace('_down.gif', '_up.gif');
	im.src = source;
}	

function MakeButton(alttext, filename, butid, updown) // updown must be either 'up' or 'down'.
{
	var img = document.createElement("IMG");
	if (updown == 'up') 
	{
		img.src = filename + '_up.gif';
	}
	else if (updown == 'down') 
	{
		img.src = filename + '_down.gif';
		selectedButton = butid;
		selectedaction = butid;
	}
	else 
	{
		img.src = filename + '.gif';
	}
	img.border = 0;
	img.id = butid;
	img.name = butid;
	img.alt = alttext;
	img.height = 32;
	img.width = 45;
	img.onmousedown = function() {HighlightImage(butid)};
	
	document.getElementById("toolbuttons").appendChild(img);
}
function MakeSubmitButton(alttext, filename, targeturl)
{
	var img = document.createElement("IMG");
	img.src = filename;
	img.border = 0;
	img.id = 'submitbutton';
	img.name = 'submitbutton';
	img.alt = alttext;
	img.height = 32;
	img.width = 45;
	//img.onmousedown = function() {window.location = targeturl};
	document.getElementById("toolbuttons").appendChild(img);
}