var agate = {
init: function () {
$.getScript('https://data.agatetravel.com/js/v2/adv.js');
if (typeof window.pageInit != 'undefined') {
pageInit()
}
this.cityguide.init();
this.scrollLoadIMG();
this.liveChat();
this.qa.init();
this.mobile.init();
this.navBar.init();
this.reply.init();
this.commt.init();
this.tourRightNav.init();
$.extend({
focusBlur: function (obj, defTxt, defColor) {
var obj = $(obj);
obj.focus(function () {
if (obj.val() == defTxt) obj.val("").removeClass(defColor)
});
obj.blur(function () {
if (obj.val() == "") obj.val(defTxt).addClass(defColor)
})
},
isOnScreen: function (obj) {
var win = $(window);
var viewport = {
top: win.scrollTop(),
left: win.scrollLeft()
};
viewport.right = viewport.left + win.width();
viewport.bottom = viewport.top + win.height();
var bounds = $(obj).offset();
bounds.right = bounds.left + $(obj).outerWidth();
bounds.bottom = bounds.top + $(obj).outerHeight();
return (!(viewport.right < bounds.left || viewport.left > bounds.right || viewport.bottom < bounds.top || viewport.top > bounds.bottom));
}
});
$(function () {
if ($(window).width() > 425) {
if ($(".page-img-link").length > 0) {
var maxH = $($(".page-img-link .img-info")[0]).height();
$(".page-img-link .img-info").each(function () {
var h = $(this).height();
if (h > maxH) maxH = h
});
$(".page-img-link .img-info").height(maxH + "px")
}
agate.gotop()
$('.pc-img').attr('src',$('.pc-img').attr('mysrc'));
}
else
{
$('.pc-mobile').attr('src',$('.pc-mobile').attr('mysrc'));
}
$("#letter-sub").click(function () {
var email = $("#letter-search").val();
var isEmailError = agate.util.myEmailCheck(email, "Sorry,the email address is invalid,please correct it.");
if (isEmailError) {
$("#letter-search").focus();
return
}
$.ajax({
type: "get",
url: "/reserve/inc/ajax/newsLetter.ashx?email=" + email,
contentType: "application/json; charset=utf-8",
success: function (retdata) {
if (retdata = true) plugAlert("You Have Submitted Successfully!", 3000)
},
error: function (XMLHttpRequest, textStatus, errorThrown) { }
})
});
$(document.body).on("click",".nav-item-lev2 li span",//live
function () {
var url = "/" + $(this).text().replace(" ", "-").toLowerCase() + "-tours.html";
if ($(this).text() == "Sri Lanka") url = "/srilanka-tours.html";
if ($(this).text() == "UAE") url = "/united-arab-emirates-tours.html";
location.href = url
});
$(".header-searchtour-form-text").on('focus',
function () {
$(".header-search-hot-country").animate({},
0,
function () {
$(".header-search-hot-country").show()
});
if ($(window).width() >= 1024 && $(window).width() < 1600) {
$(".header-searchtour").addClass("head-search-focus");
$(".header-searchtour").addClass("transition-width-05");
$(".header-searchtour-form-text").addClass("transition-width-05")
}
});
$(document).bind('click',
function (e) {
var isHotC = false;
var e = e || window.event;
var elem = e.target || e.srcElement;
while (elem) {
if (elem.id && (elem.id == 'header-searchtour-form-text' || elem.id == 'header-search-hot-country' || elem.id == 'searchtour-form-text' || elem.id == 'search-hot-country')) {
$('.header-searchtour-form-text').css('color', '#000');
return
}
elem = elem.parentNode
}
if (!isHotC && $(window).width() >= 1024) $(".header-searchtour").removeClass("head-search-focus");
//2022-08-08 812-834
if ($(window).width() > 834) {
$('.header-search-hot-country').hide()
} else {
if (e.target.hasAttribute("class") && e.target.className == "mobile-header-top-search") {
if ($(".header-searchtour").is(':visible')) {
//$('.header-searchtour').hide();
$('.header-search-hot-country').hide()
} else {
//$('.header-searchtour').show()
}
} else {
//$('.header-searchtour').hide();
$('.header-search-hot-country').hide()
}
}
if ($('.header-searchtour-form-text').val() == '' || $('.header-searchtour-form-text').val() == 'Fill in or select your destination') $('.header-searchtour-form-text').css('color', '#ccc')
});
$(".header-hot-country-ul li input[name='country']").click(function () {
if ($(this).is(':checked')) {
$(".header-hot-country-ul li input[name='country']").attr("checked",false);
$(this).attr("checked",true);
$('.header-searchtour-form-text').val($(this).val());
} else {
$('.header-searchtour-form-text').val("Fill in or select your destination");
}
});
$(".header-searchtour-form-btn").click(function () {
var newUrl = '/tour/search.html?day=&country=&page=1#content';
if ($('.header-searchtour-form-text').val() != '' && $('.header-searchtour-form-text').val() != 'Fill in or select your destination') {
newUrl = '/tour/search.html?day=&country=' + $('.header-searchtour-form-text').val().replace(new RegExp(',', 'g'), '|') + '&page=1#content'
}
window.open(newUrl, '_self');
$(".header-hot-country-ul li input[name='country']").each(function () { });
$('.header-searchtour-form-text').val('Fill in or select your destination')
});
//2022-08-08 812-834
if ($(window).width() <= 834) {
//$('.header-searchtour').insertAfter($('.mobile-header-tel'))
}
if ($(".bx-controls").find(".bx-pager-item").length < 2) $(".bx-controls").hide(); (function () {
var w = $(window).width();
if (w < 1280) {
if (w < 568) { } else {
/*$("#footer .footer-li-border").eq(1).css({
"border-top": "1px solid #d1d1d1",
"width": "100%",
"height": "1px",
"margin-top": "15px",
"display": "block"
});
var f = $(".footer-li-class-4 li");
f.eq(1).append(f.eq(2).html());
f.eq(2).remove();
$("#letter-sub").css("margin-left", "30px");
$(".footer-li-border").eq(2).hide()*/
}
}
})()
});
},
scrollLoadIMG: function () {
this.scrollLoad($('img[xsrc]'), function (_) {_.attr('src', _.attr('xsrc')).removeAttr('xsrc')});
this.scrollLoad($('iframe[xifsrc]'),function(_this){_this.attr('src',_this.attr('xifsrc')).attr('xifsrc',null);});
},
scrollLoad: function (o, f) {
if (o.length == 0) return; (function (fun) {
fun();
setInterval(fun, 500)
})(function () {
o.each(function (i) {
var _ = $(this);
if (!_.is(':hidden') && typeof _.attr('isload') == 'undefined') {
//if ((!_.is(':hidden') || !(_.css('display')=='none')) && typeof _.attr('isload') == 'undefined') {
if (_.offset().top <= ($(window).height() + $(window).scrollTop())) {
_.attr('isload', 'true');
if (typeof f != 'undefined') f(_)
}
}
})
})
},
cityguide: {
init: function () {
if ($(window).width() <= 425 && $('.table2cols').length > 0) {
$('.table2cols').each(function () {
var _this = $(this);
$(_this).find('table').each(function () {
_this.before('
')
});
_this.remove()
})
}
}
},
tourRightNav: {
init: function () {
//$(window).on('load resize', function () {
// if ($(window).width() <= 360) {
// if ($(".hidden-nav ul li").length > 2) {
// $(".hidden-nav ul li").hide();
// $(".hidden-nav ul li:lt(2)").css("display", "block");
// }
// }
// else {
// $(".hidden-nav ul li").show();
// }
//});
}
},
ad: {
goto: function (o) {
var u = '' + o;
window.open(u);
$.get("/inc/logStat/StatHandler.ashx", {
cmd: "addSearchLog",
searchType: "adv_sg_left",
searchText: ""
},
function (data) { })
}
},
qa: {
currentPage: 1,
init: function () {
agate.qa.qaList();
agate.qa.showBigImg();
$(".review-switch").each(function () {
$(this).click(function () {
var o = $(this);
if (o.text() == "More") {
o.siblings(".review-ellipsis").hide();
o.siblings(".review-more").show();
o.text("Less")
} else if (o.text() == "Less") {
o.siblings(".review-ellipsis").show();
o.siblings(".review-more").hide();
o.text("More")
}
})
})
},
check: function () {
if ($("#txtFullName").val() == 'Name') {
alert("Sorry, full name should not be empty!");
$("#txtFullName").focus();
return false
}
var email = document.getElementById("txtEmail").value;
if (email != "") {
if ($("#txtEmail").val() == 'E-mail') {
alert("Please input your valid email!");
$("#txtEmail").focus();
return false
}
var isEmailError = agate.qa.emailCheck(email, "Please input your valid email!");
if (isEmailError) {
return false
}
} else {
alert('Please input your valid email!');
return false
}
},
emailCheck: function (str, alertTxt) {
if (str == 'E-mail') {
return true
}
var myreg = /^[^.]+@([^.]+\.)+[^.]{2,3}$/;
if (!(str.indexOf("@") != -1 && str.indexOf(".") != -1)) {
alert(alertTxt);
return true
} else return false
},
qaList: function () {
var qa = $('#qaList');
if (qa.length == 0) return;
var pid = qa.attr('pid');
$.post('/reserve/inc/qa/list.ashx?type=qa&id=' + pid,
function (data) {
qa.html(data);
$('#qaList form').append('');
$.getScript('/js/v2/jquery.autocomplete.js',
function () {
var gc = $('.g_country');
if(gc.length>0) gc.autocomplete(auto_country, {
max: 8,
highlight: false,
top: gc.offset().top + 5 + gc.height(),
width: gc.outerWidth(),
scroll: true,
scrollHeight: 300
})
});
$.focusBlur("#txtFullName", "Name", "defColor");
$.focusBlur("#txtEmail", "E-mail", "defColor");
$.focusBlur("#selCountry", "Country/Region", "defColor");
agate.qa.showBigImg();
agate.commt.textArea()
})
},
moreReviews: function (pagenum) {
var review = $('#more-reviews');
if (review.length == 0) return;
var pid = review.attr('pid');
$.post('/reserve/inc/qa/list.ashx?type=morereviews&id=' + pid + '&pagenum=' + pagenum,
function (data) {
review.html(data);
agate.commt.write();
agate.qa.showBigImg();
$(".review-switch").each(function () {
$(this).click(function () {
var o = $(this);
if (o.text() == "More") {
o.siblings(".review-ellipsis").hide();
o.siblings(".review-more").show();
o.text("Less")
} else if (o.text() == "Less") {
o.siblings(".review-ellipsis").show();
o.siblings(".review-more").hide();
o.text("More")
}
})
});
var marginLeft = function () {
var topNav = $(".reviewer-info .review-pages");
if (topNav.length > 0) {
topNav.css({
"margin-left": -topNav.width() / 2,
"left": "50%"
});
topNav.show()
}
};
marginLeft()
})
},
clientSay: function (pagenum) {
var qa = $('#agate-review');
if (qa.length == 0) return;
agate.qa.currentPage = pagenum;
var pid = qa.attr('pid');
$.post('/reserve/inc/qa/list.ashx?type=review&id=' + pid + '&pagenum=' + pagenum,
function (data) {
qa.html(data);
$.getScript('/js/v1/jquery.autocomplete.js',
function () {
var gc = $('.g_country');
if (gc.length > 0) gc.autocomplete(auto_country, {
max: 8,
highlight: false,
top: gc.offset().top + 5 + gc.height(),
width: gc.outerWidth(),
scroll: true,
scrollHeight: 300
})
});
agate.qa.showBigImg();
$(".review-switch").each(function () {
$(this).click(function () {
var o = $(this);
if (o.text() == "More") {
o.siblings(".review-ellipsis").hide();
o.siblings(".review-more").show();
o.text("Less")
} else if (o.text() == "Less") {
o.siblings(".review-ellipsis").show();
o.siblings(".review-more").hide();
o.text("More")
}
})
});
var e = document.getElementById("agate-review");
var y = e.offsetTop;
while (e = e.offsetParent) {
y += e.offsetTop
}
window.scrollTo(0, y)
})
},
showBigImg: function () {
var imgCnt = 0;
var imgIndex = 0;
var pObj;
$(".review-photos li").each(function (i, e) {
$(this).click(function () {
var p = $(this).parent();
pObj = p;
imgCnt = p.find("li").length;
var curIndex = p.find("li").index(this);
imgIndex = curIndex;
var curImg = $(this).find("img").attr("bigimg");
$(".photoPreview").show();
$(".photoPreview .photoImg img").attr("src", curImg)
})
});
if ($(".agate-review").length > 0) {
if ($(".photoPreview").length == 0) {
$("body").append('')
}
agate.commt.write()
}
$(".photoPreview .photoClose").click(function () {
$(".photoPreview").hide()
});
$(".photoPreview .photoPrev").click(function () {
if (imgIndex == 0) {
imgIndex = imgCnt - 1
} else {
imgIndex -= 1
}
var showImg = $(pObj).find("li").eq(imgIndex).find("img").attr("bigimg");
$(".photoPreview").show();
$(".photoPreview .photoImg img").attr("src", showImg)
});
$(".photoPreview .photoNext").click(function () {
if (imgIndex + 1 == imgCnt) {
imgIndex = 0
} else {
imgIndex += 1
}
var showImg = $(pObj).find("li").eq(imgIndex).find("img").attr("bigimg");
$(".photoPreview").show();
$(".photoPreview .photoImg img").attr("src", showImg)
})
},
goAnchor: function (u, a) {
location.href = u + "#" + a;
location.reload(true)
}
},
reply: {
init: function () {
$('.comW').click(function () {
if ($('body').data('autoComp') != 1) {
$.getMyScript('/com/js/myJqueryplugs/jquery.autocomplete.min.js',
function () {
$('#selCountry').autocomplete(auto_country, {
max: 100,
highlight: false,
scroll: true,
scrollHeight: 60,
width: $('#selCountry').width(),
minChars: 1
});
$('body').data('autoComp', 1)
})
} else {
$('#selCountry').autocomplete(auto_country, {
max: 100,
highlight: false,
scroll: true,
scrollHeight: 60,
width: $('#selCountry').width(),
minChars: 1
})
}
});
agate.reply.loadAlertImg()
},
html: '',
loadAlertImg: function () {
agate.util.loadImg('/images/background/bgp023.png',
function () { })
},
replyTo: function (uname, commId, obj) {
$.getScript('/com/js/myjqueryplugs/jackyniceLoading/yqniceloading.js',
function () {
$().jackyNiceLoading({
icoWidth: 758,
icoHeight: 310,
myIco: '/com/js/myJqueryplugs/JackyNiceLoading/images/loading4.gif',
showOverlay: true,
tagObj: obj,
call: function () {
if ($('body').data('isLoadEasyDrag') == 1 && $('body').data('isLoadReply') == 1) {
$("#jacky_loading").html(agate.reply.html);
$('#qaWriter').html(uname);
$('#IDcommt').val(commId);
$("#jacky_loading .replyPop").easydrag();
$("#jacky_loading .replyPop").setHandler("replyTitDrag");
$('#selCountry').hide();
$('#selCountry_Reply').click(function () {
$(this).val('')
});
if ($('body').data('autoComp') == 1) {
$('#selCountry_Reply').autocomplete(auto_country, {
max: 100,
highlight: false,
scroll: true,
scrollHeight: 60,
width: $('#selCountry').width(),
minChars: 1
})
} else {
$('#selCountry_Reply').autocomplete(auto_country, {
max: 100,
highlight: false,
scroll: true,
scrollHeight: 60,
width: $('#selCountry').width(),
minChars: 1
})
}
agate.commt.beautyCommtByJenny(1);
return false
}
$("#jacky_loading").load('/js/comment/reply.htm',
function () {
$('#qaWriter').html(uname);
$('#IDcommt').val(commId);
agate.reply.html = $("#jacky_loading").html();
$("#jacky_loading #replyFmId").attr("action", "");
$('body').data('isLoadReply', 1);
agate.commt.beautyCommtByJenny(1);
$('#selCountry_Reply').click(function () {
$(this).val('')
});
$.getScript('/js/v1/jquery.autocomplete.js',
function () {
var gc = $('.g_country');
if(gc.length>0) gc.autocomplete(auto_country, {
max: 8,
highlight: false,
top: gc.offset().top + 5 + gc.height(),
width: gc.outerWidth(),
scroll: true,
scrollHeight: 300
})
})
})
}
})
});
return false
},
check: function () {
if ($("#txtFullName_Reply").val() == 'Name') {
alert("Sorry, full name should not be empty!");
$("#txtFullName_Reply").focus();
return false
}
if (!agate.util.chkForm(document.getElementById("txtFullName_Reply"), "Sorry, full name should not be empty!")) return false;
if (!agate.util.chkForm(document.getElementById("txtComment_Reply"), "Sorry, content should not be empty!")) return false;
//var ajaxUrl = '/cms/sys/function/qa/QAHandler.ashx';
var ajaxUrl = '/reserve/inc/qa/list.ashx';
var op = 1;
var isReply = 1;
var id = $('#divCommt').attr('pageid');
var commId = $('#IDcommt').val();
var txtComment = $('#txtComment_Reply').val();
var txtFullName = $('#txtFullName_Reply').val();
var txtEmail = '';
var selCountry = $('#selCountry_Reply').val();
var type = "qasubmit";
var params = {
'op': op,
'type': 'qa',
'isReply': isReply,
'id': id,
'commId': commId,
'txtFullName': txtFullName,
'txtEmail': txtEmail,
'txtComment': txtComment,
'selCountry': selCountry,
'type': type
}
$.ajax({
type: "post",
url: ajaxUrl,
dataType: "json",
data: params,
success: function (ret) {
$("#jacky_wrap").remove();
$("#selCountry").show();
agate.qa.qaList()
},
error: function (err) { }
})
},
reset: function () {
$('#replyFmId').reset()
}
},
commt: {
html: '',
init: function () {
agate.commt.write()
},
textArea: function () {
$('#txtComment').focus(function () {
if ($(this).val() == 'Type your question here in brief.') $(this).val('')
});
$('#txtComment').blur(function () {
if ($(this).val() == '') $(this).val('Type your question here in brief.')
})
},
write: function () {
$('#divCommt').load('/js/comment/comment.htm',
function () {
agate.commt.beautyCommtByJenny(0);
$('#selCountry').click(function () {
$(this).val('')
});
agate.commt.textArea()
})
},
check: function () {
if ($("#txtFullName").val() == 'Name') {
alert("Sorry, full name should not be empty!");
$("#txtFullName").focus();
return false
}
if (!agate.util.chkForm(document.getElementById("txtFullName"), "Sorry, full name should not be empty!")) return false;
if (!agate.util.chkForm(document.getElementById("txtComment"), "Sorry, content should not be empty!")) return false;
var email = document.getElementById("txtEmail").value;
if (typeof (AspIsTour) != 'undefined') {
if (AspIsTour == 1) {
if (email != "") {
if ($("#txtEmail").val() == 'E-mail') {
alert("Please input your valid email!");
$("#txtEmail").focus();
return false
}
var isEmailError = agate.util.myEmailCheck(email, "Please input your valid email!");
if (isEmailError) {
return false
}
} else {
alert('Please input your valid email!');
return false
}
}
}
//var ajaxUrl = '/cms/sys/function/qa/QAHandler.ashx';
var ajaxUrl = '/reserve/inc/qa/list.ashx';
var op = 1;
var isReply = 0;
var id = $('#divCommt').attr('pageid');
var txtComment = $('#txtComment').val();
var txtFullName = $('#txtFullName').val();
var txtEmail = $('#txtEmail').val();
var type = "qasubmit";
var selCountry = $('#selCountry').val().replace('Country/Region', '');
var params = {
'op': op,
isReply: isReply,
'id': id,
'txtFullName': txtFullName,
'txtEmail': txtEmail,
'txtComment': txtComment,
'selCountry': selCountry,
'type': type
}
$.ajax({
type: "post",
url: ajaxUrl,
dataType: "json",
data: params,
success: function (ret) {
agate.qa.qaList();
location.hash = 'qaList'
},
error: function (err) { }
})
},
reset: function () {
$('#commtFmId').reset()
},
numTxt: function () {
$('.ask').each(function (i) {
if ($(this).children('.askT')[0]) {
$(this).children('.askT').html((i + 1))
} else $(this).prepend("" + (i + 1) + "
")
})
},
beautyCommtByJenny: function (isReply) {
var stringTxt = "";
stringTxt = (isReply == 1 ? '_Reply' : '');
$.extend({
focusBlur: function (obj, defTxt, defColor) {
var obj = $(obj);
obj.focus(function () {
if (obj.val() == defTxt) obj.val("").removeClass(defColor)
});
obj.blur(function () {
if (obj.val() == "") obj.val(defTxt).addClass(defColor)
})
}
});
$.focusBlur("#txtFullName" + stringTxt, "Name", "defColor");
$.focusBlur("#txtEmail" + stringTxt, "E-mail", "defColor");
$.focusBlur("#selCountry" + stringTxt, "Country/Region", "defColor")
},
writeReview: function (pageid) {
window.open('/js/comment/review.html?pid=' + pageid)
},
submitReview: function () {
if ($(".starNote").attr("data-rate") == '') {
alert("Please choose your overall rating of this tour.");
$(".starRating").focus();
return false
}
if (!agate.util.chkForm(document.getElementById("txtComment_Reply"), "Sorry, please enter your review.")) {
$("#txtComment_Reply").focus();
return false
}
if ($("#txtFullName_Reply").val() == '') {
alert("Sorry, please enter your name.");
$("#txtFullName_Reply").focus();
return false
}
$(".photoLoading").show();
var ajaxUrl = '/reserve/inc/ajax/ajaxSubmit.ashx';
var op = 1;
var isReply = 0;
var pageId = agate.util.queryString('pid');
var trackNo = agate.util.queryString('trackno');
var txtComment = $('#txtComment_Reply').val();
var txtFullName = $('#txtFullName_Reply').val();
var txtEmail = '';
var selCountry = $('#selCountry_Reply').val();
var files = $(".qq-upload-list li");
var data = new FormData();
for (var i = 0; i < files.length; i++) {
var d = $(files[i]).find(".qq-thumbnail-selector").attr("src");
var name = $(files[i]).find(".qq-upload-file").attr("title");
var file = agate.util.base64ToFile(d, name);
data.append(name, file)
}
data.append("type", "review");
data.append('op', op);
data.append('isReply', isReply);
data.append('id', pageId);
data.append('txtFullName', txtFullName);
data.append('txtEmail', txtEmail);
data.append('txtComment', txtComment);
data.append('selCountry', selCountry);
data.append('starLevel', (parseInt($(".starNote").attr("data-rate")) + 1));
data.append('trackNo', trackNo);
data.append('commentType', '1');
$.ajax({
url: ajaxUrl,
type: "POST",
data: data,
contentType: false,
processData: false,
success: function (result) {
if (result == "Success") window.location.href = "/review_after.html"
},
error: function (err) {
console.log(err)
}
})
}
},
gotop:function(){
(function(f){
$(document.body).append('');
f();$(window).scroll(function(){f();});
})(function(){
if($(window).scrollTop()>0){
if($('.gotop').length==0)$(document.body).append('');
}else{
$('.gotop').remove();
}
});
},
/*gotop: function () {
$('body').append('');
$(window).scroll(function () {
if ($(window).scrollTop() > 100) {
if ($(window).width() > 425) {
$("#goTop").css({
"bottom": "190px"
});
$('#goTop').show()
} else {
$('#goTop').hide()
}
} else {
$("#goTop").css({
"bottom": "0px"
});
$('#goTop').hide()
}
})
},*/
liveChat: function () {
if ($('#liveChat').length > 0) {
window.openChat = function () {
try {
parent.closeMini()
} catch (e) { }
var live800_companyID = "1224816";
var live800_configID = "127751";
var pagetitle = escape(document.title);
if (document.title.length > 80) {
pagetitle = escape(document.title.substring(0, 80))
}
var protocol = ((document.location.protocol == "https:") ? "https://" : "http://");
var live800_baseUrl = "v2.live800.com";
var live800_baseWebApp = "/live800";
var live800_baseChatHtmlDir = "/chatClient";
var jid = "1271345258";
var globalWindowAttribute = 'toolbar=0,scrollbars=0,location=0,menubar=0,resizable=1,width=770,height=560';
var openUrl = protocol + live800_baseUrl + live800_baseWebApp + live800_baseChatHtmlDir + "/chatbox.jsp?companyID=" + live800_companyID;
if (typeof jid != "undefined") {
openUrl += "&jid=" + jid
}
if (typeof live800_configID != "undefined") {
openUrl += "&configID=" + live800_configID
}
openUrl += "&enterurl=" + escape(document.URL) + "&pagetitle=" + pagetitle;
openUrl += "&lan=en&tm=" + (new Date()).getTime() + "&s=1";
var winAttr = globalWindowAttribute;
var winnName = "chatbox" + live800_companyID;
if (typeof live800_chatVersion != "undefined" && live800_chatVersion == 5) winnName += (new Date()).getTime();
var wnd = window.open(openUrl, winnName, winAttr);
if (typeof wnd != "undefined") {
wnd.focus()
}
return false
}
$("#livechat").attr("onclick", "window.openChat($(\'#livechat\')[0]);");
$(window).scroll(function () {
if ($(window).scrollTop() > 100) {
$("#rightFixed").css({
"bottom": "120px"
})
} else {
$("#rightFixed").css({
"bottom": "10px"
})
}
});
window.closeChat = function () {
$.cookie("livechatClosed", 1, {
expires: 1,
path: '/'
});
$(".live-icon").hide();
$(".live-close").hide();
$(".live-show").show()
}
var isClosedLivechat = ($.cookie("livechatClosed") == "" || $.cookie("livechatClosed") == null) ? false : true;
if (isClosedLivechat) window.closeChat();
$(".rightFixed-nav").show();
$(".icon-delete").click(function (e) {
$("#rightFixed").hide();
return false
})
}
},
mobile: {
init: function () {
$(document.body).append('');
if ($('.header-sub').length > 0) {
if (typeof window.subHotLink != 'undefined') {
$('.header-sub li').eq(window.subHotLink).addClass('hot')
}
}
if (typeof window.subNavCurrentIndex != 'undefined') {
$('#header-navigator-view .nav-item').eq(window.subNavCurrentIndex).append('')
}
$('.mobile-nav').on('click', function () {
var divul = '';
var divul2 = $('#header-navigator-view').html();
divul = divul + divul2 + '
';
$(document.body).append(divul);
var destinations = $('#header-navigator-view .nav-item-list').prop("outerHTML").replace("nav-item-list", "nav-item-list nav-item-list-fixed");
$(document.body).append(destinations);
var sub = '';
if ($('.header-sub').length > 0) {
sub = $('.header-sub').html()
}
$('#mobile-nav-list-view >li').each(function (i) {
var _this = $(this);
var img = _this.attr('data-img');
//if (i == 0) _this.find('a').before('');
//else _this.find('a').before('');
var s = _this.find('.nav-item-sub');
if (s.length > 0) {
s.append(sub)
}
});
$('.nav-item-list-all-btn').text('VIEW ALL');
agate.util.maskOpen();
$('.mobile-nav-list').show();
$('.mobile-nav-list').animate({
left: 0
},
300);
$(".mobile-nav-list").css({
"top": $(window).scrollTop() + "px",
"height": $(window).height() + "px"
});
$("#mobile-nav-list-view .Destinations").on("click",
function (event) {
if ($(".nav-item-list-fixed").hasClass("close")) $('.nav-item-list-fixed').removeClass("close");
else $('.nav-item-list-fixed').addClass("close");
event.stopPropagation()
})
});
$(function () {
$(".Destinations > a").css("pointer-events", "none");
});
$(".header-phone").click(function (event) {
if ($(".header-tel-more").is(':hidden')) $(".header-tel-more").show();
else $(".header-tel-more").hide();
event.stopPropagation()
});
$(document.body).on("click",".mobile-nav-list",//live
function () {
if (!$(".nav-item-list-fixed").is(':hidden')) $(".nav-item-list-fixed").addClass("close")
});
$(document).click(function () {
if (!$(".header-tel-more").is(':hidden')) $(".header-tel-more").hide()
});
$('.g_overlay').bind('click',
function () {
if ($('.mobile-nav-list').length > 0) {
$('.mobile-nav-list').animate({
left: -320
},
300,
function () {
$('.mobile-nav-list').remove();
agate.util.maskClose()
})
}
if ($('.mobile_menu_list').length > 0) {
$('.mobile_menu_list').animate({
left: $(window).width()
},
300,
function () {
$('.mobile_menu_list').remove();
$('.pos-fixed').removeClass('pos-fixed');
agate.util.maskClose()
})
}
$('.nav-item-list-fixed').remove();
$("#telBox").remove();
agate.util.maskClose()
});
$(document.body).on('click','.mobile-nav-list-arrow img',//live
function () {
if ($('.mobile-nav-list').length > 0) {
$('.mobile-nav-list').animate({
left: -320
},
300,
function () {
$('.mobile-nav-list').remove();
agate.util.maskClose()
})
}
if ($('.mobile_menu_list').length > 0) {
$('.mobile_menu_list').animate({
left: 480
},
300,
function () {
$('.mobile_menu_list').remove();
agate.util.maskClose()
})
}
$('.nav-item-list-fixed').remove();
$("#telBox").remove();
agate.util.maskClose()
});
$('.mobile-header-top-phone').on('click',function () {
if ($(window).width() < 1024) {
var divul = '';
$(document.body).append(divul);
agate.util.setCenter($("#telBox"));
agate.util.maskOpen()
}
});
$(document.body).on('click','.telBoxClose',//live
function () {
$("#telBox").remove();
agate.util.maskClose()
});
$(window).bind('scroll',
function () {
var a = $('#header').height();
var b = $(document).scrollTop();
if (b >= a) {
$('.mobile_menu').css({
'position': 'fixed',
'top': ($(window).width()<=900?'120px':'150px')
})
} else {
$('.mobile_menu').css({
'position': 'absolute',
'top': ($(window).width()<=900?'120px':'150px')
})
}
if ($('.mobile_menu_list').length > 0) {
$(".mobile_menu_list").css({
"top": $(window).scrollTop() + "px",
"max-height": $(window).height()
})
}
});
$(window).bind('resize',
function () {
if ($(window).width() <= 425) { } else {
$('#mobile-nav-list,.g_overlay').remove()
}
});
//new header start
$('.headerPhone').on('click',function () {
if(!$(".headerPhone-title").is(":visible")){
var divul = '';
$(document.body).append(divul);
agate.util.setCenter($("#telBox"));
agate.util.maskOpen()
}
});
//new header end
}
},
navBar: {
menu: function () {
return $('.navigator')
},
menuItem: function () {
return $('.navItem')
},
count: function () {
return agate.navBar.menuItem().length
},
mobileMenuCSS: {
bg: '#b1a890'
},
mobileMenu: function () {
return $('.navPhone')
},
init: function () {
agate.navBar.setNav();
agate.navBar.setLeftNav();
agate.navBar.nav2018();
$('.navItemMore').click(function () {
agate.navBar.mobileMenu().css({
'position': 'absolute',
'right': '-2px',
'padding': '10px',
'z-index': 999,
'background': agate.navBar.mobileMenuCSS.bg,
top: '61px'
}).toggle();
return false
});
$(window).resize(function () {
agate.navBar.mobileMenu().hide();
agate.navBar.setNav()
});
$(document).click(function () {
agate.navBar.mobileMenu().hide()
});
$(window).scroll(function () {
var scrolltop = $(this).scrollTop();
var header_top_height = $("#header").height();
//2022-08-08 815-837
if ($(window).width() > 837) {
if (scrolltop > header_top_height) {
$("#header-navigator").css({
"position": "fixed",
"z-index": "1000"
});
$(".header-sub").css({
"position": "fixed",
"z-index": "500"
});
$(".header-sub").css({
"width": "100%",
"top": "48px"
});
$("#header-top").hide()
} else {
$("#header-navigator").css({
"position": "static",
"z-index": "0"
});
$("#header-navigator,.header-sub").css({
"position": "static",
"z-index": "0"
});
$("#header-top").show()
}
} else {
if (scrolltop > header_top_height) {
$("#header-top").css({
"position": "fixed",
"background-color": "#fff",
"border-bottom": "1px solid #D0D0D0",
"z-index": "500"
});
$(".mobile-nav-list").css({
"top": scrolltop + "px",
"height": $(window).height()
})
} else {
$("#header-top").css({
"position": "static"
})
}
}
//2022-08-08 815--837
if ($(window).width() < 837) {
var footerLinkH = $(".link").height();
if ($(document).height() - $(window).height() - scrolltop > footerLinkH) { } else {
if ($("#rightFixed").length > 0 && $("#rightFixed").is(":visible")) {
if ($("#footerExt").length == 0) {
$("#footer").after('')
}
} else {
$("#footerExt").remove()
}
}
}
//2022-08-08 812--834
if ($(window).width() <= 834) {
//$('.header-searchtour').hide()
}
$('.header-search-hot-country').hide()
})
},
setLeftNav: function () {
var w = agate.util.getSize();
var LW = window.LEFTWIDTH || 770;
if (w > LW) return;
if ($('.leftMenu *').length > 0) {
$('.mainCon').after('');
$('.mobile_menu').click(function () {
if ($('.leftMenu').length == 0) return;
var leftTotal = '';
$('.leftMenu').each(function (index, element) {
leftTotal += $(this).html()
});
var leftTotal2 = '';
$('.leftMenu2').each(function (index, element) {
leftTotal2 += $(this).html()
});
var leftTotal3 = '';
if (leftTotal2 != '') leftTotal3 = '';
var divul = '';
$('body').append(divul);
$('.menuTit').each(function () {
var s = $(this).html();
$(this).html('' + s + '
');
if ($(this).find('div').height() > 33) {
$(this).css({
'line-height': '23px',
'height': 'auto'
})
}
});
agate.util.maskOpen();
$('.mobile_menu_list').show();
var s = $('.mobile_menu_list').width();
var totalW = $(window).width() - s;
$('.mobile_menu_list').animate({
left: totalW
},
300);
$('.mobile_menu_list').css({
'top': $(window).scrollTop(),
"max-height": $(window).height()
})
})
}
},
setNav: function () {
agate.navBar.menuItem().removeClass('display_none_320').removeClass('display_none_460').removeClass('display_none_640').removeClass('display_none_770');
var s = agate.util.getSize();
if (s > 770) agate.navBar.menuItem().show();
if (s <= 770 && s > 640) agate.navBar.showNav([6]);
if (s <= 640 && s > 460) agate.navBar.showNav([5, 6, 7]);
if (s <= 460 && s > 360) agate.navBar.showNav([4, 5, 6, 7]);
if (s <= 360 && s > 320) agate.navBar.showNav([2, 4, 5, 6, 7]);
if (s <= 320) agate.navBar.showNav([2, 4, 5, 6, 7])
},
setMobileNav: function (ary) {
if (agate.navBar.mobileMenu().length > 0) agate.navBar.mobileMenu().remove();
var h = '';
for (var j = 0; j < ary.length; j++) h += '' + agate.navBar.menuItem().eq(ary[j]).html() + '
';
agate.navBar.menu().append('' + h + '
');
agate.navBar.mobileMenu().hide()
},
showNav: function (a) {
agate.navBar.setMobileNav(a);
for (var i = agate.navBar.count() ; i >= 1; i--) agate.navBar.menuItem().eq(i).show();
if (a.length == 0) return;
for (var j = 0; j < a.length; j++) agate.navBar.menuItem().eq(a[j]).hide()
},
nav2018: function () {
$('.nav-item').hover(function () {
if ($(this).hasClass('Destinations')) {
if ($('.nav-item-list').hasClass('close')) {
$('.nav-item-list').removeClass('close')
} else $('.nav-item-list').addClass('close')
} else {
$('.nav-item-list').addClass('close')
}
},
function () {
$('.nav-item-list').addClass('close')
})
}
},
util: {
getSize: function () {
return $(window).width()
},
maskOpen: function () {
$('.g_overlay').css({
'display': 'block',
'height': $(document.body).height() + 'px'
})
},
maskClose: function () {
$('.g_overlay').hide()
},
setCenter: function (o) {
if (o.length == 0) return;
o.css({
'top': '218.5px',
'left': (($(window).width() - o.outerWidth(true)) / 2) + 'px'
});
o.show()
},
loadImg: function (url, fn) {
var img = new Image();
img.src = url;
if (img.complete) {
fn.call(img)
} else {
img.onload = function () {
fn.call(img);
img.onload = null
}
}
},
fixDesigner: function () {
var $divAttr2 = $(".Attr2");
if ($divAttr2[0]) {
if ($divAttr2.html().replace(/\s/ig, '') == '') {
$divAttr2.hide();
$(".bg3").hide()
}
};
var $divInfo = $(".info");
if ($divInfo[0]) {
$divInfo.each(function () {
if ($(this).html().replace(/\s/ig, '') == '') {
$(this).hide()
}
})
}
},
flikeBox: function () { },
msnSkype: function () {
if ($("#msnSkype")[0]) {
if ($("#msnSkype").attr("isHome") == "1") $("#msnSkype").load("/com/js/msn/msnhome.htm");
else $("#msnSkype").load("/com/js/msn/msn.htm")
}
},
footLogo: function () {
if ($("#bottom")[0]) {
var $imgAll = $("#bottom img");
var N = $imgAll.length - 1;
if ($($imgAll.get(N)).attr("src") != "/images/logo/cats.gif") return false;
$($imgAll.get(N)).removeAttr("width").after('')
}
},
errorComment: function () {
if (!$("#targetFrame")[0]) {
$("#comments").before('')
}
},
checkEmail: function (alertTxt, obj) {
var temp = $('#' + obj);
var myreg = /^[^.]+@([^.]+\.)+[^.]{2,3}$/;
if (temp.val() != "") {
var str = temp.val();
if (!(str.indexOf("@") != -1 && str.indexOf(".") != -1)) {
alert(alertTxt);
temp.focus();
return false
} else return true
} else {
alert(alertTxt);
temp.focus();
return false
}
},
myEmailCheck: function (str, alertTxt) {
if (str == 'E-mail') {
return true
}
var myreg = /^[^.]+@([^.]+\.)+[^.]{2,3}$/;
if (!(str.indexOf("@") != -1 && str.indexOf(".") != -1)) {
alert(alertTxt);
return true
} else return false
},
chkForm: function (obj, strDesc) {
var strTemp = obj.value;
var re = /[a-zA-Z]/g;
if (!re.test(strTemp)) {
alert(strDesc);
obj.select();
return false
}
return true
},
queryString: function (p) {
var qs = location.search.substr(1),
args = {},
items = qs.length ? qs.split("&") : [],
item = null,
len = items.length;
for (var i = 0; i < len; i++) {
item = items[i].split("=");
var name = decodeURIComponent(item[0]),
value = decodeURIComponent(item[1]);
if (name) {
args[name] = value
}
}
return args[p]
},
base64ToFile: function (dataurl, filename) {
var arr = dataurl.split(','),
mime = arr[0].match(/:(.*?);/)[1],
bstr = atob(arr[1]),
n = bstr.length,
u8arr = new Uint8Array(n);
while (n--) {
u8arr[n] = bstr.charCodeAt(n)
}
return new File([u8arr], filename, {
type: mime
})
}
/* ,
scrollLoad: function (o, f) {
if (o.length == 0) return; (function (fun) {
fun();
setInterval(fun, 500)
})(function () {
o.each(function (i) {
var _ = $(this);
if (typeof _.attr('xwidth') != 'undefined') {
if ($(window).width() < parseInt(_.attr('xwidth'))) {
_.remove();
return
}
}
if (typeof _.attr('isload') == 'undefined') {
if (_.offset().top <= ($(window).height() + $(window).scrollTop())) {
_.attr('isload', 'true');
if (typeof f != 'undefined') f(_)
}
}
})
})
}*/
},
countryAutoComplete: function (o) {
$.getScript("https://data.agatetravel.com/js/v2/jquery_ui/jquery-ui/jquery-ui.min.js",
function () {
var auto_country = ["Afghanistan", "Albania", "Algeria", "Andorra", "Angola", "Anguilla", "Antigua and Barbuda", "Argentina", "Armenia", "Ascension", "Australia", "Austria", "Azerbaijan", "Bahamas", "Bahrain ", "Bangladesh", "Barbados", "Belarus", "Belgium", "Benin", "Bermuda Islands", "Bhutan", "Bolivia", "Bosnia and Herzegovina", "Botswana", "Brazil", "Brunei", "Bulgaria", "Burkina Faso", "Burma", "Burundi", "Belize", "Bermuda", "Cambodia ", "Cameroon", "Canada", "Cape Verde", "Chad", "Chile", "China", "Colombia", "Comorin", "Congo", "Cook Islands", "Costa Rica", "Cote d\'ivoire", "Croatia", "Cuba", "Cyprus", "Czech", "Denmark", "Djibouti", "Dominica ", "DPRK", "East Timor", "Ecuador", "Egypt", "El Salvador", "Equatorial Guinea", "Eritrea", "Estonia", "Ethiopia", "Fiji", "Finland", "France", "French Guiana", "French Polynesia", "Gabon", "Gambia", "Georgia", "Germany", "Ghana", "Greece", "Grenada ", "Guatemala", "Guinea", "Guinea Bissau", "Guyana", "Haiti", "Netherlands", "Honduras", "Hungary", "Iceland", "India", "Indonesia", "Iran", "Iraq", "Ireland", "Israel", "Italy", "Ivory Coast", "Jamaica", "Japan", "Jordan", "Kazakhstan", "Kenya", "Kuwai", "Kirgizstan", "Laos", "Latvia", "Lebanon", "Lesotho", "Liberia", "Libya", "Liechtenstein", "Lithuania", "Luxemburg", "Macedonia", "Madagascar", "Malawi", "Malaysia", "Maldives", "Mali", "Malta", "Mauritania", "Mauritius", "Mexico", "Micronesia", "Moldova", "Monaco", "Mongolia", "Montserrat", "Montenegro", "Morocco", "Mozambique", "Namibia", "Nauru", "Nepal", "Netherlands Antilles", "New Zealand", "Nicaragua", "Niger", "Nigeria", "Norway", "Oman", "Pakistan", "Palestine", "Panama", "Papua New Guinea", "Paraguay", "Peru", "Philippines", "Poland", "Polynesia", "Portugal", "Puerto Rico", "Qatar", "Republic of Korea", "Romania", "Russia", "Rwanda", "Saint Lucia", "Saint Vincent and the Grenadines", "Samoa Western", "Samoa Eastern", "San Marino", "Sao Tome and Principe", "Saudi Arabia", "Senegal", "Serbia", "Seychelles", "Sierra Leone", "Singapore", "Slovakia", "Slovenia", "Solomon Islands", "Somalia", "South Africa", "Spain", "Sri Lanka", "Sudan", "Suriname", "Swaziland", "Sweden", "Switzerland", "Syria", "Tajikistan", "Tanzania", "Thailand", "The Central African Republic", "Togo", "Tonga", "Trinidad and Tobago", "Tunisia", "Turkey", "Turkmenistan", "Uganda", "Ukraine", "UAE", "United Kingdom", "USA", "Uruguay", "Uzbekistan", "Vanuatu", "Venezuela", "Vietnam", "Yemen", "Zaire", "Zambia", "Zimbabwe"];
o.autocomplete({
source: function (request, response) {
var matcher = new RegExp("^" + $.ui.autocomplete.escapeRegex(request.term), "i");
response($.grep(auto_country,
function (item) {
return matcher.test(item)
}))
}
})
})
}
};
var web={
funcLoaded:[],
setFunction: function() {
$('[class*=function]:not(.disabled)').each(function() {
var className = this.className;
var l = className.split(' ');
for (var i = 0,j = l.length; i < j; i++) {
if(web.funcLoaded.indexOf(l[i])==-1){
if (l[i].indexOf('function-') > -1) $.getScript('/js/function/' + l[i].replace(' ', '').replace('function-', '') + '/init.js');
web.funcLoaded.push(l[i]);
}
}
});
},
initHeaderFloat:function(){
(function(f) {f();$(window).scroll(function() {f();});$(window).resize(function() {f();});})(function() {
if($(window).width() <= 640){
if ($(window).scrollTop() > 56) {
$('.header-top').css({'top': "-56px"});
} else {
$('.header-top').css({'top': 0});
}
}else{
$('.header-top').css({'top': 0});
}
if($(".header-nav").is(":visible")){
if ($(window).scrollTop() <= 68) {
$(".header-nav").css({"position":"relative","width":"100%","z-index":"98","top":"0"});
} else {
$(".header-nav").css({"position":"fixed","width":"100%","z-index":"98","top":"0"});
}
}
});
}
};
$(function () {
agate.init();
web.initHeaderFloat();
web.setFunction();
(function(win, doc) {
if (win.postMessage) {
if (win.addEventListener) {
win.addEventListener("message",
function(e) {
var data=e.data;
if(data.type&&data.type=="slider-reviews-size"){
$("#reviews-iframe").height(data.height);
}
},
false);
}
}
})(window, document);
});