/*************************************************************
* Page: blogs.js v 1.0  
* Description: Validate the Blog application
* 
* Hospitality Recruitment - Online Strategies
* Copyright (C) 2005 Online Strategies, All rights reserved
* Email  info@hospitalityonline.co.uk
* 
*************************************************************/
function validate_create_blog(e){
	// Validate the form
	String.prototype.trim = function()
	{
		return this.replace(/^\s*|\s*$/g, '');
	}
	
	var grp, focus_el = null, msg = '';
	var dateObj = new Date();
	var today = dateObj.getFullYear()+''+format_date((dateObj.getMonth(0)+1))+''+format_date(dateObj.getDate());
	
	// Blog title is empty
	e.blog_title.value = e.blog_title.value.trim();
	if (is_empty(e.blog_title))
	{
		msg += error[346];
		focus_el = focus_el || e.blog_title;
	}
	
	// No Blog category selected
	if (e.blog_category.selectedIndex == 0)
	{
		msg += error[348];
		focus_el = focus_el || e.blog_category;
	}
	if(location.pathname == "/blog_centre/new/")
	{
		if (document.getElementById('pnn').checked)
		{
			var form = document.getElementsByTagName('form')[0];
			var drop_date = form.year.value+""+form.month.value+""+form.day.value
			
			if(!check_date_not_empty(form.day,form.month,form.year))
			{
				msg += error[349];
				focus_el = focus_el || e.day;
			}
			// check that all date fields are filled in
			if(check_date_not_empty(form.day,form.month,form.year))
			{
				// check if the publish date is in the past, issue error
				if(drop_date < today)
				{
					msg += error[350];
					focus_el = focus_el || e.day;
				}
			}
		}
	}
	// If there is an error then send through an alert (var msg) and return false
	if (msg != '')
	{
		var prefix = "The form has been incorrectly completed:\n";
		alert(prefix + msg);
		if (focus_el.focus)
		{
			focus_el.focus();
		}
		return false;
	}
	return true;
}