function getById(id)
{
	var it;
	if(document.getElementById)
		it=document.getElementById(id);
	else if (document.all)
		it=document.all[id];
	else if (document.layers)
		it=document.layers[id];
	else
		it=null;
	return it;	
}
function activateAll(theForm)
{
	if(theForm)
	{
		for (i = 0; i < theForm.length; i++)
		{
			if(theForm[i].id.indexOf("activate")!=-1)
			{
				if(theForm[i].id.indexOf("de")==-1)
				{
					theForm[i].checked = true;
				}
				else
				{
					theForm[i].checked = false;
				}
			}
		}
	}
}

function deactivateAll(theForm)
{
	if(theForm)
	{
		for (i = 0; i < theForm.length; i++)
		{
			if(theForm[i].id.indexOf("activate")!=-1)
			{
				if(theForm[i].id.indexOf("de")==-1)
				{
					theForm[i].checked = false;
				}
				else
				{
					theForm[i].checked = true;
				}
			}
		}
	}
}

function sameAs()
{
	getById('Shipping_Line_One').value=getById('Billing_Line_One').value;
	getById('Shipping_Line_Two').value=getById('Billing_Line_Two').value;
	getById('Shipping_City').value=getById('Billing_City').value;
	getById('Shipping_State').value=getById('Billing_State').value;
	getById('Shipping_Country').value=getById('Billing_Country').value;
	getById('Shipping_Zip').value=getById('Billing_Zip').value;
}

function new_freecap()
{
	// loads new freeCap image
	if(document.getElementById)
	{
		// extract image name from image source (i.e. cut off ?randomness)
		thesrc = document.getElementById("freecap").src;
		thesrc = thesrc.substring(0,thesrc.lastIndexOf(".")+4);
		// add ?(random) to prevent browser/isp caching
		document.getElementById("freecap").src = thesrc+"?"+Math.round(Math.random()*100000);
	} else {
		alert("Sorry, cannot autoreload freeCap image\nSubmit the form and a new freeCap will be loaded");
	}
}
