var etm_xmlhttp;
var AJAX_callFunction = null;
var AJAX_callParam = null;

function etm_loadXMLDoc(url, myFunc, myParam) {
	if(myFunc != '' && myFunc != undefined && myFunc != null){
		AJAX_callFunction = myFunc;
	}
	if(myParam != '' && myParam != undefined && myParam != null){
		AJAX_callParam = myParam;
	}
	// Native
	if (window.XMLHttpRequest) {
		etm_xmlhttp = new XMLHttpRequest();
		etm_xmlhttp.onreadystatechange = etm_processStateChange;
		etm_xmlhttp.open("GET", url, true);
		etm_xmlhttp.send('');
	// ActiveX
	} else if (window.ActiveXObject) {
		etm_xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		if (etm_xmlhttp) {
			etm_xmlhttp.onreadystatechange = etm_processStateChange;
			etm_xmlhttp.open("GET", url, true);
			etm_xmlhttp.send();
		}
	}
}

function etm_processStateChange() {
	if (etm_xmlhttp.readyState == 4 && etm_xmlhttp.status == 200) {
		result = etm_xmlhttp.responseText;
		if(AJAX_callFunction != null){
			eval(AJAX_callFunction + '(\'' + result + '\', \'' + AJAX_callParam.replace(', ', '\', \'') + '\')');
		}
    }
}

function updateCalendar(MONTH, URL, MAX, MIN, ID){
	if(URL == 'update'){
		document.getElementById(MAX).innerHTML = MONTH;
	}else{

		document.getElementById(ID).style.height = document.getElementById(ID).offsetHeight + 'px';
		document.getElementById(ID).innerHTML = '<img src="/imgs/_lightbox/loading.gif" alt=" " style="margin-top:'+(document.getElementById(ID).offsetHeight/2 - 16)+'px" />';

		etm_loadXMLDoc('http://www.e-timisoara.info/_generate_calendar.php?month='+MONTH+'&url='+URL+'&max='+MAX+'&min='+MIN+'&id='+ID, 'updateCalendar', 'update, '+ID);
	}
}

function js_calendar_evenimente(my_time, URL){
	if(URL == 'update'){
		document.getElementById('div_calendar_evenimente').innerHTML = my_time;
	}else{
		etm_loadXMLDoc('http://www.e-timisoara.info/_calendar_evenimente.php?time='+my_time+'&url='+URL, 'js_calendar_evenimente', 'update');
	}
		
		
}