var registerCost=0, licenceCost=0, paymentChoice;	
function calc()
{
	if (document.RegistrationRequest.Registration.checked)
	{
		document.RegistrationRequest.registerY.value=document.RegistrationRequest.Registration.value;
		registerCost=document.RegistrationRequest.Registration.value;
	}
	else { document.RegistrationRequest.registerY.value=""; registerCost=0; }

	if (document.RegistrationRequest.SiteLicence[document.RegistrationRequest.SiteLicence.selectedIndex].value>0) 
	{
		document.RegistrationRequest.licenceY.value=document.RegistrationRequest.SiteLicence[document.RegistrationRequest.SiteLicence.selectedIndex].value;
		licenceCost=document.RegistrationRequest.SiteLicence[document.RegistrationRequest.SiteLicence.selectedIndex].value; 
	}
	else { document.RegistrationRequest.licenceY.value=""; licenceCost=0; };

	document.RegistrationRequest.total.value=parseInt(registerCost)+parseInt(licenceCost) ;
}

var flag="unset", warning1="off", warning2="off", warning3="off", warning4="off", warning5="off", warning6="off", warning7="off", warning8="off";

function validate()
{
	if ((document.RegistrationRequest.total.value=="0") || (document.RegistrationRequest.total.value==""))
		{ warning1="You need to select a product or service to purchase"; flag="error"; }
	if ((document.RegistrationRequest.OrderedBy.value==null) || (document.RegistrationRequest.OrderedBy.value==""))
		{ warning2="You need to enter your name"; flag="error"; }
	if ((document.RegistrationRequest.email.value==null)  || (document.RegistrationRequest.email.value==""))
		{ warning3="You need to enter your email address"; flag="error"; }
	if (document.RegistrationRequest.SiteLicence[document.RegistrationRequest.SiteLicence.selectedIndex].value>0) 
	{
		if ((document.RegistrationRequest.SiteLicenceFor.value==null) || (document.RegistrationRequest.SiteLicenceFor.value==""))
		{ warning4="Name or URL for Site Licence is missing"; flag="error"; }
	}
	var count=document.RegistrationRequest.PaymentChoice.length;
	for (i=0; i<count; i++) 
	{ 
		if (document.RegistrationRequest.PaymentChoice[i].checked) { PaymentChoice = document.RegistrationRequest.PaymentChoice[i].value; }
	}
	if (!PaymentChoice)
		{ warning5="You need to select a method of payment"; flag="error"; }
	else 
	{ 
		if (PaymentChoice=='DirectDeposit') warning();
		else if (PaymentChoice=='Other') warning();
		else
		{
			if ((document.RegistrationRequest.cckey.value==null)  || (document.RegistrationRequest.cckey.value==""))
				{ warning6="You need to enter your credit card number"; flag="error"; }
			if ((document.RegistrationRequest.ccname.value==null)  || (document.RegistrationRequest.ccname.value==""))
				{ warning7="You need to enter the name on your credit card"; flag="error"; }
			if ((document.RegistrationRequest.ccexp.value==null)  || (document.RegistrationRequest.ccexp.value==""))
				{ warning8="You need to enter your credit card expiry date"; flag="error"; }
		}
	}

	if (flag=="error")  warning();
	else if (flag=="unset") checkForm();

	function warning()
	{
		msg= "There seems to be a problem with your application: \n\n";
		if (warning1!=="off") msg+= warning1+"\n";
		if (warning2!=="off") msg+= warning2+"\n";
		if (warning3!=="off") msg+= warning3+"\n";
		if (warning4!=="off") msg+= warning4+"\n";
		if (warning5!=="off") msg+= warning5+"\n";
		if (warning6!=="off") msg+= warning6+"\n";
		if (warning7!=="off") msg+= warning7+"\n";
		if (warning8!=="off") msg+= warning8+"\n";
		if (flag=="error") alert(msg);
		flag="unset", warning1="off", warning2="off", warning3="off", warning4="off", warning5="off", warning6="off", warning7="off", warning8="off";
	}
}

