// JavaScript conf_paper_submission.js

function checkPaperSubmission( formObj )
{
	// check required fields
	var fields_to_check = new Array( 'titleofpaper | Title of Paper | INPUT', 'author | Author(s) | INPUT', 'author_org | Institution / Organisation of Author(s) | INPUT', 'pres_title | Presenter\'s Title | INPUT', 'pres_fname | Presenter\'s First Name | INPUT', 'pres_sname | Presenter\'s Surname | INPUT', 'pres_addr | Presenter\'s Address | INPUT', 'town | Town / City | INPUT', 'state | State | SELECT', 'postcode | Postcode | INPUT', 'country | Country | SELECT', 'occupation | Occupation | INPUT', 'organisation | Institution / Organisation | INPUT', 'phone | Phone | INPUT', 'email1 | E-mail | INPUT', 'email2 | Confirm Email | INPUT' );
	var warning_msg = "";
	for ( i=0; i < fields_to_check.length; i++ )
	{
		var field_var = fields_to_check[i].split( " | " );
		if ( field_var[2].indexOf("INPUT") == 0 )
		{
			if ( eval( 'formObj.' +field_var[0]+ '.value.length' ) == 0 )
			{ warning_msg += "\n - " + field_var[1]; }
		}
		else if ( field_var[2].indexOf("SELECT") == 0 )
		{
			if ( eval( 'formObj.' +field_var[0]+ '.selectedIndex' ) == 0 )
			{ warning_msg += "\n - " + field_var[1]; }
		}
		else if ( field_var[2].indexOf("RADIO") == 0 )
		{
			var checked_counter = 0;
			for ( r=0; r < eval( 'formObj.' +field_var[0]+ '.length' ); r++ )
			{
				if ( eval( 'formObj.' +field_val[r]+ '.checked' ) == true )
				{ checked_counter++; }
			}
			if ( checked_counter > 0 )
			{ warning_msg += "\n - " + field_var[1]; }
		}
	}
	if ( warning_msg.length > 1 )
	{
		alert( "You have not completed the following required fields:\n" +warning_msg+ "\n\nPlease make sure that all the required fields have\nbeen correctly filled before proceeding to the next\npage, thank you." );
		return false;
	}
	// email checker
	if ( formObj.email1.value.indexOf(formObj.email2.value) == -1 )
	{
		alert( "The email address does not match the supplied\nconfirmation email address. Please make sure\nthe same valid email address is entered in\nboth fields, thank you." );
		return false;
	}
	var reEmail = /^[a-zA-Z0-9\-_]+\.*[a-zA-Z0-9_\.\-]*\@[a-zA-Z0-9_\-]+\.[a-zA-Z0-9_\.\-]+[a-zA-Z0-9_]+$/
	if ( !reEmail.test( formObj.email1.value ) )
	{
		alert( "The nominated e-mail address is invalid.\n\nIt is important to enter a valid e-mail\naddress in order for us to contact you\nwhen needs arise. Thank you for your\ncoorpoation." );
		return false;
	}
	// check uploads
	var uploading_files = 0;
	if ( formObj.fullref.value.length > 0 )
	{ uploading_files++; }
	if ( formObj.fullnoref.value.length > 0 )
	{ uploading_files++; }
	if ( formObj.inprog.value.length > 0 )
	{ uploading_files++; }
	if ( formObj.revised.value.length > 0 )
	{ uploading_files++; }
	if ( uploading_files > 1 )
	{
		alert( "You may upload only one file at a time." );
		return false;
	}
	else if ( uploading_files == 0 )
	{
		alert( "You must upload one file." );
		return false;
	}
	// All OK
	// formObj.Submit.disabled = true;
}