function validatecomment(form)
{
	var str = form.comment.value;
	if(trim(str)== "")
	{
		alert("Please enter your comment ");
		form.comment.focus();
		return false;
	}
	else
	{
  	  if(str.length>1000)
	  {
	    alert("Please enter only upto 1000 characters");
	    form.comment.focus();
	    return false;
	  }
	 }   
}

function blogCommentPreview(){
	var NewText 	= document.getElementById("blog_comment_textarea").value;
	splitText 		= NewText.replace(/\n\r?/g, '<br />');
	var DivElement 	= document.getElementById("comment_preview");
		
	if(NewText!=""){
		DivElement.innerHTML = "<p id=\"blog_comment_text\" style=\"color:red;\">Comment Preview</p><div id=\"blog_comment_preview_tbg\"></div><div id=\"blog_comment_preview_bg\">"+splitText+"</div><div id=\"blog_comment_preview_bbg\"></div>";
	}else{
		DivElement.innerHTML = "";
	}
}

function validateblog(form)
{

var str = form.blogcatid.value;
	if(str == "" || str==0)
	{
		alert(" Please select category");
		form.blogcatid.focus();
		return false;
	}
var str = form.title.value;
	if(trim(str)== "")
	{
		alert(" Please enter a title");
		form.title.focus();
		return false;
	}
var str = form.keyword.value;
	if(str == "")
	{
		alert("Please enter keywords seperated by comma");
		form.keyword.focus();
		return false;
	}
	else
	{
	  if(str.length>60)
	  {
	  alert("Number of characters should not exceed 60");
	    form.keyword.focus();
		return false;
	  }
	 }   
	
	
var str = form.blog.value;
	if(str == "")
	{
		alert("Please enter the blog");
		form.blog.focus();
		return false;
	}
	
	
	
	if(form.image.value!="")
	{
		
		var str = form.image.value;
		if(str.lastIndexOf('.')!=-1)
		{
			
			var index = str.lastIndexOf('.');
			str = str.substr(index);
						
			if(!(str.match("jpeg")!=null || str.match("jpg")!=null || str.match("gif")!=null || str.match("png")))
			{
				alert("Please Upload jpeg or gif Format images only");
				form.image.focus();
				return false;
			}
		}
		else
		{			
			alert("Invalid Image Name");
			form.image.focus();
			return false;
		}
	}
	
}	

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

   
   

