/*copies permanent address to mailing address on student application form*/
function fillMailing(f) {
	if(f.copyperm.checked == true) {
	    f.addressMail.value = f.addressPerm.value;
	    f.cityMail.value = f.cityPerm.value;
	    f.stateMail.value = f.statePerm.value;
	    f.zipMail.value = f.zipPerm.value;
    }
}


/*dynamic linked drop down list for location and time selections, first and second choices*/
function setOptions(chosen, linkedbox, linkedboxSelected) {
    var selbox = linkedbox;
    
    selbox.options.length = 0;
	
	switch (chosen) {
	    case "Alpharetta":
            selbox.options[selbox.options.length] = new Option('Select meeting location','0');
            (linkedboxSelected=='Nokia - Wednesday, 5:00-7:00 pm') ? selbox.options[selbox.options.length] = new Option('Nokia - 333 North Pointe Center East, Suite 100, Alpharetta, GA 30222 - Wednesday, 5:00-7:00 pm','Nokia - Wednesday, 5:00-7:00 pm', true) : selbox.options[selbox.options.length] = new Option('Nokia - 333 North Pointe Center East, Suite 100, Alpharetta, GA 30222 - Wednesday, 5:00-7:00 pm','Nokia - Wednesday, 5:00-7:00 pm');
            break;
	    case "Intown Atlanta":
            selbox.options[selbox.options.length] = new Option('Select meeting location','0');            
            /*(linkedboxSelected=='AGL Resources - Wednesday, 5:00-7:00 pm') ? selbox.options[selbox.options.length] = new Option('AGL Resources - 10 Peachtree Place, 8th Floor, Atlanta, GA 30309 - Wednesday, 5:00-7:00 pm','AGL Resources - Wednesday, 5:00-7:00 pm', true) : selbox.options[selbox.options.length] = new Option('AGL Resources - 10 Peachtree Place, 8th Floor, Atlanta, GA 30309 - Wednesday, 5:00-7:00 pm','AGL Resources - Wednesday, 5:00-7:00 pm');*/
            (linkedboxSelected=='Deloitte - Wednesday, 5:00-7:00 pm') ? selbox.options[selbox.options.length] = new Option('Deloitte - 191 Peachtree Street, Atlanta, GA 30303 - Wednesday, 5:00-7:00 pm','Deloitte - Wednesday, 5:00-7:00 pm', true) : selbox.options[selbox.options.length] = new Option('Deloitte - 191 Peachtree Street, Atlanta, GA 30303 - Wednesday, 5:00-7:00 pm','Deloitte - Wednesday, 5:00-7:00 pm');
            /*(linkedboxSelected=='Federal Reserve Bank of Atlanta - Tuesday, 5:00-7:00 pm') ? selbox.options[selbox.options.length] = new Option('Federal Reserve Bank of Atlanta - 1000 Peachtree Street NE, Atlanta,GA 30309 - Tuesday, 5:00-7:00 pm','Federal Reserve Bank of Atlanta - Tuesday, 5:00-7:00 pm', true) : selbox.options[selbox.options.length] = new Option('Federal Reserve Bank of Atlanta - 1000 Peachtree Street NE, Atlanta,GA 30309 - Tuesday, 5:00-7:00 pm','Federal Reserve Bank of Atlanta - Tuesday, 5:00-7:00 pm');*/
            (linkedboxSelected=='Generation Mortgage - Wednesday, 5:00-7:00 pm') ? selbox.options[selbox.options.length] = new Option('Generation Mortgage - 3 Piedmont Cntr., Ste. 300, 3565 Piedmont Rd., Atlanta, GA 30305 - Wednesday, 5:00-7:00 pm','Generation Mortgage - Wednesday, 5:00-7:00 pm', true) : selbox.options[selbox.options.length] = new Option('Generation Mortgage - 3 Piedmont Cntr., Ste. 300, 3565 Piedmont Rd., Atlanta, GA 30305 - Wednesday, 5:00-7:00 pm','Generation Mortgage - Wednesday, 5:00-7:00 pm');
            (linkedboxSelected=='Georgia Power - Thursday, 5:00-7:00 pm') ? selbox.options[selbox.options.length] = new Option('Georgia Power - 241 Ralph McGill Blvd NE, Atlanta, GA 30308 - Thursday, 5:00-7:00 pm','Georgia Power - Thursday, 5:00-7:00 pm', true) : selbox.options[selbox.options.length] = new Option('Georgia Power - 241 Ralph McGill Blvd NE, Atlanta, GA 30308 - Thursday, 5:00-7:00 pm','Georgia Power - Thursday, 5:00-7:00 pm');
            (linkedboxSelected=='Grant Thornton - Wednesday, 5:00-7:00 pm') ? selbox.options[selbox.options.length] = new Option('Grant Thornton - 1100 Peachtree Street, Atlanta, GA 30309-4528 - Wednesday, 5:00-7:00 pm','Grant Thornton - Wednesday, 5:00-7:00 pm', true) : selbox.options[selbox.options.length] = new Option('Grant Thornton - 1100 Peachtree Street, Atlanta, GA 30309-4528 - Wednesday, 5:00-7:00 pm','Grant Thornton - Wednesday, 5:00-7:00 pm');
            /*(linkedboxSelected=='KPMG - Tuesday, 5:00-7:00 pm') ? selbox.options[selbox.options.length] = new Option('KPMG - 303 Peachtree Center Avenue, Atlanta, GA 30303 - Tuesday, 5:00-7:00 pm','KPMG - Tuesday, 5:00-7:00 pm', true) : selbox.options[selbox.options.length] = new Option('KPMG - 303 Peachtree Center Avenue, Atlanta, GA 30303 - Tuesday, 5:00-7:00 pm','KPMG - Tuesday, 5:00-7:00 pm');*/
            (linkedboxSelected=='PricewaterhouseCoopers - Wednesday, 5:00-7:00 pm') ? selbox.options[selbox.options.length] = new Option('PricewaterhouseCoopers - 10 10th Street NW, Atlanta, GA 30309-3851 - Wednesday, 5:00-7:00 pm','PricewaterhouseCoopers - Wednesday, 5:00-7:00 pm', true) : selbox.options[selbox.options.length] = new Option('PricewaterhouseCoopers - 10 10th Street NW, Atlanta, GA 30309-3851 - Wednesday, 5:00-7:00 pm','PricewaterhouseCoopers - Wednesday, 5:00-7:00 pm');
            (linkedboxSelected=='Smith & Howard, PC - Thursday, 5:00-7:00 pm') ? selbox.options[selbox.options.length] = new Option('Smith & Howard, PC - 171 17th Street, NW  Suite 900, Atlanta, GA 30363 - Thursday, 5:00-7:00 pm','Smith & Howard, PC - Thursday, 5:00-7:00 pm', true) : selbox.options[selbox.options.length] = new Option('Smith & Howard, PC - 171 17th Street, NW  Suite 900, Atlanta, GA 30363 - Thursday, 5:00-7:00 pm','Smith & Howard, PC - Thursday, 5:00-7:00 pm');
            (linkedboxSelected=='SunTrust - Tuesday, 5:00-7:00 pm') ? selbox.options[selbox.options.length] = new Option('SunTrust - 303 Peachtree Center Avenue, Atlanta, GA 30303 - Tuesday, 5:00-7:00 pm','SunTrust - Tuesday, 5:00-7:00 pm', true) : selbox.options[selbox.options.length] = new Option('SunTrust - 303 Peachtree Center Avenue, Atlanta, GA 30303 - Tuesday, 5:00-7:00 pm','SunTrust - Tuesday, 5:00-7:00 pm');
            break;
        case "Fayette County":
            selbox.options[selbox.options.length] = new Option('Select meeting location','0');            
            /*selbox.options[selbox.options.length] = new Option('TBD - TBD (Fayetteville, Tyrone, or Peachtree City) - Thursday, 5:00-7:00 pm','TBD - Thursday, 5:00-7:00 pm');*/
            selbox.options[selbox.options.length] = new Option('Delta (Tentative) - Lafeyette Education Center or Sandy Creek High School - Thursday, 5:00 - 7:00 pm','Delta (Tentative) - Thursday, 5:00-7:00 pm');
            break;
        case "Lawrenceville":
            selbox.options[selbox.options.length] = new Option('Select meeting location','0');
            (linkedboxSelected=='Cisco - Wednesday, 5:00-7:00 pm') ? selbox.options[selbox.options.length] = new Option('Cisco - 5030 Sugarloaf Parkway, Lawrenceville, GA 30042 - Wednesday, 5:00-7:00 pm','Cisco - Wednesday, 5:00-7:00 pm', true) : selbox.options[selbox.options.length] = new Option('Cisco - 5030 Sugarloaf Parkway, Lawrenceville, GA 30042 - Wednesday, 5:00-7:00 pm','Cisco - Wednesday, 5:00-7:00 pm');
            break;
        case "Marietta":
            selbox.options[selbox.options.length] = new Option('Select meeting location','0');
            (linkedboxSelected=='GE Energy - Thursday, 5:00-7:00 pm') ? selbox.options[selbox.options.length] = new Option('GE Energy - 4200 Wildwood Pkwy, Atlanta, GA 30339-8402 - Thursday, 5:00-7:00 pm','GE Energy - Thursday, 5:00-7:00 pm', true) : selbox.options[selbox.options.length] = new Option('GE Energy - 4200 Wildwood Pkwy, Atlanta, GA 30339-8402 - Thursday, 5:00-7:00 pm','GE Energy - Thursday, 5:00-7:00 pm');
            (linkedboxSelected=='Marietta High School - Thursday, 5:00-7:00 pm') ? selbox.options[selbox.options.length] = new Option('Marietta High School - 1171 Whitlock Avenue, Marietta, GA 30064-1932 - Thursday, 5:00-7:00 pm','Marietta High School - Thursday, 5:00-7:00 pm', true) : selbox.options[selbox.options.length] = new Option('Marietta High School - 1171 Whitlock Avenue, Marietta, GA 30064-1932 - Thursday, 5:00-7:00 pm','Marietta High School - Thursday, 5:00-7:00 pm');
            break;
        case "Norcross":
            selbox.options[selbox.options.length] = new Option('Select meeting location','0');
            (linkedboxSelected=='Rock-Tenn - Tuesday, 5:00-7:00 pm') ? selbox.options[selbox.options.length] = new Option('Rock-Tenn - 504 Thrasher Street, Norcross, GA 30071 - Tuesday, 5:00-7:00 pm','Rock-Tenn - Tuesday, 5:00-7:00 pm', true) : selbox.options[selbox.options.length] = new Option('Rock-Tenn - 504 Thrasher Street, Norcross, GA 30071 - Tuesday, 5:00-7:00 pm','Rock-Tenn - Tuesday, 5:00-7:00 pm');
            break;
        case "Perimeter":
            selbox.options[selbox.options.length] = new Option('Select meeting location','0');            
            selbox.options[selbox.options.length] = new Option('IHG - Three Ravinia Drive, Suite 100, Atlanta, GA 30346 - Wednesday, 5:00-7:00 pm','IHG - Wednesday, 5:00-7:00 pm');
            break;
        case "Sandy Springs":
            selbox.options[selbox.options.length] = new Option('Select meeting location','0');            
            (linkedboxSelected=='Junior Achievement - Tuesday, 5:00-7:00 pm') ? selbox.options[selbox.options.length] = new Option('Junior Achievement - 460 Abernathy Road, NE, Sandy Springs, GA 30328 - Tuesday, 5:00-7:00 pm','Junior Achievement - Tuesday, 5:00-7:00 pm', true) : selbox.options[selbox.options.length] = new Option('Junior Achievement - 460 Abernathy Road, NE, Sandy Springs, GA 30328 - Tuesday, 5:00-7:00 pm','Junior Achievement - Tuesday, 5:00-7:00 pm');
            /*(linkedboxSelected=='Junior Achievement - Thursday, 5:00-7:00 pm') ? selbox.options[selbox.options.length] = new Option('Junior Achievement - 460 Abernathy Road, NE, Sandy Springs, GA 30328 - Thursday, 5:00-7:00 pm','Junior Achievement - Thursday, 5:00-7:00 pm', true) : selbox.options[selbox.options.length] = new Option('Junior Achievement - 460 Abernathy Road, NE, Sandy Springs, GA 30328 - Thursday, 5:00-7:00 pm','Junior Achievement - Thursday, 5:00-7:00 pm');*/
            (linkedboxSelected=='UPS - Thursday, 5:00-7:00 pm') ? selbox.options[selbox.options.length] = new Option('UPS - 55 Glenlake Parkway, Atlanta, GA 30328 - Thursday, 5:00-7:00 pm','UPS - Thursday, 5:00-7:00 pm', true) : selbox.options[selbox.options.length] = new Option('UPS - 55 Glenlake Parkway, Atlanta, GA 30328 - Thursday, 5:00-7:00 pm','UPS - Thursday, 5:00-7:00 pm');
            /*(linkedboxSelected=='TBD - Thursday, 5:00-7:00 pm') ? selbox.options[selbox.options.length] = new Option('TBD - Thursday, 5:00-7:00 pm','TBD - Thursday, 5:00-7:00 pm', true) : selbox.options[selbox.options.length] = new Option('TBD - Thursday, 5:00-7:00 pm','TBD - Thursday, 5:00-7:00 pm');*/
            break;
        case "South Atlanta":
            selbox.options[selbox.options.length] = new Option('Select meeting location','0');
            (linkedboxSelected=='Chick-fil-A - Tuesday, 5:00-7:00 pm') ? selbox.options[selbox.options.length] = new Option('Chick-fil-A - 3455 B Naturally Fresh Blvd, Atlanta, GA 30349 - Tuesday, 5:00-7:00 pm','Chick-fil-A - Tuesday, 5:00-7:00 pm', true) : selbox.options[selbox.options.length] = new Option('Chick-fil-A - 3455 B Naturally Fresh Blvd, Atlanta, GA 30349 - Tuesday, 5:00-7:00 pm','Chick-fil-A - Tuesday, 5:00-7:00 pm');
            /*(linkedboxSelected=='FedEx(Tentative) - Tuesday, 5:00-7:00 pm') ? selbox.options[selbox.options.length] = new Option('FedEx(Tentative) - 4400 International Parkway, Atlanta, GA 30354 - Tuesday, 5:00-7:00 pm','FedEx(Tentative) - Tuesday, 5:00-7:00 pm', true) : selbox.options[selbox.options.length] = new Option('FedEx(Tentative) - 4400 International Parkway, Atlanta, GA 30354 - Tuesday, 5:00-7:00 pm','FedEx(Tentative) - Tuesday, 5:00-7:00 pm');*/
            break;
        default:
            selbox.options[selbox.options.length] = new Option('Please choose a location first','0');
            break;
	}
}

