// JavaScript Document

var errorstring = "";
var first = "";
var last = "";
var address1 = "";
var address2 = "";
var city = "";
var state = "";
var zip = "";
var country = "";
var areacode = "";
var prefix = "";
var number = "";
var email = "";
var renew = "false";
var donation = "0";

function validateForm(print)
{
	isError = 0;
	errorstring = validateAddress(document.join);

	if(errorstring == "no error")
	{	
		first = document.join.first.value;
		last = document.join.last.value;
		address1 = document.join.address1.value;
		address2 = document.join.address2.value;
		city = document.join.city.value;
		state = document.join.state.value;
		zip = document.join.zip.value;
		donation = document.join.donation.value;
		country = document.join.country.value;
		areacode = document.join.areacode.value;
		prefix = document.join.prefix.value;
		number = document.join.number.value;
		email = document.join.email.value;
		if(document.join.renew.checked == true)
			renew = "true";
		
		if(print == 1)
		{
			printForm();
		}
		else
		{
			createPaypalButtonPage();
		}
		return 1;
		
	}
}
	
function doPayPalHeader()
{
	document.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\n');
	document.write('<html xmlns="http://www.w3.org/1999/xhtml"><head>\n');
	document.write('<title>Join and pay with PayPal - San Francisco Traditional Jazz Foundation</title>\n');
	document.write('<link href="SFTJFStyles.css" rel="stylesheet" type="text/plain" />\n');
	document.write('<body><center><table width="800" height="1024" align="center" valign="top" border="0" cellpadding="0"  cellspacing="0" background="../images/pagestrip.jpg">\n');
    document.write('<tr><td width="800" height="160" valign="top">\n');
	document.write('<table width="800" height="116" align="left" valign="top" background="images/contentTopStrip.jpg">\n');
	document.write('<tr> <!-- One row, 2 columns ------------------------------------------->\n');
	document.write('<td align="left" width="183" height="106">&nbsp;</td>\n');
	document.write('<td width="523" align="center" valign="top">\n');
	document.write('<table width="600" height="104" valign="top" align="center">\n');
	document.write('<tr>');
	document.write('<td height="30"><div valign="top" align="right" class="style2">&nbsp;');
	document.write('</div></td>\n');
	document.write('</tr>\n');
	document.write('<tr>\n');
	document.write('<td height="40" valign="top">');
	document.write('<table align="right" valign="top" width="91" height="32" border="0" cellpadding="2" cellspacing="2">\n');
	document.write('<tr>\n');
	document.write('<td width="91" height="32" valign="middle" background="images/BlankButtonRed.jpg" class="ButtonText" name="Back"><div align="center"><a href="#" onclick="window.history.go(-1)">Back</a></div></td>\n');
	document.write('</tr>');
	document.write('</table>');
	document.write('</td>');
	document.write('</tr>');
	document.write('</table>');
	document.write('</td>');
	document.write('</tr>');
	document.write('</table>');

	document.write('</script></td></tr>\n');

}

function doPayPalFooter()
{
	document.write('</td></tr><tr height="20%">	<td>\n<script>');
	document.write('<br>');
	document.write('<center>');
	//document.write('<a href="#pagetop">Return To The Top Of The Page</a>');
	document.write('<HR width="300"><h5>');
	document.write('<a href="index.htm" target="_top">Home</a> + <a href="photos.htm" target="_top">Photos</a> + ');
	document.write('<a href="jazz.php" target="_top">Jazz</a> + <a href="articles.htm" target="_top">Articles</a> ');
	document.write('+ <a href="join.htm" target="_TOP">Join</a> + <a href="store.htm" target="_top">Order</a> + ');
	document.write('<a href="jazz.htm" target="_top">Live Events</a><BR>');
	document.write('All contents copyright &copy; 1995 - 2008 San Francisco Traditional Jazz Foundation<BR>');
	document.write('<a href="mailto:info@sftradjazz.org">for sftradjazz questions or comments.</a> <BR></h5>');
	document.write('</center>');
	document.write('</script></td></tr>  </table></center></body></html>\n');
}

function doCCSelector()
{
	document.write('<select name="cctype">\n');
	document.write('<option value=""></option>\n');
	document.write('<option value="VISA">VISA</option>\n');
	document.write('<option value="MC">MasterCard</option>\n');
	document.write('<option value="AmEx">American Express</option></select>\n');	
}
	
