// JavaScript Document

//Global Variables

var field;	

var idLength;

var requiredFields = new Array;

var masterSpan = document.getElementsByTagName("span");

var failed;

if (document.all) {

	var browserOffset = 1;

}else{

	var browserOffset = 0;

}







//Controls Header text on pages

function reveal() {

var query = window.location.href;

var page = query.substr(query.indexOf("?")+1);

var args = new Object();

var fields = page.split('&');

for (var f = 0; f < fields.length; f++) {

      var field = fields[f].split('=');

      args[unescape(field[0].replace(/\+/g, ' '))] = unescape(field[1].replace(/\+/g, ' '));

    }

	

page = args['ip']



document.getElementById(page).style.display = 'block';

}



//confirmation after submission of interest page

function submitMessage() {

var query = window.location.href; // takes the url and turns it into a string variable

//new better way of doing it

//parsing variables with js

var page = query.substr(query.indexOf("?")+1);

var args = new Object();

var fields = page.split('&');

for (var f = 0; f < fields.length; f++) {

      var field = fields[f].split('=');

      args[unescape(field[0].replace(/\+/g, ' '))] = unescape(field[1].replace(/\+/g, ' '));

    }

//lert(args['ip']);

document.getElementById('general').style.display = 'block';

page = args['ip']



/*This section is where you add unique confirmation messages per page.  Copy one of the 'if' statements below

and change NAME in the if (page == 'PAGENAME') to the name of the page (i.e. freshman, graduate, international).

In the XML, the new statement must be named as well.*/

//Name of the interest page

if (page == 'PAGENAME') {

	document.getElementById('general').style.display = 'none';

	document.getElementById('continuing').style.display = 'block';

	document.getElementById('chronicle-submit').style.display = 'none';

}

if (page == 'PAGENAME') {

	

	document.getElementById('con').style.display = 'none';

	document.getElementById('chronicle-submit').style.display = 'block';

}

}



//When clicking submit it makes sure that all required fields are filled out

function setValidate() {

	document.emtinterestpage.onsubmit=validate;

	document.emtinterestpage.btnSetIPData.onclick="";

}





//Takes you back to the blank required fields to be filled out

function validate() {





if(window.location.href.indexOf('ip=continuing') == -1)

{

	//Buttons Go first

	document.getElementById('stepOne').style.display = "none";

	document.getElementById('stepTwo').style.display = "block";

	document.getElementById('stepThree').style.display = "none";

	//Information Messages After buttons

	document.getElementById('StepOneTitle').style.display = "block";

	document.getElementById('StepTwoTitle').style.display = "none";

	document.getElementById('StepThreeTitle').style.display = "none";

	document.getElementById('btnSetIPData').style.display = "none";

}



//Attributes Are Second

try{document.getElementById('Account Information').parentNode.parentNode.parentNode.parentNode.style.display = "inline";}catch(e){}

try{document.getElementById('Personal Information').parentNode.parentNode.parentNode.parentNode.style.display = "inline";}catch(e){}

try{document.getElementById('High School Information').parentNode.parentNode.parentNode.parentNode.style.display = "none";}catch(e){}

try{document.getElementById('Admission Information').parentNode.parentNode.parentNode.parentNode.style.display = "none";}catch(e){}

try{document.getElementById('I want to learn more about').parentNode.parentNode.parentNode.parentNode.style.display = "none";}catch(e){}

try{document.getElementById('General Information').parentNode.parentNode.parentNode.parentNode.style.display = "none";}catch(e){}







	var index = 0;

	failed = "false";

	for (i=0;i<masterSpan.length;i++) {

		if (masterSpan[i].getAttribute("id")){

			if (masterSpan[i].getAttribute("id").substr(masterSpan[i].getAttribute("id").length-8,8) == 'Required') {

				requiredFields[index] = masterSpan[i];

				//alert(requiredFields[index].innerHTML);

				index += 1;

			}

        }

	}

	//If you want data to validate in a different order (for example, validate your high school before your college picker, you can change the order here.

	try{requiredCheck();}catch(e){}

	if (failed == "true"){

		document.getElementById('errorMessageDiv').style.display = "block";

		return false

	}

	

	try{lengthCheck();}catch(e){}

	if (failed == "true"){

		document.getElementById('errorMessageDiv').style.display = "block";

		return false

	}

	

	try{passMatchCheck();}catch(e){}

	if (failed == "true"){

		document.getElementById('errorMessageDiv').style.display = "block";

		return false

	}

	

	try{requiredPickers();}catch(e){}

	if (failed == "true"){

		document.getElementById('errorMessageDiv').style.display = "block";

		return false

	}

	

	var pickerExist = "";

	pickerExists = document.emtinterestpage.hscode;

	if (pickerExists != undefined){

		try{hsRequiredPicker();}catch(e){}

		if (failed == "true"){

			document.getElementById('errorMessageDiv').style.display = "block";

			return false

		}

	}

	

	var cpickerExists = "";

	cpickerExists = document.emtinterestpage.collegename;

	if (cpickerExists !=  undefined){

		try{collegeRequiredPicker();}catch(e){}

		if (failed == "true"){

			document.getElementById('errorMessageDiv').style.display = "block";

			return false

		}

	}

	//Leave this line at the end of the function

	document.getElementById('errorMessageDiv').style.display = "none";

	for (x=0; x<document.forms[0].elements.length; x++) {document.forms[0].elements[x].disabled = false;}

	return true;	

}





