function changerMois(varMois, varAnnee, lang) {
	var xmlHttp = GetXmlHttpObject( );

	if(xmlHttp == null) {
		window.alert("Votre navigateur ne supporte pas AJAX.");
		return false;
	}

	document.getElementById('calendar').innerHTML = '<div style="padding-top:60px; height:120px; width:100%; text-align:center;"><img src="template/images/calendar/cal_load.gif" /></div>';

	xmlHttp.onreadystatechange = function() {
		if(xmlHttp.readyState == 4)
			document.getElementById('calendar').innerHTML = xmlHttp.responseText;
	}
	
	xmlHttp.open("GET", "template/ajax/calendar.php?m=" + varMois + "&y=" + varAnnee + "&l=" + lang, true);
	xmlHttp.send(null);
}

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) {
			try {
				xmlHttp = new ActiveXObject( "Microsoft.XMLHTTP" );
			}
			catch(e) {}
		}
	}
	return xmlHttp;
}


var on = 0;
var timer = 0;

var ontitle = 0;
var timertitle = 0;

function hideSubCal(id) {
	if (on == 0) {
			var divs = new Array();
			divs = document.getElementById('tblcalendar').getElementsByTagName('div') ;
			for (var i = 0 ; i < divs.length ; ++i) {
					divs[i].style.display = "none";
			}
		clearTimeout(timer);
	} else {
		timer = setTimeout("hideSubCal('"+id+"')", 500);
	}
}

function showSubCal(id) {
	on = 0;
	hideSubCal(id);
	on = 1;
	document.getElementById(id).style.display = "block";
	clearTimeout(timer);
	timer = setTimeout("hideSubCal('"+id+"')", 500);
}

function setOn() {
	on = 1;
}

function setOff() {
	on = 0;
}

function loadCalendar(language) {
	var d = new Date();
	nextAd(language);
	changerMois(d.getMonth()+1, d.getFullYear(), language);
}