function printForm()
{
	document.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">');
	document.write('<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Membership Application Form - San Francisco Traditional Jazz Foundation</title></head>');
	document.write('<body background=#ffffff>');
	document.write('<center><br /><br />');
	document.write('<table width="800" height="1024" valign="top" align="center"><tr><td>');
	document.write('	<table align="center" width="650" height="1024" valign="top" border="0" cellpadding="0"  cellspacing="0" ><tr>');
	document.write('	<td width="650" height="120" valign="middle" align="center">');
	document.write('	  <h2>The San Francisco Traditional Jazz Foundation<br /></h2>');
	document.write('	  <div align="center"><h3>Membership Application Form</h3></div></td></tr>');
	document.write('<tr height="60%" valign="top"><td valign="top" align="center">');
	document.write('	<table width="750">');
	document.write(' <tr><td width="50%"><div align="left">First Name:</div></td><td align="left">' + first + '</td></tr>');
	document.write(' <tr><td><div align="left">Last name:</div></td><td align="left">' + last + '</td></tr>');
	document.write(' <tr><td><div align="left">Address1:</div></td><td align="left">' + address1 + '</td></tr>');
	document.write('	<tr><td><div align="left">Address2:</div></td><td align="left">' + address2 + '</td></tr>');
	document.write('	<tr><td><div align="left">City, State ZIP:</div></td><td align="left">' + city + ', ' + state + ' ' + zip + '</td></tr>');
	document.write('	<tr><td><div align="left">Country:</div></td><td align="left">' + country + '</td></tr>');
	document.write('	<tr><td><div align="left">Phone:</div></td><td align="left">(' + areacode + ') ' + prefix + '-' + number + '</td></tr>');
	document.write('	<tr><td><div align="left">email:</div></td><td align="left">' + email + '</td></tr>');
	document.write('	<tr><td>&nbsp</td><td>&nbsp;</td></tr>');
	document.write('	<tr><td><div align="left">Credit Card Type:</div></td><td><div align="left">');
	document.write('	  <select name="cctype">');
	document.write('	    <option>VISA</option>');
	document.write('	    <option>MasterCard</option>');
	document.write('	    <option>American Express</option>');
	document.write('  	    </select>');
	document.write('  	  </div></td></tr>');
	document.write('      <tr><td><div align="left">Name (as it apprears on card):</div></td><td><div align="left">');
	document.write('	  <input type="text" size="64" />');
	document.write('  	  </div></td></tr>');
	document.write('	<tr><td><div align="left">Credit Card Number:</div></td><td><div align="left">');
	document.write('	  <input type="text" size="40" />');
	document.write('  	  </div></td></tr>');
	document.write(' <tr><td><div align="left">Expiration Date (MM/YYYY):</div></td><td><div align="left">');
	document.write('   <input type="text" size="3" />');
	document.write('   &nbsp;/&nbsp;');
	document.write('   <input type="text" size="6" />');
	document.write(' </div></td></tr>');
	document.write(' <tr><td>&nbsp;</td><td>&nbsp;</td></tr>');
	document.write(' <tr>');
	document.write('   <td align="left">Please sign if paying with Credit Card:</td><td>&nbsp;</td></tr>');
	document.write(' <tr><td>&nbsp;</td><td>&nbsp;</td></tr>');
	document.write(' <tr><td>&nbsp;</td><td>&nbsp;</td></tr>');
	document.write('  <tr><td>&nbsp;</td><td>&nbsp;</td></tr>');
	document.write(' <tr><td colspan="2"><hr /></td></tr>');
	document.write(' </table>');
	document.write(' <table width="750">');
	document.write(' <tr><td align="center"> <center>');
	document.write(' <p align="center">Please send this form and your payment to:<br />');
	document.write('     </p>');
	document.write(' <p align="center"><h2>The San Francisco Traditional Jazz Foundation</h2><br />');
	document.write(' <h3>41 Sutter Street, PMB 1870<br>');
	document.write(' San Francisco, CA 94104</h3><br /><p>');
	document.write('Use your browser "Print" command to print this form.');
	document.write('  	</center></td></tr>');
	document.write(' </table>');
	document.write('	</td>');
	document.write('	 	</tr>');
	document.write('	</table>');
	document.write('</td></tr></table></center>');
	document.write('</body></html>');

}
	
