" + (daysDone==1 ? "" : " ") + dspMonth + (daysDone>3 ? " " + dspYear : "" ) + "" + (daysDone==dspHorizontalDays ? "" : "" + (daysDone==dspHorizontalDays-1 ? "" : " ") + formatDate(thisDate, "MMM").substr(0,3) + (daysDone<=3 ? " "+formatDate(thisDate, "yyyy") : "") + "
" )
}
function writeDays(initial) { // initial is true first time called
var thisDate = new Date(dspStartDate.getTime());
var daysDone = 0;
if (initial) SET_DHTML(); // initialise drag and drop library
do {
daysDone += 1;
var dateFormatted = formatDate(thisDate, "yyyyMMdd");
var divID = "days" + daysDone;
var oDiv = document.getElementById(divID);
oDiv.innerHTML = formatDate(thisDate, "d");
if (initial) {
ADD_DHTML(divID+HORIZONTAL); // add to Drag 'n drop library.
dd.elements[divID].setPickFunc(bookDate)
}
dd.elements[divID].dateFormatted = dateFormatted;
dd.elements[divID].endPoint = false;
thisDate.setDate(thisDate.getDate()+1)
} while (daysDone=datesBooked[0] && thisDate<=datesBooked[1] ) )
daysDone += 1;
var dateFormatted = formatDate(thisDate, "yyyyMMdd");
var dayName = formatDate(thisDate, "E");
var WE = (dayName=="Sat" || dayName=="Fri");
var oDiv = document.getElementById("room."+room+"."+daysDone);
if(oDiv){
oDiv.dateFormatted = dateFormatted; // record for later use as lookup
oDiv.roomID = room;
var status = bookings[room][dateFormatted][0];
if(status !=null) status = status.replace('S','');
switch (status) {
case "C":
var color= ( WE ? colorConfirmedWE : colorConfirmed);
break
case "T":
color=( WE ? colorTentativeWE : colorTentative);
break
case "A":
color=( WE ? colorAvailableWE : colorAvailable);
break
case "U":
color = ( WE ? colorUnAvailableWE : colorUnAvailable);
break
}
if(status==null) color = "#000000";
if(status!="A" && roomBooked && dateBooked) {
thisClash = true;
bookingClashes += room + ": " + formatDate(thisDate, "d MMM yyyy") + "\n";
} else {
thisClash = false;
}
if(!thisClash && roomBooked && dateBooked) color=(WE ? colorSelectedWE : colorSelected);
oDiv.style.backgroundColor = color;
oDiv.style.borderBottomColor = color;
oDiv.style.borderLeftColor = color;
if(bookings[room][dateFormatted][0] && bookings[room][dateFormatted][0].indexOf('S')>-1) {
oDiv.style.backgroundImage = "url( http://alpinebookings.cbdweb.net/images/available.png)";
} else {
oDiv.style.backgroundImage = "";
}
thisDate.setDate(thisDate.getDate()+1)
}
} while (daysDonemax_number_person && max_number_person>0){
alert('Exceeded maximum number in booking ('+max_number_person+' is maximum person in booking)');
} else if(!alreadyBooked) {
roomsBooked.push(room);
}
showBookings();
showRooms();
}
function showRooms() {
for (room in bookings) { // remove colour from all rooms
oDiv = document.getElementById("room." + room)
if(oDiv){
oDiv.style.backgroundColor = colorRoomNotSelected;
oDiv.style.borderBottomColor = colorRoomNotSelected;
}
}
for(i=0; idatesBooked[1]) {
datesBooked[1] = new Date(thisDate.getTime() );
datesChanged = true;
}
if(datesBooked[0] < datesBooked[1] ) {
if(oDiv.innerHTML != multipleDateText || !instrDivClosed) {
oDiv.innerHTML = multipleDateText;
showHelp();
instrDivClosed=false;
}
}
}
if(datesChanged) {
form.date1.value = formatDate (datesBooked[0], "dd/MM/yyyy")
form.date2.value = formatDate (datesBooked[1], "dd/MM/yyyy")
showDatesBooked()
showBookings();
}
}
function readDate(field) { // user has altered a text date, fields below the tabular display
if (!isDate(field.value,"d/M/yyyy") ) {
alert('Please format dates as "dd/mm/yyyy"')
return false
}
// form.temp.value += field.value + "\n";
var thisDate = new Date(getDateFromFormat(field.value, "d/M/yyyy") );
thisDate = dateOnly(thisDate);
var oDiv = document.getElementById('helpText')
var dB = 0
if(field.name!="date1") dB=1;
// if(field.name!="date1") form.temp.value += "nick";
datesBooked[dB] = new Date(thisDate.getTime() );
if(!dateSelected) {
datesBooked[1-dB] = datesBooked[dB]
if(oDiv.innerHTML != singleDateText || !instrDivClosed ) {
oDiv.innerHTML = singleDateText;
resetInstructionLeft()
showHelp();
instrDivClosed=false;
}
} else if (datesBooked[0] < datesBooked[1] ) {
if(oDiv.innerHTML != multipleDateText || !instrDivClosed) {
oDiv.innerHTML = multipleDateText;
showHelp();
instrDivClosed=false;
}
} else {
hideHelp()
}
if (compareDates(form.date1.value,"d/M/yyyy",form.date2.value,"d/M/yyyy")==1) {
// form.temp.value += "nick";
alert('Your start date is after your end date')
hideHelp();
}
showDatesBooked();
showBookings();
}
var instrDivClosed = false; // instruction DIV closed by user
function showDatesBooked() {
bookingLengthErr = false;
var thisDate = new Date(dspStartDate.getTime() );
var daysDone = 0;
var dbt0
if(datesBooked[0]) dbt0 = datesBooked[0].getTime();
// form.temp.value += "datesBooked[0] in showDatesBooked = " + formatDate(datesBooked[0], "yyyyMMdd") + "\n";
var dbt1
if(datesBooked[1]) dbt1 = datesBooked[1].getTime();
var leftEnd=0; // record left end of bookings for later positioning instruction DIV
var rightEnd=0;
do {
var dateFormatted = formatDate(thisDate, "yyyyMMdd");
daysDone += 1;
var divID = "days" + daysDone;
var oDiv = document.getElementById(divID);
var ddDiv = dd.elements[divID];
ddDiv.endPoint = false;
ddDiv.setCursor(CURSOR_TEXT);
ddDiv.div.style.backgroundImage = "none";
var dayName = formatDate(thisDate, "E");
var WE = (dayName=="Sat" || dayName=="Fri");
if(!dateSelected || thisDate datesBooked[1] ) {
var color = (WE ? colorDateNotSelectedWE : colorDateNotSelected);
} else {
color = (WE ? colorDateSelectedWE : colorDateSelected);
tdt = thisDate.getTime();
if( (tdt==dbt0 || tdt==dbt1 ) && dbt0!=dbt1) { // date range defined, deal with endpoints
dd.elements[divID].endPoint = true;
dd.elements[divID].setCursor(CURSOR_MOVE);
dd.elements[divID].div.style.backgroundImage = "url(images/arrowbox.gif)";
if (tdt==dbt0) { // doing left end, move pointer
instrDiv = document.getElementById('divInstructionLeft')
// form.temp.value += "instrDiv.style.left = " + instrDiv.style.left + "\n";
instrDiv.style.left=ddDiv.x+12+'px';
// form.temp.value += "instrDiv.style.left = " + instrDiv.style.left + "\n";
if(!instrDivClosed) instrDiv.style.display="block";
leftEnd = ddDiv.x; // position instruction DIV later
} else { // right end
instrDiv = document.getElementById('divInstructionRight');
instrDiv.style.left=ddDiv.x+7+'px';
if(!instrDivClosed) instrDiv.style.display="block";
rightEnd = ddDiv.x
}
}
}
oDiv.style.backgroundColor = color;
oDiv.style.borderLeftColor = color;
oDiv.style.borderBottomColor = color;
thisDate.setDate(thisDate.getDate() + 1);
} while (daysDone= thisDate.getTime() ) {
alert("Your booking exceeds the maximum length of " + maxDaysBooking + " days.");
bookingLengthErr = true;
}
} else { // no dates selected
document.getElementById('helpText').innerHTML = noDateText;
}
}
function my_DragFunc() {
if(!dd.obj.endPoint) { // suppress dragging of non-endpoint divs
dd.obj.moveTo(dd.obj.defx, dd.obj.defy)
} else { // change DIV contents to arrow
dd.obj.div.innerHTML = "↔"
dd.obj.div.style.backgroundImage = "none";
}
}
function my_DropFunc() {
if(!dd.obj.endPoint) {
dd.obj.moveTo(dd.obj.defx, dd.obj.defy)
} else {
var draggedDate = new Date(getDateFromFormat(dd.obj.dateFormatted, "yyyyMMdd") );
//form.temp.value += "dd.obj = " + dd.obj.dateFormatted + "\n";
draggedDate = dateOnly(draggedDate);
var earlierEndpoint = (draggedDate.getTime()==datesBooked[0].getTime() ); // endpoint being dragged is the left-hand one (or not)
//form.temp.value += "earlierEndpoint = " + earlierEndpoint + "\n";
var retainedDate = datesBooked[1- (earlierEndpoint ? 0 : 1)]; // date that wasn't dragged
//form.temp.value += "retainedDate = " + formatDate(retainedDate, "yyyyMMdd") + "\n";
var onto = dd.obj.getEltBelow(); // where it was dragged to
if(onto) {
ontoDivId = dd.obj.getEltBelow().div.id
ontoDateFormatted = onto.dateFormatted;
}
dd.obj.div.innerHTML = formatDate(draggedDate, "d"); // restore contents of dragged DIV
dd.obj.moveTo(dd.obj.defx, dd.obj.defy); // put it back where it came from
if(onto && ontoDivId!=dd.obj.div.id) { // don't do anything if it was dragged onto itself
//form.temp.value += "onto = " + ontoDateFormatted + "\n";
var newDate = new Date(getDateFromFormat(ontoDateFormatted, "yyyyMMdd") );
newDate = dateOnly(newDate);
var rdt = retainedDate.getTime();
var ndt = newDate.getTime();
//form.temp.value += "datesBooked[0] before = " + formatDate(datesBooked[0], "yyyyMMdd") + "\n";
datesBooked[0].setTime(Math.min(rdt, ndt) );
//form.temp.value += "datesBooked[0] after = " + formatDate(datesBooked[0], "yyyyMMdd") + "\n";
datesBooked[1].setTime(Math.max(rdt, ndt) );
form.date1.value = formatDate (datesBooked[0], "dd/MM/yyyy")
form.date2.value = formatDate (datesBooked[1], "dd/MM/yyyy")
showDatesBooked();
//form.temp.value += "datesBooked[0] after showDatesBooked = " + formatDate(datesBooked[0], "yyyyMMdd") + "\n";
showBookings();
//form.temp.value += "datesBooked[0] after showBookings " + formatDate(datesBooked[0], "yyyyMMdd") + "\n";
}
}
}
function submitForm() {
if(showBookings()) { //This might not be needed
//field = form.rooms // field for returning value to server
field = form.elements['rooms[]'];
var doSubmit = true;
if(roomsBooked.length > 0) {
for(j=0; j ';
thisR = rooms[roomID];
oDiv.innerHTML += "
";
oDiv.innerHTML += "" + thisR[1] + "
";
oDiv.innerHTML += "" + thisR[4] + "
";
oDiv.innerHTML += "" + thisR[3] + "
";
oDiv.innerHTML += "Beds: " + thisR[5] + ", " + thisR[6] + " Single" + (thisR[6] > 1 ? "s" : "") + "
";
oDiv.innerHTML += "Capacity: Minimum " + thisR[8] + (thisR[8] > 1 ? " people" : " person") + " and Maximum " + thisR[7] + (thisR[7] > 1 ? " people." : " person.");
oDiv.style.visibility="visible";
}
function hideRoom() {
oDiv = document.getElementById('divShowRoom');
oDiv.style.visibility="hidden";
}
function hideDetail() {
nd();
/*
oDiv = document.getElementById('divShowBookingDetail');
oDiv.style.visibility="hidden";
*/
}
function showBookinginfo(oDiv2) {
// if(whoami!="member" & whoami!="admin") return false; // PHP won't send it if we shouldn't show it
if(oDiv2.roomID && oDiv2.dateFormatted && bookings[oDiv2.roomID] && bookings[oDiv2.roomID][oDiv2.dateFormatted]){
if(bookings[oDiv2.roomID][oDiv2.dateFormatted][1]==null) return false;
if(whoami=="admin") {
oDiv2.style.cursor = "pointer";
}
overlib(bookings[oDiv2.roomID][oDiv2.dateFormatted][1], AUTOSTATUS, WRAP);
}
/*
oDiv = document.getElementById('divShowBookingDetail');
oDiv.innerHTML = "";
oDiv.innerHTML += '
';
// oDiv2 = document.getElementById('room.rm'+roomID);
oDiv.innerHTML += bookings[oDiv2.roomID][oDiv2.dateFormatted][1];
oDiv.innerHTML += '
';
oDiv.style.visibility="visible";
*/
}
function gotoBookinginfo(oDiv2) {
if(whoami!="admin") return false;
if(oDiv2.roomID && oDiv2.dateFormatted && bookings[oDiv2.roomID] && bookings[oDiv2.roomID][oDiv2.dateFormatted]){
if(bookings[oDiv2.roomID][oDiv2.dateFormatted][2]==null) return false;
// oDiv2 = document.getElementById('room.rm'+roomID);
document.location.href=bookings[oDiv2.roomID][oDiv2.dateFormatted][2];
}
}