You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
510 lines
24 KiB
JavaScript
510 lines
24 KiB
JavaScript
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 += " <tbody class=\"Adulte\"> ";
|
|
tmp_Adulte += " <tr id=\"expi1\"> ";
|
|
tmp_Adulte += " <td class=\"traveller\">Adult "+ type_num +"</td> ";
|
|
tmp_Adulte += " <td width=\"55\"> ";
|
|
tmp_Adulte += " <select style=\"width: 50px; float: left;\" id=\"gender\" name=\"ptitle\"> ";
|
|
tmp_Adulte += " <option> Mr.</option> ";
|
|
tmp_Adulte += " <option> Ms.</option> ";
|
|
tmp_Adulte += " </select> ";
|
|
tmp_Adulte += " </td> ";
|
|
tmp_Adulte += " <td width=\"276\"> ";
|
|
tmp_Adulte += " <input type=\"text\" value=\"First Name\" id=\"pfirstname"+ type_num +"\" class=\"pfirstname1 fullname\" name=\"pfirstname\"> ";
|
|
tmp_Adulte += " <input type=\"text\" value=\"Last Name\" id=\"plastname"+ type_num +"\" class=\"plastname1 lastname\" name=\"plastname\"> ";
|
|
tmp_Adulte += " </td> ";
|
|
tmp_Adulte += " <td> ";
|
|
tmp_Adulte += " <input type=\"text\" value=\"Passport No.\" id=\"passport"+ type_num +"\" class=\"passport1 passport\" name=\"ppassport\"> ";
|
|
tmp_Adulte += " </td> ";
|
|
tmp_Adulte += " </tr> ";
|
|
tmp_Adulte += " </tbody> ";
|
|
|
|
return tmp_Adulte;
|
|
}
|
|
function getTemplateChild(type_num){
|
|
var tmp_Child = "";
|
|
tmp_Child += " <tbody class=\"Child\"> ";
|
|
tmp_Child += " <tr id=\"expi1\"> ";
|
|
tmp_Child += " <td class=\"traveller\">Child "+ type_num +"</td> ";
|
|
tmp_Child += " <td width=\"55\"> ";
|
|
tmp_Child += " <select style=\"width: 50px; float: left;\" id=\"gender\" name=\"ptitle\"> ";
|
|
tmp_Child += " <option> Mr.</option> ";
|
|
tmp_Child += " <option> Ms.</option> ";
|
|
tmp_Child += " </select> ";
|
|
tmp_Child += " </td> ";
|
|
tmp_Child += " <td width=\"276\"> ";
|
|
tmp_Child += " <input type=\"text\" value=\"First Name\" id=\"pfirstname_cn_"+ type_num +"\" class=\"pfirstname1 fullname\" name=\"pfirstname\"> ";
|
|
tmp_Child += " <input type=\"text\" value=\"Last Name\" id=\"plastname_cn_"+ type_num +"\" class=\"plastname1 lastname\" name=\"plastname\"> ";
|
|
tmp_Child += " </td> ";
|
|
tmp_Child += " <td> ";
|
|
tmp_Child += " <input type=\"text\" value=\"Passport No.\" id=\"passport_cn_"+ type_num +"\" class=\"passport1 passport\" name=\"ppassport\"> ";
|
|
tmp_Child += " </td> ";
|
|
tmp_Child += " </tr> ";
|
|
tmp_Child += " </tbody> ";
|
|
|
|
return tmp_Child;
|
|
}
|
|
function getTemplateBaby(type_num){
|
|
var tmp_Baby = "";
|
|
|
|
tmp_Baby += " <tbody class=\"Baby\"> ";
|
|
tmp_Baby += " <tr id=\"expi1\"> ";
|
|
tmp_Baby += " <td class=\"traveller\">Baby "+ type_num +"</td> ";
|
|
tmp_Baby += " <td width=\"55\"> ";
|
|
tmp_Baby += " <select style=\"width: 50px; float: left;\" id=\"gender\" name=\"ptitle\"> ";
|
|
tmp_Baby += " <option> Mr.</option> ";
|
|
tmp_Baby += " <option> Ms.</option> ";
|
|
tmp_Baby += " </select> ";
|
|
tmp_Baby += " </td> ";
|
|
tmp_Baby += " <td width=\"276\"> ";
|
|
tmp_Baby += " <input type=\"text\" value=\"First Name\" id=\"pfirstname_bn_"+ type_num +"\" class=\"pfirstname1 fullname\" name=\"pfirstname\"> ";
|
|
tmp_Baby += " <input type=\"text\" value=\"Last Name\" id=\"plastname_bn_"+ type_num +"\" class=\"plastname1 lastname\" name=\"plastname\"> ";
|
|
tmp_Baby += " </td> ";
|
|
tmp_Baby += " <td> ";
|
|
tmp_Baby += " <input type=\"text\" value=\"Passport No.\" id=\"passport_bn_"+ type_num +"\" class=\"passport1 passport\" name=\"ppassport\"> ";
|
|
tmp_Baby += " </td> ";
|
|
tmp_Baby += " </tr> ";
|
|
tmp_Baby += " </tbody> ";
|
|
|
|
return tmp_Baby;
|
|
}
|
|
|
|
function calculateForm(type_num, form_type){
|
|
var tmp_formsize = $("."+ form_type +"").size() - 1;
|
|
var tmp_peoplenum = type_num;
|
|
return tmp_peoplenum - tmp_formsize;
|
|
}
|
|
function initForm(form_type){
|
|
var tmp_formsize = $("."+ form_type +"").size();
|
|
if(tmp_formsize == 0){
|
|
return 0
|
|
}else{
|
|
return 1
|
|
}
|
|
}
|
|
function makeInitForm(form_type){
|
|
var list = [];
|
|
var _ft = 0;
|
|
if(initForm(form_type) == 0) {
|
|
var _num = $("#"+ form_type +"Num").val();
|
|
for(var i = 0 ; i < _num; i++){
|
|
list.push(pfactory(form_type, i + 1 ));
|
|
//$(".fpassagerInfo tbody:eq(0)").after(pfactory(form_type, i + 1 ));
|
|
}
|
|
var _maxPFrom = "";
|
|
if(form_type == "Adulte") {
|
|
_maxPFrom = " tbody:eq(0)";
|
|
}else if(form_type == "Child"){
|
|
_maxPFrom = " .Adulte:eq("+ getMaxPForm("Adulte") +")";
|
|
}else if(form_type == "Baby"){
|
|
_maxPFrom = " .Child:eq("+ getMaxPForm("Child") +")";
|
|
}
|
|
for(var i = list.length - 1; i >= 0; i--){
|
|
$(".fpassagerInfo"+ _maxPFrom).after(list[i]);
|
|
}
|
|
}
|
|
}
|
|
function makeWorkForm(form_type){
|
|
var list = [];
|
|
var _ft = 0;
|
|
if(form_type == 'Child' || form_type == 'Baby'){
|
|
_ft = 1;
|
|
}else{
|
|
_ft = initForm(form_type);
|
|
}
|
|
if(_ft == 1) {
|
|
var _num = $("#"+ form_type +"Num").val();
|
|
var _maxPFrom = "";
|
|
var _tmp_max_a = 0, _tmp_max_c = 0, _tmp_max_b = 0;
|
|
if(_num > getMaxPForm(form_type)){
|
|
for(var i = getMaxPForm(form_type) + 1; i < _num; i++){
|
|
list.push(pfactory(form_type, i + 1 ));
|
|
}
|
|
_maxPFrom = "";
|
|
_tmp_max_a = getMaxPForm("Adulte");
|
|
_tmp_max_c = getMaxPForm("Child");
|
|
_tmp_max_b = getMaxPForm("Baby");
|
|
if(form_type == "Adulte") {
|
|
_maxPFrom = " .Adulte:eq("+ _tmp_max_a +")";
|
|
}else if(form_type == "Child"){
|
|
_maxPFrom = _tmp_max_c == -1 ? " .Adulte:eq("+ _tmp_max_a +")" : " .Child:eq("+ _tmp_max_c +")";
|
|
}else if(form_type == "Baby"){
|
|
_maxPFrom = _tmp_max_b == -1 ? " .Child:eq("+ _tmp_max_c +")" : " .Baby:eq("+ _tmp_max_b +")";
|
|
}
|
|
for(var i = list.length - 1; i >= 0; i--){
|
|
$(".fpassagerInfo"+ _maxPFrom).after(list[i]);
|
|
}
|
|
}else if(_num <= getMaxPForm(form_type)){
|
|
for(var i = getMaxPForm(form_type) + 1; i > _num; i--){
|
|
_maxPFrom = "";
|
|
if(form_type == "Adulte") {
|
|
_maxPFrom = " .Adulte:eq("+ getMaxPForm("Adulte") +")";
|
|
}else if(form_type == "Child"){
|
|
_maxPFrom = " .Child:eq("+ getMaxPForm("Child") +")";
|
|
}else if(form_type == "Baby"){
|
|
_maxPFrom = " .Baby:eq("+ getMaxPForm("Baby") +")";
|
|
}
|
|
$(".fpassagerInfo"+ _maxPFrom).remove();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
function getMaxPForm(type){
|
|
return $(".fpassagerInfo ."+ type +"").size() - 1;
|
|
}
|
|
function pfactory(type, num){
|
|
if(type == "Adulte"){
|
|
return getTemplateAdulte(num);
|
|
}
|
|
if(type == "Child"){
|
|
return getTemplateChild(num);
|
|
}
|
|
if(type == "Baby"){
|
|
return getTemplateBaby(num);
|
|
}
|
|
}
|
|
function effectForm(){
|
|
$(".pfirstname1").live("click", function(){
|
|
if($(this).val()=="First Name"){$(this).val("")};
|
|
});
|
|
$(".pfirstname1").live("focus", function(){
|
|
if($(this).val()=="First Name"){$(this).val("")};
|
|
});
|
|
$(".pfirstname1").live("blur", function(){
|
|
if($(this).val()==""){$(this).val("First Name")};
|
|
});
|
|
|
|
$(".plastname1").live("click", function(){
|
|
if($(this).val()=="Last Name"){$(this).val("")};
|
|
});
|
|
$(".plastname1").live("focus", function(){
|
|
if($(this).val()=="Last Name"){$(this).val("")};
|
|
});
|
|
$(".plastname1").live("blur", function(){
|
|
if($(this).val()==""){$(this).val("Last Name")};
|
|
});
|
|
|
|
$(".passport1").live("click", function(){
|
|
if($(this).val()=="Passport No."){$(this).val("")};
|
|
});
|
|
$(".passport1").live("focus", function(){
|
|
if($(this).val()=="Passport No."){$(this).val("")};
|
|
});
|
|
$(".passport1").live("blur", function(){
|
|
if($(this).val()==""){$(this).val("Passport No.")};
|
|
});
|
|
|
|
}
|