/* for commit */
/*dynamic linked drop down list for location and time selections, first and second choices*/
function setVolunteerOptions(chosen, linkedbox) {
    var selbox = linkedbox;
    
    selbox.options.length = 0;
    
    switch (chosen) {
        case "Downtown Atlanta":
            selbox.options[selbox.options.length] = new Option('Tuesdays, 5:00-7:00 pm','Tuesdays, 5:00-7:00 pm');
            selbox.options[selbox.options.length] = new Option('Wednesdays, 5:00-7:00 pm','Wednesdays, 5:00-7:00 pm');
            selbox.options[selbox.options.length] = new Option('Thursdays, 5:00-7:00 pm','Thursdays, 5:00-7:00 pm');
            break;
        case "Sandy Springs":
            selbox.options[selbox.options.length] = new Option('Wednesdays, 5:00-7:00 pm','Wednesdays, 5:00-7:00 pm');
            selbox.options[selbox.options.length] = new Option('Thursdays, 5:00-7:00 pm','Thursdays, 5:00-7:00 pm');
            break;
        case "Marietta":
            selbox.options[selbox.options.length] = new Option('Thursdays, 5:00-7:00 pm','Thursdays, 5:00-7:00 pm');
            break;
        case "Alpharetta":
            selbox.options[selbox.options.length] = new Option('Wednesdays, 5:00-7:00 pm','Wednesdays, 5:00-7:00 pm');
            break;
        case "Norcross":
            selbox.options[selbox.options.length] = new Option('Tuesdays, 5:00-7:00 pm','Tuesdays, 5:00-7:00 pm');
            break;
        default:
            selbox.options[selbox.options.length] = new Option('Please choose a location first','0');
            break;
    }
}


