//this function includes all necessary js files for the application  
var folder = 'scripts/eliteCalendar/';
function includeScript(file) {  
	var script  = document.createElement('script');
	script.src  = file;
	script.type = 'text/javascript';
	script.defer = true;
	document.getElementsByTagName('head').item(0).appendChild(script);   
}
function includeStyle(file) {  
	var style  = document.createElement('link');
	style.href  = file;
	style.type = 'text/css';
	style.rel = 'stylesheet';
	style.media = 'screen';
	document.getElementsByTagName('head').item(0).appendChild(style);   
}
//includeScript(folder+'protoculous-effects-shrinkvars.js');
//includeStyle(folder+'styles.css');
function loadDDCal(field,a,date) {
	a = $(a).identify();
	var parent = $(a).up().identify();
	if(Object.isElement($(field+'1'))) {
		$(field+'1').update('<div id="calendarLoader"><img src="'+folder+'loader_gray.gif" border="0" /></div>');
	} else {
		$(parent).insert('<div id="'+field+'1" class="calendarContainer"><div id="calendarLoader"><img src="'+folder+'loader_gray.gif" border="0" /></div></div>');
	}
	$(a).onclick = function() { return closeDDCal(field,a); };
	if(!date) {
		var date = $(field).value;
	}
	new Ajax.Updater(field+'1',folder+'ajax_calendar.php?date='+date+'&field='+field+'&a='+a+'&parent='+parent);
	return false;
}
function changeDDCalMonth(id,el,field,a) {
	$(el).hide();
	if(Object.isElement($(id))) {
		$(id).show();
	} else {
		loadDDCal(field,a,id+'-01');
	}
	return false;
}
function selectDay(day,field,a) {
	$(field).value = day;
	closeDDCal(field,a);
	return false;
}
function closeDDCal(id,a) {
	$(id+'1').remove();
	$(a).onclick = function() { return loadDDCal(id,a); };
	return false;
}