//Controls the password fields

function pwControl() {

	box = document.getElementById('pw-box');

	var password = document.emtinterestpage.password;

	//alert(box.innerHTML);

	box.removeChild(password);

	var newpassword = document.createElement('input');

	newpassword.setAttribute("type","password")

	newpassword.setAttribute("id","password")

	newpassword.setAttribute("name","password")

	newpassword.width = "250";

	box.appendChild(newpassword);

}











//Confirms that the required checkboxes are selected

function requiredCheck() {

	if (masterSpan.length>0) {

        var badCount = 0;

		for (i=0;i<requiredFields.length;i++){



			if ((requiredFields[i].getAttribute("ResponseType") == "asp:TextBox")||(requiredFields[i].getAttribute("ResponseType") == "asp:DropDownList")) {

				idLength = requiredFields[i].getAttribute("id").length;

				field = requiredFields[i].getAttribute("id").substr(idLength-idLength,idLength-8);

				document.getElementById(field).onchange=valueCheck;			

				if (document.getElementById(field).value =="") {

					requiredFields[i].style.display = "block";

					failed="true";

					if (badCount < 1) {

                    document.getElementById(field).focus();

					}

                    badCount += 1;

				}else{

					requiredFields[i].style.display = "none";

				}

			}



			if ((requiredFields[i].getAttribute("ResponseType") == "asp:RadioButtonList")||(requiredFields[i].getAttribute("ResponseType") == "asp:RadioButtonList")) {

				idLength = requiredFields[i].getAttribute("id").length;

				field = requiredFields[i].getAttribute("id").substr(idLength-idLength,idLength-8);

				var checkArray = document.getElementsByName(field);

				var finalCheck ="incomplete";

				for (j=0+browserOffset; j<checkArray.length;j++) {

					checkArray[j].onclick=checkedCheck;

            		if (checkArray[j].checked) {

						requiredFields[i].style.display = "none";

						finalCheck = "complete";

					}					

				}

				if (finalCheck == "incomplete") {

					requiredFields[i].style.display = "block";

					failed="true";

					if (badCount < 1) {

					if (document.all){

                    	checkArray[1].focus();

					}else{

						checkArray[0].focus();

					}

					}

					badCount += 1;											

				}

   			}

		}

    }

}



// High School Checker

