function newWindow(filename, winWidth, winHeight)
{
	chooserWin = window.open(filename, "chooserWin", "scrollbars=yes, resizable=yes, width=" + winWidth + ",height=" + winHeight);
	chooserWin.moveTo(100, 100);
	chooserWin.focus();
}

function clearForm(formIdent)
{
  var form, elements, i, elm;
  form = document.getElementById
    ? document.getElementById(formIdent)
    : document.forms[formIdent];

	if (document.getElementsByTagName)
	{
		elements = form.getElementsByTagName('input');
		for( i=0, elm; elm=elements.item(i++); )
		{
				//alert('name ' +  elm.getAttribute('name'));
			if (elm.getAttribute('type') == "text")
			{
				elm.value = '';
				//alert('name ' +  elm.getAttribute('name'));
			} else if (elm.getAttribute('type') == "checkbox")
 			{
				elm.checked = false;
			}

		}
	}

	// Actually looking through more elements here
	// but the result is the same.
	//else
	{
		elements = form.elements;
		for( i=0, elm; elm=elements[i++]; )
		{
			//alert(elm.name + ' ' +  elm.type);
			if (elm.type == "text" || elm.getAttribute('type') == "option" || elm.type == "textarea")
			{
				elm.value ='';
			} 
		}
	}
}

function confirmPurchase(url, value) {
	if (confirm('Your balance will be deducted ' + value + ' to view this record.\nAre you sure you wish to purchase it?')) {
		window.location.href = url;
	}
}

function confirmPurchaseAgain(url, value) {
	msg = "You have previously viewed this record, but the time to view it has expired\nIf you you wish to view it again you must purchase it again.\n\n";
	msg = msg + 'Your balance will be deducted ' + value + ' to view this record again.\nAre you sure you wish to purchase it?';
	if (confirm(msg)) {
		window.location.href = url;
	}
}

var alreadySubmitted = false;

function submitTheForm(formName) {
	if (alreadySubmitted != true) {
		alreadySubmitted = true;
		//deactivateButtons();
		document[formName].submit()
	} else {
		sErr = "Duplicate Submission Detected\n\n"
		sErr = sErr+"Information to the Payment Engineshould only be submitted once.\n"
		sErr = sErr+"Double clicking the mouse, or pressing the <enter>\n"
		sErr = sErr+"or <return> key multiple times can result in the same\n"
		sErr = sErr+"information being sent twice.\n\n"
		sErr = sErr+"The extra submission has been cancelled. Please wait \n"
		sErr = sErr+"for the Payment Engine to respond to your initial submission.\n"
		alert(sErr);
		return false;
	}			
}
