var SchoolFees = new Array();
// [0]:School Name, [1]:Lecture Phase Fee, [2]:Room deposit paid Fee, [3]: Lift pass/Transportation Fee, [4]:Outreach Fee
SchoolFees[0] = new Array("sbs","4000","-500","0","0");
SchoolFees[1] = new Array("aw80","4500","-500","750","10500");
SchoolFees[2] = new Array("sdts","4500","-500","1500","4500");
SchoolFees[3] = new Array("bdts","4500","-500","750","4000");
SchoolFees[4] = new Array("ethcre","4500","-500","750","5000");
SchoolFees[5] = new Array("bdtsI","4500","-500","750","5000");
SchoolFees[6] = new Array("fathers love","4500","-500","0","5000");

function getSchoolFee(id, feeType){
	document.write(' <span class="fee">nz</span>$' + getFee(id,feeType) + '.00');
}function getFee(id, feeType){
	for(var i = 0; i < SchoolFees.length; i++){
		var fee = SchoolFees[i];
		if(fee[0] == id){
			return fee[feeType];
		}
	}
	return '0';
}function setCheckBoxValue(id, school, feeType){
	document.getElementById(id).value = getFee(school,feeType);
}var SchoolList = new Array();
SchoolList[0] = new Array('sbs','Bible Core Course');
SchoolList[1] = new Array('aw80','Around the World in 80 Days DTS');
SchoolList[2] = new Array('sdts','Snowboaders DTS');
SchoolList[3] = new Array('bdts','Backpackers DTS');
SchoolList[4] = new Array('bdtsI','Backpackers DTS International Outreach');
SchoolList[5] = new Array('ethcre','Earth Care DTS');
SchoolList[6] = new Array('fathers love','Fathers Love');

