function randomNumber(number)
{
	return parseInt(number * Math.random()+1);
}
	
function genImage()
{
	var num=5;
	var markup='';
	for(var i=0; i<num; i++)
	{
		img = randomNumber(10)-1;
		markup += '<img id="img'+i+'" src="forms/validation/'+img+'.png" alt="'+img+'" />'
	}
	document.getElementById('numImages').innerHTML=markup;
}

function validate(form) 
{
		
	if (form.requestorname.value == '') // Checks if there is text in the name textbox
	{
		alert('Please enter your name.')
		form.requestorname.focus();
		return false;
	}
	if (form.requestoremail.value == '') // Checks if there is text in the email textbox
	{
		alert('Please enter your e-mail address.  We need it to send you a confirmation.')
		form.requestoremail.focus();
		return false;
	}

	if (form.coursetitle.value == '') // Checks if there is text in the Course title textbox
	{
		alert('Please enter the desired course title.')
		form.coursetitle.focus();
		return false;
	}
	
	if (form.college.value == '') // Checks if a college was chosen
	{
		alert('Please enter the college.')
		form.college.focus();
		return false;
	}
	if (form.coursetype.value == 0) // Checks if a course type was chosen
	{
	   alert('Please specify the course type.')
	   form.coursetype.focus();
	   return false;
	}
		if (form.enrolltype.value == 0) // Checks if an enrollment type was chosen
	{
	   alert('Please specify the enrollment type.')
	   form.enrolltype.focus();
	   return false;
	}
		if (form.enrollees.value == 0) // Checks if an Enrollee type was chosen
	{
	   alert('Please specify the status of enrollees.')
	   form.enrollees.focus();
	   return false;
	}
		if (form.courseactive.value == 0) // Checks if an active length of time was chosen
	{
	   alert('Please specify the length of time for the course to remain active.')
	   form.courseactive.focus();
	   return false;
	}
	    if (form.agreement.checked == 0) // Checks if the Terms and Services checkbox was checked
    {
       alert('You must agree to the Terms and Services.')
       form.agreement.focus();
       return false;
    }
	
	var altStr = (document.getElementById('img0').alt+document.getElementById('img1').alt+document.getElementById('img2').alt+document.getElementById('img3').alt+document.getElementById('img4').alt).toString();
	
	var formText = form.validtext.value;
	

	if (formText != altStr)
	{
		alert('Security digits incorrect.  Please enter the digits shown.') 
		form.validtext.focus();
		return false;
	}
}
