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.

239 lines
7.0 KiB
JavaScript

$(function() {
$("#questionBox .infoRequired p").show();
$("#questionBox .infoRequired label").inFieldLabels();
$(".switchTags").stick_in_parent({parent: "#maintourContent"});
$("#addtionalRight1").stick_in_parent({parent: "#maintourContent1"}).on("sticky_kit:stick", function(e) {
//$("#addtionalRight").css({"margin-top": 50});
// }).on("sticky_kit:unstick", function(e) {
// $("#addtionalRight").css({"margin-top": 0});
});
$(document).on("click",".error", function() {
$(this).parent("p").find(".arrowDownTest").remove();
});
//form valid
$("#formquestion").validate({
rules: {
realname:{
required: true,
minlength: 1
},
yemail:{
required: true,
email: true
},
Starting_Date: {
required: true,
date: true
},
padult: {
required: true,
range: [1, 30],
}
},
messages: {
realname: "Please enter a real name",
yemail: "Please enter a valid email address.",
Starting_Date: "Please select the starting date",
padult: "Select the adult number"
},
errorLabelContainer: "#questionBox .infoRequired p .arrowDownTest",
errorPlacement: function(error, element) {
var error_tip = "<div class=\"arrowDownTest\"><div class=\"arrowDown\"><img src=\"/css/images/whiteArrow.png\"></div></div>";
element.parent().append(error_tip);
error.appendTo(element.parent().find(".arrowDownTest"));
},
focusInvalid: true,
submitHandler: function(form){
//form.find(".arrowDownTest").show();
form.submit();
},
//debug: true
});
$("#Q_URL").val(location.href);
//---------------------------------------------------------------------------------------------------------------------------------------
});
function productprice(star_price) {
if(star_price == '' || star_price == 'no') return;
var _cli_no = $("#cli-no").text();
var _cli_no_url = "/api/tmp/tour-detail-price.asp";
if(star_price == 's3') _cli_no_url = "/api/tmp/tour-detail-price3.asp";
if(_cli_no == "") {
_cli_no = $("#city-cli-no").text();
_cli_no_url = "/api/tmp/citytour-detail-price.asp"
if(star_price == 's3') _cli_no_url = "/api/tmp/citytour-detail-price3.asp";
}
$.get(_cli_no_url, { cli_no: _cli_no },
function(data){
$(".pricetable1").html("");
$(".pricetable1").html($(data).html());
$(".priceTitle img").hover(
function () {
$(".priceTerms").show();
},
function () {
//$(".priceTerms").hide();
}
);
$(".priceTerms .closeIt").click(function(){
$(".priceTerms").hide();
});
$(".priceTitle").show();
$.get("/api/tmp/converter.asp", function(data) {
var __p__ = eval(data);
var price_list = {'USD': __p__[0].ex_rate, 'AUD': __p__[1].ex_rate, 'CAD': __p__[2].ex_rate, 'EUR': __p__[3].ex_rate, 'GBP': __p__[4].ex_rate};
var usd = __p__[0].ex_rate;
$(".moneyConverter .currencyList").hide();
$(".moneyConverter").hover(
function () {
$(".currencyList").show();
$(".moneyConverter .currencyList li").one('click', function() {
$(".moneyConverter .currencyList li").each(function() {
$(this).removeClass("point");
});
$(this).addClass("point");
$(".moneyConverter #first").empty();
$(".moneyConverter #first").html($(this).html());
$(".currencyList").hide();
var converter_code = $.trim($(this).text()).replace(/[^A-Z]+/g, '');
var sign = $.trim($(this).text()).replace(/[A-Z|\s]+/g, '');
var converter = price_list[converter_code];
$(".book-price .hp").each(function() {
var price = $.trim($(this).text()).replace(/(\$|\-|,)/gi, '');
price = parseInt(price);
$(this).parent().find('.item').empty();
if (converter_code != 'USD') {
var _tmp = format_number(parseInt(price * usd / converter));
$(this).parent().find('.item').text(sign+_tmp);
}else{
$(this).parent().find('.item').text(sign+format_number(price));
}
});
});
},
function () {
$(".currencyList").hide();
}
);
});
});
}
function productmanager(pm) {
$.ajax({
url: '//www.chinahighlights.com/api/tmp/product-manager.js',
dataType: 'jsonp',
jsonpCallback: 'ProductManager',
success: function(data) {
var n = pm;
var html = '';
html += "<div class=\"product-manager\">";
html += " <div class=\"sayPic\"><img width=\"100\" height=\"100\" src=\""+data.item[n].img+"\"></div>";
html += " <p><strong>Tour Designer - "+data.item[n].name+"</strong></p>";
html += " <p>"+data.item[n].describe+"</p>";
html += "</div>";
$(".daytourBox").append(html);
}
});
}
function hetelsarranged(tour_code) {
$.ajax({
url: '//www.chinahighlights.com/api/tmp/hotels-we-arranged.asp',
dataType: 'jsonp',
jsonpCallback: 'hotelsarranged',
data: {code: tour_code},
success: function(data) {
$("#tourHotels").html(data.html);
$("#tourHotels div.item .defaultClass,#tourHotels div.item .hotelClass").click(function() {
//console.log($(this).parents(".item").hasClass("hotelBlock"));
var item = $(this).parents(".item");
if(item.hasClass("hotelBlock")) {
item.removeClass("hotelBlock");
item.addClass("otherClass");
item.find(".defaultClass").hide();
item.find(".hotelClass").show();
item.find(".showMore").show();
item.find("table").hide();
}else{
item.removeClass("otherClass");
item.addClass("hotelBlock");
item.find(".defaultClass").css({display: "block"});
item.find(".hotelClass").hide();
item.find(".showMore").hide();
item.find("table").show();
}
});
}
});
}
function format_number(n){
var b=parseInt(n).toString();
var len=b.length;
if(len<=3){return b;}
var r=len%3;
return r>0?b.slice(0,r)+","+b.slice(r,len).match(/\d{3}/g).join(","):b.slice(r,len).match(/\d{3}/g).join(",");
}
function priceincludes(data) {
if (data.length < 10) return;
$("#priceInclusive").html("");
$("#priceExclusive").html("");
var _tmp = data;
var priceInclusive, priceExclusive;
var priceInclusive_html, priceExclusive_html;
_tmp = _tmp.split('<hr />');
priceInclusive = _tmp[0];
priceExclusive = _tmp[1];
priceInclusive_html = "<div class=\"in-ex-title\"><span>Price Inclusion</span></div>"+priceInclusive;
priceExclusive_html = "<div class=\"in-ex-title\"><span>Price Exclusion</span></div>"+priceExclusive;
$("#priceInclusive").append(priceInclusive_html);
$("#priceExclusive").append(priceExclusive_html);
$("#priceInclusive,#priceExclusive").show();
}
//Tip
$(function(){
$('.couponPromo').mouseenter(
function(e)
{
$('.couponTip').show(100);
}
)
$('.couponPromo').mouseleave(
function()
{
var _tobj = setTimeout(function(){
$('.couponTip').hide(100);
},50);
$('.couponTip').mouseenter(function(){
clearTimeout(_tobj);
});
}
)
$('.couponTip').mouseleave(function(){
var _tobjs = setTimeout(function(){
$('.couponTip').hide(100);
},50);
$('.couponPromo').mouseenter(function(){
clearTimeout(_tobjs);
});
});
});
$(function() {
$("img.lazy").show().lazyload();
});