var polls_ajax_url 		= '/blog/wp-content/plugins/wp-polls/wp-polls.php';
var polls_text_wait 	= 'Your last request is still being processed. Please wait a while ...';
var polls_text_valid 	= 'Please choose a valid poll answer.';
var polls_text_multiple = 'Maximum number of choices allowed:';
var poll_show_loading 	= 1;
var poll_show_fading 	= 1;
		
var blog = {};

/******************************************************************************
 * wire up events
 *****************************************************************************/		
blog.handleCommentFormSubmit = function () {
	try {	
  		 var aMissingFields = new Array();
  		 
  		 if ((this.author.value).trim() == null || (this.author.value).trim() == ""){
  		 	aMissingFields[aMissingFields.length] = msgBlogNameRequired;
  		 }
  		 
  		 if ((this.email.value).trim() == null || (this.email.value).trim() == ""){
  		 	aMissingFields[aMissingFields.length] = msgBlogEmailRequired;
  		 }else if(!isValidEmail(this.email.value.trim())) {
  		 	aMissingFields[aMissingFields.length] = msgBlogEmailInvalid;
  		 }
  		 
  		 if ((this.comment.value).trim() == null || (this.comment.value).trim() == ""){
  		 	aMissingFields[aMissingFields.length] = msgBlogCommentRequired;
  		 }

  		 if ((this.comment.value).trim().length < 10){
  		 	aMissingFields[aMissingFields.length] = msgBlogCommentInvalid;
  		 }
  		 
  		 if (aMissingFields.length > 0) {
			var sMessage = "";
			sMessage = msgBlogFormInvalid+'\n\n';
			
			for (i=0;i<aMissingFields.length;i++) {
				sMessage += '  ' + aMissingFields[i]+ '\n';
			}
	
			alert(sMessage);
			return false;
		} 	
	} catch (e) {
		publishException(e);
	}
}

blog.ready = function () {
	try {
		$('#commentform').submit(blog.handleCommentFormSubmit);
	} catch (e) {
		publishException(e);
	}
}

/******************************************************************************
 * wire up events
 *****************************************************************************/		
$(document).ready(blog.ready);
