// JavaScript Document // --------------------------- Index Page ------------------------------------- var slideIndex = 1; var slideShowInterval; // Next/previous controls function plusSlides(n) { showSlides(slideIndex += n); } // Thumbnail image controls function currentSlide(n) { showSlides(slideIndex = n); } function showSlides(n) { var i; var slides = document.getElementsByClassName("mySlides"); var dots = document.getElementsByClassName("dot"); if (n > slides.length) {slideIndex = 1} if (n < 1) {slideIndex = slides.length} for (i = 0; i < slides.length; i++) { slides[i].style.display = "none"; } for (i = 0; i < dots.length; i++) { dots[i].className = dots[i].className.replace(" active", ""); } slides[slideIndex-1].style.display = "block"; dots[slideIndex-1].className += " active"; if(slideShowInterval != null) clearInterval(slideShowInterval); slideShowInterval = setInterval(function(){ plusSlides(1) }, 6*1000); } function init_slider(){ if($('.slideshow-container').length){ $('.slideshow-container .prev').click(function(){ plusSlides(-1); }); $('.slideshow-container .next').click(function(){ plusSlides(1); }); $('.slideshow-container .dot').click(function(){ currentSlide($(this).data('index')); }); showSlides(slideIndex); } // if($('.slideshow-container').length){ } // function init_slider(){ function move_to_about(){ if($('#about_feature').length){ window.location.hash = '#about'; if($('#headerContent_mobile').is(':visible')){ if(mm_still != null){ $('#mobile_mm img').stop().attr("src", mm_still.src); } $('#headerContent_mobile').stop().css('height', '84px'); } var pos_top = $('#about_feature').offset().top; $("html, body").animate({ scrollTop:pos_top }, "fast"); } else { $(location).attr('href', local_url+'#about'); } } var othersPartnerHandler, othersContactHandler; function othersPartnerForm_onFocus(_target){ _target.css("border", "1px solid #05D08F"); if(typeof($(_target).attr('id')) != 'undefined'){ if($('#'+_target.attr('id')+'_err').length){ $('#'+_target.attr('id')+'_err').remove(); } } // if(typeof(_target.attr('id')) != 'undefined'){ } function othersPartnerForm_onBlur(_target){ _target.css("border", "1px solid #ccc"); if($.trim(_target.val()) == '' || $.trim(Number(_target.val())) == '0'){ if(typeof(_target.attr('id')) != 'undefined'){ if( _target.attr('id') == 'partner_name' || _target.attr('id') == 'partner_email' || _target.attr('id') == 'partner_mobile' || _target.attr('id') == 'partner_org_id' || _target.attr('id') == 'partner_how_many' || _target.attr('id') == 'partner_url' || _target.attr('id') == 'partner_about' || _target.attr('id') == 'partner_no_attendance' || _target.attr('id') == 'partner_ticket_price'){ _target.css("border", "1px solid #FF8000"); _target.after('
'+ajax_showStatusMessage(-46)+'
'); } } // if(typeof(_target.attr('id')) != 'undefined'){ } else { // if($.trim(_target.val()) == '' || $.trim(Number(_target.val())) == '0'){ if(typeof(_target.attr('id')) != 'undefined'){ if( _target.attr('id') == 'partner_url'){ var val = _target.val(); _target.val(((val && !val.match(/^http([s]?):\/\/.*/)) ? 'http://' : '') + val); if(!validateURL($.trim(_target.val()))){ if(!$('#'+_target.attr('id')+'_err').length){ _target.css("border", "1px solid #FF8000"); _target.after('
'+ajax_showStatusMessage(-45)+'
'); } } //if(!validateURL(_target.val())){ } } //if(typeof(_target.attr('id')) != 'undefined'){ } // if($.trim(_target.val()) == '' || $.trim(Number(_target.val())) == '0'){ } function othersPartnerForm_checkNoErr(){ var err_no = 0; // out of focus, on blur $('#partnerForm input, #partnerForm textarea').each(function(){ if(typeof($(this).attr('id')) != 'undefined'){ if($(this).is(":focus")){ $(this).blur(); } // if($(this).is(":focus")){ }; }); $('#partnerForm input, #partnerForm textarea').each(function(){ othersPartnerForm_onFocus($(this)); othersPartnerForm_onBlur($(this)); }); err_no = $('#partnerForm').find('div[id*="err"]').length; if(err_no == 0){ return true; } return false; } function othersContactForm_checkNoErr(){ var err_no = 0; // out of focus, on blur $('#contactForm input, #contactForm select, #contactForm textarea').each(function(){ if(typeof($(this).attr('id')) != 'undefined'){ if($(this).is(":focus")){ $(this).blur(); } // if($(this).is(":focus")){ }; }); $('#contactForm input, #contactForm select, #contactForm textarea').each(function(){ othersContactForm_onFocus($(this)); othersContactForm_onBlur($(this)); }); err_no = $('#contactForm').find('div[id*="err"]').length; if(err_no == 0){ return true; } return false; } function othersContactForm_onFocus(_target){ _target.css("border", "1px solid #05D08F"); if(typeof($(_target).attr('id')) != 'undefined'){ if($('#'+_target.attr('id')+'_err').length){ $('#'+_target.attr('id')+'_err').remove(); } } // if(typeof(_target.attr('id')) != 'undefined'){ } function othersContactForm_onBlur(_target){ _target.css("border", "1px solid #ccc"); if($.trim(_target.val()) == '' || $.trim(Number(_target.val())) == '0'){ if(typeof(_target.attr('id')) != 'undefined'){ if( _target.attr('id') == 'contact_name' || _target.attr('id') == 'contact_email' || _target.attr('id') == 'contact_mobile' || _target.attr('id') == 'contact_about' || _target.attr('id') == 'contact_topics'){ _target.css("border", "1px solid #FF8000"); _target.after('
'+ajax_showStatusMessage(-46)+'
'); } } // if(typeof(_target.attr('id')) != 'undefined'){ } else { // if($.trim(_target.val()) == '' || $.trim(Number(_target.val())) == '0'){ if(typeof(_target.attr('id')) != 'undefined'){ if( _target.attr('id') == 'contact_url'){ var val = _target.val(); _target.val(((val && !val.match(/^http([s]?):\/\/.*/)) ? 'http://' : '') + val); if(!validateURL($.trim(_target.val()))){ if(!$('#'+_target.attr('id')+'_err').length){ _target.css("border", "1px solid #FF8000"); _target.after('
'+ajax_showStatusMessage(-45)+'
'); } } //if(!validateURL(_target.val())){ } } //if(typeof(_target.attr('id')) != 'undefined'){ } // if($.trim(_target.val()) == '' || $.trim(Number(_target.val())) == '0'){ } function init_page_index(){ if($('#about_feature').length){ if(window.location.hash){ if(window.location.hash == '#about'){ move_to_about(); } } } // if($('#about_feature').length){ // Page: Contact init_page_contact(); // Page: Partner init_page_partners(); // Page: FAQ init_page_faq(); // Page: fee init_page_fee(); init_slider(); } function init_page_fee(){ if($('#fee_mobile-buttons').length){ $('.fee_mobile').not('#fee_mobile-buttons, #basic').stop().hide(); $('#fee_mobile-buttons .button').each(function(){ $(this).click(function(){ $('#fee_mobile-buttons .button').each(function(){ $(this).removeClass('selected'); }); $(this).addClass('selected'); $('.fee_mobile').not('#fee_mobile-buttons').hide(); if($(this).data('id').length){ $('#'+$(this).data('id')).fadeIn(500); $("html, body").animate({ scrollTop:$('#'+$(this).data('id')).offset().top-30 }, "fast"); } // if($(this).data('id').length){ }); }); } // if($('#fee_mobile-buttons').length){ /* if($('#tabs-desktop-options').length){ var mBool = ($('#tabs-mobile-option-1').css('display') != 'block' && $('#tabs-mobile-option-2').css('display') != 'block') ? true : false; var dBool = ($('#tabs-desktop-option-1').css('display') != 'block' && $('#tabs-desktop-option-2').css('display') != 'block') ? true : false; if(!mBool){ $('#tabs-mobile-option-1').show(); $('#tabs-mobile-option-2').fadeOut(0); } if(!dBool){ $('#tabs-desktop-option-1').show(); $('#tabs-desktop-option-2').fadeOut(0); } $('.tabs-desktop-option-btns').each(function(){ $(this).click(function(){ var mBool = ($('#tabs-mobile-option-1').css('display') != 'block' && $('#tabs-mobile-option-2').css('display') != 'block') ? true : false; var dBool = ($('#tabs-desktop-option-1').css('display') != 'block' && $('#tabs-desktop-option-2').css('display') != 'block') ? true : false; $('.tabs-desktop-option-btns[data-select="'+(($(this).attr('data-select') == 1) ? '1' : '2')+'"]').switchClass('.tabs-desktop-option-btns', '.tabs-desktop-option-btns active', 300); $('.tabs-desktop-option-btns[data-select="'+(($(this).attr('data-select') == 1) ? '2' : '1')+'"]').switchClass('.tabs-desktop-option-btns active', '.tabs-desktop-option-btns', 500); if($(this).attr('data-select') == 1){ if(!mBool){ $('#tabs-mobile-option-1').fadeIn(500); $('#tabs-mobile-option-2').fadeOut(0); } if(!dBool){ $('#tabs-desktop-option-1').fadeIn(500); $('#tabs-desktop-option-2').fadeOut(0); } } if($(this).attr('data-select') == 2){ if(!mBool){ $('#tabs-mobile-option-1').fadeOut(0); $('#tabs-mobile-option-2').fadeIn(500); } if(!dBool){ $('#tabs-desktop-option-1').fadeOut(0); $('#tabs-desktop-option-2').fadeIn(500); } } //alert('asdfsdf'); }); }); } // if($('#tabs-desktop-options').length){ */ } // function init_page_fee(){ function init_page_faq(){ if($('#others_page_content').length && $('.faq-description').length > 0){ //ans //que $('.faq-description').each(function(){ $(this).click(function(){ $('.faq-description').each(function(){ $(this).find('.ans').stop().animate({ height:'0' }, 100); }); var boo = ($(this).find('.ans').height() == 0) ? true : false; $(this).find('.ans').stop().animate({ height:(boo) ? ($(this).find('.ans div:eq(0)').height()+25)+'px' : '0' }, 100); }); }); } } function init_page_contact(){ // Page: Contact if(!$("#contact_submitBtn").is(":disabled") && $('#others_page_content').length && $('#contactForm').length){ othersContactHandler = function(e) { if(e != null){ if(($(e.currentTarget).is('input') || $(e.currentTarget).is('textarea')) && e.which != 13){ return; } // if(($(e.currentTarget).is('input') || $(e.currentTarget).is('textarea')) && e.which != 13){ } // if(e != null){ ajax_form_show_topBarMessage(0); ajax_submitBtn_setInProgress_withLoadingBar($("#contact_submitBtn"), function(){}, true); if(!othersContactForm_checkNoErr()){ // ---------------- scroll top -------------------- var pos_top = 0; if($('#contactForm').find('div[id*="err"]').length > 0){ if(typeof($(this).attr('id')) != 'undefined'){ var id = $('#contactForm').find('div[id*="err"]').first().attr('id').replace('_err', ''); pos_top = $('#'+id+'').offset().top; } } // filter err pos_top -= 160; $("html, body").animate({ scrollTop:pos_top }, "fast"); // --- END ----- scroll top ---------------------- // button ajax_submitBtn_setInProgress_withLoadingBar($("#contact_submitBtn"), othersContactHandler, false); } else { // if(!createOrg_checkNoErr()){ $.ajax({ url: local_url+'lib/ajax/contact/', headers: { 'X-Etickets-Key': $('#h').val() }, data: $('#contactForm').serialize(), type:"POST", dataType:'json', beforeSend: function(msg){ ajax_show_loading_mask(true); }, complete: function(msg){ setTimeout(function() { ajax_show_loading_mask(false); ajax_submitBtn_setInProgress_withLoadingBar($("#contact_submitBtn"), othersContactHandler, false); }, 500); }, success: function(json_data){ //alert(json_data.status); setTimeout(function() { if(json_data.status == 1){ $('#contactForm').hide(); $('#contact_submitBtn').switchClass('form_submitBtn', 'form_submitBtn_grey_disabled', 0); var txt = ''; switch(Number(global_js_params.lang)){ default: case 1: txt = 'We have received your enquiry, and we are currently looking into it and follow up. Thanks for your patience.'; break; case 2: txt = '我們已經收到您的查詢,並盡快處理及跟進。請耐心等待我們的回覆。'; break; case 3: txt = '我们已经收到您的查询,并尽快处理及跟进。请耐心等待我们的回覆。'; break; } $('#contactForm').after('