/* USING THIS CODE - If your school would like the highschool picker to be required, remove the comment tags on the following code.  

You must use the standard naming conventions associated with the high school picker in order for this to work and only one high shool picker

can exist per page.  If you need more than one, you will need to tweak the code below by replacing the individual document.getElementById("NAME")

to match the texbox names for each required high school picker.*/



function hsRequiredPicker() {

/*

var pickerInfo = document.emtinterestpage.hscode;

	if (pickerInfo.value == "") {

	document.getElementById("hscodeRequired").style.display = 'block';

	failed="true";

    }else {

		document.getElementById("hscodeRequired").style.display = 'none';

	}

	pickerInfo = document.emtinterestpage.hsname;

	if (pickerInfo.value == "") {

	document.getElementById("hsnameRequired").style.display = 'block';

	failed="true";

    }else {

		document.getElementById("hsnameRequired").style.display = 'none';

	}

	pickerInfo = document.emtinterestpage.hsaddress1;

	if (pickerInfo.value == "") {

	document.getElementById("hsaddress1Required").style.display = 'block';

	failed="true";

    }else {

		document.getElementById("hsaddress1Required").style.display = 'none';

	}

	//This section will make the address 2 field required.  Because the Picker does not always use this field, it is highly recommended

	//that this be left commented out.  Use in circumstances where a second address must be used.

	//pickerInfo = document.emtinterestpage.hsaddress2;

	//if (pickerInfo.value == "") {

	//document.getElementById("hsaddress2Required").style.display = 'block';

	//failed="true";

    //}else {

	//	document.getElementById("hsaddress2Required").style.display = 'none';

	//}

	pickerInfo = document.emtinterestpage.hscity;

	if (pickerInfo.value == "") {

	document.getElementById("hscityRequired").style.display = 'block';

	failed="true";

    }else {

		document.getElementById("hscityRequired").style.display = 'none';

	}

	pickerInfo = document.emtinterestpage.hsstate;

	if (pickerInfo.value == " ") {

	document.getElementById("hsstateRequired").style.display = 'block';

	failed="true";

    }else {

		document.getElementById("hsstateRequired").style.display = 'none';

	}

	pickerInfo = document.emtinterestpage.hszip;

	if (pickerInfo.value == "") {

	document.getElementById("hszipRequired").style.display = 'block';

	failed="true";

    }else {

		document.getElementById("hszipRequired").style.display = 'none';

	}

	*/

}





// College Checker

/* USING THIS CODE - If your school would like the college picker to be required, remove the comment tags on the following code.  

You must use the standard naming conventions associated with the college picker in order for this to work and only one college picker

can exist per page.  If you need more than one, you will need to tweak the code below by replacing the individual document.getElementById("NAME")

to match the texbox names for each required college picker.*/



function collegeRequiredPicker() {

/* 

var pickerInfo = document.emtinterestpage.collegecode;

	if (pickerInfo.value == "") {

	document.getElementById("collegecodeRequired").style.display = 'block';

	failed="true";

    }else {

		document.getElementById("collegecodeRequired").style.display = 'none';

	}

	pickerInfo = document.emtinterestpage.collegename;

	if (pickerInfo.value == "") {

	document.getElementById("collegenameRequired").style.display = 'block';

	failed="true";

    }else {

		document.getElementById("collegenameRequired").style.display = 'none';

	}

	pickerInfo = document.emtinterestpage.collegecity;

	if (pickerInfo.value == "") {

	document.getElementById("collegecityRequired").style.display = 'block';

	failed="true";

    }else {

		document.getElementById("collegecityRequired").style.display = 'none';

	}

	pickerInfo = document.emtinterestpage.collegestate;

	if (pickerInfo.value == " ") {

	document.getElementById("collegestateRequired").style.display = 'block';

	failed="true";

    }else {

		document.getElementById("collegestateRequired").style.display = 'none';

	}

	pickerInfo = document.emtinterestpage.collegezip;

	if (pickerInfo.value == "") {

	document.getElementById("collegezipRequired").style.display = 'block';

	failed="true";

    }else {

		document.getElementById("collegezipRequired").style.display = 'none';

	}

*/

}





