var alert_color = '#FFFF00';
var last_college_id = 0;

$(document).ready(function(){
	
	$('#campus_of_interest').change(function(){
		var schoolID = $(this).val();
		
		if(schoolID != '0'){	
			$.post("/server_calls/colleges/argosy_university/get_programs_by_geo.php",
			{ 
				id: schoolID 
			},
			function(data) {
				$('#program_of_interest').html(data);
				
				$('tr[id^=tr_]').css('display', 'none')
                                                .filter('tr[id=tr_'+schoolID+']')
                                                .removeAttr("style");
				
			});
		}
	});
	
});

function reload(campus, program){
	$('#campus_of_interest').val(campus).change();
        $('#program_of_interest').ajaxStop(function(){
            $(this).val(program);
        })
}

//old functions



// validation
function validate_information()
{

	confirmation_alert = "";
	confirmation_header = "Please correct the following issues:\n";
	focus_field = '';
	

	
	
	if(document.getElementById('program_of_interest').value == '0')
	{
		document.getElementById('program_of_interest').style.backgroundColor = alert_color;
		confirmation_alert += "Please select your program of interest.\n";
		focus_field = (focus_field == '') ? 'program_of_interest' : focus_field;
	}
	else
	{
		document.getElementById('program_of_interest').style.backgroundColor = "#FFFFFF";
	}
	
	if(validate_name(document.getElementById('first_name').value, 0) == false)
	{
		document.getElementById('first_name').style.backgroundColor = alert_color;
		confirmation_alert += "Invalid First Name\n";
		focus_field = (focus_field == '') ? 'first_name' : focus_field;
	}
	else
	{
		document.getElementById('first_name').style.backgroundColor = "#FFFFFF";
	}
	
	if(validate_name(document.getElementById('last_name').value, 0) == false)
	{
		document.getElementById('last_name').style.backgroundColor = alert_color;
		confirmation_alert += "Invalid Last Name\n";
		focus_field = (focus_field == '') ? 'last_name' : focus_field;
	}
	else
	{
		document.getElementById('last_name').style.backgroundColor = "#FFFFFF";
	}
	
	if(validate_address(document.getElementById('address1').value, 0) == false)
	{
		document.getElementById('address1').style.backgroundColor = alert_color;
		confirmation_alert += "Invalid Address\n";
		focus_field = (focus_field == '') ? 'address1' : focus_field;
	}
	else
	{
		document.getElementById('address1').style.backgroundColor = "#FFFFFF";
	}
	
	if(validate_address(document.getElementById('address2').value, 1) == false)
	{
		document.getElementById('address2').style.backgroundColor = alert_color;
		confirmation_alert += "Invalid Address 2\n";
		focus_field = (focus_field == '') ? 'address2' : focus_field;
	}
	else
	{
		document.getElementById('address2').style.backgroundColor = "#FFFFFF";
	}
	
	if(validate_name(document.getElementById('city').value, 0) == false)
	{
		document.getElementById('city').style.backgroundColor = alert_color;
		confirmation_alert += "Invalid City\n";
		focus_field = (focus_field == '') ? 'city' : focus_field;
	}
	else
	{
		document.getElementById('city').style.backgroundColor = "#FFFFFF";
	}
	
	if(validate_name(document.getElementById('state').value, 0) == false)
	{
		document.getElementById('state').style.backgroundColor = alert_color;
		confirmation_alert += "Invalid State\n";
		focus_field = (focus_field == '') ? 'state' : focus_field;
	}
	else
	{
		document.getElementById('state').style.backgroundColor = "#FFFFFF";
	}
	
	if(validate_zip(document.getElementById('postal_code').value, 0) == false)
	{
		document.getElementById('postal_code').style.backgroundColor = alert_color;
		confirmation_alert += "Invalid Zip Code\n";
		focus_field = (focus_field == '') ? 'postal_code' : focus_field;
	}
	else
	{
		document.getElementById('postal_code').style.backgroundColor = "#FFFFFF";
	}
	
	if(validate_phone(document.getElementById('phone').value, 0) == false)
	{
		document.getElementById('phone').style.backgroundColor = alert_color;
		confirmation_alert += "Invalid Daytime Phone\n";
		focus_field = (focus_field == '') ? 'phone' : focus_field;
	}
	else
	{
		document.getElementById('phone').style.backgroundColor = "#FFFFFF";
	}
	
	if(validate_phone(document.getElementById('phone2').value, 1) == false)
	{
		document.getElementById('phone2').style.backgroundColor = alert_color;
		confirmation_alert += "Invalid Evening Phone\n";
		focus_field = (focus_field == '') ? 'phone2' : focus_field;
	}
	else
	{
		document.getElementById('phone2').style.backgroundColor = "#FFFFFF";
	}
	
	if(validate_email(document.getElementById('email').value, 0) == false)
	{
		document.getElementById('email').style.backgroundColor = alert_color;
		confirmation_alert += "Invalid Email\n";
		focus_field = (focus_field == '') ? 'email' : focus_field;
	}
	else
	{
		document.getElementById('email').style.backgroundColor = "#FFFFFF";
	}
	
	if(document.getElementById('LevelOfEducation').value == '0')
	{
		document.getElementById('LevelOfEducation').style.backgroundColor = alert_color;
		confirmation_alert += "Please select your level of education.\n";
		focus_field = (focus_field == '') ? 'LevelOfEducation' : focus_field;
	}
	else
	{
		document.getElementById('LevelOfEducation').style.backgroundColor = "#FFFFFF";
	}
	
	if(document.getElementById('DateOfDegree').value == '0')
	{
		document.getElementById('DateOfDegree').style.backgroundColor = alert_color;
		confirmation_alert += "Please select your graduation year.\n";
		focus_field = (focus_field == '') ? 'DateOfDegree' : focus_field;
	}
	else
	{
		document.getElementById('DateOfDegree').style.backgroundColor = "#FFFFFF";
	}
	
	if(confirmation_alert != '')
	{
		confirmation_alert = confirmation_header + confirmation_alert;
		alert(confirmation_alert);
		if(focus_field != '')
		{
			document.getElementById(focus_field).focus();
		}
		
		return false;
	}
	
	//alert("Done Validatin....");
	//return false;
	
	return true;
}