// JavaScript Document
function validateNewBlog()
{
		entryTitle=document.frmAddBlogEntry.txtTitle.value;
		entryTitle=RTrim(entryTitle);
		entryTitle=LTrim(entryTitle);		
		
		entryDesc=document.frmAddBlogEntry.txtDesc.value;
		entryDesc=RTrim(entryDesc);
		entryDesc=LTrim(entryDesc);
		
		keywords=document.frmAddBlogEntry.txtKeywords.value;
		keywords=RTrim(keywords);
		keywords=LTrim(keywords);
		
		if(entryTitle=="")
		{
			alert("Invalid title");
			document.frmAddBlogEntry.txtTitle.focus();
			return false;
			
		}
		else if(entryDesc=="")
		{
			alert("Invalid Description");
			return false;
		}
		else if(keywords=="")
		{
			alert("Please enter keywords.");
			document.frmAddBlogEntry.txtKeywords.focus();
			return false;
		}
}

function addCommentCheck()
{
	if(document.frmAddComment.txtSubject.value=="")
	{
		alert("Invalid subject");
		document.frmAddComment.txtSubject.focus();
		return false;
		
	}
	else if(document.frmAddComment.txtMessage.value=="")
	{
		alert("Invalid message");
		document.frmAddComment.txtMessage.focus();
		return false;
	}
}

function checkPref()
{
	preTitle=document.frmRefUpdate.txtTitle.value;
	preTitle=RTrim(preTitle);
	preTitle=LTrim(preTitle);
	
	preDesc=document.frmRefUpdate.txtDesc.value;
	preDesc=RTrim(preDesc);
	preDesc=LTrim(preDesc);	
	
	preKeywords=document.frmRefUpdate.txtKeywords.value;
	preKeywords=RTrim(preKeywords);
	preKeywords=LTrim(preKeywords);	
	
	
		
	if(preTitle=="")
	{
		alert("Invalid title");
		document.frmRefUpdate.txtTitle.focus();
		return false;
		
	}
	else if(preDesc=="")
	{
		alert("Invalid description");
		document.frmRefUpdate.txtDesc.focus();
		return false;
	}
	else if(preKeywords=="")
	{
		alert("Invalid keywords");
		document.frmRefUpdate.txtKeywords.focus();
		return false;
	}
}

function blogSearch()
{
	if(document.frmBlogSearch.txtBlogSearch.value=='')
	{
		alert('Please enter your search criteria');
		document.frmBlogSearch.txtBlogSearch.focus();
		return false;		
	}
}

function blogEntryDel(id)
{
	if(confirm('Are you sure you want to delete this entry?'))
	{
		window.location.href='index.php?task=delBEntry&BlogId='+id;
	}	
}


//trim functions
function RTrim(VALUE){
	var w_space = String.fromCharCode(32);
	var v_length = VALUE.length;
	var strTemp = "";
	if(v_length < 0){
		return"";
	}
	var iTemp = v_length -1;
	while(iTemp > -1){
		if(VALUE.charAt(iTemp) == w_space){
		}
		else{
		strTemp = VALUE.substring(0,iTemp +1);
		break;
		}
		iTemp = iTemp-1;

	} //End While
	return strTemp;
} //End Function

function LTrim(VALUE)
{
	var w_space = String.fromCharCode(32);
	if(v_length < 1){
	return"";
	}
	var v_length = VALUE.length;
	var strTemp = "";
	
	var iTemp = 0;
	
	while(iTemp < v_length){
	if(VALUE.charAt(iTemp) == w_space){
	}
	else{
	strTemp = VALUE.substring(iTemp,v_length);
	break;
	}
	iTemp = iTemp + 1;
	} //End While
	return strTemp;
} //End Function