//Date of Birth Check

/*

DATE PICKER CODE:  This code will check for date pickers that are flagged as required and validate them accordingly.  This code is touchy and

requires some special configuration in order to validate correctly.  If you are using date of birth, this code will work as intended if you

did not alter the default names or id's in the admin dashboard.  If you have more than one required date picker (for example, date of graduation

set to be required), then follow the steps in the next section.



IF YOUR DATE PICKER IS NOT VALIDATING

This is because Connect2 randomly assigns a unique id to all inputs regardless of the name value you gave your picker style.  If it is not validating,

run the interest page and view the source.  Find the date picker.  You will notice an id something like the following: id="date323".  Go to the

admin dashboard and rename the styles to match the name of the date input.  If you are still getting an error you will need to recreate the 

attribute.



NOTE:  This is because Dates must be in a Date attribute, not a standard textbox.  All texboxes will allow date pickers, but cannot validate

correctly unless it is in a date attribute.  In tests, it has the potential of breaking the text validater further down the page.

*/

function requiredPickers() {

	if (masterSpan.length>0) {

        var badCount = 0;

		for (i=0;i<requiredFields.length;i++){

			if (requiredFields[i].getAttribute("ResponseType") == "cc:DatePicker") {

				idLength = requiredFields[i].getAttribute("id").length;

				field = requiredFields[i].getAttribute("id").substr(idLength-idLength,idLength-14);

				document.getElementById(field).onchange=valueCheck;			

				if (document.getElementById(field).value =="") {

					requiredFields[i].style.display = "block";

					failed="true";

					if (badCount < 1) {

						scroll(0,0);

                    document.getElementById(field).focus();

					}

                    badCount += 1;

				}else{

					requiredFields[i].style.display = "none";

				}

			}



			if ((requiredFields[i].getAttribute("ResponseType") == "asp:RadioButtonList")||(requiredFields[i].getAttribute("ResponseType") == "asp:RadioButtonList")) {

				idLength = requiredFields[i].getAttribute("id").length;

				field = requiredFields[i].getAttribute("id").substr(idLength-idLength,idLength-8);

				var checkArray = document.getElementsByName(field);

				var finalCheck ="incomplete";

				for (j=0+browserOffset; j<checkArray.length;j++) {

					checkArray[j].onclick=checkedCheck;

            		if (checkArray[j].checked) {

						requiredFields[i].style.display = "none";

						finalCheck = "complete";

					}					

				}

				if (finalCheck == "incomplete") {

					requiredFields[i].style.display = "block";

					failed="true";

					if (badCount < 1) {

					if (document.all){

                    	checkArray[1].focus();

					}else{

						checkArray[0].focus();

					}

					}

					badCount += 1;											

				}

   			}

		}

    }

}





function valueCheck() {



	var myRequired = this.getAttribute("id")+"Required";

	if (document.getElementById(this.getAttribute("id")).value =="") {

		document.getElementById(myRequired).style.display = "block";

	}else{

		document.getElementById(myRequired).style.display = "none";

	}

}





function checkedCheck() {

	var myRequired = this.name+"Required";

	var checkArray = document.getElementsByName(this.name);

	var finalCheck ="incomplete";



	for (j=0+browserOffset; j<checkArray.length;j++) {

		if (checkArray[j].checked) {

			document.getElementById(myRequired).style.display = "none";

			finalCheck = "complete";

			j = checkArray.length;

		}					

	}

	if (finalCheck == "incomplete") {

		document.getElementById(myRequired).style.display = "block";

	}

}



//Length of password and login checker

