// Js Document

var resCalendar = function(t) {
    //alert(t.responseText); return;
	if (t.responseText.substr(0, 5) == 'Error') {
		Notify(t.responseText, 99);
	} else {
		newArray = t.responseText.split('-|-');
		$('calendarSpot').innerHTML = newArray[0];
		if (newArray[1] != '') {
			newAr = newArray[1].split('-||-');
			for(var i = 0; i < newAr.length; i++) {
				newA = newAr[i].split('|');
				new Tip('day_'+newA[0], newA[1], {offset: {x:10, y:-30}});
			}
		}
	}
}

function Calendar(month,year) {
	var sendVals = 'month='+escape(month)+'&&year='+escape(year);
	new Ajax.Request('/uploads/components/eventcalendar/calendar.ajax.php', {method:'post', postBody:sendVals, onComplete:resCalendar});
}

function morpher(id,val) {
	if ($('day_'+id).className != 'day active') {
		if (val == 1) {
    		new Effect.Morph('day_'+id, { style: 'background-color: #EFEFEF; color: #333;', duration: 0.1 });
    	} else if (val == 2) {
    		new Effect.Morph('day_'+id, { style: 'background-color: #ffde91; color: #FFF;', duration: 0.1 });
    	}
	}
}

window.onload = function() {
	Calendar();
}