");
div.attr("id", "moreInfo");
div.load(url, req);
var mainDiv = createBlackPage('80%', '80%');
mainDiv.append(div);
}
function openVideo(videoCode, upperText, lowerText) {
var req= { "rnd" : new Date().getTime(), "videoCode" : videoCode, "upperText" : upperText, "lowerText" : lowerText, "OVERLAY" : 'yes' };
var url = contextPath + '/applications/webwork/site_ibike/local/portlet/wp_YouTubeVideo.jsp';
var div = $("
");
div.attr("id", "videoWrapper");
div.load(url, req);
var mainDiv = createBlackPage('80%', '80%');
mainDiv.append(div);
}
function openSpecialOffer(discount) {
if(!discount)
discount = '10';
var req= { "discount": discount, "rnd" : new Date().getTime() };
var url = contextPath + '/applications/webwork/site_ibike/local/parts/partSpecialOffer.jsp';
var div = $("
");
div.attr("id", "specialOffer");
div.load(url, req);
var mainDiv = createBlackPage('50%', '40%');
mainDiv.append(div);
}
/********************** PRENOTAZIONI **********************/
function managePurchaseButtons(eventId, quantity, date, periodStartLong, periodId, sendEmail) {
var privacy = $('#privacy');
var buyerEmail = $('#buyerEmail');
var buyerEmailValue = buyerEmail.val();
var name = $('#name');
var surname = $('#surname');
var phone = $('#phone');
var ebike = $('#ebike');
if(buyerEmailValue=='') {
highlight(buyerEmail);
buyerEmail.focus();
privacy.attr('checked', false);
return false;
}
if (echeck(buyerEmailValue)==false) {
buyerEmail.val('');
buyerEmail.focus();
privacy.attr('checked', false);
return false;
}
if(!valuesConcordanceVerifier('buyerEmail', 'confirmEmail')) {
privacy.attr('checked', false);
return false;
}
if(name.val()=='') {
highlight(name);
name.focus();
privacy.attr('checked', false);
return false;
}
if(surname.val()=='') {
highlight(surname);
surname.focus();
privacy.attr('checked', false);
return false;
}
if(ebike.val()=='') {
highlight(ebike);
ebike.focus();
privacy.attr('checked', false);
return false;
}
if(phone.val()=='') {
highlight(phone);
phone.focus();
privacy.attr('checked', false);
return false;
}
if(privacy.is(':checked')) {
var ebikeVal = ebike.val();
var phoneVal = phone.val();
var lodging = $('#lodging').val();
// user data in session
var data = 'buyerEmail=' + buyerEmailValue +
'&name=' + name.val() +
'&surname=' + surname.val() +
(eventId ? '&eventId=' + eventId : '' ) +
(periodId ? '&periodId=' + periodId : '' ) +
(quantity ? '&quantity=' + quantity : '' ) +
(date ? '&date=' + date : '' ) +
(periodStartLong ? '&periodStartLong=' + periodStartLong : '' ) +
(ebikeVal ? '&ebike=' + ebikeVal : '' ) +
(phoneVal ? '&phone=' + phoneVal : '' ) +
(lodging ? '&lodging=' + lodging : '' ) +
'&ts=' + new Date().getTime();
$.ajax({
type: "POST",
dataType: "html",
url: contextPath + '/applications/webwork/site_ibike/local/parts/ajaxSessionAndOrderManager.jsp',
data: data,
cache:false,
success: function(html) {
if(html || sendEmail) {
// form to pay via credit card
$('#realCC').html(html);
lazyload();
$('#fakePP').hide();
$('#realPP').show();
$('#fakeCC').hide();
$('#realCC').show();
$('#fakeMail').hide();
$('#realMail').show();
// setto il valore reale nel campo invoice di paypal
var orderId = $('#realCC').find('#ORDER_ID').val();
$('#realPP').find('#invoice').val(orderId);
} else {
$('#realPP').hide();
$('#fakePP').show();
$('#realMail').hide();
$('#fakeMail').show();
$('#realCC').empty();
$('#realCC').hide();
$('#fakeCC').show();
}
}
});
} else {
highlight(privacy);
$('#realPP').hide();
$('#fakePP').show();
$('#realCC').hide();
$('#fakeCC').show();
$('#realMail').hide();
$('#fakeMail').show();
}
return true;
}
function eBikeMesseger(el) {
var $this = $(el);
if($this.val()>0) {
$('#ebikeDisclaimer').fadeIn('slow');
} else {
$('#ebikeDisclaimer').fadeOut('slow');
}
}
function mailSender(divId, pageId, eventId, focusMills, bookings, roofedDeposit, periodId, emailTargetPageCompleteURL) {
var theForm = document.createElement('form');
theForm.action = emailTargetPageCompleteURL;
theForm.method = 'post';
var sendMail = document.createElement('input');
sendMail.type = 'hidden';
sendMail.id = 'MAIL_GO';
sendMail.name = 'MAIL_GO';
sendMail.value = 'yes';
theForm.appendChild(sendMail);
var isPurchase = document.createElement('input');
isPurchase.type = 'hidden';
isPurchase.id = 'isPurchase';
isPurchase.name = 'isPurchase';
isPurchase.value = 'yes';
theForm.appendChild(isPurchase);
var name = document.createElement('input');
name.type = 'hidden';
name.id = 'name';
name.name = 'name';
name.value = $('#name').val();
theForm.appendChild(name);
var surname = document.createElement('input');
surname.type = 'hidden';
surname.id = 'surname';
surname.name = 'surname';
surname.value = $('#surname').val();
theForm.appendChild(surname);
var email = document.createElement('input');
email.type = 'hidden';
email.id = 'email';
email.name = 'email';
email.value = $('#buyerEmail').val();
theForm.appendChild(email);
var period = document.createElement('input');
period.type = 'hidden';
period.id = 'periodId';
period.name = 'periodId';
period.value = periodId;
theForm.appendChild(period);
var millis = document.createElement('input');
millis.type = 'hidden';
millis.id = 'FOCUS_MILLIS';
millis.name = 'FOCUS_MILLIS';
millis.value = focusMills;
theForm.appendChild(millis);
var book = document.createElement('input');
book.type = 'hidden';
book.id = 'bookings';
book.name = 'bookings';
book.value = bookings;
theForm.appendChild(book);
var roofedDep = document.createElement('input');
roofedDep.type = 'hidden';
roofedDep.id = 'roofedDeposit';
roofedDep.name = 'roofedDeposit';
roofedDep.value = roofedDeposit;
theForm.appendChild(roofedDep);
var ebike = document.createElement('input');
ebike.type = 'hidden';
ebike.id = 'ebike';
ebike.name = 'ebike';
ebike.value = $('#ebike').val();
theForm.appendChild(ebike);
var lodging = document.createElement('input');
lodging.type = 'hidden';
lodging.id = 'lodging';
lodging.name = 'lodging';
lodging.value = $('#lodging').val();
theForm.appendChild(lodging);
var phone = document.createElement('input');
phone.type = 'hidden';
phone.id = 'phone';
phone.name = 'phone';
phone.value = $('#phone').val();
theForm.appendChild(phone);
var notes = document.createElement('input');
notes.type = 'hidden';
notes.id = 'userNotes';
notes.name = 'userNotes';
notes.value = $('#usernotes').val();
theForm.appendChild(notes);
var discountCode = document.createElement('input');
discountCode.type = 'hidden';
discountCode.id = 'discountCode';
discountCode.name = 'discountCode';
discountCode.value = $('#discountCode').val();
theForm.appendChild(discountCode);
var event = document.createElement('input');
event.type = 'hidden';
event.id = 'eventId';
event.name = 'eventId';
event.value = eventId;
theForm.appendChild(event);
var mid = document.createElement('input');
mid.type = 'hidden';
mid.id = 'MID';
mid.name = 'MID';
mid.value = pageId;
theForm.appendChild(mid);
document.getElementById('hidden_form_container').appendChild(theForm);
theForm.submit();
}
// Register onpaste on inputs and textareas in browsers that don't natively support it.
(function () {
var onload = window.onload;
window.onload = function () {
if (typeof onload == "function")
onload.apply(this, arguments);
var fields = [];
var inputs = document.getElementsByTagName("input");
var textareas = document.getElementsByTagName("textarea");
for (var a = 0; a < inputs.length; a++)
fields.push(inputs[a]);
for (var b = 0; b < textareas.length; b++)
fields.push(textareas[b]);
for (var i = 0; i < fields.length; i++) {
var field = fields[i];
if (typeof field.onpaste != "function" && !!field.getAttribute("onpaste"))
field.onpaste = eval("(function () { " + field.getAttribute("onpaste") + " })");
if (typeof field.onpaste == "function") {
var oninput = field.oninput;
field.oninput = function () {
if (typeof oninput == "function")
oninput.apply(this, arguments);
if (typeof this.previousValue == "undefined")
this.previousValue = this.value;
var pasted = (Math.abs(this.previousValue.length - this.value.length) > 1 && this.value != "");
if (pasted && !this.onpaste.apply(this, arguments))
this.value = this.previousValue;
this.previousValue = this.value;
};
if (field.addEventListener)
field.addEventListener("input", field.oninput, false);
else if (field.attachEvent)
field.attachEvent("oninput", field.oninput);
}
}
}
})();