//this function toggles the show or hide for parent/guardian other
function toggleParentOther() {
	var otherCheck = document.getElementById('parentRelationship').value;
	if((otherCheck == "Other")||(otherCheck == "Guardian")) {
		document.getElementById("parentOtherContainer").style.display = '';
	} else {
		document.getElementById("parentOtherContainer").style.display = 'none';
	}
}


//this function toggles the show or hide for volunteering with a team
function toggleTeamMembers() {
	var teamCheck = document.getElementById('teamCheck');
	if(teamCheck.checked) {
		document.getElementById("teamrow").style.display = '';
	} else {
		document.getElementById("teamrow").style.display = 'none';
	}
}

//this function toggles the show or hide for the previously volunteered radio button
function toggleVolPrev() {
	var volCheck = document.getElementById('jaVolPrev');
	if(volCheck.checked) {
		document.getElementById("beforerow").style.display = 'none';
	} else {
		document.getElementById("beforerow").style.display = '';
	}
}

//this function toggles the show or hide for recommender recPrevRecOther
function toggleRecPrevRecYes() {
	document.getElementById("recPrevRecOtherContainer").style.display = '';
}

function toggleRecPrevRecNo() {
	document.getElementById("recPrevRecOtherContainer").style.display = 'none';
}

//this function toggles the show or hide for recommender relationship other in recommendation form
function toggleRecRelationOther() {
	var otherCheck = document.getElementById('studentRecRelation').value;
	if(otherCheck == "Other") {
		document.getElementById("studentRecRelationOtherContainer").style.display = '';
	} else {
		document.getElementById("studentRecRelationOtherContainer").style.display = 'none';
	}
}

