function formCheck(formName, formAction){
	ValidOk = true;
	var count = 0;
	
	while(count < formName.elements.length){
		var fieldType = formName.elements[count].type;
		var theFieldName = formName.elements[count].name;
		var fieldName = formName.elements[formName.elements[count].name];
	
		switch(fieldType){
			case 'text':
	    		if(theFieldName == "name"){
					strCheck(fieldName,1,'your full name');
				}else if(theFieldName == 'email'){
					emailCheck(fieldName, 'your valid email address');
				}else if(theFieldName == 'senderName'){
					strCheck(fieldName,1,'your full name');
				}else if(theFieldName == 'senderEmail'){
					emailCheck(fieldName, 'your valid email address');
				}else if(theFieldName == 'recipientName'){
					strCheck(fieldName,1,'your friends name');
				}else if(theFieldName == 'recipientEmail'){
					emailCheck(fieldName, 'your friends valid email address');		
				}
			break;
 	  
			case 'select-one':
				if(theFieldName == "storeState"){
					selectCheck(fieldName,'the restaurant\'s state');
				}else if(theFieldName == "recipient"){
					selectCheck(fieldName,'the department.');
				}  
			break;
	  
			case 'textarea':
				if(theFieldName == 'comment'){
					strCheck(fieldName,1,'your comment');
				}
			break;
	  
			case 'password':
	    		if(theFieldName == 'adminPassword'){
					strCheck(fieldName,4,'valid password');
				}
			break;
	  	  
			case 'radio':
				if(theFieldName == 'gender'){
					genderCheck(fieldName);
				}else if(theFieldName == 'prize'){
					prizeCheck(fieldName);
				}
			break;

			case 'checkbox':
				if(theFieldName == 'parentAgree'){
					parentCheck(formName,fieldName);
				}else if(theFieldName == 'disclaimer'){
					discCheck(fieldName);
				}
			break;

		}
		if(ValidOk == false){
	  		break;
		}
		count++;
	}
	
	if (ValidOk == true){
		if(formAction != "" && formAction != null){
			formName.action = formAction;
		}
		formName.submit();
	}
}

// clear search box
function clearSearchbox(search) {
if (search.value=='Enter Email') {
    search.value='';
    }
    else if (search.value=='') {
        search.value='Enter Email';
        }
}


