var RESET_SUBJECT = null;
var DEFAULT_SUBJECT = true;


$(function() {
	$('#faq-body').focus( function() {
		if( DEFAULT_SUBJECT ) {
			RESET_SUBJECT = $(this).val();
			$(this).val('');
			DEFAULT_SUBJECT = false;
		}
	});
	$('#supportreq').submit( function() {
		return checkForm();
	});	
});


function checkForm() {
	if( $('#faq-name').val() == '' ) {
		alert('Please fill in your name.');
		$('#faq-name').focus();
		return false;
	}
	if( $('#faq-subject').val() == '' ) {
		alert('Subject must not be empty.');
		$('#faq-subject').focus();
		return false;
	}	
	if( $('#faq-body').val() == '' || DEFAULT_SUBJECT) {
		alert('You must Describe your problem.');
		$('#faq-body').focus();
		return false;
	}	
    if( $('#faq-catagory').val() == 0 ) {
		alert('You must select a catagory');
		$('#faq-catagory').focus();
		return false;
	}	
	if( $('#faq-email').val() == '' ) {
		alert('Please fill in your email address.');
		$('#faq-email').focus();
		return false;
	} else {
		if(window.validEmail) {
			if( !validEmail( $('#faq-email').val() ) ) {
				alert('Please provide a valid email address (example: your-name@some-domain.com).');
				$('#faq-email').focus();
				return false;
			}
		}
	}
	return true;
}