function lengthCheck() {

	if (document.emtinterestpage.login.value.length < 5) {

		document.getElementById('loginLength').style.display = "block";

		failed="true";

		document.emtinterestpage.login.focus();

	}

	if (document.emtinterestpage.login.value.length >= 5) {

		document.getElementById('loginLength').style.display = "none";

	}

	if (document.emtinterestpage.password.value.length < 5) {

		document.getElementById('passwordLength').style.display = "block";

		failed="true";

		document.emtinterestpage.password.focus();

	}

	if (document.emtinterestpage.password.value.length >= 5) {

		document.getElementById('passwordLength').style.display = "none";

	}

    document.emtinterestpage.login.onchange = lengthCheck;

    document.emtinterestpage.password.onchange = lengthCheck;

}



//Makes sure that both password fields are matching 

function passMatchCheck() {

	if (document.emtinterestpage.password.value != document.emtinterestpage.passwordConfirm.value) {

		document.getElementById('passwordMatch').style.display = "block";

		failed="true";

		document.emtinterestpage.passwordConfirm.focus();

	}else{

		document.getElementById('passwordMatch').style.display = "none";

	}

    document.emtinterestpage.password.onchange = passMatchCheck;

    document.emtinterestpage.passwordConfirm.onchange = passMatchCheck;	

}



function ValidatorHookupControlID(splitName,b){

	/* This will temporarily remove the javascript error coming from split pickers.  Since the function is not working at the moment,

	placing this code seems to have no affect on the current functionality of the page.  However, remove this section when the split picker

	error is fixed.

	*/

}



//Controls the popup window for the HS picker

function hsPopup(url,popupwidth,popupheight) { 

	var params = "'location=0,status=0,scrollbars=0,width=" + popupwidth + ",height=" + popupheight + "'"; 

	window.open (url,"CustomSelect",params); 

 } 



//Controls the popup window for the College picker

function collegePopup(url,popupwidth,popupheight){ 

var params = "'location=0,status=0,scrollbars=0,width=" + popupwidth + ",height=" + popupheight + "'"; 

window.open (url,"CustomSelect",params); 

 } 



//hideAttributes function to determine if hidden attributes exist on the page

function hideAttributes(){

try{

	var allTables = document.getElementsByTagName('table');

	for (i = 0; i < allTables.length; i++){

		var hiddenAttributesExist = document.getElementsByTagName('table').item(i).innerHTML.indexOf("Hidden Attributes");

		//alert(hiddenAttributesExist = document.getElementsByTagName('table').item(i).innerHTML.indexOf("Hidden Attributes"));

		if (hiddenAttributesExist > -1 && hiddenAttributesExist < 100){		

			try{

			document.getElementsByTagName('table').item(i).setAttribute("style","");

			}catch(e){}

			try{

			document.getElementsByTagName('table').item(i).style.cssText = "";

			}catch(e){}

			try{

			document.getElementsByTagName('table').item(i).setAttribute("id","hiddenAttributes");

			}catch(e){}

			try{

			document.getElementsByTagName('table').item(i).id = "hiddenAttributes";

			}catch(e){}

		}

	}

}

catch(e){}



}





function changeLoginMessage(loginMessage){



	var header3Elements = document.getElementsByTagName('h3');



	for (i = 0; i < header3Elements.length; i++){



		header3Elements.item(i).innerHTML = loginMessage;

		

			try{

			document.getElementById('loginpicture').setAttribute("style","display:block;");

			}catch(e){}

			try{

			document.getElementById('loginpicture').style.cssText = "display:block;";

			}catch(e){}

	}



}



function checkingForRefresh(){



	try{



		var loggedInDiv = document.getElementById("ucContactInfo_lblWelcome");



		var loginRequestActive = document.getElementById("loginOuterTable");



	



		if (loggedInDiv != null && loginRequestActive != null){



			var currentURL = unescape(window.location.pathname);



			window.location.href = currentURL + 'Vip.aspx';



		}



	}catch(e){}



}



 // used to Validate special attributes

