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.name.value == '') // Checks if there is text in the name textbox
	{
		alert('Please enter your name.')
		form.name.focus();
		return false;
	}
	if (form.username.value == '') // Checks if there is text in the username textbox
	{
		alert('Please enter your Blackboard username.')
		form.username.focus();
		return false;
	}

	if (form.email.value == '') // Checks if there is text in the email textbox
	{
		alert('Please enter your email address.  We need it to send you a confirmation.')
		form.email.focus();
		return false;
	}
	if (form.Status.value == '') //Checks if an instructor Status was chosen
	{
		alert('Please enter your instructor status.')
		form.Status.focus();
		return false;
	}
	if (form.coursecode.value == '') // Checks if a Course Code was entered
	{
		alert('Please enter a Course Code. (ex. ART100)')
		form.coursecode.focus();
		return false;
	}
	if (form.coursetitle.value == '') // Checks if a Course Title was entered
	{
		alert('Please enter a Title for your course.')
		form.coursetitle.focus();
		return false;
	}
	if (form.crn.value == '') // Checks if a CRN was entered
	{
		alert('Please enter a CRN for your course.')
		form.crn.focus();
		return false;
	}
	if (form.college.value == 0) // Checks if a college was chsoen
	{
	   alert(' Please specify your college.')
	   form.college.focus();
	   return false;
	}
	if (form.term.value == 0) // Checks if a term was chosen
	{
	   alert(' Please specify the term for this course.')
	   form.term.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;
	}

}
