/*
just do something like:
<script language="javascript" src="http://qconline.com/home/js/parse_form_fields.js"></script>
<form name="myform" action="#" method="post" ONSUBMIT="return parse_form_fields('field1,field2,field3,..');">
hint: make sure all required fields have "id='fieldname' for the getelementbyid attribute to work right
hint: a field's 'id' does NOT have to match the field's 'name'
*/
function parse_form_fields(mycheckfields,extra){
	
	//var checkfields=new Array("name","address","phone");
	var checkfields = mycheckfields.split(",");
	var error_message = "";

	for (i=0;i<checkfields.length;i++){
		if(!document.getElementById(checkfields[i]).value){
			error_message = error_message + "\n- " + checkfields[i];
			document.getElementById(checkfields[i]).style.border = '2px solid #9E0B0E';
		}
	}
	if(error_message==""){
                if(extra == 'check_times'){ //validate password and email 
			var startdate=document.thisform.start.value.split("/");
			var stopdate=document.thisform.stop.value.split("/");

			var start = startdate[2] + startdate[0] + startdate[1] + '0000';
			var stop = stopdate[2] + stopdate[0] + stopdate[1] + '2359';

			var reg = /^http\:\/\//;

			if(parseInt(start) > parseInt(stop)){
				alert('Yours End time must be later than your Start time');
				document.getElementById("Start Date").style.border = '2px solid #9E0B0E';
				document.getElementById("End Date").style.border = '2px solid #9E0B0E';
                                return false;
                        }
                        else if(reg.test(document.thisform.target.value) == false) {
	                        alert('the Target must include "http://"');
				document.getElementById("Target").style.border = '2px solid #9E0B0E';
        	                return false;
                        }
                        else{
                                return true;
                        }
                }

		else{
			return true;
		}
	}
	else{
		alert ('Please make sure you filled out the following required fields: ' + error_message);
		return false;
	}
}

