//	ajax
//	update calendar availability

var update_url	=	'./update_cal.ajax.php';	//	path to ajax file
var image_dir	=	"./images/";				//	path to calendar images
var cal_off		=	"cal_off_";					//	start of cal number file name (off/available)
var cal_on		=	"cal_on_";					//	start of cal number file name (om/booked)
var cal_file_type=	".png";						//	file type extension
var	image_loading=	"<img src='./images/icon_loading.gif' border='0' width='16' height='16'/>";

var state_elm	=new Object();
var elm_num		=	new Object();
function ajax_mod_state(id_item,the_date,the_num){	
	//	 start class
	ajax 		=	new sack();
	
	//	 define image span to update
	state_elm=document.getElementById("state_"+the_date);
	// set state loading while ajax is executed
	state_elm.innerHTML = image_loading;
	
	//	define number for grahic to show (needed in completion function)
	elm_num	=	the_num;
	
	//	 call ajax file to update state
	var the_url=update_url+"?id_item="+id_item+"&the_date="+the_date;
	//alert(the_url);
	
	ajax.requestFile = the_url;
	ajax.onCompletion =reset_state;
	ajax.runAJAX();
	
}
function reset_state(){
	//alert(ajax.response);
	if (ajax.response=="on")	state_elm.innerHTML = "<img src='./images/cal_on_"+elm_num+".png' width='20px' height='20px' border='0'/>";
	else if (ajax.response=="off")	state_elm.innerHTML = "<img src='./images/cal_off_"+elm_num+".png' width='20px' height='20px' border='0'/>";
	else	alert(ajax.response);
}
