
// ***************************************************
// Plugin CalSite 0.2 - 2007 (c) FredoMkb
// ***************************************************

// Objet XMLHttpRequest
var obj_xhr = null;

// Fonction Ajax pour mise a jour du contenu d'un "div" identifie par "theId"
function getCalsiteAjax(theId, theUrl, theReq)
{
	var theUrlReq = theUrl + theReq;

	if (obj_xhr) 
	{
		obj_xhr.abort();
	}

	if (window.XMLHttpRequest) 
	{
		obj_xhr = new XMLHttpRequest(); 
	}
	else if (window.ActiveXObject)
	{ 
		try 
		{
			obj_xhr = new ActiveXObject("Msxml2.XMLHTTP");
		} 
		catch(e) 
		{
			obj_xhr = new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	else 
	{ 
		document.location.href = theReq;
		return false; 
	} 

	// obj_xhr.status == 200
	obj_xhr.onreadystatechange = function()
	{ 
		if (obj_xhr.readyState == 4 && obj_xhr.responseText)
		{
			var theText = obj_xhr.responseText;
			document.getElementById(theId).innerHTML = theText;
		}
		else if (obj_xhr.readyState >= 4)
		{
			document.location.href = theReq;
			return false; 
		}
	};

	obj_xhr.open("GET", theUrlReq, true); 
	obj_xhr.send(null);
	return false;
}

// Fonction pour recuperer les valeurs choisies dans les poupup-menus du calendrier
function getCalsiteForm(theId, theUrl, theReq) 
{
	// alert(theId + ' - ' + theUrl + theReq);
	var theDay = '01';
	var theMonth = '' + document.getElementById('calsitelistemois').options[calsitelistemois.selectedIndex].value;
	var theYear = '' + document.getElementById('calsitelisteannees').options[calsitelisteannees.selectedIndex].value;
	theReqNew = theReq + theYear + '-' + theMonth + '-' + theDay;
	getCalsiteAjax(theId, theUrl, theReqNew);
}

