/////////////// BEGIN HELPER FUNCTIONS //////////////////////

function requestHeader(formWin, title) {

formWin.document.write('<html>\n');

formWin.document.write('<head>\n');
formWin.document.write('<title>Transcript Request</title>\n');
formWin.document.write('<style>\n');
formWin.document.write('TD {\n');
formWin.document.write('font-size: 8pt;\n');
formWin.document.write('}\n');
formWin.document.write('UL {\n');
formWin.document.write('font-size: 10pt;\n');
formWin.document.write('}\n');
formWin.document.write('P {\n');
formWin.document.write('font-size: 10pt;\n');
formWin.document.write('}\n');
formWin.document.write('</style>\n');
formWin.document.write('</head>\n');
formWin.document.write('<body bgcolor="white">\n');
formWin.document.write('<img src="images/seal_transcript_form.gif" align="left">\n');
formWin.document.write('<img src="images/seal_transcript_form.gif" align="right">\n');
formWin.document.write('<center>\n');
formWin.document.write('<br>\n');
formWin.document.write('<h3><font color="firebrick">Indiana University - Bloomington</font></h3>\n');
formWin.document.write('<h3><font color="firebrick">' + title + '</font></h3>\n');
formWin.document.write('<font color="firebrick">');
var d = new Date();
formWin.document.write((d.getMonth() + 1) + '/' + d.getDate() + '/' + d.getFullYear() + '</font>\n');
formWin.document.write('</center>\n');
formWin.document.write('<br clear>\n');
formWin.document.write('<br>\n');

}

function requestInstructions(formWin, serviceTypeB, instrURL, serviceType, costInfo, sendMethod) {

formWin.document.write('<h4><u>BEFORE ' + serviceTypeB + ' YOUR REQUEST</u></h4>\n');
formWin.document.write('<ul>\n');
formWin.document.write('<li>Be sure to read the on-line instructions for our <a href="' + instrURL + '" target="_blank">' + serviceType + '</a>.\n');
formWin.document.write('<li>Be sure all financial obligations to the University are clear/current.  This includes your account with the Bursar (812) 855-2636, Student Loan Administration (812)855-4511, or the Dean of Students/Greek Housing (812) 855-8187.  <b>If we encounter any financial holds, your request and payment will be returned with a letter of explanation.</b>  Please check if you are at all unsure about your account status.\n');
formWin.document.write('<li>' + costInfo);
formWin.document.write('<li>After entering the information, make sure you print this form and then <u>sign your request</u> before' + sendMethod);
formWin.document.write('<li>Please see the bottom of this form for a list of reasons why your requests may not be processed.');
formWin.document.write('</ul>\n');

}

