function showHideChooseCities() { $("#headerChooseCity").slideToggle(); } function hideLandingDiv(){ $("#messageLanding").slideUp(); var expDate = new Date(); expDate.setTime(expDate.getTime() + (30 * 24 * 3600 * 1000)); document.cookie = "TwangooviewLandingMacau=true"+";expires=" + expDate.toGMTString(); } function hideReferDiv(){ $("#messageLanding").slideUp(); } function valideSyntaxOfMail(strOfEmail){ var place = strOfEmail.indexOf("@",1); var point = strOfEmail.indexOf(".",place+1); if ((place > -1)&&(strOfEmail.length >2)&&(point > 1)){ return true; } else{ return false; } } function openModalDialog(){ $("#dialog").dialog({ modal:true, resizable:false, buttons: { 'Close' : function(){ $(this).dialog('close'); } }, close : function(){ resetModalDialog(); $(this).dialog('destroy'); } }); } function resetModalDialog(){ $("#dialog").attr('title', 'Loading'); $("#dialog").attr('style', ''); $("#dialog").html('Loading'); } function fillModalError(){ $('#dialog').attr('title', 'Error'); $('#dialog').html('
An internal error has occured. Please retry.
'); } function test_email(my_email) { var new_string = new String(my_email); if (!new_string.match('^[-_\.0-9a-zA-Z]{1,}@[-_\.0-9a-zA-Z]{1,}[\.][0-9a-zA-Z]{2,}$')) { return false; } else { return true; } } function addCommentaireDeal(){ var error = 0; var messageErreur = ''; if( $('#formCommentaireMessage').val() == '' ) { messageErreur = 'Your comment can\'t be blank
'; error = 1; } if( error == 1 ) { $("#dialog").attr('title', 'Comments'); $("#dialog").html(messageErreur); $("#dialog").dialog({ modal:true, resizable:false, height:200, width:400, buttons: { 'Ok' : function(){ $(this).dialog('close'); } }, close : function(){ resetModalDialog(); $(this).dialog('destroy'); } }); } else { $('#formCommentaire').submit(); } } function openModalLogin(){ var html = '' + '' ; $("#prompt").html(html); $("#prompt").overlay().load(); } function twangooLogin(){ $("#messageErreur").attr('style', 'display:none;'); var email = $('#formEmailValue').val(); var password = $('#formPassValue').val(); if( email != '' && password != '' ) { if(test_email(email)) { $('#formLogin').attr('action', document.location); $('#formLogin').submit(); } else { $("#formEmailValue").attr('style', 'width:180px;color:#000000;background:#dbeff7;'); $("#messageErreur").attr('style', 'display:block;'); $("#messageErreur").html('Invalid email!'); } } else { $("#formEmailValue").attr('style', 'width:180px;color:#000000;background:#dbeff7;'); $("#formPassValue").attr('style', 'width:180px;color:#000000;background:#dbeff7;'); $("#messageErreur").attr('style', 'display:block;'); $("#messageErreur").html('Fill in the form.'); } } function closePrompt(){ $("#prompt").overlay().close(); } function openModalLogin2(){ var html = '' + '' + ''; $("#dialog").attr('title', 'Sign in'); $("#dialog").html(html); $("#dialog").dialog({ dialogClass: "flora", modal:true, resizable:false, width:400, buttons: { 'Cancel' : function(){ $(this).dialog('close'); }, 'Submit' : function(){ $("#formEmailValue").attr('style', 'width:180px;color:#000000;background:ffffff;'); $("#formPassValue").attr('style', 'width:180px;color:#000000;background:ffffff;'); $("#messageErreur").attr('style', 'display:none;'); var email = $('#formEmailValue').val(); var password = $('#formPassValue').val(); if( email != '' && password != '' ) { if(test_email(email)) { $('#formLogin').attr('action', document.location); $('#formLogin').submit(); } else { $("#formEmailValue").attr('style', 'width:180px;color:#000000;background:#dbeff7;'); $("#messageErreur").attr('style', 'display:block;'); $("#messageErreur").html('Invalid email!'); } } else { $("#formEmailValue").attr('style', 'width:180px;color:#000000;background:#dbeff7;'); $("#formPassValue").attr('style', 'width:180px;color:#000000;background:#dbeff7;'); $("#messageErreur").attr('style', 'display:block;'); $("#messageErreur").html('Fill in the form.'); } } }, close : function(){ resetModalDialog(); $(this).dialog('destroy'); } }); $('.flora.ui-dialog').css({top:50}); } function submitFormNewsletterSubscribe(landing){ var error = false; var msgError = ''; $("#dialog").html('Please wait...
'); if ($("#newsletterEmail").val() == '' || (!valideSyntaxOfMail($("#newsletterEmail").val()))){ error = true; msgError += 'Please enter a valid email!
' } if (error == false){ $.ajax({ type: "POST", async: false, url: "/ajax/newsletter.ajax.php?task=subscribe", data: "newsletterEmail="+$("#newsletterEmail").val()+ "&newsletterRefer="+$("#newsletterRefer").val(), success: function(msg){ document.cookie = "TwangooNewsleterSubscribe=true"; var tabReponse = msg.split('|@|'); if(tabReponse[0] != 'ok') {//cas d'erreur $("#dialog").html(''+ tabReponse[1] +'
'); } else{ $("#dialog").html('You just register to Twangoo\'s newsletter.
'); $("#newsletterEmail").val(''); } }, failure: function(){ $("#dialog").html('An internal error has occured. Please retry.
'); } }); } else { $("#dialog").html(msgError); } $("#dialog").attr('title', 'Newsletter'); $("#dialog").dialog({ modal:true, resizable:false, buttons: { 'Close' : function(){ $(this).dialog('close'); } }, close : function(){ resetModalDialog(); $(this).dialog('destroy'); } }); } function submitFormNewsletterLanding(){ var error = false; var msgError = ''; $("#dialog").html('Please wait...
'); if ($("#newsletterEmail").val() == '' || (!valideSyntaxOfMail($("#newsletterEmail").val()))){ error = true; msgError += 'Please enter a valid email!
' } if (error == false){ $.ajax({ type: "POST", async: false, url: "/ajax/newsletter.ajax.php?task=subscribe", data: "newsletterEmail="+$("#newsletterEmail").val()+"&city="+$("#newsletterCity").val()+"&newsletterRefer="+$("#newsletterRefer").val(), success: function(msg){ document.cookie = "TwangooNewsleterSubscribe=true"; var tabReponse = msg.split('|@|'); if(tabReponse[0] != 'ok') {//cas d'erreur $("#dialog").html(''+ tabReponse[1] +'
'); } else{ //Pour laffil et le tracking if (tabReponse[4] == 3){ document.location.replace("affiliate-tracking,"+tabReponse[3]); } else { document.location.replace("city,1"); } } }, failure: function(){ $("#dialog").html('An internal error has occured. Please retry.
'); } }); } else { $("#dialog").html(msgError); } $("#dialog").attr('title', 'Newsletter'); $("#dialog").dialog({ modal:true, resizable:false, buttons: { 'Close' : function(){ $(this).dialog('close'); } }, close : function(){ resetModalDialog(); $(this).dialog('destroy'); } }); } //A supprimer ? function submitFormNewsletterSubscribe2(){ var error = false; var msgError = ''; if ($("#newsletterEmail2").val() == '' || (!valideSyntaxOfMail($("#newsletterEmail2").val()))){ error = true; msgError += 'Please enter a valid email!
' } if (error == false){ $.ajax({ type: "POST", url: "/ajax/newsletter.ajax.php?task=subscribe", data: "newsletterEmail="+$("#newsletterEmail2").val()+"&newsletterCity="+$("#newsletterCity2").val()+"&newsletterRefer="+$("#newsletterRefer").val(), success: function(msg){ var tabReponse = msg.split('|@|'); if(tabReponse[0] != 'ok') {//cas d'erreur $("#dialog").html(''+ tabReponse[1] +'
'); } else{ $("#dialog").html('You just register to Twangoo\'s newsletter.
'); $("#newsletterEmail2").val(''); } }, failure: function(){ $("#dialog").html('An internal error has occured. Please retry.
'); } }); } else { $("#dialog").html(msgError); } $("#dialog").attr('title', 'Suscribe to the newsletter'); openModalDialog(); } function loadModalCGV(){ $.ajax({ type: "POST", url: '/ajax/common.ajax.php?task=getPageCMSContent', data:'pageid=4', success: function(msg){ var tabReponse = msg.split('|@|'); if(tabReponse[0] == 'ok') { $("#dialog").html('Chargement de la météo
'); $("#dialog").dialog({ modal: true, resizable: false, width: 600, buttons: { "Close": function() { $(this).dialog("close"); } }, close : function(){ resetModalDialog(); $(this).dialog('destroy'); } }); $.ajax({ type: "GET", url: "/ajax/meteo.ajax.php", success: function(msg){ var tabReponse = msg.split('|@|'); if(tabReponse[0] != 'ok') {//cas d'erreur $("#dialog").html('La météo ne peut pas être affichée.
'); } else{ $("#dialog").dialog( "option" , 'title' , tabReponse[2] ); $("#dialog").html(''+ tabReponse[1] +'
'); } }, failure: function(){ $("#dialog").html('An internal error has occured. Please retry.
'); } }); } function handleErrors(){ var html = ''; if (gdir.getStatus().code == G_GEO_UNKNOWN_ADDRESS) html += 'Une des adresses n\'a pas été trouvée.'; else html += 'L\itinénéraire ne peut pas être calculé.'; html += '
'; $("#dialog").html(html); $("#dialog").attr('title', 'Error'); openModalDialog(); } function checkDirection(fromStreet, fromZipCode, fromCity) { var error = false; var txtError = ''; if (fromStreet == ''){ error = true; txtError += 'Veuillez saisir un nom de rue.
'; } if (fromZipCode == ''){ error = true; txtError += 'Veuillez saisir un code postal.
'; } if (fromCity == ''){ error = true; txtError += 'Veuillez saisir une ville.
'; } if (error == false){ return true; } else { $("#dialog").html(txtError); $("#dialog").attr('title', 'Error'); openModalDialog(); return false; } } function toogleCity(){ $('#villeListeContainer').slideToggle(); } function toogleFaq(id){ $('#'+id).slideToggle(); } function IsNumeric(sText){ //v�rifie si la chaine envoy�e est de type num�rique /*var ValidChars = "0123456789."; var IsNumber=true; var Char; for (i = 0; i < sText.length ; i++) { Char = sText[i]; if (ValidChars.indexOf(Char) == -1){ IsNumber = false; } } return IsNumber;*/ return !isNaN(parseFloat(sText)) && isFinite(sText); } function submitOverlayFormNewsletter(){ var error = false; var msgError = ''; parent.$.fancybox.showActivity(); if ($("#overlayEmail").val() == '' || (!valideSyntaxOfMail($("#overlayEmail").val()))){ error = true; msgError += 'Please enter a valid email!' } if (error == false){ $.ajax({ type: "POST", async: false, url: "/ajax/newsletter.ajax.php?task=subscribe", data: "newsletterRefer="+$("#newsletterRefer").val()+"&newsletterEmail="+$("#overlayEmail").val()+"&newsletterCity="+$("#overlayCity").val(), success: function(msg){ var tabReponse = msg.split('|@|'); if(tabReponse[0] != 'ok') {//cas d'erreur $("#overlay-error").html(''+ tabReponse[1] +''); } else { $.cookie('TwangooNewsleterSubscribe', true, { expires: 99999 }); parent.$.fancybox.close(); } }, failure: function(){ $("#overlay-error").html('An internal error has occured. Please retry.'); } }); } else { $("#overlay-error").html(msgError); } parent.$.fancybox.hideActivity(); } function submitWelcomeFormNewsletter(){ var error = false; var msgError = ''; if ($("#overlayEmail").val() == '' || (!valideSyntaxOfMail($("#overlayEmail").val()))){ error = true; msgError += 'Please enter a valid email!' } if (error == false){ $.ajax({ type: "POST", async: false, url: "/ajax/newsletter.ajax.php?task=subscribe", data: "newsletterRefer="+$("#newsletterRefer").val()+"&newsletterEmail="+$("#overlayEmail").val()+"&newsletterCity="+$("#overlayCity").val(), success: function(msg){ var tabReponse = msg.split('|@|'); if(tabReponse[0] != 'ok') {//cas d'erreur $("#overlay-error").html(''+ tabReponse[1] +''); } else { $.cookie('TwangooNewsleterSubscribe', true, { expires: 99999 }); document.location= 'deal' ; } }, failure: function(){ $("#overlay-error").html('An internal error has occured. Please retry.'); } }); } else { $("#overlay-error").html(msgError); } } function clickLuckyDraw(){ parent.$.fancybox.close(); parent.document.location= '/hong-kong/en/luckydraw'; } function loginFacebook(){ document.getElementById( 'formLoginFB' ).submit(); } function initFancyBox(){ $("#overlay-iframe").fancybox({ 'type' : 'iframe', 'href' : '///overlay-subscribe', 'width' : 675, 'height' : 630, 'padding' : 0, 'opacity' : true, 'hideOnOverlayClick' : false }); if(isLogin)$.cookie('TwangooNewsleterSubscribe', true, { expires: 9999 }); if ( !$.cookie('first_visit') && !$.cookie('TwangooNewsleterSubscribe')) { $("#overlay-iframe").trigger('click'); $.cookie('first_visit', true, { expires: 7 }); } } function submitLuckyDraw(landing){ var error = false; var msgError = ''; $("#dialog").html('Please wait...
'); if ($("#luckyEmail").val() == '' || (!valideSyntaxOfMail($("#luckyEmail").val()))){ error = true; msgError += 'Please enter a valid email!
' } if (error == false){ $.ajax({ type: "POST", async: false, url: "/ajax/luckydraw.ajax.php?task=subscribe", data: "luckyEmail="+$("#luckyEmail").val()+ "&luckyRefer="+$("#luckyRefer").val(), success: function(msg){ var tabReponse = msg.split('|@|'); if($.trim(tabReponse[0]) != 'ok') {//cas d'erreur $("#dialog").html(''+ tabReponse[2] +'
'); } else{ document.location= 'lucky-conf'; } }, failure: function(){ $("#dialog").html('An internal error has occured. Please retry.
'); } }); } else { $("#dialog").html(msgError); } $("#dialog").attr('title', 'Lucky Draw'); $("#dialog").dialog({ modal:true, resizable:false, buttons: { 'Close' : function(){ $(this).dialog('close'); } }, close : function(){ resetModalDialog(); $(this).dialog('destroy'); } }); } function updateLuckyShare(type){ $.ajax({ type: "POST", async: false, url: "/ajax/luckydraw.ajax.php?task=share", data: "luckyRefer="+type, success: function(msg){ }, failure: function(){ } }); }