function rest_getElementsByAttribute(attribute,value,within,recursive,match)
{
	if(!attribute)
	{
		return false;
	}

	within2 = within;



	within=rest_getElementById(within);


	within || (within=document.body);

	var element= within.firstChild;

	result=[];
	
	while(element)
	{
		if(element[attribute])
		{
			if(typeof value=="undefined"||element[attribute]==value)
			{
				result.push(element);
				new Insertion.Bottom( 'carts', "<input type='hidden' name=" + within2 + "[] value='" + element.id  + "'>");
			}
			else if(match&&typeof element[attribute]=="string"&&element[attribute].indexOf(value)!=-1)
			{
				result.push(element);
			}
		};

		element=element.nextSibling
	};

	return rest_array(result);
};




function rest_getElementById(element)
{
	if(typeof element=='string')
	{
		return document.getElementById(element);

	}

	return element;
};


function rest_array(arr)
{
	if(!rest_isArray(arr))
	{
		var array=[];
		for(var i=0;i<arguments.length;++i)
		{
			array.push(arguments[i]);
		}
		arr=array;
	}
	
	return arr;
};


function rest_isArray(arr)
{
	if(arr&&typeof arr=="object"&&arr.constructor==Array)
	{	
		return true;
	}

	return false;
};


function showOrder(items) 
{
	var allitems = [];

	allitems = rest_getElementsByAttribute("className","nameSpan",items, false, true);

	res = "";
	for(var i = 0; i < allitems.length; ++i) {
		res += (allitems[i].innerHTML + "\n");
	}
//alert(res);
}


function showAllOrders(names)
{
	for(i=0; i < names.length; i++)
		showOrder(names[i]);
	
	document.mycartsform.submit();
}

/////////////////////////////////////////////////////////////////////////

function hover(c)
{
identity=document.getElementById(c);
if (identity.className.indexOf('clicked') >= 0)
{}
else
identity.className += ' over';
}

/////////////////////////////////////////////////////////////////////////

function out(a, b)
{
identity=document.getElementById(a);
if(identity.className.indexOf('clicked') >= 0)
{}
else
identity.className=b;
}

/////////////////////////////////////////////////////////////////////////

function selected(a, b, form)
{
//This sets the background class to change the color for a specific table
var x = eval("document.getElementById('"+ form + "').getElementsByTagName('tr')");
for (var i=0;i<x.length;i++)
{
	x[i].className = x[i].className.replace(' clicked', '');
	x[i].className = x[i].className.replace(' over', '');
}
identity=document.getElementById(a);
identity.className += ' clicked';


//This clicks the hidden checkbox
var rows = eval("document." + form + ".parentmenus");

var radio = eval("document." + form + ".parentmenus");
for ( var i = 0; i < rows.length; i++ )
{
	if(eval("document." + form + ".parentmenus[i].value") == b)
			radio[i].checked = true;
	else
		radio[i].checked = false;
}

}
