function form_validation( ){

	var valid = 1;
	var validCode = 0;
	
	$$( '.required' ).each( function( el ) {

		$( el.id ).removeClass( 'field_error' );

		if( el.getProperty( 'alt' ) == 'email' ) {
			
			if( !checkEmail( el ) ){
			
				$( el.id ).addClass( 'field_error' );
				$( el.id ).focus( );
				valid = 0;
								
			};
				
		} else if( el.getProperty( 'alt' ) == 'credit card' ) {
						
			if( !checkCreditCard( el ) ){
			
				$( el.id ).addClass( 'field_error' );
				$( el.id ).focus( );
				valid = 0;
				
			};

		} else if( el.value == '' ){

			$( el.id ).addClass( 'field_error' );
			$( el.id ).focus( );
			valid = 0;
			
		};

	});
	
	$$( '.required_check' ).each( function( el ) {		

		// find the name of this set (not this id)
		var checkGroup = document.getElementsByName( el.get( 'name' ) );
		var checked = 0;
		
		// loop through and make sure at least 1 element in this group was checked
		for( i=0; i<checkGroup.length; i++ ){

			if( checkGroup[ i ].checked ){
				
				checked = 1;
				
			};

		};
		
		if( !checked ){
			
			valid = 0;
			$( 'error_'+ el.get( 'name' ) ).removeClass( 'hide' );
			$( el.id ).focus( );
			
		};
	
	});
	
	/* check promo codes
	if ( $( 'promo_code' ) && $( 'promo_code' ).value != '' && $( 'promo_code' ).value != 'Invalid Promo Code...' ) {
		
		// validate the promo code
		var myRequest = new Request.JSON({
			url: 'ajax.html&ajax=promo_code&code=' + $( 'promo_code' ).value,
			noCache: false,
			onRequest: function(){
			
			},
			onSuccess: function( json ){
			
				setValidCode( json.result );
			
			},
			onFailure: function(){
			
			}
		}).send();

		if ( validCode == 0 ) {
		
			$( 'promo_code' ).value = 'Invalid Promo Code...';
			$( 'promo_code' ).addClass( 'field_error' );
			//return false;
			
		} else {
		
			//return true;
			
		};
		
	} else {
	
		if (!valid) {
		
			return false;
			
		} else {
		
			return true;
			
		};
		
	};
	*/
	
	if (!valid) {
	
		return false;
		
	} else {
	
		return true;
		
	};	

};
