// $Id$

var Selection_cookiearray = 0;
var Selection_enabled = 0;
var Selection_disabled = 0;

function Selections_init(enabled, disabled)
{
	Selection_enabled = new Image
	Selection_disabled = new Image

	Selection_enabled.src = enabled
	Selection_disabled.src = disabled

	Selection_cookiearray = new Array(0);

	var ticks = document.getElementsByName('TICK');

	for(var idx = 0; idx < ticks.length; idx++)
	{
		itemId = ticks[idx].id

		i = Selection_cookiearray.indexOf(itemId)

		if(i == -1)
		{
			ticks[idx].src = Selection_disabled.src
			ticks[idx].title="Click here to select this item for an action";
		}
		else
		{
			ticks[idx].src = Selection_enabled.src
			ticks[idx].title="Click here to deselect this item";
		}
	}
}

function Selection(me)
{
	var itemId = me.id;
	var i = Selection_cookiearray.indexOf(itemId)

	if(i == -1)
	{
		Selection_cookiearray[Selection_cookiearray.length] = itemId;
		me.src = Selection_enabled.src
	}
	else
	{
		Selection_cookiearray.remove(i)
		me.src = Selection_disabled.src
	}

	var cookiestring = Selection_cookiearray.join('.')
}

function DoAction(action)
{
	if (Selection_cookiearray.length > 0)
	{
		var cookiestring = Selection_cookiearray.join('.');
		document.cookie = 'actionitems=' + escape(cookiestring);
		
		window.location.href="index.php?a=cart&s=gallery&action=" + action;
	}
	else alert('Please select at least one item before attempting to perform this action');
}