'+txt+'

'); //$(location).attr('href', local_url+'org/dashboard'); } else { if(json_data.status == -4003){ $(location).attr('href', local_url+'logout/'); } else if(json_data.status == -1001){ ajax_form_show_topBarMessage(1); } } }, 600); }, error:function(xhr, ajaxOptions, thrownError){ setTimeout(function() { ajax_form_show_topBarMessage(1); }, 500); } }); } // if(!createOrg_checkNoErr()){ }; // othersContactHandler = function(e) { $('#contactForm input, #contactForm select, #contactForm textarea').each(function(){ // select if($(this).is('select')) { $(this).change(function(){ $('.contactFormHidden').stop().animate({ height:($( "#"+$(this).attr('id')+" option:selected" ).val() != 0 && $( "#"+$(this).attr('id')+" option:selected" ).val() != "") ? ($('.contactFormHidden div:eq(0)').height()+20)+'px' : '0' }, 200); }); } $(this).focus(function(){ othersContactForm_onFocus($(this)); }); $(this).blur(function(){ othersContactForm_onBlur($(this)); }); }); $("#contactForm input[type!='hidden']").each(function(){ $(this).bind("keypress", othersContactHandler); }); // $("#contactForm input[type!='hidden']").each(function(){ $("#contact_submitBtn").bind("click", othersContactHandler); } } function init_page_partners(){ if(!$("#partner_submitBtn").is(":disabled") && $('#others_page_content').length && $('#partnerForm').length){ othersPartnerHandler = function(e) { if(e != null){ if(($(e.currentTarget).is('input') || $(e.currentTarget).is('textarea')) && e.which != 13){ return; } // if(($(e.currentTarget).is('input') || $(e.currentTarget).is('textarea')) && e.which != 13){ } // if(e != null){ ajax_form_show_topBarMessage(0); ajax_submitBtn_setInProgress_withLoadingBar($("#partner_submitBtn"), function(){}, true); if(!othersPartnerForm_checkNoErr()){ // ---------------- scroll top -------------------- var pos_top = 0; if($('#partnerForm').find('div[id*="err"]').length > 0){ if(typeof($(this).attr('id')) != 'undefined'){ var id = $('#partnerForm').find('div[id*="err"]').first().attr('id').replace('_err', ''); pos_top = $('#'+id+'').offset().top; } } // filter err pos_top -= 160; $("html, body").animate({ scrollTop:pos_top }, "fast"); // --- END ----- scroll top ---------------------- // button ajax_submitBtn_setInProgress_withLoadingBar($("#partner_submitBtn"), othersPartnerHandler, false); } else { // if(!createOrg_checkNoErr()){ $.ajax({ url: local_url+'lib/ajax/partners/', headers: { 'X-Etickets-Key': $('#h').val() }, data: $('#partnerForm').serialize(), type:"POST", dataType:'json', beforeSend: function(msg){ ajax_show_loading_mask(true); }, complete: function(msg){ setTimeout(function() { ajax_show_loading_mask(false); ajax_submitBtn_setInProgress_withLoadingBar($("#partner_submitBtn"), othersPartnerHandler, false); }, 500); }, success: function(json_data){ //alert(json_data.status); setTimeout(function() { if(json_data.status == 1){ $('#partnerForm').hide(); $('#partner_submitBtn').switchClass('form_submitBtn', 'form_submitBtn_grey_disabled', 0); var txt = ''; switch(Number(global_js_params.lang)){ default: case 1: txt = 'We have received your request, and we are currently looking into it. Our representative will contact you to follow up.'; break; case 2: txt = '我們已經收到您的指示,營業代表將盡快處理資料並聯絡閣下。'; break; case 3: txt = '我们已经收到您的指示,营业代表将尽快处理资料并联络阁下。'; break; } $('#partnerForm').after('

'+txt+'

'); //$(location).attr('href', local_url+'org/dashboard'); } else { if(json_data.status == -4003){ $(location).attr('href', local_url+'logout/'); } else if(json_data.status == -1001){ ajax_form_show_topBarMessage(1); } } }, 600); }, error:function(xhr, ajaxOptions, thrownError){ setTimeout(function() { ajax_form_show_topBarMessage(1); }, 500); } }); } // if(!createOrg_checkNoErr()){ }; // othersPartnerHandler = function(e) { $('#partnerForm input, #partnerForm textarea').each(function(){ $(this).focus(function(){ othersPartnerForm_onFocus($(this)); }); $(this).blur(function(){ othersPartnerForm_onBlur($(this)); }); }); $("#partnerForm input[type!='hidden']").each(function(){ $(this).bind("keypress", othersPartnerHandler); }); // $("#partnerForm input[type!='hidden']").each(function(){ $("#partner_submitBtn").bind("click", othersPartnerHandler); } // if($('#others_page_content').length && $('#partnerForm').length){ } // ----- END --------------- Index Page -------------------------------------