function validate_form( )
{
	var validate = true;
	var message = 'Following Error has to be fixed.\n';
	var errorNum = 0;

	// loops through every input element with rel="text".
	// remove rel="text" if you want to leave blank.
	$( '[rel="text"]' ).each( function( index )
	{
		if( trim( this.value ).length == 0 )
		{
			message += this.name + ' is blank!\n';
			validate = false;
			errorNum++;
		}
	});
	
	// loops through every input element with rel="email".
	// remove rel="email" if you want to leave blank or not in email form.
	$( '[rel="email"]' ).each( function( index )
	{
		if( trim( this.value ).length == 0 )
		{
			message += this.name + ' is blank!\n';
			validate = false;
			errorNum++;
		}
	
		else if( !checkForEmail( trim( this.value ) ) )
		{
			message += this.name + ' is not in correct email format!\n';
			validate = false;
			errorNum++;
		}
	});
	
	
	$( '[rel="dropdown"]' ).each( function( index )
	{
		if( this.selectedIndex == 0 )
		{
			message += 'Must select a country!\n';
			validate = false;
			errorNum++;
		}
	});

	if( errorNum > 0 ){ alert( message ); }
	
	return validate;
} // end validate_form.

function checkForEmail(email)
{var re=/^([0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*@(([0-9a-zA-Z])+([-\w]*[0-9a-zA-Z])*\.)+[a-zA-Z]{2,9})$/i;var success=true;if(!email.match(re)){success=false;}
return success;}

function trim(stringToTrim)
{return stringToTrim.replace(/^\s+|\s+$/g,"");}