function requestPersInfo(formWin, yourname, fname, mname, lname) {

formWin.document.write('<h4><u>IDENTIFYING INFORMATION</u></h4>\n');
formWin.document.write('<form method=POST\n');
formWin.document.write('enctype="text/plain"\n');
formWin.document.write('action="">\n');
formWin.document.write('<table border="0" cellpadding="1">\n');
formWin.document.write('<!-- Need to set size and maxlength to the same value for each input text field.  \n');
formWin.document.write('     This is to insure that that the values in the fields appear when the form is printed.\n');
formWin.document.write('  -->\n');
formWin.document.write('<tr>\n');
formWin.document.write('	<td align="right">Last Name</td>\n');
formWin.document.write('	<td align="left"><input type="Text" size="24" maxlength="18" name="lnam" value="' + lname + '"></td>\n');
formWin.document.write('</tr>\n');
formWin.document.write('<tr>\n');
formWin.document.write('	<td align="right">First Name</td>\n');
formWin.document.write('	<td align="left"><input type="Text" size="24" maxlength="18" name="fnam" value="' + fname + '">&nbsp;&nbsp;&nbsp;&nbsp;Middle Name&nbsp;&nbsp;<input type="Text" size="24" maxlength="18" name="mnam" value="' + mname + '"></td>\n');
formWin.document.write('</tr>\n');
/*
formWin.document.write('<tr>\n');
formWin.document.write('	<td align="right">Middle Name</td>\n');
formWin.document.write('	<td align="left"><input type="Text" size="24" maxlength="24" name="mnam"></td>\n');
formWin.document.write('</tr>\n');
*/
formWin.document.write('<tr>\n');
formWin.document.write('	<td align="right">Former Name</td>\n');
formWin.document.write('	<td align="left"><input type="Text" size="24" maxlength="18" name="former"></td>\n');
formWin.document.write('</tr>\n');
formWin.document.write('<tr><td colspan=2><hr></td></tr>\n');
formWin.document.write('<tr><td colspan=2 align="left">Address Information for '+yourname+'</td></tr>\n');
formWin.document.write('<tr>\n');
formWin.document.write('	<td align="right" valign="top">Street</td>\n');
formWin.document.write('	<td align="left">\n');
formWin.document.write('	<input type="Text" size="60" maxlength="45" name="str1"><br>\n');
formWin.document.write('	<input type="Text" size="60" maxlength="45" name="str2"><br>\n');
formWin.document.write('</tr>\n');
formWin.document.write('<tr>\n');
formWin.document.write('	<td align="right">City</td>\n');
formWin.document.write('	<td align="left"><input type="Text" size="60" maxlength="45" name="city"></td>\n');
formWin.document.write('</tr>\n');
formWin.document.write('<tr>\n');
formWin.document.write('	<td align="right">State or<br>Province</td>\n');
formWin.document.write('	<td align="left"><input type="Text" size="60" maxlength="45" name="state"></td>\n');
formWin.document.write('</tr>\n');
formWin.document.write('<tr>\n');
formWin.document.write('	<td align="right">Zip or<br>Postal Code</td>\n');
formWin.document.write('	<td align="left"><input type="Text" size="13" maxlength="10" name="zip">&nbsp;&nbsp;&nbsp;&nbsp;Country (if not USA)&nbsp;&nbsp;<input type="Text" size="30" maxlength="22" name="country"></td>\n');
formWin.document.write('</tr>\n');
/*
formWin.document.write('<tr>\n');
formWin.document.write('	<td align="right">Country, (if not USA)</td>\n');
formWin.document.write('	<td align="left"><input type="Text" size="40" maxlength="40" name="country"></td>\n');
formWin.document.write('</tr>\n');
*/
formWin.document.write('<tr>\n');
formWin.document.write('	<td align="right">Phone Number (8AM-5PM)</td>\n');
formWin.document.write('	<td align="left"><input type="Text" size="28" maxlength="20" name="phone"></td>\n');
formWin.document.write('</tr>\n');
formWin.document.write('<tr><td colspan=2><hr></td></tr>\n');
formWin.document.write('<tr>\n');
formWin.document.write('	<td align="right">Date of Birth</td>\n');
formWin.document.write('	<td align="left"><input type="Text" size="20" maxlength="15" name="birth"></td>\n');
formWin.document.write('</tr>\n');
formWin.document.write('<tr>\n');
formWin.document.write('	<td align="right">Approximate<br>Dates of Attendance</td>\n');
formWin.document.write('	<td align="left"><input type="Text" size="60" maxlength="45" name="attendance"></td>\n');
formWin.document.write('</tr>\n');
formWin.document.write('<tr>\n');
formWin.document.write('	<td align="right">Completed I.U. Degree(s)</td>\n');
formWin.document.write('	<td align="left"><input type="Text" size="60" maxlength="45" name="degree"></td>\n');
formWin.document.write('</tr>\n');
formWin.document.write('<tr>\n');
formWin.document.write('	<td align="right">Email Address</td>\n');
formWin.document.write('	<td align="left"><input type="Text" size="60" maxlength="45" name="email"></td>\n');
formWin.document.write('</tr>\n');
formWin.document.write('<tr><td colspan=2><hr></td></tr>\n');
formWin.document.write('</table>\n');
formWin.document.write('<p>\n');
formWin.document.write('10 Digit University ID Number: ___________________________ &nbsp;&nbsp; And/or &nbsp;&nbsp; Last 4 digits of Social Security Number: ________<br><br>\n');
formWin.document.write('Signature: ____________________________________<br>\n');
formWin.document.write('<b>Your request will be returned to you by mail if it does not have your required signature.</b>');
formWin.document.write('</p>\n');

}

function requestMailNumberofTranscripts(formWin) {


	formWin.document.write('		<table border="0" cellpadding="1">\n');
	formWin.document.write('		<td align="left">Mail <select name="mnumcopies" size="1"><option value="1">1<option value="2">2<option value="3">3<option value="4">4<option value="5">5<option value="6">6<option value="7">7<option value="8">8<option value="9">9<option value="10">10<option value="11">11<option value="12"><option value="12">12<option value="13">13<option value="14">14<option value="15">15<option value="16">16<option value="17">17<option value="18">18<option value="19">19<option value="20">20</select>transcript(s) to:</td></td>\n');
	formWin.document.write('		</tr>\n');
}

function requestFaxNumberofTranscripts(formWin, multiples) {
	
formWin.document.write('		<td align="left">Mail ' + multiples + ' transcript(s) to:</td></td>\n');
formWin.document.write('		</tr>\n');
formWin.document.write('		</table>\n');

}

