function get_month(dt, type)
{
	if (dt < 0)
		return;
	
	if ($('loading_'+type) != undefined)
		$('loading_'+type).style.display = 'block';
	if ($('link_'+type) != undefined)
		$('link_'+type).style.display = 'none';

	new ajax(url_cal, {postBody:'ajax=1&dt='+dt+'&curr_dt='+curr_dt, onComplete:after_get_month});
}

function after_get_month(request)
{
	if ($('loading_p'))
		$('loading_p').style.display = 'none';
	if ($('loading_n'))
		$('loading_n').style.display = 'none';
	if ($('link_p'))
		$('link_p').style.display = 'block';
	if ($('link_n'))
		$('link_n').style.display = 'block';
	
	$('calendar').innerHTML = request.responseText;
}

function isWhitespace (s)
{
	var i;
	// Search through string's characters one by one
	// until we find a non-whitespace character.
	// When we do, return false; if we don't, return true.

	for (i = 0; i < s.length; i++)
	{
		// Check that current character isnt whitespace.
		var c = s.charAt(i);

		if (c != " ") return false;
	}

	// All characters are whitespace.
	return true;
}

function nullcheck(searchform)
{
	if ((searchform.query.value=="") || isWhitespace(searchform.query.value))
		alert("Please enter a search term ");
	else
		searchform.submit();
}

function q(txt)
{
	document.searchform.xc.value = txt;
	return true;
}
function putq(txt)
{
	document.searchform.query.value = txt;
	return true;
}
function unencode (txt)
{
	txt = unescape(txt);
	txt = txt.replace (/\+/gi, " ");
	return txt;
}

z= "";
function unsub()
{
	a=x.split("\"");
	b = "";
	for(i=0; i<a.length; i++){
		if (i==0 || i==2 || i==4 || i==6 || i==8 || i==10)
		{
			c = a[i].replace("/ /gi", " AND ");
			a[i] = c;
		}
		else
		{
			c = "\"" + a[i] + "\"";
			a[i] = c;
		}
		v = b + a[i];
		b = v;
	}
	z = b.replace (/ and or and /gi, " OR ");
	w = z.replace (/ and and and /gi, " AND ");
	document.searchform.xc.value = w;
	document.searchform.r.value = w;
	document.searchform.submit();
}

function sub()
{
	x = document.searchform.xc.value;
	if (x.indexOf("\"") >= 0)
		{
		unsub();
		}
	else
	{
		y = x.replace (/ /gi, " and ");
		z = y.replace (/ and or and /gi, " or ");
		w = z.replace (/ and and and /gi, " and ");
		document.searchform.xc.value = w;
		document.searchform.r.value = w;
		document.searchform.submit();
	}
}
