function setCookie(sName, sValue) {
var today = new Date(), expires = new Date();
if(sValue==""){
expires.setTime(today.getTime() - 3600);
} else {
expires.setTime(today.getTime() + (365*24*60*60*1000));
}
document.cookie = sName + "=" + encodeURIComponent(sValue) + ";expires=" + expires.toGMTString()+"; path=/ ;domain = .tipimail.com";
}
function getCookie(sName) {
var oRegex = new RegExp("(?:; )?" + sName + "=([^;]*);?");
if (oRegex.test(document.cookie)) {
return decodeURIComponent(RegExp["$1"]);
} else {
return null;
}
}
function delCookie(nom) {
setCookie(nom,"")
}
function is_int(value){
if((parseFloat(value) == parseInt(value)) && !isNaN(value)){
return true;
} else {
return false;
}
}
function goToByScroll(id){
// Remove "link" from the ID
id = id.replace("link", "");
if (document.getElementById(id)) {
$('html,body').animate({
scrollTop: $("#"+id).offset().top-70},
'slow');
}
return false;
}
function verifMail(mail){
var reg = new RegExp('^[a-z0-9]+([_|\.|-]{1}[a-z0-9]+)*@[a-z0-9]+([_|\.|-]{1}[a-z0-9]+)*[\.]{1}[a-z]{2,6}$', 'i');
return(reg.test(mail));
}
function changeprice(value){
if(value!="all"){
$(".tab.premium").find(".price").find(".value").html(value);
$("#pricing").find(".premium").find(".price").animate({opacity: 1});
} else {
$("#pricing").find(".premium").find(".price").animate({opacity: 0});
goToByScroll("contact");
}
return false;
}
function checkFormStore(prd){
$("#formprocess").find("#cdprd").val(prd);
$("#formprocess").submit();
}
function checkContactForm(){
erreur="";
if($("#msg").val().length<10){
erreur='Merci de saisir votre message';
}
if($("#email").val().length == 0){
erreur='Merci de saisir votre email';
}else{
if(!verifMail($("#email").val())){
erreur='Adresse email non valide';
}
}
if($("#lastname").val().length<2){
erreur='Merci de saisir un nom';
}
if($("#firstname").val().length<2){
erreur='Merci de saisir un prénom';
}
if(erreur!=""){
swal({ title: 'Erreur!', text: erreur, type: "error" });
return false;
}
}
function inscriptionBeta(email){
//if email empty
if(email.length == 0){
swal({ title: 'Merci de saisir votre email', text: "", type: "error" });
} else {
if(verifMail(email)){
$.ajax({
type: "POST",
url: '//static.tipimail.com/ws/addbeta.asp',
data: 'mail='+email.toLowerCase()+'&langBeta=FR',
success: function(data){
myTextSuccess = "Félicitations! Vous êtes le %X%e inscrit.\n\nVous recevrez votre invitation dans les %nb% prochains jours.\n\nFaites passer le message";
splitData = data.split("--");
if(splitData[0]=="OK"){
swal({
title: 'Merci de votre inscription',
text: myTextSuccess.replace("%X%", splitData[1]).replace("%nb%", splitData[2]),
html: true,
type: "success"
});
showShare(splitData[1]);
} else if(data=="NOK1") {
swal({ title: 'Votre adresse email existe déjà !', text: "", type: "error", html: true });
} else {
swal({ title: 'Adresse email non valide', text: "", type: "error" });
}
}
});
} else {
swal({ title: 'Adresse email non valide', text: "", type: "error" });
}
}
}
function addNewsletter(email){
if(email.length == 0){
swal({ title: 'Merci de saisir votre email', text: "", type: "error" });
} else {
if(verifMail(email)){
$.ajax({
type: "POST",
url: 'https://static.tipimail.com/ws/addNewsletter.asp',
data: 'mail='+email.toLowerCase()+'&lang=FR',
success: function(data){
if(data=="OK"){
swal({
title: "Merci de votre inscription",
text: "Vous êtes dorénavant inscrit à notre newsletter",
html: true,
type: "success"
});
$("#footer_news_email").val("");
} else if(data=="NOK1") {
swal({ title: "Déjà abonné !", text: "", type: "error", html: true });
} else {
swal({ title: "Email non valide.", text: "", type: "error" });
}
}
});
} else {
swal({ title: "Email non valide.", text: "", type: "error" });
}
}
return false;
}
function showShare(nb){
txt="Je suis le %X%e inscrit pour essayer la beta #Tipimail. Inscrivez vous aussi pour recevoir une invitation à l'outil d'#email de #service !";
txt=encodeURIComponent(txt.replace("%X%", nb));
html='\n\n';
html+='';
html+='
'
html+='
';
$(".sweet-alert").find("p").append(html);
//$(".sweet-alert").find("button.confirm").hide();
}
function popitup(url) {
if(url==""){ return false; }
newwindow=window.open(url,'name','height=400,width=600');
if(window.focus){ newwindow.focus(); }
return false;
}
function checkMobileFormStore(value){
if(value != "more"){
checkFormStore(value);
} else {
goToByScroll('contact');
}
}
function searchFAQ(value){
if( value != "" ){
$.ajax({
type: "POST",
url: '//static.tipimail.com/ws/faq-search.asp',
data: 'word='+value+'&lang=FR',
success: function(data){
createOverlayFaq();
var obj = jQuery.parseJSON(data);
exvalue="";
myHtml="";
$.each(obj, function(key, val){
if(val.c_url != exvalue){ htmltop="