var flagCaptcha = false; var flagFields = true; var minSlots=3; var maxSlots=5; var message = 'Please fill in all mandatory fields ! \n'; var bustcachevar=1; //bust potential caching of external pages after initial request? (1=yes, 0=no) var bustcacheparameter=""; function checkForm() { re = /([0-9a-zA-Z\.-_]+)@([0-9a-zA-Z\.-_]+)\.([0-9a-zA-Z\.-_]+)/; var name, email, phone, dataRight = true; var message = ""; name = document.frm.customerName.value; email = document.frm.email.value; phone = document.frm.phone.value; if (name.length==0){ message += "\n - Name"; dataRight=false; } if (email.length==0){ message += "\n - Email"; dataRight=false; } if (phone.length==0){ message += "\n - Phone"; dataRight=false; } if (email.length!=0 && email.match(re)==null){ dataRight=false; message += "\n - Your Email is Incorrect"; } var selected_slots = 0; all_inputs=document.getElementsByTagName("input"); for (i=0;i< all_inputs.length;i++) { if (all_inputs[i].type=="checkbox") { if ((all_inputs[i].checked)&&(! all_inputs[i].disabled)) { selected_slots++; } } } if(selected_slots< minSlots){ dataRight=false; message += "\n - Select at least " + minSlots + " time slot(s)"; } if (!dataRight){ if (message != ""){ message ="\nYou failed to correctly fill in the form:\n" + message + "\n\nPlease re-enter and click the Book button again!"; } alert(message); } return dataRight; } function getDiscount(slots,price){ var discount = 0; var discounts = document.getElementById("discounts").value; var discountArr = discounts.split(","); if(slots>1) discount = parseFloat(discountArr[slots-2]); document.getElementById("price").value=(price-discount); document.getElementById("priceDiv").innerHTML=(price-discount); } function selectTimeSlot() { disableElements(); singlePrice=document.getElementById("singlePrice").value; price=0; slots=0; all_inputs=document.getElementsByTagName("input"); for (i=0;i< all_inputs.length;i++) { if (all_inputs[i].type=="checkbox") { if ((all_inputs[i].checked)&&(! all_inputs[i].disabled)) { price=parseFloat(price)+parseFloat(singlePrice); slots++; } } } getDiscount(slots,price); } function disableElements() { first=-1; last=-1; emptySpot=false; all_inputs=document.getElementsByTagName("input"); for (i=0;i< all_inputs.length;i++) { if (all_inputs[i].type=="checkbox") { if ((all_inputs[i].checked)&&(! all_inputs[i].disabled)) { if (emptySpot) { all_inputs[i].checked=false; } else { if (first<0) { first=i; last=i; } if ((i-last)>1) { all_inputs[i].checked=false; emptySpot=true; } else { last=i; } } } } } if ((last-first+1)==maxSlots) { reachedMax=1; } else { reachedMax=0; } if (first>=0 && last>=0) { for (i=0;i< all_inputs.length;i++) { if (all_inputs[i].type=="checkbox") { if ((i<(first-(1-reachedMax))) || (i>(last+(1-reachedMax)))) { if ((! all_inputs[i].checked) && (! all_inputs[i].disabled)) { all_inputs[i].disabled=true; } } else { if ((! all_inputs[i].checked)) { all_inputs[i].disabled=false; } } } } } else { for (i=0;i< all_inputs.length;i++) { if (all_inputs[i].type=="checkbox") { if ((! all_inputs[i].checked)) { all_inputs[i].disabled=false; } } } } } function createRequestObject(){ try { xmlhttp = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) { alert('Sorry, but your browser doesn\'t support XMLHttpRequest.'); }; return xmlhttp; }; function ajaxpage(url, containerid, requesttype){ var page_request = createRequestObject(); if (requesttype=='get'){ if (bustcachevar) bustcacheparameter=(url.indexOf("?")!=-1)? "&"+new Date().getTime() : "?"+new Date().getTime() page_request.open('GET', url+bustcacheparameter, true) page_request.send(null) } else if (requesttype=='post') { page_request.open('POST', url, true); page_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); page_request.setRequestHeader("Content-length", poststr.length); page_request.setRequestHeader("Connection", "close"); page_request.send(poststr); }; page_request.onreadystatechange=function(){ loadpage(page_request, containerid) } } function ShowToolTip(object) { document.getElementById(object).style.visibility = 'visible'; } function HideToolTip(object) { document.getElementById(object).style.visibility = 'hidden'; } function loadpage(page_request, containerid){ if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1)) { document.getElementById(containerid).innerHTML=page_request.responseText; }; } function submitDate(date) { ajaxpage("/bookings/load-calendar.php?perDay="+date+"&view=2&cid=1","AvailabilityCalendar1","get"); } function submitBooking(startdate,sMonth,sYear) { var poststr = "ac=book&startDate="+startdate+"&customerName=" + encodeURIComponent( document.frm.customerName.value ) + "&email=" + encodeURIComponent( document.frm.email.value ) + "&phone=" + encodeURIComponent( document.frm.phone.value ) + "¬es=" + encodeURIComponent( document.frm.notes.value ) + "&price=" + encodeURIComponent( document.frm.price.value ); all_inputs=document.getElementsByTagName("input"); for (i=0;i< all_inputs.length;i++) { if (all_inputs[i].type=="checkbox") { if ((all_inputs[i].checked)&&(! all_inputs[i].disabled)) { poststr=poststr+"&"+parseInt(all_inputs[i].id)+"=on"; } } } ajaxpage('/bookings/load-bookingform.php?ac=book&cid=1&'+poststr,'DateBookings1','get'); var start = new Date().getTime(); while (new Date().getTime() < start + 500); ajaxpage('/bookings/load-calendar.php?view=2&cid=1&month='+sMonth+'&year='+sYear,'AvailabilityCalendar1','get'); }; function submitPayment() { if (document.getElementById("MasterCard").checked) { card_type="MasterCard"; } else if (document.getElementById("Visa").checked) { card_type="Visa"; } else if (document.getElementById("Discover").checked) { card_type="Discover"; } else if (document.getElementById("Amex").checked) { card_type="Amex"; } var poststr = "example_payment_amuont=" + encodeURIComponent( document.frm.example_payment_amuont.value ) + "&credit_card=" + encodeURIComponent( card_type ) + "&customer_credit_card_number=" + encodeURIComponent( document.frm.customer_credit_card_number.value )+ "&customer_last_name=" + encodeURIComponent( document.frm.customer_last_name.value ) + "&cc_expiration_month=" + encodeURIComponent( document.frm.cc_expiration_month.value ) +"&cc_expiration_year=" + encodeURIComponent( document.frm.cc_expiration_year.value ) +"&cc_cvv2_number=" + encodeURIComponent( document.frm.cc_cvv2_number.value ) +"&customer_address1=" + encodeURIComponent( document.frm.customer_address1.value )+"&customer_city=" + encodeURIComponent( document.frm.customer_city.value )+"&customer_state=" + encodeURIComponent( document.frm.customer_state.value )+"&customer_zip=" + encodeURIComponent( document.frm.customer_zip.value )+"&customer_country=" + encodeURIComponent( document.frm.customer_country.value )+"&customer_first_name=" + encodeURIComponent( document.frm.customer_first_name.value ); ajaxpage('/bookings/load-bookingform.php?ac=pay&cid=1&'+poststr,'DateBookings1','get'); }; loadCalendar = '
'; document.writeln(loadCalendar);