function checkForm()
{
	var buildPage='<html><head>';
	buildPage+='<link rel="stylesheet" href="../scr/base.css" type="text/css">';
	buildPage+='</head>';
	buildPage+='<body>';

	buildPage+='<form action="/cgi-bin/kwrego" method="post">';
	buildPage+='<input type="hidden" name="Registration" value="'+document.RegistrationRequest.registerY.value+'" />';
	buildPage+='<input type="hidden" name="SiteLicence" value="'+document.RegistrationRequest.licenceY.value+'" />';
	buildPage+='<input type="hidden" name="SiteLicenceFor" value="'+document.RegistrationRequest.SiteLicenceFor.value+'" />';
	buildPage+='<input type="hidden" name="OrderedBy" value="'+document.RegistrationRequest.OrderedBy.value+'" />';
	buildPage+='<input type="hidden" name="email" value="'+document.RegistrationRequest.email.value+'" />';
	buildPage+='<input type="hidden" name="Company" value="'+document.RegistrationRequest.Company.value+'" />';
	buildPage+='<input type="hidden" name="PaymentChoice" value="'+PaymentChoice+'" />';
	buildPage+='<input type="hidden" name="cckey" value="'+document.RegistrationRequest.cckey.value+'" />';
	buildPage+='<input type="hidden" name="ccname" value="'+document.RegistrationRequest.ccname.value+'" />';
	buildPage+='<input type="hidden" name="ccexp" value="'+document.RegistrationRequest.ccexp.value+'" />';

	buildPage+='<table cellpadding="0" cellspacing="0" border="0" width="568">';
	buildPage+='	<tr><td colspan="2" class="masthead"><img src="/img/spinner-POSM.gif" width="430" height="63" border="0" alt="Spinner-No-Plug-Ins alternatives" /><img src="/img/spinner-POSM-bkLeft.gif" width="32" height="63" alt="" /><img src="/img/spinner-POSM-bkRight.gif" width="32" height="63" alt="" /><br /></td></tr>';
	buildPage+='	<tr><td valign="top" bgcolor="#ffffff"><img src="/img/positionX.gif" width="138" height="1" alt="" /><br /><p>Please review your order carefully. If everything is correct, proceed to <b>Step 5</b> and click on the <b>Process Order</b> button.</p><p>During this introductory period applications are being processed manually, however you should expect a reply within 24 hours.</p><p>If there is a problem with the order details you can go back and change your order by <a href="registration.html" onclick="window.close(\'checkSubmission\'); return false;">clicking here to close this window</a>. If there is some other problem you can e-mail us at <a href="mailto:info@spinner-scripts.com">info@spinner-scripts.com</a>.</p><p>If you experience any problems with the order form, or the ordering process, or have not heard from us in within 2 working days, please e-mail <a href="mailto:info@spinner-scripts.com">info@spinner-scripts.com</a> promptly with details of your query and confirmation of your contact/delivery e-mail address.</p></td>';
	buildPage+='	<td valign="top" bgcolor="#ffffff"><table cellpadding="0" cellspacing="0" border="0" width="438" bgcolor="#9999cc">';
	buildPage+='	<tr><td class="black"><b>&nbsp;STEP 4: Review your Order&nbsp;</b></td><td>&nbsp;</td></tr><tr>';
	buildPage+='	<td valign="top">';
	buildPage+='<br /><p>You have requested the following:</p></td><td valign="top"><br />';
	if (document.RegistrationRequest.registerY.value==50)
		buildPage+='<p>Registration for access to Registered Users areas<br />';
	if (document.RegistrationRequest.licenceY.value>=10)
	{
		buildPage+='<p>A Site Licence for up to '+document.RegistrationRequest.licenceY.value+' panoramas/objects registered to: <b>'+document.RegistrationRequest.SiteLicenceFor.value+'</b><br />';
	}
	buildPage+='At a total cost of <b>$'+document.RegistrationRequest.total.value+'.00</b></p>';
	buildPage+='</td></tr><tr><td valign="top"><br /><p>Your personal details:</p></td><td valign="top">';
	buildPage+='<br /><p><b>'+document.RegistrationRequest.OrderedBy.value+'</b><br />';
	buildPage+='<b>'+document.RegistrationRequest.email.value+'</b><br />';
	buildPage+='<b>'+document.RegistrationRequest.Company.value+'</b></p>';
	buildPage+='</td></tr><tr><td valign="top"><br /><p>Payment by:</p></td><td valign="top"><br />';
	if (PaymentChoice=='DirectDeposit')
		{
		buildPage+='<p><b>DirectDeposit</b></p>';
		buildPage+='<p>We will contact you directly via the email address you supplied to arrange the details.</p>';
		}
	else if (PaymentChoice=='Other')
		{
		buildPage+='<p><b>Other</b></p>';
		buildPage+='<p>We will contact you directly via the email address you supplied to arrange the details.</p>';
		}
	else
		{
		buildPage+='<p>Your total purchase value of $'+document.RegistrationRequest.total.value+'.00<br />will be billed to the following card:<br />';
		buildPage+='<b>'+PaymentChoice+'</b><br>';
		buildPage+='<b>'+document.RegistrationRequest.cckey.value+'</b><br>';
		buildPage+='<b>'+document.RegistrationRequest.ccname.value+'</b><br>';
		buildPage+='<b>'+document.RegistrationRequest.ccexp.value+'</b></p>';
		}

	buildPage+='	<br /></td></tr>';
	buildPage+='	<tr>';
	buildPage+='	<td bgcolor="#000000"><b class="black">&nbsp;STEP 5: Send your order &gt;&gt;</b></td><td>&nbsp;</td></tr>';
	buildPage+='	<tr>';
	buildPage+='	<td><input type="submit" value="Process Order Now"></input></td><td>&nbsp;</td></tr>';
	buildPage+='	</td></tr></table>';
	buildPage+='	<table width="438px"><tr><td  align="center"><p><a href="registration.html" onmousedown="window.close(\'checkSubmission\'); return false;"><b>&nbsp;&lt;&lt; Cancel &gt;&gt;&nbsp;</b></a></p><p class="copyright">&copy;2000 spinner-scripts.com</p></td></tr></table>';
	buildPage+='		</td></tr></table></form></body></html>';

check=window.open("","checkSubmission","width=640,height=480,resizable=no,scrollbars=yes,screenX=10,screenY=10,top=10,left=10");
check.document.write(buildPage);

}
