function getSideBar(dir){
	//updateContainer('sideBar',dir+'/sidebar.html')
	
	var myurl = (dir+"sidebar.php")
	ajaxUpdate( "sideBar", myurl, {
					params:"" ,
					meth:"post",
					async:true,
					startfunc:"",
					endfunc:"",
					errorfunc:"ajaxError()",
					noauthfunc:"ajaxNoAuth()" }
				);
}
function joinEmail(email,returnURL){
	if (email==undefined) email = ""
	if (returnURL==undefined) returnURL = document.location.href
	document.location.href="/join_email_list.php?email="+email+"&returnURL="+returnURL
	/*
	var myurl = "email="+eml.value
	ajaxUpdate( "emailSignup", "/join_email_list.php", {
					params: myurl ,
					meth:"post",
					async:true,
					startfunc:"document.getElementById(\"emailSignup\").innerHTML=\"LOADING\"",
					endfunc:"",
					errorfunc:"ajaxError()",
					noauthfunc:"ajaxNoAuth()" }
				);
	*/
}
function initializeContainer(ctr,url) {
	alert("initializeContainer("+ctr+","+url+")")
	new Ajax(url, {update:ctr}).request();
}
function ajaxRequest(ctr) {
	$('sideBar').effect('opacity',{duration:1000, fps:50, onComplete:updateContainer('sideBar')}).start(1,0);
};

function updateContainer(ctr,url) {
	status = "updateContainer("+ctr+","+url+")"
	new Ajax(url, {update:'sideBar', onComplete:fadeInContainer}).request();
}

function fadeInContainer(ctr) {
	$('sideBar').effect('opacity',{duration:1000, fps:50}).start(0,1);
}
function doSearch(qry){
	document.location.href='search.php?query='+qry
}

function ajaxNoAuth(){
	alert("AJAX unauthorized URL")
}
function ajaxError(){
	alert("AJAX Error")
}

function ajaxUpdate( elemid, url, options )
{
	var params = options.params || "";
	var meth = options.meth || "post";
	var async = options.async;
	if( async == null )
		async = true;
	var startfunc = options.startfunc || "";
	var endfunc = options.endfunc || "";
	var errorfunc = options.errorfunc || "";
	var noauthfunc = options.noauthfunc || "";
	var req = false;
	if( window.XMLHttpRequest )
		req = new XMLHttpRequest();
	else if( window.ActiveXObject )
		req = new ActiveXObject( "Microsoft.XMLHTTP" );
	else
	{
		alert(  "Your browser cannot perform the requested action. "+
				"Either your security settings are too high or your "+
				"browser is outdated. Try the newest version of "+
				"Internet Explorer or Mozilla Firefox." );
		return false;
	}
	if( startfunc != "" )
		eval( startfunc );
	req.onreadystatechange =
		function()
		{
			if ( req.readyState == 4 ) 
			{
				if ( req.status == 200 )
				{
					if( elemid != '' )
						document.getElementById(elemid).innerHTML = req.responseText;
						//make it a more variable target
						//elemid = req.responseText;
					if( endfunc != "" )
						eval( endfunc );
					return true;
				}
				else
				{
					if( req.status == 403 && noauthfunc != "" )
						eval( noauthfunc );
					else
					{
						if( endfunc != "" )
							eval( endfunc );
						if( errorfunc != "" )
							eval( errorfunc );
					}
					return false;
				}
			}
		};
	if( meth == "get" )
	{
		req.open( meth, url+( params != "" ? "?"+params : "" ), async );
		req.send(null);
	}
	else
	{
		req.open( meth, url, async );
		req.setRequestHeader( "Content-Type", "application/x-www-form-urlencoded" );
		req.send( params );
	}
}