var productform = { mainurl : 'https://www.kundematch.dk/crm/libraries/productform/', redirecturl : '', referrerurl : '', click : 0, getListfirstproduct : function(productid,redirecturl){ this.redirecturl = redirecturl; var referrer = ''; var mainreferrer = ''; var url = ''; var gclid = ''; var paid = 0; try { referrer = document.referrer; this.referrerurl = document.referrer; setTimeout(function(){ console.log(document.URL); $("#referer").val(document.URL); }, 2000); url = document.URL; if( referrer.indexOf('google') >= 0){ mainreferrer = 'google'; } else if( referrer.indexOf('bing') >= 0){ mainreferrer = 'bing'; } else if( referrer.indexOf('facebook') >= 0){ mainreferrer = 'facebook'; } if( url.indexOf('gclid') >= 0){ paid = 1; var urlParams = new URLSearchParams(window.location.search); var gclid = urlParams.get('gclid'); } if( url.indexOf('utm_medium=cpc') >= 0){ paid = 1; } var partner_paid = this.getParam(url,'paid'); var partner_pacid = this.getParam(url,'pacid'); if( typeof partner_paid !== 'undefined' && typeof partner_pacid !== 'undefined' ) { this.setCookie("partner_paid",partner_paid,40); this.setCookie("partner_pacid",partner_pacid,40); } } catch(err) { console.log(err) } jQuery.ajax({ url: this.mainurl+'product.php?mode=product&mainreferrer='+mainreferrer+'&paid='+paid+'&gclid='+gclid+'&server=&b2b=&addressinput=1&addon=task&addon1=&checkbox=&record='+productid+'&idtime='+new Date().getTime(), data : { redirecturl:redirecturl }, type: 'POST', cache: false, success: function(data, textStatus, jqXHR) { $('#productlistimentor').html(data); }, error: function(jqXHR, textStatus, errorThrown) { // Handle errors here //console.log('ERRORS: ' + textStatus); //progressIndicatorElement.progressIndicator({'mode' : 'hide'}); alert(textStatus); // STOP LOADING SPINNER } }); }, getListfirstproductCheckbox : function(productid,redirecturl){ this.redirecturl = redirecturl; var referrer = ''; var mainreferrer = ''; var url = ''; var paid = 0; try { referrer = document.referrer; url = document.URL; if( referrer.indexOf('google') >= 0){ mainreferrer = 'google'; } else if( referrer.indexOf('bing') >= 0){ mainreferrer = 'bing'; } else if( referrer.indexOf('facebook') >= 0){ mainreferrer = 'facebook'; } if( url.indexOf('gclid') >= 0){ paid = 1; } if( url.indexOf('utm_medium=cpc') >= 0){ paid = 1; } } catch(err) { } jQuery.ajax({ url: this.mainurl+'product.php?mode=product&mainreferrer='+mainreferrer+'&paid='+paid+'&server=&b2b=&checkbox=1&record='+productid+'&idtime='+new Date().getTime(), data : { redirecturl:redirecturl }, type: 'POST', cache: false, success: function(data, textStatus, jqXHR) { $('#productlistimentor').html(data); }, error: function(jqXHR, textStatus, errorThrown) { // Handle errors here //console.log('ERRORS: ' + textStatus); //progressIndicatorElement.progressIndicator({'mode' : 'hide'}); alert(textStatus); // STOP LOADING SPINNER } }); }, profileproductselectFinancial : function(){ var error = 0; $('#productformimentor').find( '[class="productmaintype"]' ).each(function () { //console.log($(this).attr('required')+$(this).attr('id')); if ( $(this).val() == '' && error==0 && $(this).attr('required')) { alert("Vælg venligst en af valgmulighederne"); $(this).focus(); $('html,body').animate({scrollTop: $(this).offset().top -100}, 'slow'); error=1; } }); $('#productformimentor').find( '[class="productmaintyperadio"]' ).each(function () { console.log($(this).attr('required')+$(this).attr('id')); if (error==0 && $(this).attr('required')) { var namef = $(this).attr('name') var checkbox = $("[name='"+namef+"']:checked"); if( checkbox .length > 0 ){ } else { alert("Vælg venligst en af valgmulighederne"); $('html,body').animate({scrollTop: $(this).offset().top -100}, 'slow'); error=1; } } }); if (error==1 ) { return ; } $(".slidingDivformimentorfinancial").slideToggle(); $(".slidingDivformimentorbutton").hide(); $('html,body').animate({scrollTop: ($('.slidingDivformimentorfinancial').offset().top-150)}, 'slow'); try { ga('gtm2.send', 'event', { eventCategory: 'calculator', eventAction: 'click', eventLabel: 'beregn prisen'}); }catch(err) { } }, profileproductselectFinancialnext : function(){ var error = 0; $('#productformimentor').find( '[class="productmaintype"]' ).each(function () { //console.log($(this).attr('required')+$(this).attr('id')); if ( $(this).val() == '' && error==0 && $(this).attr('required')) { alert("Vælg venligst en af valgmulighederne"); $(this).focus(); $('html,body').animate({scrollTop: $(this).offset().top -100}, 'slow'); error=1; } }); $('#productformimentor').find( '[class="productmaintyperadio"]' ).each(function () { console.log($(this).attr('required')+$(this).attr('id')); if (error==0 && $(this).attr('required')) { var namef = $(this).attr('name') var checkbox = $("[name='"+namef+"']:checked"); if( checkbox .length > 0 ){ } else { alert("Vælg venligst en af valgmulighederne"); $('html,body').animate({scrollTop: $(this).offset().top -100}, 'slow'); error=1; } } }); if (error==1 ) { return ; } var checkbox = $("[name='financial']:checked"); if( checkbox .length > 0 ){ } else { alert("Vælg venligst en af valgmulighederne"); $('html,body').animate({scrollTop: $("[name='financial']").offset().top -100}, 'slow'); return; } $(".slidingDivformimentor").slideToggle(); $(".slidingDivformimentorbutton").hide(); $(".slidingDivformimentorfinancial").slideUp(); $('html,body').animate({scrollTop: ($('.slidingDivformimentor').offset().top-280)}, 'slow'); $('#fname').focus(); try { ga('gtm2.send', 'event', { eventCategory: 'calculator', eventAction: 'click', eventLabel: 'naeste'}); }catch(err) { } }, profileproductselect : function(){ var error = 0; $('#productformimentor').find( '[class="productmaintype"]' ).each(function () { //console.log($(this).attr('required')+$(this).attr('id')); if ( $(this).val() == '' && error==0 && $(this).attr('required')) { alert("Vælg venligst en af valgmulighederne"); $(this).focus(); $('html,body').animate({scrollTop: $(this).offset().top -100}, 'slow'); error=1; } }); $('#productformimentor').find( '[class="productmaintyperadio"]' ).each(function () { console.log($(this).attr('required')+$(this).attr('id')); if (error==0 && $(this).attr('required')) { var namef = $(this).attr('name') var checkbox = $("[name='"+namef+"']:checked"); if( checkbox .length > 0 ){ } else { alert("Vælg venligst en af valgmulighederne"); $('html,body').animate({scrollTop: $(this).offset().top -100}, 'slow'); error=1; } } }); if (error==1 ) { return ; } $(".slidingDivformimentortask").slideToggle(); $(".slidingDivformimentorbutton").hide(); $(".slidingDivformimentorfinancial").slideUp(); $('html,body').animate({scrollTop: ($('.slidingDivformimentortask').offset().top-215)}, 'slow'); }, profileproductselectTasknext : function(){ var error = 0; if(!$('#divbudget').is(':visible')){ $('#ftask_error').removeClass("hide"); return; } $(".slidingDivformimentortask").hide(); $(".slidingDivformimentor").slideToggle(); $(".slidingDivformimentorbuttontask").hide(); $('html,body').animate({scrollTop: ($('.slidingDivformimentor').offset().top-215)}, 'slow'); $('#fname').focus(); }, findcity : function(){ $('#fcity_verified').fadeIn('slow'); var zip = $('#fzip').val(); if (zip.length == 4 && zip.match(/[^0]([0-9]){3}$/)) { $.ajax({ url: 'https://prisberegning.dk/findcity/city.php?id=' + zip + '', dataType: 'jsonp', type: 'GET', timeout: 2000, success: function(json) { //if (json.navn.length > 1 && json.navn.match(/^[a-zæøå]([a-zæøå\s])+$/i)) { if (json.navn.length > 1 && json.navn !== 'Ukendt') { $('#fcity').val(json.navn); $('#fcity_verified').fadeIn('slow'); } else { $('#fcity').val(''); // $('#fcity_verified').fadeOut('slow'); } }, error: function(e) { $('#fcity').val(''); // $('#fcity_verified').fadeOut('slow'); } }); } }, preproductformaction : function(){ $(":input").focus(function(){ if ($(this).hasClass("needsfeildimentor") ) { $(this).val(""); $(this).removeClass("needsfeildimentor"); } }); var error = 0; $('#productformimentor').find( '[class="productmaintype"]' ).each(function () { console.log($(this).attr('required')); if ( $(this).val() == '' && error==0 && $(this).attr('required')) { alert("Vælg venligst en af valgmulighederne"); $(this).focus(); $('html,body').animate({scrollTop: $(this).offset().top -100}, 'slow'); error=1; } }); if (error==1 ) { return ; } var a = "En eller flere tegn er ikke gyldige"; if( $('#fname').val().length <= 1 && error==0 ) { alert(a + " i dit navn!"); $('#fname').focus(); error=1; } if( ! $('#fzip').val().match(/[^0]([0-9]){3}$/) && error==0 ) { alert(a + " i dit postnummer!"); $('#fzip').focus(); error=1; } if( ! $('#femail').val().match(/^([a-z0-9_\-])+([.]?[a-z0-9_\-]{1,})*@([a-z0-9\-_]{1,}[.])+[a-z]{2,4}$/i) && error==0 ) { alert(a + " i din emailaddresse!"); $('#femail').focus(); error=1; } if( ! $('#ftelephone').val().match(/[^0]([0-9]){7}$/) && error==0 ) { alert(a + " i dit telefonnummer!"); $('#ftelephone').focus(); error=1; } if(error==0){ $('#prename').html($('#fname').val()); $('#prepost').html($('#fzip').val()); $('#preby').html($('#fcity').val()); $('#preemail').html($('#femail').val()); $('#prephone').html($('#ftelephone').val()); $("#slidingDivformimentor").slideUp('fast',function() { $("#summarydiv").slideDown('fast',function() { $('html,body').animate({scrollTop: $('#prename').offset().top-200}, 'fast'); }); }); }else{ $("#productformimentor").removeClass("loadingimentor"); $('html,body').animate({scrollTop: $('#slidingDivformimentor').offset().top-30}, 'slow'); } }, preproductformaction_new : function(){ $(":input").focus(function(){ if ($(this).hasClass("needsfeildimentor") ) { $(this).val(""); $(this).removeClass("needsfeildimentor"); } }); var error = 0; $('#productformimentor').find( '[class="productmaintype"]' ).each(function () { console.log($(this).attr('required')); if ( $(this).val() == '' && error==0 && $(this).attr('required')) { alert("Vælg venligst en af valgmulighederne"); $(this).focus(); $('html,body').animate({scrollTop: $(this).offset().top -100}, 'slow'); error=1; } }); if (error==1 ) { return ; } var a = "En eller flere tegn er ikke gyldige"; if( $('#fname').val().length <= 1 ) { $('#fname_error').removeClass("hide"); $('#fname').addClass('border-error'); $('#fname').keyup(function(event){ $('#fname_error').addClass("hide"); $('#fname').removeClass('border-error'); }); if(error == 0) { $('#fname').focus(); } error=1; } if( ! $('#fzip').val().match(/[^0]([0-9]){3}$/) ) { $('#fzip_error').removeClass("hide"); $('#fzip').addClass('border-error'); $('#fzip').keyup(function(event){ $('#fzip_error').addClass("hide"); $('#fzip').removeClass('border-error'); }); if(error == 0) { $('#fzip').focus(); } error=1; } if( ! $('#femail').val().match(/^([a-z0-9_\-])+([.]?[a-z0-9_\-]{1,})*@([a-z0-9\-_]{1,}[.])+[a-z]{2,4}$/i) ) { $('#femail_error').removeClass("hide"); $('#femail').addClass('border-error'); $('#femail').keyup(function(event){ $('#femail_error').addClass("hide"); $('#femail').removeClass('border-error'); }); if(error == 0) { $('#femail').focus(); } error=1; } if( ! $('#ftelephone').val().match(/[^0]([0-9]){7}$/) ) { $('#ftelephone_error').removeClass("hide"); $('#ftelephone').addClass('border-error'); $('#ftelephone').keyup(function(event){ $('#ftelephone_error').addClass("hide"); $('#ftelephone').removeClass('border-error'); }); if(error == 0) { $('#ftelephone').focus(); } error=1; } if(error==0){ $('#prename').html($('#fname').val()); $('#prepost').html($('#fzip').val()); $('#preby').html($('#fcity').val()); $('#preemail').html($('#femail').val()); $('#prephone').html($('#ftelephone').val()); $("#slidingDivformimentor").slideUp('fast',function() { $("#summarydiv").slideDown('fast',function() { $('html,body').animate({scrollTop: $('#prename').offset().top-200}, 'fast'); }); }); }else{ $("#productformimentor").removeClass("loadingimentor"); $('html,body').animate({scrollTop: $('#slidingDivformimentor').offset().top-30}, 'slow'); } }, hentproductformaction : function(){ $(":input").focus(function(){ if ($(this).hasClass("needsfeildimentor") ) { $(this).val(""); $(this).removeClass("needsfeildimentor"); } }); var error = 0; var errorTilbud = 0; if( $('#tilbudNote').val().trim().length == 0 && error==0 ) { alert("Du maagler beskriv kort din opgave"); $('#tilbudNote').focus(); error=1; errorTilbud=1; } var a = "En eller flere tegn er ikke gyldige"; if( $('#fname').val().length <= 1 && error==0 ) { alert(a + " i dit navn!"); $('#fname').focus(); error=1; } if( ! $('#fzip').val().match(/[^0]([0-9]){3}$/) && error==0 ) { alert(a + " i dit postnummer!"); $('#fzip').focus(); error=1; } if( ! $('#femail').val().match(/^([a-z0-9_\-])+([.]?[a-z0-9_\-]{1,})*@([a-z0-9\-_]{1,}[.])+[a-z]{2,4}$/i) && error==0 ) { alert(a + " i din emailaddresse!"); $('#femail').focus(); error=1; } if( ! $('#ftelephone').val().match(/[^0]([0-9]){7}$/) && error==0 ) { alert(a + " i dit telefonnummer!"); $('#ftelephone').focus(); error=1; } if (!$('#henttilbud_checkbox').is(':checked') && error==0) { alert("Du skal accepte betingelserne."); $('#henttilbud_checkbox').focus(); error=1; } if(error==0){ this.productformaction(); }else{ $("#productformimentor").removeClass("loadingimentor"); if(errorTilbud == 0) { $('html,body').animate({scrollTop: $('#slidingDivformimentor').offset().top-30}, 'slow'); } else { $('html,body').animate({scrollTop: $('#productformimentor').offset().top-60}, 'slow'); } } }, hentproductformaction_new : function(){ $(":input").focus(function(){ if ($(this).hasClass("needsfeildimentor") ) { $(this).val(""); $(this).removeClass("needsfeildimentor"); } }); var error = 0; var errorTilbud = 0; if( $('#tilbudNote').val().trim().length == 0 && error==0 ) { $('#tilbudNote_error').removeClass("hide"); $('#tilbudNote').addClass('border-error'); $('#tilbudNote').keyup(function(event){ $('#tilbudNote_error').addClass("hide"); $('#tilbudNote').removeClass('border-error'); }); $('#tilbudNote').focus(); error=1; errorTilbud=1; } var a = "En eller flere tegn er ikke gyldige"; if( $('#fname').val().length <= 1 ) { $('#fname_error').removeClass("hide"); $('#fname').addClass('border-error'); $('#fname').keyup(function(event){ $('#fname_error').addClass("hide"); $('#fname').removeClass('border-error'); }); if(error == 0) { $('#fname').focus(); } error=1; } if( ! $('#fzip').val().match(/[^0]([0-9]){3}$/) ) { $('#fzip_error').removeClass("hide"); $('#fzip').addClass('border-error'); $('#fzip').keyup(function(event){ $('#fzip_error').addClass("hide"); $('#fzip').removeClass('border-error'); }); if(error == 0) { $('#fzip').focus(); } error=1; } if( ! $('#femail').val().match(/^([a-z0-9_\-])+([.]?[a-z0-9_\-]{1,})*@([a-z0-9\-_]{1,}[.])+[a-z]{2,4}$/i) ) { $('#femail_error').removeClass("hide"); $('#femail').addClass('border-error'); $('#femail').keyup(function(event){ $('#femail_error').addClass("hide"); $('#femail').removeClass('border-error'); }); if(error == 0) { $('#femail').focus(); } error=1; } if( ! $('#ftelephone').val().match(/[^0]([0-9]){7}$/) ) { $('#ftelephone_error').removeClass("hide"); $('#ftelephone').addClass('border-error'); $('#ftelephone').keyup(function(event){ $('#ftelephone_error').addClass("hide"); $('#ftelephone').removeClass('border-error'); }); if(error == 0) { $('#ftelephone').focus(); } error=1; } if (!$('#henttilbud_checkbox').is(':checked') ) { $('#henttilbud_checkbox_error').removeClass("hide"); $('#henttilbud_checkbox').addClass('border-error'); $('#henttilbud_checkbox').change(function() { $('#henttilbud_checkbox_error').addClass("hide"); $('#henttilbud_checkbox').removeClass('border-error'); }); if(error == 0) { $('#ftelephone').focus(); } error=1; } if(error==0){ this.productformaction(); }else{ $("#productformimentor").removeClass("loadingimentor"); if(errorTilbud == 0) { $('html,body').animate({scrollTop: $('#slidingDivformimentor').offset().top-30}, 'slow'); } else { $('html,body').animate({scrollTop: $('#productformimentor').offset().top-60}, 'slow'); } } }, hentproductformaction_new_address : function(){ $(":input").focus(function(){ if ($(this).hasClass("needsfeildimentor") ) { $(this).val(""); $(this).removeClass("needsfeildimentor"); } }); var error = 0; var errorTilbud = 0; if( $('#tilbudNote').val().trim().length == 0 && error==0 ) { $('#tilbudNote_error').removeClass("hide"); $('#tilbudNote').addClass('border-error'); $('#tilbudNote').keyup(function(event){ $('#tilbudNote_error').addClass("hide"); $('#tilbudNote').removeClass('border-error'); }); $('#tilbudNote').focus(); error=1; errorTilbud=1; } var a = "En eller flere tegn er ikke gyldige"; if( $('#fname').val().length <= 1 ) { $('#fname_error').removeClass("hide"); $('#fname').addClass('border-error'); $('#fname').keyup(function(event){ $('#fname_error').addClass("hide"); $('#fname').removeClass('border-error'); }); if(error == 0) { $('#fname').focus(); } error=1; } if( $('#faddress').val().length <= 1 ) { $('#faddress_error').removeClass("hide"); $('#faddress').addClass('border-error'); $('#faddress').keyup(function(event){ $('#faddress_error').addClass("hide"); $('#faddress').removeClass('border-error'); }); if(error == 0) { $('#faddress').focus(); } error=1; } if( ! $('#femail').val().match(/^([a-z0-9_\-])+([.]?[a-z0-9_\-]{1,})*@([a-z0-9\-_]{1,}[.])+[a-z]{2,4}$/i) ) { $('#femail_error').removeClass("hide"); $('#femail').addClass('border-error'); $('#femail').keyup(function(event){ $('#femail_error').addClass("hide"); $('#femail').removeClass('border-error'); }); if(error == 0) { $('#femail').focus(); } error=1; } if( ! $('#ftelephone').val().match(/[^0]([0-9]){7}$/) ) { $('#ftelephone_error').removeClass("hide"); $('#ftelephone').addClass('border-error'); $('#ftelephone').keyup(function(event){ $('#ftelephone_error').addClass("hide"); $('#ftelephone').removeClass('border-error'); }); if(error == 0) { $('#ftelephone').focus(); } error=1; } if (!$('#henttilbud_checkbox').is(':checked') ) { $('#henttilbud_checkbox_error').removeClass("hide"); $('#henttilbud_checkbox').addClass('border-error'); $('#henttilbud_checkbox').change(function() { $('#henttilbud_checkbox_error').addClass("hide"); $('#henttilbud_checkbox').removeClass('border-error'); }); if(error == 0) { $('#ftelephone').focus(); } error=1; } if(error==0){ $("#productformimentor").addClass("loadingimentor"); var partner_paid = ''; var partner_pacid = ''; try { partner_paid = this.getCookie("partner_paid"); partner_pacid = this.getCookie("partner_pacid"); } catch(err) { } this.click = this.click +1; var form = $("#productformimentor"); var json = form.serialize(); jQuery.ajax({ url: this.mainurl+'product.php?mode=saveaddress&partner_paid='+partner_paid+'&partner_pacid='+partner_pacid+'&click='+this.click+'&idtime='+new Date().getTime(), data: json, type: 'POST', cache: false, success: function(data, textStatus, jqXHR) { if(data['success']) { var price = data['result']['price']; var email = $('#femail').val(); localStorage.setItem('email', email); // window.location.href=$("#redirecturl").val()+'?id='+price+'&email='+email; window.location.href=$("#redirecturl").val()+'?id='+price; }else{ $("#productformimentor").removeClass("loadingimentor"); alert(data['error']['message']); } }, error: function(jqXHR, textStatus, errorThrown) { // Handle errors here //console.log('ERRORS: ' + textStatus); //progressIndicatorElement.progressIndicator({'mode' : 'hide'}); alert(textStatus); $("#productformimentor").removeClass("loadingimentor"); // STOP LOADING SPINNER } }); try { ga('gtm2.send', 'event', { eventCategory: 'calculator', eventAction: 'click', eventLabel: 'final confirmation'}); }catch(err) { } }else{ $("#productformimentor").removeClass("loadingimentor"); if(errorTilbud == 0) { $('html,body').animate({scrollTop: $('#slidingDivformimentor').offset().top-30}, 'slow'); } else { $('html,body').animate({scrollTop: $('#productformimentor').offset().top-60}, 'slow'); } } }, setCookie : function(c_name,value,exdays) { var exdate=new Date(); exdate.setDate(exdate.getDate() + exdays); var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString()); document.cookie = c_name+"="+c_value+"; path=/"; }, getCookie : function(name) { const value = `; ${document.cookie}`; const parts = value.split(`; ${name}=`); if (parts.length === 2) return parts.pop().split(';').shift(); }, getParam : function(url,param){ return new URLSearchParams(window.location.search).get(param); }, preproductformaction_other_new_address : function(){ $(":input").focus(function(){ if ($(this).hasClass("needsfeildimentor") ) { $(this).val(""); $(this).removeClass("needsfeildimentor"); } }); var error = 0; var errorTilbud = 0; var a = "En eller flere tegn er ikke gyldige"; if( $('#fname').val().length <= 1 ) { $('#fname_error').removeClass("hide"); $('#fname').addClass('border-error'); $('#fname').keyup(function(event){ $('#fname_error').addClass("hide"); $('#fname').removeClass('border-error'); }); if(error == 0) { $('#fname').focus(); } error=1; } if( $('#faddress').val().length <= 1 ) { $('#faddress_error').removeClass("hide"); $('#faddress').addClass('border-error'); $('#faddress').keyup(function(event){ $('#faddress_error').addClass("hide"); $('#faddress').removeClass('border-error'); }); if(error == 0) { $('#faddress').focus(); } error=1; } if( ! $('#femail').val().match(/^([a-z0-9_\-])+([.]?[a-z0-9_\-]{1,})*@([a-z0-9\-_]{1,}[.])+[a-z]{2,4}$/i) ) { $('#femail_error').removeClass("hide"); $('#femail').addClass('border-error'); $('#femail').keyup(function(event){ $('#femail_error').addClass("hide"); $('#femail').removeClass('border-error'); }); if(error == 0) { $('#femail').focus(); } error=1; } if( ! $('#ftelephone').val().match(/[^0]([0-9]){7}$/) ) { $('#ftelephone_error').removeClass("hide"); $('#ftelephone').addClass('border-error'); $('#ftelephone').keyup(function(event){ $('#ftelephone_error').addClass("hide"); $('#ftelephone').removeClass('border-error'); }); if(error == 0) { $('#ftelephone').focus(); } error=1; } if (!$('#henttilbud_checkbox').is(':checked') ) { $('#henttilbud_checkbox_error').removeClass("hide"); $('#henttilbud_checkbox').addClass('border-error'); $('#henttilbud_checkbox').change(function() { $('#henttilbud_checkbox_error').addClass("hide"); $('#henttilbud_checkbox').removeClass('border-error'); }); if(error == 0) { $('#ftelephone').focus(); } error=1; } if(error==0){ $("#productformimentor").addClass("loadingimentor"); this.click = this.click +1; var form = $("#productformimentor"); var json = form.serialize(); var partner_paid = ''; var partner_pacid = ''; try { partner_paid = this.getCookie("partner_paid"); partner_pacid = this.getCookie("partner_pacid"); } catch(err) { } jQuery.ajax({ url: this.mainurl+'product.php?mode=saveaddress&typecal=calc&partner_paid='+partner_paid+'&partner_pacid='+partner_pacid+'&click='+this.click+'&idtime='+new Date().getTime(), data: json, type: 'POST', cache: false, success: function(data, textStatus, jqXHR) { if(data['success']) { var price = data['result']['price']; var email = $('#femail').val(); localStorage.setItem('email', email); // window.location.href=$("#redirecturl").val()+'?id='+price+'&email='+email; window.location.href=$("#redirecturl").val()+'?id='+price+'&email='+email; }else{ $("#productformimentor").removeClass("loadingimentor"); alert(data['error']['message']); } }, error: function(jqXHR, textStatus, errorThrown) { // Handle errors here //console.log('ERRORS: ' + textStatus); //progressIndicatorElement.progressIndicator({'mode' : 'hide'}); alert(textStatus); $("#productformimentor").removeClass("loadingimentor"); // STOP LOADING SPINNER } }); try { ga('gtm2.send', 'event', { eventCategory: 'calculator', eventAction: 'click', eventLabel: 'final confirmation'}); }catch(err) { } }else{ $("#productformimentor").removeClass("loadingimentor"); if(errorTilbud == 0) { $('html,body').animate({scrollTop: $('#slidingDivformimentor').offset().top-30}, 'slow'); } else { $('html,body').animate({scrollTop: $('#productformimentor').offset().top-60}, 'slow'); } } }, preproductformaction_other_new : function(){ $(":input").focus(function(){ if ($(this).hasClass("needsfeildimentor") ) { $(this).val(""); $(this).removeClass("needsfeildimentor"); } }); var error = 0; var errorTilbud = 0; var a = "En eller flere tegn er ikke gyldige"; if( $('#fname').val().length <= 1 ) { $('#fname_error').removeClass("hide"); $('#fname').addClass('border-error'); $('#fname').keyup(function(event){ $('#fname_error').addClass("hide"); $('#fname').removeClass('border-error'); }); if(error == 0) { $('#fname').focus(); } error=1; } if( ! $('#fzip').val().match(/[^0]([0-9]){3}$/) ) { $('#fzip_error').removeClass("hide"); $('#fzip').addClass('border-error'); $('#fzip').keyup(function(event){ $('#fzip_error').addClass("hide"); $('#fzip').removeClass('border-error'); }); if(error == 0) { $('#fzip').focus(); } error=1; } if( ! $('#femail').val().match(/^([a-z0-9_\-])+([.]?[a-z0-9_\-]{1,})*@([a-z0-9\-_]{1,}[.])+[a-z]{2,4}$/i) ) { $('#femail_error').removeClass("hide"); $('#femail').addClass('border-error'); $('#femail').keyup(function(event){ $('#femail_error').addClass("hide"); $('#femail').removeClass('border-error'); }); if(error == 0) { $('#femail').focus(); } error=1; } if( ! $('#ftelephone').val().match(/[^0]([0-9]){7}$/) ) { $('#ftelephone_error').removeClass("hide"); $('#ftelephone').addClass('border-error'); $('#ftelephone').keyup(function(event){ $('#ftelephone_error').addClass("hide"); $('#ftelephone').removeClass('border-error'); }); if(error == 0) { $('#ftelephone').focus(); } error=1; } if (!$('#henttilbud_checkbox').is(':checked') ) { $('#henttilbud_checkbox_error').removeClass("hide"); $('#henttilbud_checkbox').addClass('border-error'); $('#henttilbud_checkbox').change(function() { $('#henttilbud_checkbox_error').addClass("hide"); $('#henttilbud_checkbox').removeClass('border-error'); }); if(error == 0) { $('#ftelephone').focus(); } error=1; } if(error==0){ this.productformaction(); }else{ $("#productformimentor").removeClass("loadingimentor"); if(errorTilbud == 0) { $('html,body').animate({scrollTop: $('#slidingDivformimentor').offset().top-30}, 'slow'); } else { $('html,body').animate({scrollTop: $('#productformimentor').offset().top-60}, 'slow'); } } }, preproductupdate : function(){ $("#slidingDivformimentor").slideDown(); $("#summarydiv").slideUp(); }, productformaction : function(){ $("#productformimentor").addClass("loadingimentor"); this.click = this.click +1; var form = $("#productformimentor"); var json = form.serialize(); jQuery.ajax({ url: this.mainurl+'product.php?mode=save&click='+this.click+'&idtime='+new Date().getTime(), data: json, type: 'POST', cache: false, success: function(data, textStatus, jqXHR) { if(data['success']) { //alert($("#redirecturl").val()); var price = data['result']['price']; var email = $('#femail').val(); localStorage.setItem('email', email); // window.location.href=$("#redirecturl").val()+'?id='+price+'&email='+email; window.location.href=$("#redirecturl").val()+'?id='+price; }else{ $("#productformimentor").removeClass("loadingimentor"); alert(data['error']['message']); } }, error: function(jqXHR, textStatus, errorThrown) { // Handle errors here //console.log('ERRORS: ' + textStatus); //progressIndicatorElement.progressIndicator({'mode' : 'hide'}); alert(textStatus); $("#productformimentor").removeClass("loadingimentor"); // STOP LOADING SPINNER } }); try { ga('gtm2.send', 'event', { eventCategory: 'calculator', eventAction: 'click', eventLabel: 'final confirmation'}); }catch(err) { } }, mainproductselect : function(mainproductid,divid){ if(mainproductid == ''){ $('#subprodcut_'+divid).html(''); return ; } $("#productformimentor").addClass("loadingimentor"); jQuery.ajax({ url: this.mainurl+'product.php?mode=producttype&server=&b2b=&checkbox=&record='+mainproductid+'&idtime='+new Date().getTime(), type: 'POST', cache: false, processData: false, // Don't process the files contentType: false, // Set content type to false as jQuery will tell the server its a query string request success: function(data, textStatus, jqXHR) { $("#productformimentor").removeClass("loadingimentor"); $('#subprodcut_'+divid).html(data); }, error: function(jqXHR, textStatus, errorThrown) { // Handle errors here //console.log('ERRORS: ' + textStatus); //progressIndicatorElement.progressIndicator({'mode' : 'hide'}); $("#productformimentor").removeClass("loadingimentor"); alert(textStatus); // STOP LOADING SPINNER } }); }, mainproducttypeselect : function(mainproductid,divid){ if(mainproductid == ''){ return ; } $("#productformimentor").addClass("loadingimentor"); jQuery.ajax({ url: this.mainurl+'product.php?mode=producttype&server=&b2b=&checkbox=&record='+mainproductid+'&idtime='+new Date().getTime(), type: 'POST', cache: false, processData: false, // Don't process the files contentType: false, // Set content type to false as jQuery will tell the server its a query string request success: function(data, textStatus, jqXHR) { $("#productformimentor").removeClass("loadingimentor"); $('#subprodcuttype_'+divid).html(data); }, error: function(jqXHR, textStatus, errorThrown) { // Handle errors here //console.log('ERRORS: ' + textStatus); //progressIndicatorElement.progressIndicator({'mode' : 'hide'}); $("#productformimentor").removeClass("loadingimentor"); alert(textStatus); // STOP LOADING SPINNER } }); } }