var book_transfers_together = new Array(); var global_SingleNum = 0, global_SharedTwinNum = 0; $(document).ready(function(){ book_transfers_together[0] = result_package_price("/api/api.asp?method=cht.single-city-tour.day-trip-price&name=airport-pickup-and-transfer-to-chongqing-dock&city=chongqing"); book_transfers_together[1] = result_package_price("/api/api.asp?method=cht.single-city-tour.day-trip-price&name=airport-pickup-and-transfer&city=yichang"); var total_package_price, book_transfers_together_price0 = 0, book_transfers_together_price1 = 0; var cruise_price = 0; $("#AdulteNum,#ChildNum,#BabyNum,#SingleNum,#SharedTwinNum").change(function(){ var obj = $(this), id = obj.attr("id"); write_price("#js_toralprice", get_cruise_price(id)); if (id != "SingleNum" && id != "SharedTwinNum"){ if("checked" == $(".daytripsbox0").attr("checked")) book_transfers_together_price0 = get_package_price(0); if("checked" == $(".daytripsbox1").attr("checked")) book_transfers_together_price1 = get_package_price(1); total_package_price = (function(book_transfers_together_price0, book_transfers_together_price1){ $("#js_daytrips_extendprice").html(""); $("#js_daytrips_extendprice").html("USD " + parseInt(book_transfers_together_price0 + book_transfers_together_price1)); return "USD " + book_transfers_together_price0 + book_transfers_together_price1; })(book_transfers_together_price0, book_transfers_together_price1); } merge_total_price(get_cruise_price(id, 1)); }); $(".transferTitle,.transferTitle img").click(function(){ $(".noteInfo").show(); }); $("#paynow_button").click(function(){ $(".arrowUp").show(); if($("#ship_order_info").css("display") == "none"){ makeInitForm("Adulte"); makeInitForm("Child"); makeInitForm("Baby"); effectForm(); $("#AdulteNum,#ChildNum,#BabyNum").change(function(){ effectForm(); }); $("#AdulteNum").change(function(){ makeWorkForm("Adulte");}); $("#ChildNum").change(function(){ makeWorkForm("Child");}); $("#BabyNum").change(function(){ makeWorkForm("Baby");}); }else{ if($("#ship_order_info").css("display") != "none"){ var AdulteI = IsEmptyOrNotNum("AdulteNum", "Please select the number of Auduts in your group.", "", false); var realnameI = StrIsNullOrEmpty("realname", "Please fill in your full name.", "", "", false); var NationalityI = StrIsNullOrEmpty("Nationality", "Please fill in your Nationality.", "", "", false); var emailI = RegCkElement("email", "Please fill in a valid email address! example: yourname@domain.com", "^([a-zA-Z0-9_-_\.])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-])+", "", "", false); var PhoneNoI = StrIsNullOrEmpty("PhoneNo", "Please fill in your phone number", "", "", false); if (!IsEmptyOrNotNum("ChildNum")) $("#ChildNum").val("0"); if (!IsEmptyOrNotNum("BabyNum")) $("#BabyNum").val("0"); if (!IsEmptyOrNotNum("days")) $("#days").val("0"); $("#email,#email2").click(function(){ $(".arrowDownTest").hide(); }); if($("#email").val() != $("#email2").val()) { //$(".arrowDownTest").show(); //return false; } ans = $("#AdulteNum").val(); cns = $("#ChildNum").val(); bns = $("#BabyNum").val(); ans = parseInt(ans); cns = parseInt(cns); bns = parseInt(bns); for (i=1;i<=ans;i++){ if (!StrIsNullOrEmpty("pfirstname"+i,"Please fill in your first name.","","",true)) return false; if (!StrIsNullOrEmpty("pfirstname"+i,"Please fill in your first name.","First Name","",true)) return false; if (!StrIsNullOrEmpty("plastname"+i,"Please fill in your last name.","","",true)) return false; if (!StrIsNullOrEmpty("plastname"+i,"Please fill in your last name.","Last Name","",true)) return false; if (!StrIsNullOrEmpty("passport"+i,"Please fill in your passport.","","",true)) return false; if (!StrIsNullOrEmpty("passport"+i,"Please fill in your passport.","Passport No.","",true)) return false; //if (!StrIsNullOrEmpty("atakeoffDate"+i,"Please select your birthday","mm/dd/yyyy","",true)) return false; } for (i=1;i<=cns;i++){ if (!StrIsNullOrEmpty("pfirstname_cn_"+i,"Please fill in your first name.","","",true)) return false; if (!StrIsNullOrEmpty("pfirstname_cn_"+i,"Please fill in your first name.","First Name","",true)) return false; if (!StrIsNullOrEmpty("plastname_cn_"+i,"Please fill in your last name.","","",true)) return false; if (!StrIsNullOrEmpty("plastname_cn_"+i,"Please fill in your last name.","Last Name","",true)) return false; //if (!StrIsNullOrEmpty("ctakeoffDate"+i,"Please select your birthday","mm/dd/yyyy","",true)) return false; } for (i=1;i<=bns;i++){ if (!StrIsNullOrEmpty("pfirstname_bn_"+i,"Please fill in your first name.","","",true)) return false; if (!StrIsNullOrEmpty("pfirstname_bn_"+i,"Please fill in your first name.","First Name","",true)) return false; if (!StrIsNullOrEmpty("plastname_bn_"+i,"Please fill in your last name.","","",true)) return false; if (!StrIsNullOrEmpty("plastname_bn_"+i,"Please fill in your last name.","Last Name","",true)) return false; //if (!StrIsNullOrEmpty("btakeoffDate"+i,"Please select your birthday","mm/dd/yyyy","",true)) return false; } $("#TourForm").attr("action", "/forms/reserve-cruise-save.asp?p=pay").submit(); //document.TourForm.action = "/forms/reserve-cruise-save.asp?p=pay"; //document.TourForm.submit(); } } $("#ship_order_info").show(); }); }); function get_cruise_price(id, control_form ){ var cruise = new CruiseProductManager(); //actsAsAspect(cruise); global_SingleNum = $("#SingleNum").val() ; global_SharedTwinNum = $("#SharedTwinNum").val(); if (control_form != 1){ if (id != "SingleNum" && id != "SharedTwinNum"){ control_cruise_from(); } } //cruise.before("calculation_price", beforeHander); var temp_price = 0 ; cruise.adults_people = parseInt($("#AdulteNum").val()); cruise.children_people = parseInt($("#ChildNum").val()); cruise.babies_people = parseInt($("#BabyNum").val()); cruise.price = $("#js_OnlyCruisePrice").text().replace(/([USD|\s]+)/, ""); cruise.extra = global_SingleNum; temp_price = cruise.calculation_price(new Array(new EvenPriceDifference(), new OddPriceDifference()), new Array(new AdultsPriceCalculator(), new ChildrenPriceCalculator(), new BabiesPriceCalculator())); return Math.floor(temp_price); } function write_price(para, value){ $(para).html(""); $(para).html(value); } function control_cruise_from(s){ var people = 0, adults_people = 0, children_people = 0, babies_people = 0; adults_people = parseInt($("#AdulteNum").val()); children_people = parseInt($("#ChildNum").val()); babies_people = parseInt($("#BabyNum").val()); people = adults_people + children_people + babies_people; if (people % 2 == 0) { if (people / 2 < 1) { $("#SingleNum")[0].selectedIndex = 0; $("#SharedTwinNum")[0].selectedIndex = 1; global_SingleNum = 0; global_SharedTwinNum = 1; }else{ $("#SingleNum")[0].selectedIndex = (parseInt(people / 2)); $("#SharedTwinNum")[0].selectedIndex = 0; global_SingleNum = parseInt(people / 2); global_SharedTwinNum = 0; } }else { if(people / 2 < 1) { $("#SingleNum")[0].selectedIndex = (people / 2); $("#SharedTwinNum")[0].selectedIndex = 1; global_SingleNum = parseInt(people / 2); global_SharedTwinNum = 0; }else{ $("#SingleNum")[0].selectedIndex = (people / 2); $("#SharedTwinNum")[0].selectedIndex = 1; global_SingleNum = parseInt(people / 2); global_SharedTwinNum = 1; } } } function beforeHander(s) { control_cruise_from(s); } function get_package_price(selectType){ var package = new PackageProductManager(); var people = 0 , people_interval = ""; package.adults_people = parseInt($("#AdulteNum").val()); package.children_people = parseInt($("#ChildNum").val()); package.babies_people = parseInt($("#BabyNum").val()); people = package.adults_people + package.children_people + package.babies_people; package.price = (function(people, selectType){ var Data; var Class_price = 0; if (people == 1) { Class_price = book_transfers_together[selectType][0]; people_interval = "based on 1 person" }else if(people >= 2 && people <= 3) { Class_price = book_transfers_together[selectType][1]; people_interval = "based on 2-3 persons" }else if(people >= 4 && people <= 5) { Class_price = book_transfers_together[selectType][2]; people_interval = "based on 4-5 persons" }else if(people >= 6 && people <= 9) { Class_price = book_transfers_together[selectType][3]; people_interval = "based on 6-9 persons" }else if(people >= 10) { Class_price = book_transfers_together[selectType][4]; people_interval = "based on > 10 persons" } wirte_package_info(Class_price, people_interval, selectType); return Class_price; })(people, selectType); package.extra = parseInt($("#SingleNum").val()); temp_price = package.calculation_price(new Array(new AdultsPriceCalculator(), new ChildrenPriceCalculator(), new BabiesPriceCalculator())); return temp_price != 0 ? Math.floor(temp_price) : 0; } result_package_price = function(_url){ var Data = new Array(); var Class_price; $.ajax({ type: "GET", url: _url, dataType: "xml", async: false, timeout: 14000, success: function(msg){ var count = 0; var temp_html = ""; temp_html = $(msg).find("item").size(); count = $(msg).find("item").size() $(msg).find("item").each(function(){ temp_html = $(this).find("price").text().replace(/([USD|\s]+)/, ""); Data.push(temp_html); }); Class_price = Data; }, error: function(a,b,c){ Class_price = 0; } }); return Class_price; } function immediately_package_price(){ var daytripsbox0 = 0, daytripsbox1 = 0; if("checked" == $(".singleInfo .daytripsbox0").attr("checked")){ if(parseInt($("#js_daytrips_extendprice").text().replace(/([USD|\s]+)/, "")) != 0){ daytripsbox0 = get_package_price(0); }else{ daytripsbox0 = get_package_price(0);//parseInt($(".daytripsbox0").attr("id")); } } if("checked" == $(".singleInfo .daytripsbox1").attr("checked")){ if(parseInt($("#js_daytrips_extendprice").text().replace(/([USD|\s]+)/, "")) != 0){ daytripsbox1 = get_package_price(1); }else{ daytripsbox1 = get_package_price(1);//parseInt($(".daytripsbox1").attr("id")); } } $("#js_daytrips_extendprice").html(""); $("#js_daytrips_extendprice").html("USD " + parseInt(daytripsbox0 + daytripsbox1)); merge_total_price(get_cruise_price("", 1)); } function merge_total_price(cruise_price){ var price = 0; price = parseInt($("#js_daytrips_extendprice").text().replace(/([USD|\s]+)/, "")) + parseInt(cruise_price); write_price("#js_toralprice", "USD " + price + " "); $("#CruisePrice").val(cruise_price); $("#daytrips_price").val($("#js_daytrips_extendprice").text().replace(/([USD|\s]+)/, "")); } function wirte_package_info(Class_price, info, selectType){ if (selectType == 0){ $("#js_id_daytrips_extendprice .singleInfo:eq(0) .font11Red.red_price").text(""); $("#js_id_daytrips_extendprice .singleInfo:eq(0) .font11Red.red_price").text("USD " + Class_price); $("#js_id_daytrips_extendprice .singleInfo .basedOn:eq(0)").text(""); $("#js_id_daytrips_extendprice .singleInfo .basedOn:eq(0)").text(info); } if (selectType == 1){ $("#js_id_daytrips_extendprice .singleInfo:eq(1) .font11Red.red_price").text(""); $("#js_id_daytrips_extendprice .singleInfo:eq(1) .font11Red.red_price").text("USD " + Class_price); $("#js_id_daytrips_extendprice .singleInfo .basedOn:eq(1)").text(""); $("#js_id_daytrips_extendprice .singleInfo .basedOn:eq(1)").text(info); } } //===================点击下一步操作 验证=============================== $(function(){ $("#js_confirm_button").click(function() { // Victoria系列不需要在线支付 var shipname = $("#shipname").val(); console.info("shipname: " + shipname); if (shipname == 'victoria-jenna' || shipname == 'victoria-katarina' || shipname == 'victoria-lianna' || shipname == 'victoria-sophia' || shipname == 'victoria-anna' || shipname == 'victoria-selina' || shipname == 'victoria-grace') { $("#TourForm").attr("action", "/forms/reserve-cruise-save.asp"); } var AdulteI = IsEmptyOrNotNum("AdulteNum", "Please select the number of Auduts in your group.", "", false); var realnameI = StrIsNullOrEmpty("realname", "Please fill in your full name.", "", "", false); var NationalityI = StrIsNullOrEmpty("Nationality", "Please fill in your Nationality.", "", "", false); var emailI = RegCkElement("email", "Please fill in a valid email address! example: yourname@domain.com", "^([a-zA-Z0-9_-_\.])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-])+", "", "", false); var DateI = RegCkElement("Starting_Date", "Error Date", "/^[1|2]?[0-9]{1}\\/(31|30|[1,2]?[0-9]{1})\\/[1,2]{1}\\d{3}$/", "", "", false); if (!IsEmptyOrNotNum("ChildNum")) $("#ChildNum").val("0"); if (!IsEmptyOrNotNum("BabyNum")) $("#BabyNum").val("0"); if (!IsEmptyOrNotNum("days")) $("#days").val("0"); $("#email,#email2").click(function(){ $(".arrowDownTest").hide(); }); if($("#email").val() != $("#email2").val()) { //$(".arrowDownTest").show(); //return false; } //集体捕获 if (AdulteI && realnameI && NationalityI && emailI && PhoneNoI) { // document.TourForm.action = "/forms/reserve-cruise-save.asp?action=add"; //document.TourForm.submit(); $("#TourForm").attr("action", "/forms/reserve-cruise-save.asp?p=add").submit(); return; } //location.href = "#"; return false; }); }); function controlTemplate(){ getTemplateAdulte(); } function getTemplateAdulte(type_num){ var tmp_Adulte = ""; tmp_Adulte += "
"; tmp_Adulte += "