function validateForm()
{
	trimFields();
	if(obj.story_type.value == "")
	{
		alert("Please select a Story Type.");
		obj.story_type.focus();
		return;
	}
	if(obj.story_title.value == "")
	{
		alert("Please enter your Story Title.");
		obj.story_title.focus();
		return;
	}
	if(obj.story_text.value == "")
	{
		alert("Please enter your Story.");
		obj.story_text.focus();
		return;
	}
	if(obj.story_text.value != "" && obj.story_text.value.length >= 1000)
	{
		alert("Your Story Text seems like to long. Please be specific and shorter it.");
		obj.story_text.focus();
		obj.story_text.select();
		return;
	}
	if(obj.keywords.value == "")
	{
		alert("Please enter atleast one keyword for your post.");
		obj.keywords.focus();
		return;
	}
	if(obj.keywords.value != "")
	{
		if(!chkString(obj.keywords.value))
		{
			alert("Invalid keywords!!!.\n Keywords should be contain only a-z [Lowercase] and 0-9.");
			obj.keywords.focus();
			obj.keywords.select();
			return;
		}

		arrTemp = obj.keywords.value.split(',');
		if(arrTemp.length > 5)
		{
			alert("You can write upto 5 keywords only.");
			obj.keywords.focus();
			obj.keywords.select();
			return;
		}
	}
	if(obj.first_name.value == "")
	{
		alert("Please enter your First Name.");
		obj.first_name.focus();
		return;
	}
	if(obj.email.value == "")
	{
		alert("Please enter your Email Address.");
		obj.email.focus();
		return;
	}
	if(!chkEmail(obj.email.value))
	{
		alert("Invalid Email Address.\nPlease check and correct it.")
		obj.email.focus();
		obj.email.select();
		return;
	}
	if(obj.captcha.value == '')
	{
		alert("Please enter the security code shown.");
		obj.captcha.focus();
		return;
	}
	if(obj.chkTAC.checked == false)
	{
		alert("Please read our Terms and Conditions and tick the box.");
		obj.chkTAC.focus();
		return;
	}
	//All Okay??
	obj.action = rewriteBase+"send_us_your_story.php?opt=add";
	obj.submit();
}

function loadCategory(tipType)
{
	var ajax = new AJAX();
	var arrParam = new Array();
	arrParam['type'] = tipType;
	ajax.getRequest(rewriteBase+'category_list.php', arrParam, showResponse);
}
function showResponse(retVal)
{
	while(obj.category.hasChildNodes())
		obj.category.removeChild(obj.category.childNodes[0]);

	if(retVal)
	{
		arrTemp = retVal.split('||');
		for(i=0; i<(arrTemp.length);i++)
		{
			arrTemp1 = arrTemp[i].split("|");
			optionValue = arrTemp1[0];
			optionText = arrTemp1[1];

			var opt = document.createElement("option");
	        obj.category.options.add(opt);
	        opt.text = optionText;
	        opt.value = optionValue;
		}
	}
	else
	{
		var opt = document.createElement("option");
		obj.category.options.add(opt);
		opt.text = "--You must choose a type first--";
		opt.value = 0;
	}
}

//Display BBCode Reference window
function showBBCodeRef()
{
	window.open(rewriteBase+"bbcode_ref.php", "bbcode", "width=465,height=525,toolbar=0,menubar=0,location=0;");
}