function createPaypalButtonPage()
{
	doPayPalHeader();
	
	document.write('<tr height="60%" valign="top"><td width="800" valign="top" align="center">\n');
	document.write('<center><h5>Click on button to make a one-time payment using a major credit card or PayPal</h5>\n');
	document.write('<FORM ACTION="https://www.paypal.com/cgi-bin/webscr" METHOD="POST" name="payform">\n');
    document.write('<INPUT TYPE="hidden" name="cmd" VALUE="_xclick">\n');
    document.write('<INPUT TYPE="hidden" name="business" VALUE="sales@sftradjazz.org">\n');
    document.write('<INPUT TYPE="hidden" name="undefined_quantity" VALUE="1">\n');
	if(renew == "true")
	{
		if(donation != "0" && donation != "")
		{
			document.write('<INPUT TYPE="hidden" name="item_name" VALUE="SFTJF Renewal plus tax deductible donation">\n');
		}
		else
		{
    		document.write('<INPUT TYPE="hidden" name="item_name" VALUE="SFTJF Renewal">\n');
		}
	}
	else
	{
		if(donation != "0" && donation != "")
		{
    		document.write('<INPUT TYPE="hidden" name="item_name" VALUE="SFTJF Membership plus tax deductible donation">\n');
		}
		else
		{
			document.write('<INPUT TYPE="hidden" name="item_name" VALUE="SFTJF Membership">\n');	
		}
	}
	if(donation != "0" && donation != "")
	{
		total = 25.00 + parseInt(donation);
		document.write('<INPUT TYPE="hidden" name="amount" VALUE="' + total + '">\n');
	}
	else
	{
		document.write('<INPUT TYPE="hidden" name="amount" VALUE="25.00">\n');
	}
    document.write('<INPUT TYPE="hidden" name="first_name" VALUE="' + first + '">\n');
    document.write('<INPUT TYPE="hidden" name="last_name" VALUE="' + last + '">\n');
    document.write('<INPUT TYPE="hidden" name="address1" VALUE="' + address1 + '">\n');
   	document.write('<INPUT TYPE="hidden" name="address2" VALUE="' + address2 + '">\n');
    document.write('<INPUT TYPE="hidden" name="city" VALUE="' + city + '">\n');
	document.write('<INPUT TYPE="hidden" name="state" VALUE="' + state + '">\n');
    document.write('<INPUT TYPE="hidden" name="zip" VALUE="' + zip + '">\n');
	document.write('<INPUT TYPE="hidden" name="no_shipping" VALUE="2">\n');
    document.write('<INPUT TYPE="hidden" name="lc" VALUE="' + country + '">\n');
	document.write('<INPUT TYPE="hidden" name="night_phone_a" VALUE="' + areacode + '">\n');
	document.write('<INPUT TYPE="hidden" name="night_phone_b" VALUE="' + prefix + '">\n');
	document.write('<INPUT TYPE="hidden" name="night_phone_c" VALUE="' + number + '">\n');
    document.write('<INPUT TYPE="hidden" name="email" VALUE="' + email + '">\n');
	document.write('<input type="hidden" name="tax" value="0.00">\n');
    document.write('<INPUT TYPE="image"  name="submit" border="0" SRC="images/one_year_paypal_button.gif" alt="PayPal - The safer, easier way to pay online">\n');
    document.write('<img alt="" border="" width="1" height="1" onclick="this.payform.submit.disabled="true" src="https://www.paypal.com/en_US/i/scr/pixel.gif"></FORM>\n');
	
	// Subscribe button Description
	/*
	document.write('<br><br><p><h5>Click on the "Subscribe" button to pay using a major credit card or PayPal<br>and be automatically billed for your renewal each year for 5 years.</h5>\n');
	
	// Button form definition
	document.write('<form name="_xclick" action="https://www.paypal.com/cgi-bin/webscr" method="post">\n');
    document.write('<input type="hidden" name="cmd" value="_xclick-subscriptions">\n');
    document.write('<INPUT TYPE="hidden" name="business" VALUE="sales@sftradjazz.org">\n');
    document.write('<input type="hidden" name="currency_code" value="USD">\n');
	document.write('<INPUT TYPE="hidden" name="item_name" VALUE="subscription">\n');
    document.write('<input type="hidden" name="no_shipping" value="2">\n');
	document.write('<input type="hidden" name="return" value="http://www.sftradjazz.org/test/subscriptionthanks.htm">');
    document.write('<input type="hidden" name="a3" value="25.00">\n');
    document.write('<INPUT TYPE="hidden" name="first_name" VALUE="' + first + '">\n');
    document.write('<INPUT TYPE="hidden" name="last_name" VALUE="' + last + '">\n');
    document.write('<INPUT TYPE="hidden" name="address1" VALUE="' + address1 + '">\n');
   	document.write('<INPUT TYPE="hidden" name="address2" VALUE="' + address2 + '">\n');
    document.write('<INPUT TYPE="hidden" name="city" VALUE="' + city + '">\n');
	document.write('<INPUT TYPE="hidden" name="state" VALUE="' + state + '">\n');
    document.write('<INPUT TYPE="hidden" name="zip" VALUE="' + zip + '">\n');
    document.write('<INPUT TYPE="hidden" name="lc" VALUE="' + country + '">\n');
	document.write('<INPUT TYPE="hidden" name="night_phone_a" VALUE="' + areacode + '">\n');
	document.write('<INPUT TYPE="hidden" name="night_phone_b" VALUE="' + prefix + '">\n');
	document.write('<INPUT TYPE="hidden" name="night_phone_c" VALUE="' + number + '">\n');
    document.write('<INPUT TYPE="hidden" name="email" VALUE="' + email + '">\n');
    document.write('<input type="hidden" name="p3" value="1">\n');
	document.write('<input type="hidden" name="t3" value="Y">\n');
	document.write('<input type="hidden" name="src" value="1">\n');
	document.write('<input type="hidden" name="sra" value="1">\n');
	document.write('<input type="hidden" name="tax" value="0.00">\n');
	document.write('<input type="hidden" name="no_note" value="1">\n');
    document.write('<input type="image" src="images/subscribe_paypal_button.gif" border="0" name="submit" alt="Make payments with PayPal - it fast, free and secure!"></form>\n');
*/
	doPayPalFooter();
}
	