function requestMailingAddress(formWin, yourname) {

formWin.document.write('		<table border="0" cellpadding="1">\n');
formWin.document.write('			<tr><td colspan="2" align="right"><i><small>Student name: ' + yourname + '</small></i></td></tr>\n');
formWin.document.write('			<td align="right">Recipient Name</td>\n');
formWin.document.write('			<td align="left"><input type="Text" size="60" maxlength="45" name="recipient"></td>\n');
formWin.document.write('		</tr>\n');
formWin.document.write('		<tr>\n');
formWin.document.write('			<td align="right">Address Line 1</td>\n');
formWin.document.write('			<td align="left"><input type="Text" size="60" maxlength="45" name="rstr1"></td>\n');
formWin.document.write('		</tr>\n');
formWin.document.write('		<tr>\n');
formWin.document.write('			<td align="right">Address Line 2</td>\n');
formWin.document.write('			<td align="left"><input type="Text" size="60" maxlength="45" name="rstr2"></td>\n');
formWin.document.write('		</tr>\n');
formWin.document.write('		<tr>\n');
formWin.document.write('			<td align="right">City</td>\n');
formWin.document.write('			<td align="left"><input type="Text" size="60" maxlength="45" name="rcity"></td>\n');
formWin.document.write('		</tr>\n');
formWin.document.write('		<tr>\n');
formWin.document.write('			<td align="right">State or Province</td>\n');
formWin.document.write('			<td align="left"><input type="Text" size="60" maxlength="45" name="rstate"></td>\n');
formWin.document.write('		</tr>\n');
formWin.document.write('		<tr>\n');
formWin.document.write('			<td align="right">Zip or Postal Code</td>\n');
formWin.document.write('			<td align="left"><input type="Text" size="15" maxlength="10" name="zip"></td>\n');
formWin.document.write('		</tr>\n');
formWin.document.write('		<tr>\n');
formWin.document.write('			<td align="right">Country (if not USA)</td>\n');
formWin.document.write('			<td align="left"><input type="Text" size="60" maxlength="45" name="rcountry"></td>\n');
formWin.document.write('		</tr>\n');
formWin.document.write('			\n');
formWin.document.write('		</table>\n');

}


function requestSpecInstructions(formWin, type) {

// ***Special Instructions section
formWin.document.write('<p>Special Instructions (If Applicable)\n');
formWin.document.write('<table cellpadding="1">\n');

if (type == 'mail') {
	/*
	formWin.document.write('<tr>\n');
	formWin.document.write('	<td valign="top"><input type="checkbox" name="holdcurr"></td>\n');
	formWin.document.write('	<td align="left">Hold for current semester grades</td>\n');
	formWin.document.write('</tr>\n');
	formWin.document.write('<tr>\n');
	formWin.document.write('	<td valign="top"><input type="checkbox" name="holddegree"></td>\n');
	formWin.document.write('	<td align="left">Hold for upcoming degree</td>\n');
	formWin.document.write('</tr>\n');
	*/
	formWin.document.write('<tr>\n');
	formWin.document.write('	<td valign="top"><input type="checkbox" name="holdind"></td>\n');
	formWin.document.write('	<td align="left">Hold for Independent Study grade<br>\n');
	formWin.document.write('	Department <input type="text" size="10" maxlength="6" name="inddept">&nbsp;&nbsp;&nbsp;\n');
	formWin.document.write('	Course # <input type="text" size="10" maxlength="6" name="indcrse"></td>\n');
	formWin.document.write('</tr>\n');
}

//formWin.document.write('<tr>\n');
//formWin.document.write('	<td valign="top"><input type="checkbox" name="context"></td>\n');
//formWin.document.write('	<td align="left">Send Context record format (Bloomington campus only, courses from Fall 1994 to present)</td>\n');
//formWin.document.write('</tr>\n');
formWin.document.write('<tr>\n');
formWin.document.write('	<td valign="top"><input type="checkbox" name="signseal"></td>\n');
formWin.document.write('	<td align="left">If the recipient of your transcripts has requested that we sign and seal the back of the envelope, check here</td>\n');
formWin.document.write('</tr>\n');
formWin.document.write('<tr>\n');
formWin.document.write('	<td valign="top"><input type="checkbox" name="other"></td>\n');
formWin.document.write('	<td align="left">Other:  Please specify <input type="Text" size="60" maxlength="45" name="otherreason"></td>\n');
formWin.document.write('</tr>\n');
formWin.document.write('<tr><td colspan=2><hr></td></tr>\n');
formWin.document.write('</table>\n');


}