function createSchoolList(id){
	createSelectList(id,SchoolList);
}function writeSchoolName(name){
	for(var i = 0; i < SchoolList.length; i++){
		var school = SchoolList[i];
		if(school[0] == name) document.write(school[1]);
	}
}var PaymentPages = new Array();
PaymentPages[0] = new Array("application-fee.php", "Application Fee");
PaymentPages[1] = new Array("room-deposit.php", "Room Deposit");
PaymentPages[2] = new Array("school-fees.php", "School Fees");
PaymentPages[3] = new Array("donation.php", "Donation");function createPaymentList(id){
	createSelectList(id, PaymentPages);
}function movePage(obj){
	for(var i = 0; i < obj.length; i++){
		var opt = obj.options[i];
		if(opt.selected && opt.value != null && opt.value.length != 0) window.open('./' + opt.value,'_self');
	}
}var CountryList = new Array();
CountryList[0] = new Array("AF","Afghanistan");
CountryList[1] = new Array("AL","Albania");
CountryList[2] = new Array("DZ","Algeria");
CountryList[3] = new Array("AS","American Samoa");
CountryList[4] = new Array("AD","Andorra");
CountryList[5] = new Array("AO","Angola");
CountryList[6] = new Array("AI","Anguilla");
CountryList[7] = new Array("AQ","Antarctica");
CountryList[8] = new Array("AG","Antigua and Barbuda");
CountryList[9] = new Array("AR","Argentina");
CountryList[10] = new Array("AM","Armenia");
CountryList[11] = new Array("AW","Aruba");
CountryList[12] = new Array("AU","Australia");
CountryList[13] = new Array("AT","Austria");
CountryList[14] = new Array("AZ","Azerbaijan");
CountryList[15] = new Array("BS","Bahamas");
CountryList[16] = new Array("BH","Bahrain");
CountryList[17] = new Array("BD","Bangladesh");
CountryList[18] = new Array("BB","Barbados");
CountryList[19] = new Array("BY","Belarus");
CountryList[20] = new Array("BE","Belgium");
CountryList[21] = new Array("BZ","Belize");
CountryList[22] = new Array("BJ","Benin");
CountryList[23] = new Array("BM","Bermuda");
CountryList[24] = new Array("BT","Bhutan");
CountryList[25] = new Array("BO","Bolivia");
CountryList[26] = new Array("BA","Bosnia and Herzegowina");
CountryList[27] = new Array("BW","Botswana");
CountryList[28] = new Array("BV","Bouvet Island");
CountryList[29] = new Array("BR","Brazil");
CountryList[30] = new Array("IO","British Indian Ocean Territory");
CountryList[31] = new Array("BN","Brunei Darussalam");
CountryList[32] = new Array("BG","Bulgaria");
CountryList[33] = new Array("BF","Burkina Faso");
CountryList[34] = new Array("BI","Burundi");
CountryList[35] = new Array("KH","Cambodia");
CountryList[36] = new Array("CM","Cameroon");
CountryList[37] = new Array("CA","Canada");
CountryList[38] = new Array("CV","Cape Verde");
CountryList[39] = new Array("KY","Cayman Islands");
CountryList[40] = new Array("CF","Central African Republic");
CountryList[41] = new Array("TD","Chad");
CountryList[42] = new Array("CL","Chile");
CountryList[43] = new Array("CN","China");
CountryList[44] = new Array("CX","Christmas Island");
CountryList[45] = new Array("CC","Cocos (Keeling) Islands");
CountryList[46] = new Array("CO","Colombia");
CountryList[47] = new Array("KM","Comoros");
CountryList[48] = new Array("CG","Congo");
CountryList[49] = new Array("CD","Congo, the Democratic Republic of the");
CountryList[50] = new Array("CK","Cook Islands");
CountryList[51] = new Array("CR","Costa Rica");
CountryList[52] = new Array("CI","Cote d'Ivoire");
CountryList[53] = new Array("HR","Croatia (Hrvatska)");
CountryList[54] = new Array("CU","Cuba");
CountryList[55] = new Array("CY","Cyprus");
CountryList[56] = new Array("CZ","Czech Republic");
CountryList[57] = new Array("DK","Denmark");
CountryList[58] = new Array("DJ","Djibouti");
CountryList[59] = new Array("DM","Dominica");
CountryList[60] = new Array("DO","Dominican Republic");
CountryList[61] = new Array("TP","East Timor");
CountryList[62] = new Array("EC","Ecuador");
CountryList[63] = new Array("EG","Egypt");
CountryList[64] = new Array("SV","El Salvador");
CountryList[65] = new Array("GQ","Equatorial Guinea");
CountryList[66] = new Array("ER","Eritrea");
CountryList[67] = new Array("EE","Estonia");
CountryList[68] = new Array("ET","Ethiopia");
CountryList[69] = new Array("FK","Falkland Islands (Malvinas)");
CountryList[70] = new Array("FO","Faroe Islands");
CountryList[71] = new Array("FJ","Fiji");
CountryList[72] = new Array("FI","Finland");
CountryList[73] = new Array("FR","France");
CountryList[74] = new Array("FX","France, Metropolitan");
CountryList[75] = new Array("GF","French Guiana");
CountryList[76] = new Array("PF","French Polynesia");
CountryList[77] = new Array("TF","French Southern Territories");
CountryList[78] = new Array("GA","Gabon");
CountryList[79] = new Array("GM","Gambia");
CountryList[80] = new Array("GE","Georgia");
CountryList[81] = new Array("DE","Germany");
CountryList[82] = new Array("GH","Ghana");
CountryList[83] = new Array("GI","Gibraltar");
CountryList[84] = new Array("GR","Greece");
CountryList[85] = new Array("GL","Greenland");
CountryList[86] = new Array("GD","Grenada");
CountryList[87] = new Array("GP","Guadeloupe");
CountryList[88] = new Array("GU","Guam");
CountryList[89] = new Array("GT","Guatemala");
CountryList[90] = new Array("GN","Guinea");
CountryList[91] = new Array("GW","Guinea-Bissau");
CountryList[92] = new Array("GY","Guyana");
CountryList[93] = new Array("HT","Haiti");
CountryList[94] = new Array("HM","Heard and Mc Donald Islands");
CountryList[95] = new Array("VA","Holy See (Vatican City State)");
CountryList[96] = new Array("HN","Honduras");
CountryList[97] = new Array("HK","Hong Kong");
CountryList[98] = new Array("HU","Hungary");
CountryList[99] = new Array("IS","Iceland");
CountryList[100] = new Array("IN","India");
CountryList[101] = new Array("ID","Indonesia");
CountryList[102] = new Array("IR","Iran (Islamic Republic of)");
CountryList[103] = new Array("IQ","Iraq");
CountryList[104] = new Array("IE","Ireland");
CountryList[105] = new Array("IL","Israel");
CountryList[106] = new Array("IT","Italy");
CountryList[107] = new Array("JM","Jamaica");
CountryList[108] = new Array("JP","Japan");
CountryList[109] = new Array("JO","Jordan");
CountryList[110] = new Array("KZ","Kazakhstan");
CountryList[111] = new Array("KE","Kenya");
CountryList[112] = new Array("KI","Kiribati");
CountryList[113] = new Array("KP","Korea, Democratic People's Republic of");
CountryList[114] = new Array("KR","Korea, Republic of");
CountryList[115] = new Array("KW","Kuwait");
CountryList[116] = new Array("KG","Kyrgyzstan");
CountryList[117] = new Array("LA","Lao People's Democratic Republic");
CountryList[118] = new Array("LV","Latvia");
CountryList[119] = new Array("LB","Lebanon");
CountryList[120] = new Array("LS","Lesotho");
CountryList[121] = new Array("LR","Liberia");
CountryList[122] = new Array("LY","Libyan Arab Jamahiriya");
CountryList[123] = new Array("LI","Liechtenstein");
CountryList[124] = new Array("LT","Lithuania");
CountryList[125] = new Array("LU","Luxembourg");
CountryList[126] = new Array("MO","Macau");
CountryList[127] = new Array("MK","Macedonia, The Former Yugoslav Republic of");
CountryList[128] = new Array("MG","Madagascar");
CountryList[129] = new Array("MW","Malawi");
CountryList[130] = new Array("MY","Malaysia");
CountryList[131] = new Array("MV","Maldives");
CountryList[132] = new Array("ML","Mali");
CountryList[133] = new Array("MT","Malta");
CountryList[134] = new Array("MH","Marshall Islands");
CountryList[135] = new Array("MQ","Martinique");
CountryList[136] = new Array("MR","Mauritania");
CountryList[137] = new Array("MU","Mauritius");
CountryList[138] = new Array("YT","Mayotte");
CountryList[139] = new Array("MX","Mexico");
CountryList[140] = new Array("FM","Micronesia, Federated States of");
CountryList[141] = new Array("MD","Moldova, Republic of");
CountryList[142] = new Array("MC","Monaco");
CountryList[143] = new Array("MN","Mongolia");
CountryList[144] = new Array("MS","Montserrat");
CountryList[145] = new Array("MA","Morocco");
CountryList[146] = new Array("MZ","Mozambique");
CountryList[147] = new Array("MM","Myanmar");
CountryList[148] = new Array("NA","Namibia");
CountryList[149] = new Array("NR","Nauru");
CountryList[150] = new Array("NP","Nepal");
CountryList[151] = new Array("NL","Netherlands");
CountryList[152] = new Array("AN","Netherlands Antilles");
CountryList[153] = new Array("NC","New Caledonia");
CountryList[154] = new Array("NZ","New Zealand");
CountryList[155] = new Array("NI","Nicaragua");
CountryList[156] = new Array("NE","Niger");
CountryList[157] = new Array("NG","Nigeria");
CountryList[158] = new Array("NU","Niue");
CountryList[159] = new Array("NF","Norfolk Island");
CountryList[160] = new Array("MP","Northern Mariana Islands");
CountryList[161] = new Array("NO","Norway");
CountryList[162] = new Array("OM","Oman");
CountryList[163] = new Array("PK","Pakistan");
CountryList[164] = new Array("PW","Palau");
CountryList[165] = new Array("PA","Panama");
CountryList[166] = new Array("PG","Papua New Guinea");
CountryList[167] = new Array("PY","Paraguay");
CountryList[168] = new Array("PE","Peru");
CountryList[169] = new Array("PH","Philippines");
CountryList[170] = new Array("PN","Pitcairn");
CountryList[171] = new Array("PL","Poland");
CountryList[172] = new Array("PT","Portugal");
CountryList[173] = new Array("PR","Puerto Rico");
CountryList[174] = new Array("QA","Qatar");
CountryList[175] = new Array("RE","Reunion");
CountryList[176] = new Array("RO","Romania");
CountryList[177] = new Array("RU","Russian Federation");
CountryList[178] = new Array("RW","Rwanda");
CountryList[179] = new Array("KN","Saint Kitts and Nevis");
CountryList[180] = new Array("LC","Saint LUCIA");
CountryList[181] = new Array("VC","Saint Vincent and the Grenadines");
CountryList[182] = new Array("WS","Samoa");
CountryList[183] = new Array("SM","San Marino");
CountryList[184] = new Array("ST","Sao Tome and Principe");
CountryList[185] = new Array("SA","Saudi Arabia");
CountryList[186] = new Array("SN","Senegal");
CountryList[187] = new Array("SC","Seychelles");
CountryList[188] = new Array("SL","Sierra Leone");
CountryList[189] = new Array("SG","Singapore");
CountryList[190] = new Array("SK","Slovakia (Slovak Republic)");
CountryList[191] = new Array("SI","Slovenia");
CountryList[192] = new Array("SB","Solomon Islands");
CountryList[193] = new Array("SO","Somalia");
CountryList[194] = new Array("ZA","South Africa");
CountryList[195] = new Array("GS","South Georgia and the South Sandwich Islands");
CountryList[196] = new Array("ES","Spain");
CountryList[197] = new Array("LK","Sri Lanka");
CountryList[198] = new Array("SH","St. Helena");
CountryList[199] = new Array("PM","St. Pierre and Miquelon");
CountryList[200] = new Array("SD","Sudan");
CountryList[201] = new Array("SR","Suriname");
CountryList[202] = new Array("SJ","Svalbard and Jan Mayen Islands");
CountryList[203] = new Array("SZ","Swaziland");
CountryList[204] = new Array("SE","Sweden");
CountryList[205] = new Array("CH","Switzerland");
CountryList[206] = new Array("SY","Syrian Arab Republic");
CountryList[207] = new Array("TW","Taiwan, Province of China");
CountryList[208] = new Array("TJ","Tajikistan");
CountryList[209] = new Array("TZ","Tanzania, United Republic of");
CountryList[210] = new Array("TH","Thailand");
CountryList[211] = new Array("TG","Togo");
CountryList[212] = new Array("TK","Tokelau");
CountryList[213] = new Array("TO","Tonga");
CountryList[214] = new Array("TT","Trinidad and Tobago");
CountryList[215] = new Array("TN","Tunisia");
CountryList[216] = new Array("TR","Turkey");
CountryList[217] = new Array("TM","Turkmenistan");
CountryList[218] = new Array("TC","Turks and Caicos Islands");
CountryList[219] = new Array("TV","Tuvalu");
CountryList[220] = new Array("UG","Uganda");
CountryList[221] = new Array("UA","Ukraine");
CountryList[222] = new Array("AE","United Arab Emirates");
CountryList[223] = new Array("GB","United Kingdom");
CountryList[224] = new Array("US","United States");
CountryList[225] = new Array("UM","United States Minor Outlying Islands");
CountryList[226] = new Array("UY","Uruguay");
CountryList[227] = new Array("UZ","Uzbekistan");
CountryList[228] = new Array("VU","Vanuatu");
CountryList[229] = new Array("VE","Venezuela");
CountryList[230] = new Array("VN","Viet Nam");
CountryList[231] = new Array("VG","Virgin Islands (British)");
CountryList[232] = new Array("VI","Virgin Islands (U.S.)");
CountryList[233] = new Array("WF","Wallis and Futuna Islands");
CountryList[234] = new Array("EH","Western Sahara");
CountryList[235] = new Array("YE","Yemen");
CountryList[236] = new Array("YU","Yugoslavia");
CountryList[237] = new Array("ZM","Zambia");
CountryList[238] = new Array("ZW","Zimbabwe");function createCountryList(id){
	createSelectList(id,CountryList);
}function createSelectList(id, list){
	var select = document.getElementById(id);
	if(select != null){
		for(var i = 0; i < list.length; i++){
			var opt = document.createElement('option');
			opt.value = list[i][0];
			opt.text = list[i][1];
			try{
				select.add(opt,null);
			}catch(ex){
				select.add(opt);
			}
		}
	}
}function OnlinepymentCheckBox(id){
	var given = document.getElementById('payer_givenname');
	var sur = document.getElementById('payer_surname');
	if(document.getElementById(id).checked){
		given.value = '';
		given.disabled = true;
		sur.value = '';
		sur.disabled = true;
	}else{
		given.disabled = false;
		sur.disabled = false;
	}
}var paymentItems = new Array();
paymentItems[0] = new Array('pageName','Page Name');
paymentItems[1] = new Array('app_school','Applicant School');
paymentItems[2] = new Array('app_givenname','Applicant given name');
paymentItems[3] = new Array('app_surname','Applicant surname');
paymentItems[4] = new Array('amount','Donation Amount');
paymentItems[5] = new Array('purpose','Donation purpose');
paymentItems[6] = new Array('payer_givenname','Billing given name');
paymentItems[7] = new Array('payer_surname','Billing surname');
paymentItems[8] = new Array('location','Billing loaction');
paymentItems[9] = new Array('payer_email','Billing e-mail');
function OnlinepaymentCheck(){
	var app_givenname;
	var app_surname;
	var payer_givenname;
	var payer_surname;	for(var i = 0; i < paymentItems.length;i++){
		var id = paymentItems[i][0];
		var idItem = document.getElementById(id);		if(id == 'app_givenname' && idItem != null){
			app_givenname = idItem.value;
		}else if(id == 'app_surname' && idItem != null){
			app_surname = idItem.value;
		}else if(id == 'payer_givenname'){
			payer_givenname = idItem.value;
			if(!checkParam(idItem)){
				idItem.disabled = false;
				payer_givenname = (app_givenname != null && app_givenname.length != 0)? app_givenname:'';
				idItem.value = payer_givenname;
			}
		}else if(id == 'payer_surname'){
			payer_surname = idItem.value;
			if(!checkParam(idItem)){
				idItem.disabled = false;
				payer_surname = (app_surname != null && app_surname.length != 0)? app_surname:'';
				idItem.value = payer_surname;
			}
		}else if(id == 'amount'){
			if(idItem != null && idItem.value.indexOf('.') < 0) idItem.value += '.00';
		}		var app_name = (app_givenname != null && app_surname != null)? app_givenname+app_surname:'';
		var payer_name = (payer_givenname != null && payer_surname != null)? payer_givenname+payer_surname:'';
		if(app_name.length > 20 || payer_name.length > 20){
			alert('Payer Given name and Surname must not be more than 20 characters. Please shorten.');
			return false;
		}		if(!checkParam(idItem)){
			alert('Input the ' + paymentItems[i][1] + ', please');
			return false;
		}else if(idItem != null && id == 'amount' && !checkNum(idItem.value)){
			alert('Put the only Numeric in the Amount Text');
			return false;
		}else if(idItem != null && id == 'payer_email' && !checkMail(idItem.value)){
			alert('Put the correct mail Address, please');
			return false;
		}
	}
	return true;
}function checkParam(item){
	if(item == null) return true;
	return (item.value != null && item.value.length != 0)? true:false;
}function checkNum(value){
	for(var i = 0; i < value.length; i++){
		switch(value.substr(i,1)){
			case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9':	continue;
			case '.': 
				if((value.length - i) != 3) return false;
				else continue;
			default: return false;
		}
	}
	return true;
}function checkMail(value){
	var at = false;
	var dot = false;
	for(var i = 0; i < value.length; i++){
		switch(value.substr(i,1)){
			case '@': at = true; continue;
			case '.': dot = true; continue;
		}
	}	
	return (at && dot)? true: false;
}function getHttpObject(){
	try{
		// Firefox, Opera 8.0+, Safari
		return new XMLHttpRequest();
	}catch (e){
		// Internet Explorer
		try{
			return new ActiveXObject("Msxml2.XMLHTTP");
		}catch (e){
			try{
				return new ActiveXObject("Microsoft.XMLHTTP");
			}catch (e){
				alert("Your browser does not support AJAX!");
				return false;
			}
		}
	}
}var xmlHttp;function GatewayTransaction(){	xmlHttp = getHttpObject();
	if(xmlHttp){
		var form = document.gwTrans;
		var url = "../scripts/trans-utils.php?page="+form.trnPage.value;		if(checkObject(form.trnAppSchool)) url += '&app_school='+form.trnAppSchool.value;
		if(checkObject(form.trnAppGivenname)) url += '&app_givenname='+form.trnAppGivenname.value;
		if(checkObject(form.trnAppSurname)) url += '&app_surname='+form.trnAppSurname.value;
		if(checkObject(form.trnPayerGivenname)) url += '&payer_givenname='+form.trnPayerGivenname.value;
		if(checkObject(form.trnPayerSurname)) url += '&payer_surname='+form.trnPayerSurname.value;
		if(checkObject(form.trnLocation)) url += '&location='+form.trnLocation.value;
		if(checkObject(form.trnPayerEmail)) url += '&payer_email='+form.trnPayerEmail.value;
		if(checkObject(form.trnAmount)) url += '&amount='+form.trnAmount.value;
		if(checkObject(form.trnPurpose)) url += '&purpose='+form.trnPurpose.value;
		
		xmlHttp.onreadystatechange=stateChagned;
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);
	}
}function stateChagned(){
	if(xmlHttp.readyState == 4)	window.location = xmlHttp.responseText;
}function checkObject(obj){
	return (obj != null && obj.value.length != 0);
}