var offerNames = [];/*{{{*/
var offerDescriptions = [];
var offerShortDescriptions = [];
var offerPrices = [];
var offerMinDays = [];
var offerMaxDays = [];
var offerUnfolds = [];
var offerParents = [];
var offerPricePerStay = [];
var offerDateFrom = [];
var offerPaymentOnlineLocked = [];
var offerPaymentOfflineLocked = [];
var offerPaymentPreauthLocked = [];
var offerPaymentReceptionLocked = [];
var offerPaymentEnquiryLocked = [];
var offerAdvanceLocked = [];
var roomEnquiryOnly = [];
var roomNames = [];
var roomDescriptions = [];
var roomPrices = [];
var roomCapacities = [];
var roomMaxExtensionCounts = [];
var onlyRoom = 0;
var receptionPaymentSelected = 0;
var extensionsNames = [];
var optionsNames = [];
var months = ['', 'STYCZEŃ', 'LUTY', 'MARZEC', 'KWIECIEŃ', 'MAJ', 'CZERWIEC', 'LIPIEC', 'SIERPIEŃ', 'WRZESIEŃ', 'PAŹDZIERNIK', 'LISTOPAD', 'GRUDZIEŃ'];
var selectionStarted = 0;
var selectionDateStart = '';
var selectionDateEnd = '';
var selectionCurrentDate = '';
var currentDateFrom = '';
var savedCurrentDateFrom = '';
var currentOffer = 0;
var reservationComplete = 0;
var totalPrice = '';
var discount = 0;
var extensionsPrice = 0;
var extensionsCount = 0;
var undoElement = false;
var undoSelect = '';
var offer_id = 1;
var roomIds = [];
var roomAmounts = [];
var pendingRequests = 0;
var scrollPosition = 0;
var sliderDirection = "left";
var sliderOffers = 0;
var activeStep = 1;
var firstDisplay = 0;
/*}}}*/
function paymentReturn() {/*{{{*/
$(".payment-status").html("(potwierdzona opłacona)");
$("#payment-finalized").show('slow');
$("#makeReservationButton").unbind();
$("#makeReservationButton").val("Drukuj");
$("#makeReservationButton").show();
$("#makeReservationButton").click(function() {
$("#step1-top").hide();
$("#step2-top").hide();
$("#step3-top").hide();
$("#makeReservationButton").hide();
$(".reservation a").hide();
window.print();
});
}/*}}}*/
function roomsString() {/*{{{*/
var roomsAmount = '';
$(".room_amount").each(function() {
roomsAmount += this.id + ":" + $(this).val() + "/";
});
return roomsAmount;
}/*}}}*/
function optionsString() {/*{{{*/
var optionsCounts = "";
$(".option-checkbox").each(function() {
if (this.checked) {
optionsCounts += this.id + ":" + $("#" + this.id + "-amount").val() + "/";
}
});
return optionsCounts;
}/*}}}*/
function extensionsString() {/*{{{*/
var extensionsCounts = "";
$(".extensions-options-select").each(function() {
extensionsCounts += this.id + ":" + $(this).val() + "/";
});
return extensionsCounts;
}/*}}}*/
function selectedRoomsHtml() {/*{{{*/
var roomsHtml = "";
$(".room_amount").each(function() {
var roomId = this.id.replace('rooms_amount_', '');
var capacityIco;
for (i=0;i<$(this).val();i++) {
capacityIco = roomCapacities[roomId];
if (parseInt(capacityIco) > 6) {
capacityIco = "x";
}
roomsHtml += '
';
roomsHtml += '
'+roomNames[roomId]+'
';
roomsHtml += '
Cena: ' + (roomPrices[roomId] / $(this).val()).toFixed(2) + " zł";
roomsHtml += '
';
if (0 && roomMaxExtensionCounts[roomId] > 0) { // TODO; potrzebne?
roomsHtml += '
+ ';
roomsHtml += '
';
} else {
roomsHtml += '
';
}
roomsHtml += '
';
roomsHtml += '';
roomsHtml += 'opcje dodatkowe » ';
roomsHtml += '
';
roomsHtml += '';
}
});
return roomsHtml;
}/*}}}*/
function updateSummary() {/*{{{*/
var optionsTotal = 0;
var advance_percent = 0.3;
var is_immediate_payment = 0;
var online_payment_avail = 0;
var offline_payment_avail = 0;
var preauth_payment_avail = 0;
var reception_payment_avail = 0;
$(".option-checkbox").each(function() {
if (this.checked) {
optionsTotal += parseFloat($("#" + this.id + '-value').val()) * $("#" + this.id + '-amount').val();
}
});
$("#summary-visitors-count").html("Ilość gości: " + visitorsCount() + "");
$("#summary-extensions-price").html(extensionsPrice.toFixed(2) + " zł");
$("#step3-extensions-price").html(extensionsPrice.toFixed(2) + " zł");
$("#summary-options-price").html(optionsTotal.toFixed(2) + " zł");
$("#step3-options-price").html(optionsTotal.toFixed(2) + " zł");
$("#step3-base-price").html(parseFloat(totalPrice).toFixed(2) + " zł");
$("#step3-discount").html((parseFloat(totalPrice) * discount).toFixed(2) + " zł");
optionsTotal += parseFloat(totalPrice) + extensionsPrice - parseFloat(totalPrice) * discount;
$("#summary-total").html(optionsTotal.toFixed(2) + " zł");
$("#step3-total").html(optionsTotal.toFixed(2) + " zł");
if ($("#payment-full:checked").val() != undefined && $("#payment-full:checked").val() == "full") {
$("#amount-to-pay").html(optionsTotal.toFixed(2) + " zł");
$("#paymentFormAmount").val(optionsTotal.toFixed(2));
$("#step3-to-pay").html(optionsTotal.toFixed(2) + " zł");
$("#step3-payment-form").html("Całość");
} else {
$("#amount-to-pay").html((optionsTotal * advance_percent).toFixed(2) + " zł");
$("#paymentFormAmount").val((optionsTotal * advance_percent).toFixed(2));
$("#step3-to-pay").html((optionsTotal * advance_percent).toFixed(2) + " zł");
$("#step3-payment-form").html("Zadatek");
}
}/*}}}*/
function daysCount(date1, date2) {/*{{{*/
var startParts = date1.split('-');
var endParts = date2.split('-');
var startDay = new Date(startParts[0], parseInt(startParts[1], 10) - 1, parseInt(startParts[2], 10));
var endDay = new Date(endParts[0], parseInt(endParts[1], 10) - 1, parseInt(endParts[2], 10));
return (endDay.getTime() - startDay.getTime()) / (1000 * 3600 * 24);
}/*}}}*/
function updateRoomExtensions() {/*{{{*/
var parts = this.id.replace('room-extensions-options-', '').split('-');
var room_id = parts[0];
var room_no = parts[1];
var extension_no = parts[2];
var extensions_count = parseInt($(this).val());
var current_room_extensions = 0;
var skipExtensions = 0;
$(".extensions-options-select").each(function() {
if (this.id.search("room-extensions-options-" + room_id + "-" + room_no + "-") != -1) {
current_room_extensions += parseInt($(this).val());
if ($(this).hasClass('extension-skip')) {
skipExtensions += parseInt($(this).val());
}
}
});
if (current_room_extensions - skipExtensions > roomMaxExtensionCounts[room_id]) {
current_room_extensions -= parseInt($(this).val());
$(this).val(0);
}
$(".options-select").each(function() {
if (this.id.search("-options-"+room_id+"-"+room_no) != -1) {
$(this).val(roomCapacities[room_id] + current_room_extensions - skipExtensions);
}
});
extensionsPrice = 0;
extensionsCount = 0;
$(".extensions-options-select").each(function() {
extensionsPrice += parseFloat($("#" + this.id.replace('amount', 'value')).val()) * parseInt($(this).val());
extensionsCount += parseInt($(this).val());
});
updateSummary();
}/*}}}*/
function loadConfirmationMessages() {
queueRequest();
$.get('/cms/view/9', function(xml) {
dequeueRequest();
$(".choose-offer").html($("cms cm content", xml).text());
});
queueRequest();
$.get('/cms/view/3', function(xml) {
dequeueRequest();
$("#payment-finalized").html($("cms cm content", xml).text());
});
queueRequest();
$.get('/cms/view/5', function(xml) {
dequeueRequest();
$("#payment-need-confirmation").html($("cms cm content", xml).text());
});
queueRequest();
$.get('/cms/view/19', function(xml) {
dequeueRequest();
$("#payment-enquiry-info").html($("cms cm content", xml).text());
});
}
function saveReservationSource(source) {
if (source == "") {
return;
}
queueRequest();
$.get('/reservations/save_source/' + source, function(xml) {
dequeueRequest();
});
}
function loadRegulationsAndPreauthInfo() {
queueRequest();
$.get('/cms/view/1', function(xml) {
dequeueRequest();
$(".regulations").html($("cms cm content", xml).text() + $(".regulations").html());
});
queueRequest();
$.get('/cms/view/17', function(xml) {
dequeueRequest();
$(".preauth-info").html($("cms cm content", xml).text() + $(".preauth-info").html());
});
}
function bindAndLoadAdditionalOptions() {/*{{{*/
$(".show-additional-options").each(function() {
var optionsDivId = this.id.replace('show-additional-options', 'room-additional-options');
var offerOptionsDivId = this.id.replace('show-additional-options', 'room-offer-options');
var extensionsOptionsDivId = this.id.replace('show-additional-options', 'room-extensions-options');
var room_id = this.id.replace('show-additional-options-', '').split("-")[0];
$(this).click(function() {
$("#"+optionsDivId).toggle(400);
});
queueRequest();
$.get('/additional_options/index/'+offer_id+'/'+ room_id + '/' + selectionDateStart + '/' + selectionDateEnd, function(xml) {
dequeueRequest();
var optionsHtml = "";
var i = 0;
$("options extension", xml).each(function() {
var currentId = parseInt($('id', this).text(), 10);
var currentName = $('name', this).text();
var currentPrice = $('price', this).text() == ""?0:$('price', this).text();
var currentMaxCount = parseInt($('count', this).text());
optionsHtml += '';
/* optionsHtml += ''; */
optionsHtml += '';
optionsHtml += '';
optionsHtml += '';
optionsHtml += '
';
extensionsNames[extensionsOptionsDivId.replace('room-extensions-options-', '') + '-' + currentId] = currentName;
});
if (optionsHtml != "") {
optionsHtml += '
';
}
$("options additional_option", xml).each(function() {
var currentId = parseInt($('id', this).text(), 10);
var currentName = $('name', this).text();
var currentPrice = $('price', this).text();
optionsHtml += '';
optionsHtml += '';
optionsHtml += '';
optionsHtml += '';
if ($('single', this).text() == 0 && roomCapacities[room_id] + roomMaxExtensionCounts[room_id] > 1) {
optionsHtml += '';
} else {
optionsHtml += '';
}
optionsHtml += '
';
optionsNames['a' + currentId] = currentName;
i++;
});
$("options offer_option", xml).each(function() {
var currentId = parseInt($('id', this).text(), 10);
var currentName = $('name', this).text();
var currentPrice = $('price', this).text();
optionsHtml += '';
optionsHtml += '';
optionsHtml += '';
optionsHtml += '';
if ($('single', this).text() == 0 && roomCapacities[room_id] + roomMaxExtensionCounts[room_id] > 1) {
optionsHtml += '';
} else {
optionsHtml += '';
}
optionsHtml += '
';
optionsNames['o' + currentId] = currentName;
i++;
});
optionsHtml += '
';
$("#"+optionsDivId).html(optionsHtml);
$("#"+optionsDivId + "-hide").click(function() {
$('#' + optionsDivId).hide('slow');
});
$(".option-checkbox").change(updateSummary);
$(".options-select").change(updateSummary);
$('.extensions-options-select').change(updateRoomExtensions);
// $('.extension-checkbox').click(updateRoomExtensions);
});
});
}/*}}}*/
function roomSelected() {/*{{{*/
var anySelected = 0;
$(".room_amount").each(function() {
if ($(this).val() > 0) {
anySelected += parseInt($(this).val());
}
});
return anySelected;
}/*}}}*/
function visitorsCount() {/*{{{*/
var visitors = 0;
$(".room_amount").each(function() {
if ($(this).val() > 0) {
visitors += parseInt($(this).val()) * roomCapacities[this.id.replace("rooms_amount_", "")];
}
});
return visitors + extensionsCount;
}/*}}}*/
function queueRequest() {/*{{{*/
if (pendingRequests == 0) {
$("#whole").css("height", $(document).height());
$("#whole").css("width", $(document).width());
$("#whole").show();
// $("#whole").css("display","block");
// $("#whole").fadeTo("slow", 0.5);
$(".ajax-loader").show();
}
pendingRequests += 1;
}/*}}}*/
function dequeueRequest() {/*{{{*/
pendingRequests -= 1;
if (pendingRequests == 0) {
$(".ajax-loader").hide();
$("#whole").hide();
/* $("#whole").fadeTo("slow", 0.0, function(){
$("#whole").css("display","none");
});
*/
}
}/*}}}*/
function isCreditCard( CC )
{
if (CC.length > 19)
return (false);
sum = 0; mul = 1; l = CC.length;
for (i = 0; i < l; i++)
{
digit = CC.substring(l-i-1,l-i);
tproduct = parseInt(digit ,10)*mul;
if (tproduct >= 10)
sum += (tproduct % 10) + 1;
else
sum += tproduct;
if (mul == 1)
mul++;
else
mul--;
}
if ((sum % 10) == 0)
return (true);
else
return (false);
}
function verifyReservation() {/*{{{*/
var requiredFields = ["name", "surname", "street", "postCode", "city", "country", "phone", "email"];
var companyFields = ["company-name", "company-tax-id", "company-street", "company-postCode", "company-city", "company-country"];
var fieldNames = [];
var errorInfo = "Proszę wypełnić następujące pola:\n";
var error = 0;
var i;
fieldNames["name"] = "Imie:";
fieldNames["surname"] = "Nazwisko";
fieldNames["street"] = "Ulica";
fieldNames["postCode"] = "Kod pocztowy";
fieldNames["city"] = "Miasto";
fieldNames["country"] = "Kraj";
fieldNames["phone"] = "Numer telefonu";
fieldNames["email"] = "Email";
fieldNames["company-name"] = "Nazwa firmy";
fieldNames["company-tax-id"] = "NIP";
fieldNames["company-street"] = "Ulica (faktura)";
fieldNames["company-postCode"] = "Kod pocztowy (faktura)";
fieldNames["company-city"] = "Miasto (faktura)";
fieldNames["company-country"] = "Kraj (faktura)";
for (i = 0; i < requiredFields.length; i++) {
if ($("#"+requiredFields[i]).val() == "") {
error = 1;
errorInfo += "* Proszę wypełnić " + fieldNames[requiredFields[i]] + "\n";
}
}
if ($("#invoice:checked").val() == "on") {
for (i = 0; i < companyFields.length; i++) {
if ($("#"+companyFields[i]).val() == "") {
error = 1;
errorInfo += "* Proszę wypełnić " + fieldNames[companyFields[i]] + "\n";
}
}
}
if ($("#conditions:checked").val() != "on") {
error = 1;
errorInfo += "Musisz zaakceptować regulamin.\n";
}
if (error) {
alert(errorInfo);
} else {
loadStep3();
}
}/*}}}*/
function sendReservation() {/*{{{*/
var postData = "";
$("#makeReservationButton").unbind();
postData += "data[Reservation][offer_id]="+offer_id;
postData += "&data[Reservation][date_from]="+selectionDateStart;
postData += "&data[Reservation][date_to]="+selectionDateEnd;
postData += "&data[Customer][name]="+escape($("#name").val());
postData += "&data[Customer][company_name]="+escape($("#company-name").val());
postData += "&data[Customer][surname]="+escape($("#surname").val());
postData += "&data[Customer][company_address]="+escape($("#company-street").val());
postData += "&data[Customer][address]="+escape($("#street").val());
postData += "&data[Customer][post_code]="+escape($("#postCode").val());
postData += "&data[Customer][company_post_code]="+escape($("#company-postCode").val());
postData += "&data[Customer][tax_id]="+escape($("#company-tax-id").val());
postData += "&data[Customer][city]="+escape($("#city").val());
postData += "&data[Customer][company_city]="+escape($("#company-city").val());
postData += "&data[Customer][country]="+escape($("#country").val());
postData += "&data[Customer][company_country]="+escape($("#company-country").val());
postData += "&data[Customer][phone]="+escape($("#phone").val());
postData += "&data[Customer][email]="+escape($("#email").val());
postData += "&data[Reservation][comment]="+escape($("#specialRequirements").val());
postData += "&data[Reservation][aproximate_arrival]="+escape($("#timeOfArrival").val());
postData += "&data[Reservation][card_name]="+escape($("#card-name").val());
postData += "&data[Reservation][card_surname]="+escape($("#card-surname").val());
postData += "&data[Reservation][card_number]="+escape($("#card-number").val());
postData += "&data[Reservation][card_expiration_date]="+escape($("#card-expiration-date").val());
postData += "&data[Reservation][card_cvc]="+escape($("#card-cvc").val());
if ($("#payment-enquiry:checked").val() == "enquiry") {
postData += "&data[Reservation][enquiry]=1";
} else {
postData += "&data[Reservation][enquiry]=0";
}
if ($("#payment-full:checked").val() == "full") {
postData += "&data[Payment][zaliczka]=0";
} else {
postData += "&data[Payment][zaliczka]=1";
}
if ($("#payment-online:checked").val() == "online") {
postData += "&data[Payment][online]=1";
$("#makeReservationButton").click(function() {
if (reservationComplete) {
$("#onlinePaymentForm").submit();
}
});
$("#makeReservationButton").val("Zapłać");
} else {
postData += "&data[Payment][online]=0";
if ($("#payment-enquiry:checked").val() == "enquiry") {
$("#payment-enquiry-info").show('slow');
} else if (!receptionPaymentSelected) {
$("#payment-need-confirmation").show('slow');
}
$("#makeReservationButton").val("Drukuj");
$("#makeReservationButton").click(function() {
$("#step1-top").hide();
$("#step2-top").hide();
$("#step3-top").hide();
$("#makeReservationButton").hide();
$(".reservation a").hide();
window.print();
});
}
$("#back-button").hide('slow');
activeStep = 0;
queueRequest();
$.post("/reservations/add/language:pol/" + roomsString() + optionsString() + extensionsString(), postData, function(response) {
dequeueRequest();
var error = 0;
var reservationNumbers = [];
var control = '';
var i;
error = $("response error", response).text();
control = $("response control", response).text();
if (error != "0") {
$(".step4").html($("response msg", response).text());
$("#makeReservationButton").hide();
$(".step3").hide('slow');
$(".step4").show('slow');
} else {
i = 0;
$("response reservations", response).each(function() {
reservationNumbers[i] = $(this).text();
i += 1;
});
i = 0;
$(".reservationId").each(function() {
$(this).html("(reservation number: " + reservationNumbers[i] + ")");
i += 1;
});
$("#paymentDescription").val("Płatność za rezerwacje: " + reservationNumbers);
$("#paymentControl").val(control);
$("#dotpay-forename").val($("#name").val());
$("#dotpay-surname").val($("#surname").val());
$("#dotpay-street").val($("#street").val());
$("#dotpay-postcode").val($("#postCode").val());
$("#dotpay-city").val($("#city").val());
$("#dotpay-email").val($("#email").val());
reservationComplete = 1;
if ($("response msg", response).text() != "") {
alert($("response msg", response).text());
}
}
});
}/*}}}*/
function showSummary() {/*{{{*/
$("#summary-arrival").html(selectionDateStart);
$("#summary-departure").html(selectionDateEnd);
$("#summary-rooms-count").html("Ilość pokoi: " + roomSelected() + "");
$("#summary-visitors-count").html("Ilość gości: " + visitorsCount() + "");
$("#summary-base-price").html(parseFloat(totalPrice).toFixed(2) + " zł");
$("#summary-discount").html((parseFloat(totalPrice) * discount).toFixed(2) + "zł");
$("#summary-offer").html(offerNames[offer_id]);
$("#payment-full").click(updateSummary);
$("#payment-advance").click(updateSummary);
updateSummary();
}/*}}}*/
function bindInvoice() {/*{{{*/
$("#invoice").click(function() {
$("#company-details").toggle("slow");
});
}/*}}}*/
function loadStep3() {/*{{{*/
activeStep = 3;
$(".step2-left").hide('slow');
$(".step2-right").hide('slow');
$(".ofert-details").css("background-image", "url(/img/tlo2.png)");
$(".step3").show('slow');
$(".step").each(function() {
$(this).removeClass("selected");
});
$("#step3-top").addClass("selected");
// change bindings
$("#back-button").unbind();
$('#makeReservationButton').unbind();
bindBackButtonHover();
bindReservationButtonHover();
$("#back-button").click(function() {
loadStep2(1);
});
$("#makeReservationButton").click(sendReservation);
$("#step3-reservation-arrival").html("Data przyjazdu: " + selectionDateStart);
$("#step3-reservation-departure").html("Data wyjazdu: " + selectionDateEnd);
$("#step3-name").html("Imie: " + $('#name').val());
$("#step3-surname").html("Nazwisko: " + $('#surname').val());
$("#step3-address").html("Adres: " + $('#street').val() + "
" + $('#postCode').val() + " " + $("#city").val() + "
" + $('#country').val());
if ($("#invoice:checked").val() == "on") {
$("#step3-invoice-details").show();
$("#step3-company-name").html("Nazwa firmy: " + $("#company-name").val());
$("#step3-company-address").html("Adres: " + $('#company-street').val() + "
" + $('#company-postCode').val() + " " + $("#company-city").val() + "
" + $('#company-country').val());
$("#step3-taxId").html("NIP: " + $("#company-tax-id").val());
} else {
$("#step3-invoice-details").hide();
}
var extensionsForRooms = [];
$(".extensions-options-select").each(function() {
extensionsForRooms[this.id.replace('room-extensions-options-', '').replace('-amount', '')] = parseInt($(this).val());
});
var roomsHtml = '';
var i = 0;
var d = 0;
roomsHtml += 'Wybrane pokoje
';
$(".room_amount").each(function() {
var roomId = this.id.replace('rooms_amount_', '');
if ($(this).val() > 0) {
for (i=0; i < $(this).val(); i++) {
roomsHtml += '' + roomNames[roomId] + ' ';
for (d = 1;d <= 4; d++) {
if (extensionsForRooms[roomId + '-' + i + '-' + d] > 0) {
roomsHtml += '+ ' + extensionsNames[roomId + '-' + i + '-' + d] + ' ';
if (extensionsForRooms[roomId + '-' + i + '-' + d] > 1) {
roomsHtml += 'x ' + extensionsForRooms[roomId + '-' + i + '-' + d] + ' ';
}
}
}
roomsHtml += '
';
roomsHtml += "";
for (var option_id in optionsNames) {
var option_type = "";
if (option_id.substring(0, 1) == "a") {
option_type = "additional";
} else {
option_type = "offer";
}
if ($("#room-" + option_type + "-options-" + roomId + "-" + i + "-" + option_id.substring(1) + ":checked").val() == 1) {
roomsHtml += "- " + optionsNames[option_id];
if ($("#room-" + option_type + "-options-" + roomId + "-" + i + "-" + option_id.substring(1) + "-amount").val() > 1) {
roomsHtml += " x " + $("#room-" + option_type + "-options-" + roomId + "-" + i + "-" + option_id.substring(1) + "-amount").val();
}
roomsHtml += "
";
}
}
roomsHtml += "
";
}
}
});
$("#step3-rooms").html(roomsHtml);
}/*}}}*/
function loadStep2(backward) {/*{{{*/
activeStep = 2;
if (!backward) {
$(".thumbs-outer").hide('slow');
$(".calendar").hide('slow');
$(".ofert-info").hide('slow');
$(".more-info").hide('slow');
sliderDirection = "none";
$(".thumbs").animate({ marginLeft : '0' });
$("#payment-offline").attr("checked", "checked");
$("#payment-online").attr("disabled", "disabled");
$("#payment-enquiry").click(function() {
receptionPaymentSelected = 0;
});
if (offerPaymentEnquiryLocked[currentOffer]) {
$("#payment-enquiry").attr("disabled", "disabled");
$("#payment-enquiry").attr("checked", "");
}
// if immediate payment and typ != online and preautoryzacja, disabled
if ($("#payment-enquiry").attr("disabled") == "") {
$("#payment-enquiry").attr("checked", "checked");
}
if (offerPaymentReceptionLocked[currentOffer]) {
$("#payment-reception").attr("disabled", "disabled");
$("#payment-reception").attr("checked", "");
}
// if immediate payment and typ != online and preautoryzacja, disabled
if ($("#payment-reception").attr("disabled") == "") {
$("#payment-reception").attr("checked", "checked");
}
if (offerPaymentOfflineLocked[currentOffer]) {
$("#payment-offline").attr("disabled", "disabled");
$("#payment-offline").attr("checked", "");
}
// if immediate payment and typ != online and preautoryzacja, disabled
if ($("#payment-offline").attr("disabled") == "") {
$("#payment-offline").attr("checked", "checked");
}
if (offerPaymentOnlineLocked[currentOffer]) {
$("#payment-online").attr("disabled", "disabled");
$("#payment-online").attr("checked", "");
}
// if immediate payment and typ != online and preautoryzacja, disabled
if ($("#payment-online").attr("disabled") == "") {
$("#payment-online").attr("checked", "checked");
}
if (offerPaymentPreauthLocked[currentOffer]) {
$("#payment-preauth").attr("disabled", "disabled");
$("#payment-preauth").attr("checked", "");
}
// if immediate payment and typ != online and preautoryzacja, disabled
if ($("#payment-preauth").attr("disabled") == "") {
$("#payment-preauth").attr("checked", "checked");
$("#payment-full").attr("checked", "checked");
$("#payment-advance").attr("disabled", "disabled");
receptionPaymentSelected = 1;
updateSummary();
}
} else {
$(".ofert-details").css("background-image", "url(/img/tlo.png)");
$(".step3").hide('slow');
}
$(".step2-left").show('slow');
$(".step2-right").show('slow');
$(".step").each(function() {
$(this).removeClass("selected");
});
$("#step2-top").addClass("selected");
$("#back-button").unbind();
$("#back-button").val("Wstecz");
$("#back-button").click(function() {
loadStep1();
});
$('#makeReservationButton').unbind();
$('#makeReservationButton').click(verifyReservation);
if (!backward) {
$("#confirmation-selected-rooms").html(selectedRoomsHtml());
bindReservationButtonHover();
bindBackButtonHover();
bindAndLoadAdditionalOptions();
bindInvoice();
showSummary();
$("#show-regulations").click(showRulesAndRegulations);
$("#preauth-more-info").click(showPreauthMoreInfo);
}
if (offerAdvanceLocked[currentOffer]) {
$("#payment-full").attr("checked", "checked");
$("#payment-advance").attr("disabled", "disabled");
}
updateSummary();
}/*}}}*/
function loadStep1() {/*{{{*/
activeStep = 1;
$(".thumbs-outer").show('slow');
setTimeout("slideOffers()", 6000);
sliderDirection = "left";
$(".calendar").show('slow');
$(".ofert-info").show('slow');
$(".step2-left").hide('slow');
$(".step2-right").hide('slow');
$(".step").each(function() {
$(this).removeClass("selected");
});
$("#step1-top").addClass("selected");
$("#back-button").unbind();
$("#back-button").val("Resetuj");
$("#back-button").click(function() {
window.location.reload();
});
extensionsPrice = 0;
extensionsCount = 0;
updateSummary();
selectionDone();
}/*}}}*/
function selectionDone() {/*{{{*/
loadRooms(offer_id);
if (roomSelected() && offer_id) {
queueRequest();
$.get("/div/total/" + offer_id + "/" + selectionDateStart + "/" + selectionDateEnd + "/" + roomsString(), function(response) {
dequeueRequest();
totalPrice = response;
queueRequest();
$.get("/div/discount/" + offer_id + "/" + selectionDateStart + "/" + selectionDateEnd, function(response) {
dequeueRequest();
discount = parseFloat(response);
$("#total-price").html((parseFloat(totalPrice) - parseFloat(totalPrice) * discount).toFixed(2) + " zł");
});
});
}
$("#period-of-stay-start").html(selectionDateStart);
$("#period-of-stay-end").html(selectionDateEnd);
if (roomSelected()) {
$('#makeReservationButton').unbind();
$('#makeReservationButton').click(function() {
if (offer_id && roomSelected()) {
loadStep2(0);
}
});
bindReservationButtonHover();
}
}/*}}}*/
function bindReservationButtonHover() {/*{{{*/
$("#makeReservationButton").css("background-image", "url(/img/dalej1.png)");
$("#makeReservationButton").mouseover(function() {
$(this).css("background-image", "url(/img/dalej2.png)");
});
$("#makeReservationButton").mouseout(function() {
$(this).css("background-image", "url(/img/dalej1.png)");
});
}/*}}}*/
function markSelection(currentId, force) {/*{{{*/
var cell_id = '';
var date_parts = selectionDateStart.split("-");
var current_date = new Date();
var current_month = '';
var current_day = '';
var lastDay = 0;
current_date.setFullYear(parseInt(date_parts[0], 10), parseInt(date_parts[1], 10) - 1, parseInt(date_parts[2], 10));
$('.day, .selected').each(function() {
if ($(this).hasClass('day')) {
$(this).removeClass('selected');
}
});
while (cell_id != currentId) {
if (lastDay) {
return false;
}
current_month = current_date.getMonth()+1;
current_day = current_date.getDate();
if (current_month.toString().length == 1) {
current_month = "0"+current_month;
}
if (current_day.toString().length == 1) {
current_day = "0"+current_day;
}
cell_id = "day_"+current_date.getFullYear()+"-"+current_month+"-"+current_day;
if (!$("#"+cell_id).hasClass('selectable') && !force) {
if (lastDay) {
return false;
} else {
lastDay = 1;
}
}
$("#"+cell_id).addClass('selected');
current_date.setDate(current_date.getDate()+1);
}
$(".day-price").hide();
return true;
}/*}}}*/
function isTurn(id) {/*{{{*/
if (offerMinDays[id] != 0 && offerMinDays[id] == offerMaxDays[id]) {
return true;
} else {
return false;
}
}/*}}}*/
function bindPrevAndNextMonth(date_from) {/*{{{*/
var dateFromParts = date_from.split("-");
var nextMonth = new Date();
var prevMonth = new Date();
nextMonth.setFullYear(dateFromParts[0], parseInt(dateFromParts[1], 10) - 1, parseInt(dateFromParts[2], 10));
prevMonth.setFullYear(dateFromParts[0], parseInt(dateFromParts[1], 10) - 1, parseInt(dateFromParts[2], 10));
prevMonth.setDate(prevMonth.getDate() - 1);
nextMonth.setDate(nextMonth.getDate() + 31);
$("#next-month").unbind();
$("#prev-month").unbind();
$("#prev-month").click(function() {
$("#month-and-year").html(months[prevMonth.getMonth() + 1]+" "+prevMonth.getFullYear());
getCalendar(prevMonth.getFullYear()+"-"+(prevMonth.getMonth() + 1)+"-01");
});
$("#next-month").click(function() {
$("#month-and-year").html(months[nextMonth.getMonth() + 1]+" "+nextMonth.getFullYear());
getCalendar(nextMonth.getFullYear()+"-"+(nextMonth.getMonth() + 1)+"-01");
});
}/*}}}*/
function checkSelection(date_from, date_to) {/*{{{*/
var cell_id = '';
var date_parts = date_from.split("-");
var endId = "day_"+date_to;
var current_date = new Date();
var current_month = '';
var current_day = '';
var lastDay = 0;
current_date.setFullYear(parseInt(date_parts[0], 10), parseInt(date_parts[1], 10) - 1, parseInt(date_parts[2], 10));
while (cell_id != endId) {
if (lastDay) {
return false;
}
current_month = current_date.getMonth()+1;
current_day = current_date.getDate();
if (current_month.toString().length == 1) {
current_month = "0"+current_month;
}
if (current_day.toString().length == 1) {
current_day = "0"+current_day;
}
cell_id = "day_"+current_date.getFullYear()+"-"+current_month+"-"+current_day;
if (!$("#"+cell_id).hasClass('selectable')) {
if (lastDay) {
return false;
} else {
lastDay = 1;
}
}
current_date.setDate(current_date.getDate()+1);
}
return true;
}/*}}}*/
function selectPeriod(date_from, date_to) {/*{{{*/
var old_date_from = selectionDateStart;
var old_date_to = selectionDateEnd;
selectionDateStart = date_from;
selectionDateEnd = date_to;
/*
if (!checkSelection(date_from, date_to)) {
selectionDateStart = old_date_from;
selectionDateEnd = old_date_to;
return;
}
*/
clearSelection();
markSelection("day_"+selectionDateEnd, 1);
undoSelect = $("#day_"+selectionDateEnd).html();
undoElement = $("#day_"+selectionDateEnd);
$("#day_"+selectionDateEnd).html(' dzień wyjazdu');
$("#day_"+selectionDateEnd).addClass('selection-end');
selectionDone();
$("#day_"+selectionDateStart).addClass('selection-start');
selectionCurrentDate = currentDateFrom;
currentOffer = offer_id;
}/*}}}*/
function periodEnd(date_from, number_of_days) {/*{{{*/
var start = new Date();
var day = "";
var month = "";
var firstDay = date_from.split("-");
start.setFullYear(firstDay[0], parseInt(firstDay[1], 10) - 1, parseInt(firstDay[2], 10));
start.setDate(start.getDate()+parseInt(number_of_days));
day = start.getDate();
month = start.getMonth() + 1;
if (day < 10) {
day = "0" + day;
}
if (month < 10) {
month = "0" + month;
}
return start.getFullYear()+'-'+month+'-'+day;
}/*}}}*/
function clearSelection() {/*{{{*/
$(".selection-start").removeClass('selection-start');
$(".selection-end").removeClass('selection-end');
if (undoElement) {
undoElement.html(undoSelect);
undoElement = false;
}
$("#period-of-stay-start").html("nie wybrano");
$("#period-of-stay-end").html("nie wybrano");
$("#total-price").html("----");
$('#makeReservationButton').unbind();
$(".day-price").show();
$(".selected").each(function() {
if ($(this).hasClass("day")) {
$(this).removeClass("selected");
}
});
}/*}}}*/
function getCalendar(date_from) {/*{{{*/
currentDateFrom = date_from;
var turnsSuffix = "";
if (isTurn(offer_id)) {
turnsSuffix = "/turns:" + $("#turnsAmount").val();
}
queueRequest();
$.get('/reservations/calendar/'+offer_id+'/'+date_from+'/'+roomsString()+turnsSuffix, function(xml) {
dequeueRequest();
var calendarCode = '';
var firstDay = '';
var dateParts = [];
var current_date = new Date();
var dayOfWeek = 0;
var emptyDays = 0;
var error = $("error", xml).text();
if (error) {
showError(error);
return;
}
$("days day", xml).each(function() {
if (firstDay == '') {
firstDay = $('date', this).text().split('-');
current_date.setFullYear(firstDay[0], parseInt(firstDay[1], 10) - 1, parseInt(firstDay[2], 10));
dayOfWeek = current_date.getDay();
if (dayOfWeek == 0) {
emptyDays = 6;
} else {
emptyDays = dayOfWeek - 1;
}
for (i = 0; i < emptyDays; i++) {
calendarCode += '';
}
} else {
dayOfWeek++;
if (dayOfWeek == 7) {
dayOfWeek = 0;
}
}
dateParts = $('date', this).text().split('-');
if (firstDay[1] != dateParts[1] && dateParts[2] == "01") {
calendarCode += '';
calendarCode += ''+months[parseInt(dateParts[1], 10)]+' '+dateParts[0]+'
';
if (dayOfWeek == 0) {
emptyDays = 6;
} else {
emptyDays = dayOfWeek - 1;
}
for (i = 0; i < emptyDays; i++) {
calendarCode += '';
}
}
if ($('price', this).text() != '-1') {
if (roomSelected()) {
calendarCode += ''+dateParts[2]+'od '+parseFloat($('price', this).text()).toFixed(2)+'zł
';
} else {
if (isTurn(offer_id)) {
calendarCode += ''+dateParts[2]+'start
';
} else {
calendarCode += ''+dateParts[2]+'
';
}
}
} else {
calendarCode += ''+dateParts[2]+'
';
}
});
$('.day, .selected').each(function() {
$(this).unbind();
});
selectionStarted = false;
$('#calendarDays').html(calendarCode);
bindPrevAndNextMonth(date_from);
if (selectionDateStart != "" && selectionDateEnd != "" && selectionCurrentDate == currentDateFrom && currentOffer == offer_id) {
selectPeriod(selectionDateStart, selectionDateEnd);
}
$('.day, .selected').each(function() {
$(this).click(function() {
if (selectionStarted) {
var details = this.id.split("_");
if (!markSelection(this.id, 0) || selectionDateStart == details[1] || daysCount(selectionDateStart, details[1]) < offerMinDays[offer_id] || (offerMaxDays[offer_id] != 0 && daysCount(selectionDateStart, details[1]) > offerMaxDays[offer_id])) {
return;
}
selectionStarted = 0;
selectionDateEnd = details[1];
selectionCurrentDate = currentDateFrom;
currentOffer = offer_id;
undoSelect = $(this).html();
undoElement = $(this);
$(this).html(' dzień wyjazdu');
$(this).addClass('selection-end');
selectionDone();
} else {
if (!$(this).hasClass('selectable')) {
return;
}
var details = this.id.split("_");
if (isTurn(offer_id)) {
selectPeriod(details[1], periodEnd(details[1], offerMaxDays[offer_id] * $("#turnsAmount").val()));
return;
}
selectionStarted = 1;
selectionDateStart = details[1];
selectionDateEnd = '';
clearSelection();
$(this).addClass('selection-start');
}
});
$(this).mouseover(function() {
if (selectionStarted) {
markSelection(this.id, 0);
}
});
});
});
}/*}}}*/
function showError(error) {/*{{{*/
$(".thumbs").hide('slow');
$(".calendar").hide('slow');
$(".ofert-info").hide('slow');
$(".more-info").hide('slow');
$(".regulations").html(error);
$(".regulations").show('slow');
$(".ofert-details").css("background-image", "url(/img/tlo2.png)");
$("#makeReservationButton").hide('slow');
// $("#back-button").hide('slow');
}/*}}}*/
function moreInfoShow(event) {/*{{{*/
$(".calendar").hide('slow');
$(".more-info").show('slow');
scrollPosition = $(".content").scrollTop();
$(".content").animate({scrollTop : 0}, 'slow');
$(".hide-more-info").unbind();
$(".hide-more-info").click(function() {
$(".more-info").hide('slow');
$(".calendar").show('slow');
$(".content").animate({ scrollTop : scrollPosition}, 'slow');
});
}/*}}}*/
function showRulesAndRegulations() {/*{{{*/
$(".step2-left").hide('slow');
$(".step2-right").hide('slow');
$(".regulations").show('slow');
$(".ofert-details").css("background-image", "url(/img/tlo2.png)");
$("#makeReservationButton").hide('slow');
$("#back-button").hide('slow');
$(".hide-regulations").click(function() {
$(".step2-left").show('slow');
$(".step2-right").show('slow');
$(".regulations").hide('slow');
$(".ofert-details").css("background-image", "url(/img/tlo.png)");
$("#makeReservationButton").show('slow');
$("#back-button").show('slow');
});
}/*}}}*/
function showPreauthMoreInfo() {/*{{{*/
$(".step2-left").hide('slow');
$(".step2-right").hide('slow');
$(".preauth-info").show('slow');
$(".ofert-details").css("background-image", "url(/img/tlo2.png)");
$("#makeReservationButton").hide('slow');
$("#back-button").hide('slow');
$(".hide-preauth-info").click(function() {
$(".step2-left").show('slow');
$(".step2-right").show('slow');
$(".preauth-info").hide('slow');
$(".ofert-details").css("background-image", "url(/img/tlo.png)");
$("#makeReservationButton").show('slow');
$("#back-button").show('slow');
});
}/*}}}*/
function bindRoomsMoreInfo() {/*{{{*/
$(".room-more-info").each(function() {
var moreid = this.id.replace("room-more-info", "");
$(this).click(function(event) {
$(".more-info").html('
'+roomDescriptions[moreid]+'
');
moreInfoShow(event);
});
});
}/*}}}*/
function showMoreInfo(id, description, no_back_button, event) {/*{{{*/
var content = '
'+description+'
';
if (!no_back_button) {
content += '';
}
$(".more-info").html(content);
moreInfoShow(event);
}/*}}}*/
function bindOffersMoreInfo(id, description) {/*{{{*/
$("#offer-more-info").click(function(event) {
showMoreInfo(id, description, 0, event);
});
}/*}}}*/
function bindRoomsEvents() {/*{{{*/
$(".room").each(function() {
var room_id = parseInt(this.id.replace("room_", ""));
$(".room-select-"+room_id).each(function() {
$(this).click(function() {
if ($("#rooms_amount_"+room_id).val() == 0) {
$("#rooms_amount_"+room_id).val("1");
if ($("#rooms_amount_"+room_id).val() == "1") {
getCalendar(currentDateFrom);
$("#room_"+room_id).addClass("room-selected");
if (selectionDateStart != "" && selectionDateEnd != "") {
selectionDone();
}
}
} else {
$("#room_"+room_id).removeClass("room-selected");
$("#rooms_amount_"+room_id).val("0");
onlyRoom = 0;
}
});
});
$(this).mouseover(function() {
$(".room").each(function() {
$(this).removeClass('room-hover');
});
$(this).addClass('room-hover');
});
$(this).mouseout(function() {
$(this).removeClass('room-hover');
});
});
$(".room_amount").each(function() {
$(this).change(function() {
var room_id = this.id.replace("rooms_amount_", "");
getCalendar(currentDateFrom);
if (selectionDateStart != "" && selectionDateEnd != "") {
selectionDone();
}
if ($(this).val() == "0") {
onlyRoom = 0;
$("#room_"+room_id).removeClass("room-selected");
} else {
$("#room_"+room_id).addClass("room-selected");
}
});
});
}/*}}}*/
function loadRooms(for_offer_id) {/*{{{*/
queueRequest();
roomAmounts = [];
roomIds = [];
if (for_offer_id == offer_id) {
$(".room_amount").each(function() {
roomAmounts.push($(this).val());
});
$(".room").each(function() {
roomIds.push(this.id.replace("room_", ""));
});
}
$.get('/rooms/index/' + for_offer_id + '/date_from:' + selectionDateStart + '/date_to:' + selectionDateEnd + '/' + roomsString(), function(xml) {
dequeueRequest();
var roomsList = '';
roomNames = [];
roomDescriptions = [];
roomPrices = [];
$("rooms room", xml).each(function() {
var currentId = parseInt($('id', this).text(), 10);
var currentAmount = parseInt($('amount', this).text());
if (parseInt($('amount', this).text()) > 5) {
currentAmount = 5;
}
if (currentAmount != 0 && parseFloat($('price', this).text()) > 0) {
var selectedAmount;
var capacityIco = $('capacity', this).text();
if (parseInt(capacityIco) > 6) {
capacityIco = "x";
}
selectedAmount = 0;
for (i=0;i'+
''+
''+
''+$('name', this).text()+''+
''+parseFloat($('price', this).text()).toFixed(2)+'zł'+
'
'+
''+
'
więcej informacji'+
'
';
if (currentAmount > 1) {
roomsList += 'Ilość pokoi:'+
'';
} else {
roomsList += '';
}
roomsList += ''+
'
'+
'';
}
roomNames[currentId] = $('name', this).text();
roomDescriptions[currentId] = $('description', this).text();
roomPrices[currentId] = parseFloat($('price', this).text());
roomCapacities[currentId] = parseInt($('capacity', this).text());
roomMaxExtensionCounts[currentId] = parseInt($('max_extensions_count', this).text());
});
$("#rooms").html(roomsList);
bindRoomsMoreInfo();
bindRoomsEvents();
if (onlyRoom && $("#rooms_amount_"+onlyRoom).val() == 0) {
$("#rooms_amount_"+onlyRoom).val("1");
getCalendar(currentDateFrom);
$("#room_"+onlyRoom).addClass("room-selected");
if (selectionDateStart != "" && selectionDateEnd != "") {
selectionDone();
}
}
});
}/*}}}*/
function getOffers(parent_id, offerToLoad) {/*{{{*/
$(".thumbs").css('margin-left', '0');
$(".thumbs").hide('slow');
queueRequest();
$.get('/offers/index/' + parent_id, function(xml) {
dequeueRequest();
var offersList = '';
var alreadySelected = offerToLoad;
if (parent_id) {
sliderOffers = 1;
offersList += ''+
'
Wstecz
'+
'
'+
'
';
} else {
sliderOffers = 0;
}
$("offers offer", xml).each(function() {
var currentId = parseInt($('id', this).text());
sliderOffers += 1;
offersList += ''+
'
'+$('name', this).text()+'
'+
'
'+
'
od '+parseFloat($('price', this).text()).toFixed(2)+'zł';
if ($('price_per_stay', this).text() != "1") {
offersList += '/noc';
}
offersList += '
';
offerNames[currentId] = $('name', this).text();
offerDescriptions[currentId] = $('description', this).text();
offerShortDescriptions[currentId] = $('short_description', this).text();
offerPrices[currentId] = $('price', this).text();
offerMinDays[currentId] = parseInt($('minimum', this).text());
offerMaxDays[currentId] = parseInt($('maximum', this).text());
offerUnfolds[currentId] = parseInt($('unfold', this).text());
offerParents[currentId] = parseInt($('parent_id', this).text());
offerPricePerStay[currentId] = parseInt($('price_per_stay', this).text());
offerDateFrom[currentId] = $('date_from', this).text();
offerAdvanceLocked[currentId] = parseInt($('advance_locked', this).text());
if ($('payment_offline_locked', this).text() == "1") {
offerPaymentOfflineLocked[currentId] = 1;
} else {
offerPaymentOfflineLocked[currentId] = 0;
}
if ($('payment_online_locked', this).text() == "1") {
offerPaymentOnlineLocked[currentId] = 1;
} else {
offerPaymentOnlineLocked[currentId] = 0;
}
if ($('payment_preauth_locked', this).text() == "1") {
offerPaymentPreauthLocked[currentId] = 1;
} else {
offerPaymentPreauthLocked[currentId] = 0;
}
if ($('payment_reception_locked', this).text() == "1") {
offerPaymentReceptionLocked[currentId] = 1;
} else {
offerPaymentReceptionLocked[currentId] = 0;
}
if ($('payment_enquiry_locked', this).text() == "1") {
offerPaymentEnquiryLocked[currentId] = 1;
} else {
offerPaymentEnquiryLocked[currentId] = 0;
}
if (!alreadySelected) {
alreadySelected = currentId;
}
});
$(".thumbs").html(offersList);
if (sliderOffers > 1) {
$(".thumbs-outer").show();
$(".thumbs").show('slow');
} else {
$(".thumbs-outer").hide();
}
selectOffer(alreadySelected);
$(".thumbs .thumb").each(function() {
$(this).click(function() {
var currentId = parseInt(this.id.replace('offer', ''));
if (this.id == "offer_back") {
getOffers(offerParents[parent_id], 0);
} else {
offerClick(currentId);
}
});
});
});
}/*}}}*/
function offerClick(currentId) {/*{{{*/
firstDisplay = 0;
$("#left-arrow").hide();
$("#right-arrow").hide();
$(".thumbs").css("width", "767px");
$(".thumbs").css("height", "auto");
$(".thumbs-frame").css("height", "auto");
$(".thumbs-outer").css("height", "auto");
if (offerUnfolds[currentId]) {
getOffers(currentId, 0);
} else {
selectOffer(currentId);
}
selectionDateStart = '';
}/*}}}*/
function selectOffer(id) {/*{{{*/
var name = offerNames[id];
var description = offerDescriptions[id];
var short_description = offerShortDescriptions[id];
var offerDateFromParts = offerDateFrom[id].split("-");
var offerDateFromDay = new Date(offerDateFromParts[0], parseInt(offerDateFromParts[1], 10) - 1, parseInt(offerDateFromParts[2], 10));
var today = new Date();
$("#offer-name").html(name);
if (today.getTime() - offerDateFromDay.getTime() < 0) { // offer begins in future
$("#month-and-year").html(months[offerDateFromDay.getMonth() + 1]+" "+offerDateFromDay.getFullYear());
currentDateFrom = offerDateFrom[id];
} else {
if (savedCurrentDateFrom != "") {
var savedYear = savedCurrentDateFrom.split("-")[0];
var savedMonth = parseInt(savedCurrentDateFrom.split("-")[1], 10);
$("#month-and-year").html(months[savedMonth]+" "+savedYear);
currentDateFrom = savedCurrentDateFrom;
savedCurrentDateFrom = "";
} else {
$("#month-and-year").html(months[today.getMonth() + 1]+" "+today.getFullYear());
currentDateFrom = '2024-05-01';
}
}
roomIds = [];
roomAmounts = [];
offer_id = id;
$("#turnsAmount").val(1);
$(".thumbs .thumb").each(function() {
$(this).removeClass('select-thumb');
});
$(".thumbs #offer"+id).addClass('select-thumb');
$('.ofert-info .title').html(''+name);
$('.ofert-info .informations').html(short_description+'więcej informacji
');
if (!offerUnfolds[id]) {
$(".ofert-info").show('slow');
$(".choose-offer").hide('slow');
bindOffersMoreInfo(id, description);
loadRooms(id);
$("#turns").unbind();
if (isTurn(id)) {
$("#turns").show();
$("#turnsAmount").change(function() {
clearSelection();
selectionDateStart = "";
selectionDateEnd = "";
getCalendar(currentDateFrom);
loadRooms(offer_id);
});
} else {
$("#turns").hide();
}
} else {
$(".ofert-info").hide('slow');
$(".choose-offer").show('slow');
}
getCalendar(currentDateFrom);
}/*}}}*/
function bindBackButtonHover() {/*{{{*/
$(".button-style").mouseover(function() {
$(this).css("background-image", "url(/img/button2.png)");
});
$(".button-style").mouseout(function() {
$(this).css("background-image", "url(/img/button1.png)");
});
}/*}}}*/
function bindSliderArrows() {/*{{{*/
$("#left-arrow").click(function() {
var currentMargin = parseInt($(".thumbs").css('margin-left'));
if (currentMargin >= 0) {
$(".thumbs").css('margin-left', "0px");
} else {
if (currentMargin > -625) {
$(".thumbs").animate({ marginLeft : '0' });
} else {
$(".thumbs").animate({ marginLeft : '+=625' });
}
}
});
$("#right-arrow").click(function() {
var currentMargin = parseInt($(".thumbs").css('margin-left'));
if (currentMargin <= -125*Math.max(sliderOffers - 5, 0)) {
$(".thumbs").css('margin-left', (-125*Math.max(sliderOffers - 5, 0))+"px");
} else {
if (currentMargin < 625-125*Math.max(sliderOffers - 5, 0)) {
$(".thumbs").animate({ marginLeft : -125*Math.max(sliderOffers - 5, 0) });
} else {
$(".thumbs").animate({ marginLeft : '-=625' });
}
}
});
$(".thumbs-outer").live('mouseover', function() {
if (firstDisplay) {
return;
}
if (sliderDirection != "none") {
$(".thumbs").animate({ marginLeft : '0' });
sliderDirection = "none";
}
$("#left-arrow").hide();
$("#right-arrow").hide();
$(".thumbs").css("width", "767px");
$(".thumbs").css("height", "auto");
$(".thumbs-frame").css("height", "auto");
$(".thumbs-outer").css("height", "auto");
// $(".thumbs-frame").css("margin-left", "68px");
});
$(".thumbs-outer").live('mouseout', function() {
if (firstDisplay) {
return;
}
$("#left-arrow").show();
$("#right-arrow").show();
$(".thumbs").css("width", "2000px");
$(".thumbs").css("height", "95px");
$(".thumbs-frame").css("height", "93px");
$(".thumbs-outer").css("height", "95px");
$(".thumbs-frame").css("margin-left", "0");
});
$("#left-arrow").mouseover(function() {
$(this).css('background', 'url(/img/le1.png)');
});
$("#left-arrow").mouseout(function() {
$(this).css('background', 'url(/img/le2.png)');
});
$("#right-arrow").mouseover(function() {
$(this).css('background', 'url(/img/r1.png)');
});
$("#right-arrow").mouseout(function() {
$(this).css('background', 'url(/img/r2.png)');
});
}/*}}}*/
function slideOffers() {/*{{{*/
if (sliderDirection == "none") {
return;
}
var currentMargin = parseInt($(".thumbs").css('margin-left'));
if (sliderDirection == "right") {
if (currentMargin >= 0) {
$(".thumbs").css('margin-left', "0px");
sliderDirection = "left";
} else {
$(".thumbs").css('margin-left', (currentMargin + 2)+"px");
}
}
if (sliderDirection == "left") {
if (currentMargin <= -125*Math.max(sliderOffers - 6, 0)) {
$(".thumbs").css('margin-left', (-125*Math.max(sliderOffers - 6, 0))+"px");
sliderDirection = "right";
} else {
$(".thumbs").css('margin-left', (currentMargin - 2)+"px");
}
}
setTimeout("slideOffers()", 100);
}/*}}}*/
function bindStepsTop() {
$("#step1-top").live('click', function() {
if (activeStep != 2) {
return;
}
loadStep1();
});
$("#step2-top").live('click', function() {
if (activeStep != 3) {
return;
}
loadStep2(1);
});
}
$(document).ready(function() {/*{{{*/
var currentLocation = new String(document.location);
var offerToLoad = 1;
var parentToLoad = 0;
var language = 'pol';
var reservationSource = '';
var params = currentLocation.split("?");
if (params.length > 1) {
params = params[1].split("&");
for (i=0;i