function getHTTPObject() {

  	http_request = false;
	if (window.XMLHttpRequest) { // Mozilla, Safari, ...
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) {
			http_request.overrideMimeType('text/xml');
			// See note below about this line
		}
	} else if (window.ActiveXObject) { // IE
		try {
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	}

	return http_request;

}

var http = new Array();


function sendAjax(method, url, async, parameters, callback, handlerId) {

	var parameters = (parameters == undefined) ? null : parameters;
	var async = (async == undefined) ? true : async;
	var callback = (callback == undefined) ? handleAjax : callback;

	myhttp = getHTTPObject();

	myhttp.open(method, url, async);
	myhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	myhttp.onreadystatechange = callback;
	myhttp.send(parameters);

	http[handlerId] = myhttp;

}


function clearHttp(id) {

	http[id] = null;
	/*
	if (http[id] == null) {
		http.splice(id, 1);
	} else {
		return;
	}
	*/
}


function hideElement(id) {

	var theElement = document.getElementById(id);
	theElement.style.display = 'none';

}

function showElement(id) {

	var theElement = document.getElementById(id);
	theElement.style.display = 'block';

}

function toggleDisplay(id) {

	var theElement = document.getElementById(id);

	if (theElement.style.display == 'none') {
		theElement.style.display = 'block';
	} else if (theElement.style.display == 'block') {
		theElement.style.display = 'none';
	}

}

function toggleImage(imageId, image1src, image2src) {

	var theElement = document.getElementById(imageId);

	if (theElement.src.search(image1src) != -1) {
		theElement.src = image2src;
	} else {
		theElement.src = image1src;
	}
}


function eraseDivHtml(id) {
	var theElement = document.getElementById(id);
	theElement.innerHTML = '';
}

function fadeIn(id) {

	var divStyle = document.getElementById(id).style;

	//can only fade it in if its opacity is 0
	if (divStyle.opacity == 0) {
		for (i = 0; i < 101; i++) {
			setTimeout("changeOpac(" + i + ",'" + id + "')", i * 5);
		}
	}
}

function fadeOut(id) {

	var divStyle = document.getElementById(id).style;

	//can only fade it out if its opacity is 1
	if (divStyle.opacity == 1) {
		var timer = 0;
		for (i = 100; i > -1; i--) {
			setTimeout("changeOpac(" + i + ",'" + id + "')", timer * 5);
			timer++;
		}
	}
}



//change the opacity for different browsers
function changeOpac(opacity, id) {
	var object = document.getElementById(id).style;
	object.opacity = (opacity / 100);
	object.MozOpacity = (opacity / 100);
	object.KhtmlOpacity = (opacity / 100);
	object.filter = "alpha(opacity=" + opacity + ")";
}


function prevMonth(){

	var thisMonth = this.getMonth();
	this.setMonth(thisMonth-1);
	if(this.getMonth() != thisMonth-1 && (this.getMonth() != 11 || (thisMonth == 11 && this.getDate() == 1)))
	this.setDate(0);
}
function nextMonth(){
	var thisMonth = this.getMonth();
	this.setMonth(thisMonth+1);
	if(this.getMonth() != thisMonth+1 && this.getMonth() != 0)
	this.setDate(0);
}

Date.prototype.nextMonth = nextMonth;
Date.prototype.prevMonth = prevMonth;