function numberCatcher(fieldToRun,charactersToValidate){

	var fieldName = fieldToRun;

	//document.getElementsByTagName('form').item(0);

	var fieldValue = document.getElementById(fieldName).value;

	var passedCharacters = "";

	var passed = false;

	

	for (i=0; i < fieldValue.length ; i++){

		var checkCharacter = fieldValue.charAt(i);

		

		for(n=0; n < charactersToValidate.length ; n++){

			if(checkCharacter == charactersToValidate.charAt(n)){

				passed = false;

				n = charactersToValidate.length;

			}else{passed = true;}

		}

		if(passed == true){passedCharacters = passedCharacters + checkCharacter;}

	}

	document.getElementById(fieldName).value = passedCharacters;

	document.getElementById(fieldName).text = passedCharacters;

}



function hsPickerEditable() {

	try{

		document.emtinterestpage.hsname.disabled=false;

		document.emtinterestpage.hscode.disabled=false;

		document.emtinterestpage.hsaddress1.disabled=false;

		document.emtinterestpage.hsaddress2.disabled=false;

		document.emtinterestpage.hscity.disabled=false;

		document.emtinterestpage.hsstate.disabled=false;

		document.emtinterestpage.hszip.disabled=false;

		getElementById('hsclickheremessage').style.cssText = "";

		

	}catch(e){}

}



function collegePickerEditable() {

	try{

		document.emtinterestpage.collegename.disabled=false;

		document.emtinterestpage.collegecode.disabled=false;

		document.emtinterestpage.collegecity.disabled=false;

		document.emtinterestpage.collegestate.disabled=false;

		document.emtinterestpage.collegezip.disabled=false;

		document.getElementById('colclickheremessage').style.cssText = "";

		

	}catch(e){}

}



	//Special Code to Remove Select One Option if it exists



function populateDatePicker(fieldName){

	try{

	var monthAttribute = document.getElementById(fieldName + "MonthDrop");

	var dayAttribute = document.getElementById(fieldName + "DayDrop");

	var yearAttribute = document.getElementById(fieldName + "YearDrop");

	//This special code is needed to use pickers correctly

	if (fieldName.indexOf('picker') != '-1'){fieldName = fieldName.substring(0,fieldName.indexOf('picker'));}

	var dateAttribute = document.getElementById(fieldName);

	

	

	dateAttribute.value = monthAttribute[monthAttribute.selectedIndex].value + "/" + dayAttribute[dayAttribute.selectedIndex].value + "/" + yearAttribute[yearAttribute.selectedIndex].value

	}catch(e){}

}



function populateYear(fieldName,beginningYear,offsetYear){

	var date = new Date();

	var year = date.getFullYear() + offsetYear;

	fieldName = fieldName + "YearDrop";

	ClearOptions(document.getElementById(fieldName));

	

	AddToOptionList(document.getElementById(fieldName), "","Year")

	

	for (i=year;i>=beginningYear;i--){

		AddToOptionList(document.getElementById(fieldName), i, i);

	}

}



function AddToOptionList(OptionList, OptionValue, OptionText) {

	OptionList[OptionList.length] = new Option(OptionText, OptionValue);

}



function ClearOptions(OptionList) {



	//Always clear an option list from the last entry to the first

	for (x = OptionList.length; x >= 0; x = x - 1) {

		OptionList[x] = null;

	}

	text121List = document.emtinterestpage.text121;



}



