/*main site scripts*/

function submitValForm_dyn(formName,subPath,retPath,required) {
/*
Use this function to validate a form and then submit it to a destination

formName string : name of form you are submitting
subPath string : URL to submit form data to (ie: dynFormSub.php)
retPath string : URL to return form response to
required string : comma seperated list of required field names (ie: name,phone,email)
*/
	var data = new Array();
	var required_arr = new Array();
	var myForm;
	var qstring = '';
	var error = 0;
	required_arr = required.split(",");
	switch(formName) {
		case 'dmc_login_form':
			myForm = document.dmc_login_form.elements;
		break;
	}
	for(var i=0; i<myForm.length; i++) {
		data[myForm[i].name] = myForm[i].value;
		qstring += '&'+myForm[i].name+'='+myForm[i].value;
	}
	qstring += '&form_name='+formName;
	qstring += '&rURL='+retPath;
	
	if(required_arr.length > 0) {
		for(i=0;i<required_arr.length;i++) {
			if(data[required_arr[i]] == '') {
				error++;
			}	
		}
		if(error == 0) {
			document.location.href = subPath+'?'+qstring;
		} else {
			alert('Please include all required fields');
		}
	} else {
		document.location.href = subPath+'?'+qstring;
	}
}