window.onload = function(e)
{
	var selArr = document.getElementsByTagName('select');
	if (selArr)
	{
		for (i = 0; i < selArr.length; i++)
		{
			selArr[i].selectedIndex = Math.floor(Math.random()*selArr[i].options.length);
		}
	}
}

document.onclick = function(e)
{
	var t = getTarget(e);
	var b = getButton(e);
	// If they clicked outside the body drop out
	if (t.nodeName.toLowerCase() == 'html' || t.nodeName.toLowerCase() == 'body') return;
	if (t.nodeName.toLowerCase() == 'img' && t.parentNode.className.search(/newwindow/) > -1 && b == 0)
	{
		var strUrl = t.parentNode.href;
		WindowObjectReference = window.open(strUrl, 'de-gifting');
		if (WindowObjectReference != null && !WindowObjectReference.closed)
		{
			WindowObjectReference.focus();
		}
		return false;
	}
}

function getTarget(e)
{
	var e = e || window.event;
	var targ = e.target || e.srcElement;
	if (targ.nodeType == 3)
	{
		targ = targ.parentNode;
	}
	return targ;
}

function getButton(e)
{
	var e = e || window.event;
	return e.button;
}

function checkValue()
{
	var sel = document.getElementById('amount');
	if (sel.selectedIndex == (sel.options.length-1))
	{
		var newVal = prompt('Please specify an amount');
		if (newVal)
		{
			newVal = newVal.match(/\D*((\d|\.|,)+(,|\.|\d)*)/)[1];
			newVal = newVal.replace(/,/g, '');
			sel.options[sel.selectedIndex].value = newVal;
		}
	}
}