function populateDays(fieldName) {

	var dayName = fieldName + "DayDrop";

	var monthName = fieldName + "MonthDrop";

	var textList = document.getElementById(monthName);

	ClearOptions(document.getElementById(dayName));

	if (textList[textList.selectedIndex].value == "1") {

		for (i=1;i <= 31;i++){

			AddToOptionList(document.getElementById(dayName), i, i);

		}

	}

	if (textList[textList.selectedIndex].value == "2") {

		for (i=1;i <= 29;i++){

			AddToOptionList(document.getElementById(dayName), i, i);

		}

	}

	if (textList[textList.selectedIndex].value == "3") {

		for (i=1;i <= 31;i++){

			AddToOptionList(document.getElementById(dayName), i, i);

		}

	}

	if (textList[textList.selectedIndex].value == "4") {

		for (i=1;i <= 30;i++){

			AddToOptionList(document.getElementById(dayName), i, i);

		}

	}

	if (textList[textList.selectedIndex].value == "5") {

		for (i=1;i <= 31;i++){

			AddToOptionList(document.getElementById(dayName), i, i);

		}

	}

	if (textList[textList.selectedIndex].value == "6") {

		for (i=1;i <= 30;i++){

			AddToOptionList(document.getElementById(dayName), i, i);

		}

	}

	if (textList[textList.selectedIndex].value == "7") {

		for (i=1;i <= 31;i++){

			AddToOptionList(document.getElementById(dayName), i, i);

		}

	}

	if (textList[textList.selectedIndex].value == "8") {

		for (i=1;i <= 31;i++){

			AddToOptionList(document.getElementById(dayName), i, i);

		}

	}

	if (textList[textList.selectedIndex].value == "9") {

		for (i=1;i <= 30;i++){

			AddToOptionList(document.getElementById(dayName), i, i);

		}

	}

	if (textList[textList.selectedIndex].value == "10") {

		for (i=1;i <= 31;i++){

			AddToOptionList(document.getElementById(dayName), i, i);

		}

	}

	if (textList[textList.selectedIndex].value == "11") {

		for (i=1;i <= 30;i++){

			AddToOptionList(document.getElementById(dayName), i, i);

		}

	}

	if (textList[textList.selectedIndex].value == "12") {

		for (i=1;i <= 31;i++){

			AddToOptionList(document.getElementById(dayName), i, i);

		}

	}

	

	if (textList[0].value == "0") {

		document.getElementById(monthName).remove(0);

	}

}



function properCaseConverter(inputName,formatFieldCompletely){

	//set function variables

	if (formatFieldCompletely == 'yes'){

		var fieldValue = document.getElementById(inputName).value.toLowerCase();

	} else {

		var fieldValue = document.getElementById(inputName).value;

	}

	var passed = false;

	var lowerCaseCharacters = "abcdefghijklmnopqrstuvwxyz";

	var upperCaseCharacters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

	

	for (i=0; i < fieldValue.length ; i++){

		//Set instance variables

		var currentCharacter = fieldValue.charAt(i);

		try{var previousCharacter = fieldValue.charAt(i-1);}catch(e){var previousCharacter = "";}

		if (previousCharacter == " " || previousCharacter == ""){

			//fieldValue = fieldValue.toLowerCase();

			for (n=0; n < lowerCaseCharacters.length; n++){

				if (lowerCaseCharacters.charAt(n) == currentCharacter){

					var preValues = fieldValue.substring(0,i);

					var postValues = fieldValue.substring(i+1,fieldValue.length);

					currentCharacter = upperCaseCharacters.charAt(n);

					fieldValue = preValues + currentCharacter + postValues;

				}

			}

			

		}

		

	}

	document.getElementById(inputName).value = fieldValue

	

}



//This function limits a textfield size

function limitTextSize(textFieldName, textFieldLength) {

	if (document.getElementById(textFieldName).value.length > textFieldLength) {document.getElementById(textFieldName).value = document.getElementById(textFieldName).value.substring(0, textFieldLength);} else {}

}



//Due to Retain, this function needs to be present as well

function limitText(textFieldName, textFieldLength) {

	if (textFieldName.value.length >= textFieldLength) {textFieldName.value = textFieldName.value.substring(0, textFieldLength);} else {}

}