function AddNewBlog(objForm)
{
   if(!IsValidValue(objForm.Blog_BlogTitle.value,"Blog Title")){
		objForm.Blog_BlogTitle.focus()
		return false
	}
	if(!IsValidValue(objForm.Blog_Description.value,"Description")){
	    objForm.Blog_Description.focus()
		return false;
	}
	if(!IsValidValue(objForm.Blog_PostsPerPage.value,"Number of Post")){
	    objForm.Blog_PostsPerPage.focus()
		return false;
	}
	return true;
}
function AddNewPost(objForm,type)
{
	var isSelected = false;
	
   if(!IsValidValue(objForm.PostTitle.value,"Post Title")){
		objForm.PostTitle.focus()
		return false
	}
	
	
	if(!document.NewPost.Category.length)
		{
			if(document.NewPost.Category.checked)
				isSelected = true;
			else
				isSelected = false;
		}
		else
		{
			for(i=0;i<document.NewPost.Category.length;i++)
			{
				if(document.NewPost.Category[i].checked)
				{
					isSelected = true;
					break;
				}
			}
	}
	if(!isSelected)
	{
		alert("Please select the Category");
		return false;
	}
	
	if(!IsValidValue(objForm.PostTags.value,"Tags")){
	    objForm.PostTags.focus()
		return false;
	}
	if(document.getElementById('postIdent').value == '')
		document.getElementById('fAction').value = 'AddPost';
	else
		document.getElementById('fAction').value = 'EditPost';
	//document.NewPost.submit();
}
	
function AddCategory()	{
	if(!IsValidValue(document.getElementById('newcategory').value,"Category")){
		document.getElementById('newcategory').focus()
		return false;
	}
	if(document.getElementById('CategoryIdent'))	{
		if(document.getElementById('CategoryIdent').value != '')
			document.getElementById('fAction').value = 'EditCategory';
		else
			document.getElementById('fAction').value = 'Addcategory';
	}	else
		document.getElementById('fAction').value = 'Addcategory';
		document.NewPost.submit();
	
}	
function gethover(id) {
	var d = document.getElementById(id);
	for (var i = 1; i<=10; i++) {
		if (document.getElementById('socialdropdown'+i)) {document.getElementById('socialdropdown'+i).style.display='none';}
	}
	if (d) {d.style.display='block';}
}

function losthover(id) {
	var d = document.getElementById(id);
	for (var i = 1; i>=10; i++) {
		if (document.getElementById('socialdropdown'+i)) {document.getElementById('socialdropdown'+i).style.display='block';}
	}
	if (d) {d.style.display='none';}
}
function ValidateAddComment(){
	if(document.BlogComment.Comment_Response.value==""){
		alert("Enter the Blog Comments");
		document.BlogComment.Comment_Response.focus();
		return false;
	}
	if(document.BlogComment.Comment_Code.value==""){
		alert("Enter the Verification Code");
		document.BlogComment.Comment_Code.focus();
		return false;
	}
	document.BlogComment.fAction.value="AddComment";
	document.BlogComment.submit();
}

function ShowComments(articleId)	{
	if(document.getElementById('Comments'+articleId).style.display == 'none')
		document.getElementById('Comments'+articleId).style.display	= 'block';
	else
		document.getElementById('Comments'+articleId).style.display	= 'none';
}

function RateBlog()	{
	if(document.getElementById('BlogRate').value == '')	{
		alert('Please select the count you want to rate');
		return false;
	}
	document.getElementById('fAction1').value="RateIt";
	document.RateIt.submit();
}
function AddNewCategory(strNewsCategory,title) {
	if(!IsValidValue(document.getElementById('newcategory').value,"Category")){
		document.getElementById('newcategory').focus()
		return false;
	}

	var success   = function(t){AddNewCategoryComplete(t);}
	var failure   = function(t){LoadFailed(t);}
	var url       = "ajax/blogs.php"; 
	var pars      = 'op=addcategory&newcategory='+strNewsCategory+'&title='+title;
	var myAjax    = new Ajax.Request(url, {method:'post',postBody:pars, onSuccess:success, onFailure:failure});
}
function LoadFailed(t)	{
	alert(t.reponseText);
}	
function AddNewCategoryComplete(t)
{
	var strValue = t.responseText.split("||");
	if(strValue[0] == 1)
	{	
	}
	else {
		$('categoryTpl').innerHTML	= strValue[1];
		$('newcategory').value = '';
	}
}



function ShowLongDescription(id)	{
	if(document.getElementById('LongDescription_'+id).style.display == 'none'){
		document.getElementById('LongDescription_'+id).style.display	= 'block';
		document.getElementById('ReadMore_'+id).style.display	= 'none';
		document.getElementById('HideMore_'+id).style.display	= 'block';
	}else{
		document.getElementById('LongDescription_'+id).style.display	= 'none';
		document.getElementById('ReadMore_'+id).style.display	= 'block';
		document.getElementById('HideMore_'+id).style.display	= 'none';
	}
	
}