/*counts the number of words the applicant enters for their essay*/
function wordCount(valfield, infofield) {
	var fullStr = valfield.value + " ";
	var initial_whitespace_rExp = /^[^A-Za-z0-9]+/gi;
	var left_trimmedStr = fullStr.replace(initial_whitespace_rExp, "");
	var non_alphanumerics_rExp = rExp = /[^A-Za-z0-9]+/gi;
	var cleanedStr = left_trimmedStr.replace(non_alphanumerics_rExp, " ");
	var splitString = cleanedStr.split(" ");
	var word_count = splitString.length -1;
	
	var r = 0;
	for (z=0; z<splitString.length; z++) {
		if (splitString[z].length >= 1) {
			r++;
		}
	}
	infofield.value=r;
}


function dayfill(monthid, dayid, yearid)
{
    var month = document.getElementById(monthid).value;
    var day = document.getElementById(dayid).value;
    var year = document.getElementById(yearid).value;
    if (month == 2) {
        if(year%4 == 0) {
            var days = 29;
        } else {
            var days = 28;
        }
    } else if (month == 4 || month == 6 || month == 9 || month == 11) {
        var days = 30;
    } else {
        var days = 31;
    }
    
    document.getElementById(dayid).options.length=1;
    
    if(day > days) {
        day = days;
    }
    
    var i=1;
    for (i=1;i<=days;i++) {
        if(i == day) {
            document.getElementById(dayid).options[i-1] = new Option(i,i, true, true);							
        } else {
            document.getElementById(dayid).options[i-1] = new Option(i,i);							
        }
    }
}