function requestPaymentAndClose(formWin, yourname, type, closingMessage) {

formWin.document.write('<h4><u>PAYMENT INFORMATION for '+yourname+'</u></h4>\n');

if (type == 'mail') {
	formWin.document.write('<table cellpadding="1">\n');
	formWin.document.write('<tr>\n');
	formWin.document.write('	<td><input type="checkbox" name="perscheck"></td>\n');
	formWin.document.write('	<td align="left">Enclosing Personal Check payable to Indiana University in US Dollars</td>\n');
	formWin.document.write('</tr>\n');
	formWin.document.write('<tr>\n');
	formWin.document.write('	<td><input type="checkbox" name="moneyorder"></td>\n');
	formWin.document.write('	<td align="left">Enclosing Money Order payable to Indiana University</td>\n');
	formWin.document.write('</tr>\n');
	formWin.document.write('</table>\n');
}

formWin.document.write('<table cellpadding="1">\n');
formWin.document.write('<tr><td colspan=2>Credit Card Information:</td></tr>\n');
formWin.document.write('<tr><td colspan=2>Please make sure that your credit card number is correct.</td></tr>\n');
formWin.document.write('<tr><td colspan=2>\n');
formWin.document.write('	<table cellpadding="1">\n');
formWin.document.write('	<tr>\n');
formWin.document.write('		<td><input type="radio" name="creditcard" value="MC"></td>\n');
formWin.document.write('		<td align="left">Mastercard</td>\n');
formWin.document.write('		<td rowspan=2><input type="text" size="8" maxlength="4" name="mc1"></td>\n');
formWin.document.write('		<td rowspan=2><input type="text" size="8" maxlength="4" name="mc2"></td>\n');
formWin.document.write('		<td rowspan=2><input type="text" size="8" maxlength="4" name="mc3"></td>\n');
formWin.document.write('		<td rowspan=2><input type="text" size="8" maxlength="4" name="mc4"></td>\n');
formWin.document.write('		<td align="left" rowspan=2>Expiration Date</td>\n');
formWin.document.write('		<td rowspan=2><input type="text" size="15" maxlength="10" name="mcexp"></td>\n');
formWin.document.write('	</tr>\n');
formWin.document.write('	<tr>\n');
formWin.document.write('		<td><input type="radio" name="creditcard" value="V"></td>\n');
formWin.document.write('		<td align="left">Visa</td>\n');
formWin.document.write('	</tr>\n');
formWin.document.write('	<tr>\n');
formWin.document.write('		<td><input type="radio" name="creditcard" value="A"></td>\n');
formWin.document.write('		<td align="left">American Express</td>\n');
formWin.document.write('	</tr>\n');
formWin.document.write('	<tr>\n');
formWin.document.write('		<td><input type="radio" name="creditcard" value="D"></td>\n');
formWin.document.write('		<td align="left">Discover</td>\n');
formWin.document.write('	<tr>\n');
formWin.document.write('		<td colspan=8>Name on credit card if other than student\'s name: <input type="text" name="othername" size="60" maxlength="40"></td>\n');
formWin.document.write('	</tr>\n');
formWin.document.write('	</table>\n');
formWin.document.write('</td></tr>\n');
formWin.document.write('</table>\n');
formWin.document.write('' +closingMessage);
formWin.document.write('<input type="Reset" value="Clear All Fields">\n');
formWin.document.write('</form>\n');
formWin.document.write('</body>\n');
formWin.document.write('</html>\n');


formWin.document.close();

}


function requestFaxNumber(formWin) {

//Print out the fax number portion of the form
formWin.document.write('		<table border="0" cellpadding="1">\n');
formWin.document.write('<tr><td><hr width=50%></td></tr>\n');
formWin.document.write('		<tr><td align="left">If you would like another transcript (working copy) faxed to this address, please provide the fax #. <b>This faxed copy counts toward your two transcript limit.</b></td>\n');
formWin.document.write('		</tr>\n');
formWin.document.write('		<tr>\n');
formWin.document.write('			<td align="left">Fax an additional working copy to <input type="Text" size="20" maxlength="15" name="faxnum" onkeyup="faxWorkingCopy()"></td>\n');
formWin.document.write('		</tr>\n');
formWin.document.write('<tr><td><hr width=50%></td></tr>\n');
formWin.document.write('		</table>\n');

}



/////////////////////// END HELPER FUNCTIONS /////////////////////////////

