		$(document).ready(function(){

			/* menu behaviour */
			$("#mainmenu li").mouseenter(function(event) {
				$("ul:first", this).fadeIn(50);
			});
			$("#mainmenu li").mouseleave(function(event) {
				$("ul:first", this).fadeOut(50);
			});
		});


function showSearch(str)
{
	$.doTimeout( 'typing', 50, function(){
		if (str.length<=1)
		{ 
			//document.getElementById("content_box").innerHTML="";
			//document.getElementById("content_box").style.visibility="hidden";
			$("#content_box").hide(150);
			return;
		}
		else if (!document.getElementById("results"))
		{
			//document.getElementById("content_box").style.visibility="visible";
			document.getElementById("content_box").innerHTML = '<div id="results"></div>';
			$("#content_box").show(150);
			//$("#content_box").height( $("#results").height() + 2 );
		}
		else
		{
			//document.getElementById("content_box").style.visibility="visible";
			//document.getElementById("results").innerHTML += "searching...";
			$("#content_box").show(150);
			//$("#content_box").height( $("#results").height() + 2);
		}

		var http = GetXmlHttpObject();
		var url = "ajax.aspx";
		var params = "search="+str+"&rnd="+Math.random();
		http.open("POST", url, true);

		//Send the proper header information along with the request
		http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		http.setRequestHeader("Content-length", params.length);
		http.setRequestHeader("Connection", "close");

		http.onreadystatechange = function() {//Call a function when the state changes.
			if(http.readyState == 4 && http.status == 200) {
				document.getElementById('results').innerHTML = http.responseText
				$("#content_box").animate( { height: $("#results").height() }, 150, "swing" );
			}
		}
		http.send(params);

	});
} 

function getComment(comment_id, page_id)
{
	http = GetXmlHttpObject();
	var url="ajax.aspx?c=" + comment_id + "&p=" + page_id + "&rnd="+Math.random();
	http.onreadystatechange= function() { 
		if (http.readyState==4)
		{
			document.getElementById('comment_'+comment_id).innerHTML = http.responseText;
		}
		
	}
	http.open("GET",url,true);
	http.send(null);
}

function getAComment(comment_id, r, page_id)
{
	http = GetXmlHttpObject();
	var url="ajax.aspx?c=" + comment_id + "&rmv="+r+"&p=" + page_id + "&rnd="+Math.random();
	http.onreadystatechange= function() { 
		if (http.readyState==4)
		{
			document.getElementById('comment_'+comment_id).innerHTML = http.responseText;
		}
		
	}
	http.open("GET",url,true);
	http.send(null);
}


function postComment(comment_id, page_id)
{
	http = GetXmlHttpObject();
	var url = "ajax.aspx";
	var params = "post_comment=" + comment_id + "&page_id=" + page_id;
	if(document.getElementById('author_'+comment_id))
		params += "&author=" + encodeURIComponent(document.getElementById('author_'+comment_id).value);
	if(document.getElementById('subject_'+comment_id))
		params += "&subject=" + encodeURIComponent(document.getElementById('subject_'+comment_id).value);
	if(document.getElementById('http_'+comment_id))
		params += "&http=" + encodeURIComponent(document.getElementById('http_'+comment_id).value);
	if(document.getElementById('email_'+comment_id))
		params += "&email=" + encodeURIComponent(document.getElementById('email_'+comment_id).value);
	if(document.getElementById('message_'+comment_id))
		params += "&message=" + encodeURIComponent(document.getElementById('message_'+comment_id).value);
		
	params += "&rnd="+Math.random();
	http.open("POST", url, true);

	//Send the proper header information along with the request
	http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	http.setRequestHeader("Content-length", params.length);
	http.setRequestHeader("Connection", "close");

	http.onreadystatechange = function() {//Call a function when the state changes.
		if(http.readyState == 4 && http.status == 200) {
			document.getElementById('comment_'+comment_id).innerHTML = http.responseText
		}
	}
	http.send(params);
}

function GetXmlHttpObject()
{
	var xmlHttp=null;
	try
	{
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{
		// Internet Explorer
		try
		{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return xmlHttp;
}
