
function Calendar(){

	
	this.init = function(calendarId){
		this.calID = calendarId;
	}
	
	this.getID = function(){
		return this.calID;
	}
	
	this.getCalendar = function(url, year, month, day, id){
		
		 var url = url + 'xml.php?get=calendar&year=' + year + '&month=' + month + '&day=' + day + '&id=' + id;
	//	 try {
			 
			 document.getElementById(this.calID).innerHTML = PageClass.loadingHTML;
			this.req = null;
			 if (window.XMLHttpRequest) {
			     this.req = new XMLHttpRequest();
			 } else if (window.ActiveXObject) {
			     this.req = new ActiveXObject("Microsoft.XMLHTTP");
			 }

		     //this.req.onreadystatechange = function(){ alert() };

		     this.req.open("GET", url, false);
		     this.req.send(null);

			if (this.req.status == 200) {
				document.getElementById(this.calID).innerHTML = this.req.responseText;
			}

	
	/*	 } catch(e) {
		     var msg = (typeof e == "string") ? e : ((e.message) ? e.message : "Unknown Error");
		     alert("Klaida. Negalima užkrauti duomenų iš serverio.\n");
		     return;
		 }
	*/	
		
	}
	
	
	this.processReqChange = aaa;
	
	/*this.processReqChange = function () {

		result = "";
		for (var i in this) {
        	result += this[i] + "\n";
    	}

		try {
		
			if (this.req.readyState == 4) {
				if (this.req.status == 200) {
					document.getElementById(this.calID).innerHTML = this.req.responseText;
				}
			} else {
	//			alert(this.calID);
	//			document.getElementById(this.calID).innerHTML = '';
				alert("There was a problem retrieving the XML data:\n" + this.req.statusText);
			}
			
		} catch (e){
			
			alert(e.message);
			
		}
		
	}*/


};

function aaa(){

		result = "";
		for (var i in this) {
        	result += this[i] + "\n";
    	}

		try {
		
			if (this.req.readyState == 4) {
				if (this.req.status == 200) {
					document.getElementById(this.calID).innerHTML = this.req.responseText;
				}
			} else {
	//			alert(this.calID);
	//			document.getElementById(this.calID).innerHTML = '';
				alert("There was a problem retrieving the XML data:\n" + this.req.statusText);
			}
			
		} catch (e){
			
			alert(e.message);
			
		}

}

	procesFunc = function () {

		result = "";
		for (var i in this) {
        	result += this[i] + "\n";
    	}

		try {
		
			if (req.readyState == 4) {
				alert(req.status);
				if (req.status == 200) {
					alert(req.status)
					//document.getElementById(this.calID).innerHTML = this.req.responseText;
				}
			} else {
	//			alert(this.calID);
	//			document.getElementById(this.calID).innerHTML = '';
				alert("There was a problem retrieving the XML data:\n" + this.req.statusText);
			}
			
		} catch (e){
			
			alert(e.message);
			
		}
		
	}