function printTranscriptmailFormWin(addresses, fname, mname, lname) {

/*
if (addresses != 0) {
	var yourname = prompt('Please enter your full name:', '');
}
*/

var yourname = fname + " " + lname;

if (yourname != '' && addresses != 0 && yourname != null) {

	var mailFormWin = window.open("", "Transcript_Mail_Form", "menubar=yes,toolbar=yes,height=600,width=800,resizable=yes,scrollbars=yes");

	requestHeader(mailFormWin, 'TRANSCRIPT REQUEST BY MAIL');

	requestInstructions(mailFormWin, 'MAILING', 'transcript.shtml#mail', 'mail service', 'Transcripts by mail are $10.00 each.', ' mailing.');
	
	requestPersInfo(mailFormWin, yourname, fname, mname, lname);

	mailFormWin.document.write('<h4><u>MAILING INSTRUCTIONS</u></h4>\n');

	//for loop for printing out multiple recipient addresses
	//
	for (i=0; i<addresses; i++) {

		requestMailNumberofTranscripts(mailFormWin);
		
		requestMailingAddress(mailFormWin, yourname);

		requestSpecInstructions(mailFormWin, 'mail');

	}
	var failedRequestReasons = "<ul><li>Missing signature</li><li>Any financial holds on your record</li><li>A credit card that is declined for payment</li><li>Missing or partial credit card information</li></ul>";
	requestPaymentAndClose(mailFormWin, yourname, 'mail', '<p>Mail your completed and signed form to Office of the Registrar, Transcripts, Franklin 100, 601 E. Kirkwood Avenue, Bloomington, IN 47405-1223.  <p><ul><li>If you have any questions, please call (812) 855-7505.</li><li>If your request is not in order, it will not be processed.  It will be returned by mail, with a letter of explanation, for any of the following reasons:</p>' + failedRequestReasons);

} // close if statement

} // close function printTranscriptmailFormWin


function printTranscriptfaxFormWin(optionNumber, fname, mname, lname){

	/*
	if (addresses != 0){
		var yourname = prompt('Please enter your full name:', '');
	}
	*/
	
	var yourname = fname + " " + lname;
	
	if (yourname != '' && optionNumber != 0 && yourname != null) {
		var faxFormWin = window.open("", "Transcript_Fax_Form", "menubar=yes,toolbar=yes,height=600,width=800,resizable=yes,scrollbars=yes");
		requestHeader(faxFormWin, 'TRANSCRIPT REQUEST BY FAX');
		requestInstructions(faxFormWin, 'FAXING', 'transcript.shtml#fax', 'fax service', 'With this fax service, there is a $24.00 charge:  1 transcript = $24\; 2 transcripts = $24\.  In order to meet the priority demand from all students, the fax transcript service can only be used for one or two transcripts per student per business day.', ' faxing.');
		requestPersInfo(faxFormWin, yourname, fname, mname, lname);
		faxFormWin.document.write('<h4><u>MAILING INSTRUCTIONS</u></h4>\n');
	
		
		var addresses;
		var multiples;
		var faxable;
		
		if (optionNumber == "1"){
			addresses = 1;
			multiples = 1;
			faxable = false;
		}else if (optionNumber == "2"){
			addresses = 1;
			multiples = 2;
			faxable = false;
		}else if (optionNumber == "3"){
			addresses = 1;
			multiples = 1;
			faxable = true;
		}else if (optionNumber == "4"){
			addresses = 2;
			multiples = 1;
			faxable = false;
		}else{
			addresses = 0;
		}
		
		//for loop for printing out multiple recipient addresses
		//
		for (i=0; i<addresses; i++) {
			faxFormWin.document.write('<div id = ' + i + '>');
			requestFaxNumberofTranscripts(faxFormWin, multiples);
			requestMailingAddress(faxFormWin, yourname);
			if (faxable) {
				requestFaxNumber(faxFormWin);
			}
			requestSpecInstructions(faxFormWin, 'fax');
			faxFormWin.document.write('</div>');
		}
	
		var failedRequestReasons = "<ul><li>Missing signature</li><li>Any financial holds on your record</li><li>A credit card that is declined for payment</li><li>Missing or partial credit card information</li></ul>";
		requestPaymentAndClose(faxFormWin, yourname, 'fax', '<p>Your credit card will be billed $24.00.   </p><p><ul><li>Fax your completed and signed form to (812) 855-3999.</li><li>Call our Transcript Information Line at (812) 855-7505 shortly after faxing us your request to make sure the transmission was received and is in order.</li><li>If your request is not in order, it will not be processed.  It will be returned by mail, with a letter of explanation, for any of the following reasons:</p>' + failedRequestReasons);
			
} // close if statement
	

} // close function printTranscriptfaxFormWin