function mh_setCookie(name, value, expires, path, domain, secure)
{ 
	var curCookie = name + "=" + escape(value) + ((expires) ? "; expires=" + expires.toGMTString() : "") + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + ((secure) ? "; secure" : "");
 	document.cookie = curCookie; 
}

function mh_testCookies()
{
	var useSecure = false;
	/*if (window.location.protocol.indexOf('https:')==0)
	{
		useSecure = true;
	}*/

	var exp = new Date(); 
	exp.setTime(exp.getTime() + 1800000); 
	// first write a test cookie 
	mh_setCookie("cookies", "cookies", exp, false, false, useSecure); 
	var result=document.cookie.indexOf('cookies');
	
	// Delete the test cookie 
 	exp = new Date();
 	exp.setTime(exp.getTime() - 1800000);
 	mh_setCookie("cookies", "cookies", exp, false, false, useSecure);
	
	if ( result != -1)
	{ 
  		return true;
 	} 
 	else
 	{ 
		return false;
	} 
}

function mh_getXMLHttpRequest()
{
	var xmlHttp;
	try
	{
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{
		// Internet Explorer
		try
		{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			try
			{
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e)
			{
				alert("Your browser does not support AJAX!");
				return false;
			}
		}
	}
	return xmlHttp;
}

function mh_modifyElementWithResults( qurl, el, type /*'GET' or 'POST'*/, data /* array for POST */ )
{
	if ( (type != "GET") && (type != "POST") )
	{
		return false;
	}
	
	var xmlHttpl = mh_getXMLHttpRequest();
	
	xmlHttpl.onreadystatechange=function()
	{
		if(xmlHttpl.readyState==4)
		{
			// Get the data from the server's response
			var myP = document.getElementById(el);
			myP.innerHTML=xmlHttpl.responseText;
		}
	}
	
	xmlHttpl.open(type,qurl,true);
	xmlHttpl.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	if ( type == "POST" )
	{
		var i;
		var fq = '';
		
		for ( i = 0 ; i < data.length ; i+=2 )
		{
			if ( fq.length > 0 )
			{
				fq = fq+"&";
			}
			fq = fq+data[i]+"="+data[i+1];
		}
		
		xmlHttpl.send(fq);
	}
	else
	{
		xmlHttpl.send(null);
	}
}