function searchBlog(path, key)
{
	window.location=path+"/index.php?search="+encodeURIComponent(key);
}

function toggleLayer(whichLayer)
{
  var elem, vis;

  if( document.getElementById ) // this is the way the standards work
    
	elem = document.getElementById( whichLayer );
  
  else if( document.all ) // this is the way old msie versions work
     
	 elem = document.all[whichLayer];
  
  else if( document.layers ) // this is the way nn4 works
    
	elem = document.layers[whichLayer];
  
  vis = elem.style;
  // if the style.display value is blank we try to figure it out here
  
  if(vis.display==''&&elem.offsetWidth!=undefined&&elem.offsetHeight!=undefined)
    
	vis.display = (elem.offsetWidth!=0&&elem.offsetHeight!=0)?'block':'none';
    
	vis.display = (vis.display==''||vis.display=='block')?'none':'block';
}

function postComment(blog_id, form, error_div, comment_div, count_div)
	{
		name = form.name.value;
		comment = form.comment.value;
		content_type = form.content_type.value;
		var flag=true;
		var msg="<ul>";
		if(name == null || name == "")
			{
				name = "Anonymous";	
			}
		if(comment == null || comment == "" || comment == " ")
			{
				flag=false;
				msg+="<li><font color=\"red\" ><b>Comment Field Required</b></font></li>";
			}
		else
			{
				flag=true;
			}
		if(flag)
			{
				document.getElementById(error_div).innerHTML="";
				POSTDATA  = "action=postComment";
				var params = Array();
				params[0] = blog_id;
				params[1] = comment_div;
				params[2] = count_div;
				POSTDATA += "&blog_id="+encodeURIComponent(blog_id);
				POSTDATA += "&name="+encodeURIComponent(name);
				POSTDATA += "&comment="+encodeURIComponent(comment);
				POSTDATA += "&content_type="+encodeURIComponent(content_type);
				var URL="server/blog_server.php";
				var myRequest = new ajaxObject(URL, postCommentAction, 0);
				myRequest.update(comment_div, POSTDATA, 'post', null, params);
				form.name.value="";
				form.comment.value="";
				form.content_type.selectedIndex=0;
			}
		else
			{
				msg+="</ul>";
				document.getElementById(error_div).innerHTML=msg;
			}
	}
	
function postCommentAction(responseText, responseStatus, responseXML, divid, funct, params)
	{			
		if(responseStatus == 200)
			{
				if(responseText == 1)
					{
						showComment(params[0], params[1], 0);
						getCommentCount(params[0], params[2]);
					}
				else
					{
						document.getElementById(divid).innerHTML = responseText;
					}
			}
		else
			{
				alert(responseStatus);
			}
	}
function showComment(blog_id, divid, page)
	{
		POSTDATA  = "action=showComment";
		POSTDATA += "&blog_id="+encodeURIComponent(blog_id);
		POSTDATA += "&page="+encodeURIComponent(page);
		POSTDATA += "&divid="+encodeURIComponent(divid);
		var URL="server/blog_server.php";
		var myRequest = new ajaxObject(URL, showCommentAction, 0);
		myRequest.update(divid, POSTDATA, 'post');
	}
	
function showCommentAction(responseText, responseStatus, responseXML, divid)
	{			
		if(responseStatus == 200)
			{
				//alert(divid);
				document.getElementById(divid).innerHTML = responseText;		
			}
		else
			{
						alert(responseStatus);
			}
	}
	
function submitSearchOnEnter(e, value, approot) {
if (!e) var e = window.event;
if (e.keyCode) code = e.keyCode;
else if (e.which) code = e.which;
if (code==13) {
	window.location =approot+"/index.php?search="+value;
}
}

function getCommentCount(blog_id, divid)
	{
		POSTDATA  = "action=getCommentCount";
		POSTDATA += "&blog_id="+encodeURIComponent(blog_id);
		var URL="server/blog_server.php";
		var myRequest = new ajaxObject(URL, getCommentCountAction, 0);
		myRequest.update(divid, POSTDATA, 'post');
	}
	
function getCommentCountAction(responseText, responseStatus, responseXML, divid)
	{			
		if(responseStatus == 200)
			{
						document.getElementById(divid).innerHTML = responseText;
			}
		else
			{
						alert(responseStatus);
			}
	}