function fAddListItem(strDate) {
	var dl=document.testForm.dateList;
	dl.options[dl.options.length]=new Option(strDate,strDate);
}
function fRemoveListItem(strDate) {
	var dl=document.testForm.dateList;
	for (var i=0;i<dl.options.length;i++)
		if (strDate==dl.options[i].value) break;
	dl.options[i]=null;
}
// The above 2 functions are called from within the plugins1.js when adding dates into the selected ranges. We use them to add dates explicitly to the <select> list.
// These 2 have to be defined in the same page with the <select> tag, otherwise a bug of IE5.0 will prevent the list from getting new options. IE5.5+ doesn't have this bug.
// param strDate has a format of yyyy/mm/dd, you may modify this format in function fDateString in the plugins1.js

function submitByDates(fm) {	// construct the selected dates in the hidden form field allSelected
	fm.allSelected.value="";
	for (var i=0; i<fm.dateList.length; i++) {
		if (i>0) fm.allSelected.value+=",";
		fm.allSelected.value+=fm.dateList.options[i].value;
	}
	// fm.action="ByDate.php";
	alert(fm.allSelected.value); // in your app you should call fm.submit() instead so that the allSelected.value can be submitted.
}

function submitByRanges(fm) {	// construct the selected date ranges in the hidden form field allSelected
	fm.allSelected.value="";
	for (var i=0; i<gfFlat._pds.length; i++) {
		var d0=new Date(gfFlat._pds[i][0]);
		var d1=new Date(gfFlat._pds[i][1]);
		//fm.allSelected.value+="["+d0.getUTCFullYear()+"/"+(d0.getUTCMonth()+1)+"/"+d0.getUTCDate()
			//+","
			//+d1.getUTCFullYear()+"/"+(d1.getUTCMonth()+1)+"/"+d1.getUTCDate()+"]";
	}
	// fm.action="ByRange.php";
	//alert(fm.allSelected.value); // in your app you should call fm.submit() instead so that the allSelected.value can be submitted.
	document.forms[5].elements[0].value = d0.getUTCFullYear()+"-"+(d0.getUTCMonth()+1)+"-"+d0.getUTCDate();
	document.forms[5].elements[1].value = d1.getUTCFullYear()+"-"+(d1.getUTCMonth()+1)+"-"+d1.getUTCDate();
	document.forms[5].elements[3].checked = true;
}

function fInitAgenda() {
	// the following presets the date range selected, check the fOnload() in plugins1.js
	/*
	with (gfFlat) {
		fAddRange(gToday[0],gToday[1],5,false);
		fAddRange(gToday[0],gToday[1],10,true);
		fAddRange(gToday[0],gToday[1],15,false);
		fAddRange(gToday[0],gToday[1],16,false);
		if (gRange.length>0) fRepaint();
	}
	*/
}

function editBooking(dateFrom, dateTo, clientID, confirmed){
	
	//alert(dateFrom+'-'+dateTo+'-'+clientID+'-'+confirmed);
	document.forms[5].elements[0].value = dateFrom;
	document.forms[5].elements[1].value = dateTo;
	document.forms[5].elements[2].value = clientID;
	if(confirmed!=0){
		document.forms[5].elements[4].checked = true;
	}else{
		document.forms[5].elements[5].checked = true;
	}
}
