jQuery.noConflict(); function getCookie(name) { var nameEQ = name + "="; var ca = document.cookie.split(';'); for(var i=0;i < ca.length;i++) { var c = ca[i]; while (c.charAt(0)==' ') c = c.substring(1,c.length); if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length); } return null; } function setCookie(name,value,days) { if (days) { var date = new Date(); date.setTime(date.getTime()+(days*24*60*60*1000)); var expires = "; expires="+date.toGMTString(); } else var expires = ""; document.cookie = name+"="+value+expires+"; path=/"; } var was_leave = false; var go_step2 = true; var need_confirm = false; var need_loading = true; function subm() { var errors = validate_step_1(); if (errors === true) return false; save_lead(1, ''); } function subm2() { var errors = validate_step_1(); if (errors === true) return false; var lead_id = parseInt(jQuery('#new_lead_id').val()); save_lead(1, ''); save_lead(2, lead_id); } function show_step2(lead_id) { jQuery('#step1').hide(); jQuery('#step2').show(); jQuery('#new_lead_id').attr('value', lead_id); } function save_lead(step, lead_id) { //jQuery('#ajax_loader').show(); if (need_loading == true) { jQuery('.min-width').css('opacity','0.2'); jQuery('#body').append('
מתבצעת העברת נתונים
'); } // step 1 var ctl00_Form_InsCommonForm_ActionType = jQuery('#ctl00_Form_InsCommonForm_ActionType').val(); var ctl00_Form_InsCommonForm_FirstName = jQuery('#ctl00_Form_InsCommonForm_FirstName').val(); var ctl00_Form_InsCommonForm_LastName = jQuery('#ctl00_Form_InsCommonForm_LastName').val(); var ctl00_Form_InsCommonForm_AreaCode1 = jQuery('#ctl00_Form_InsCommonForm_AreaCode1').val(); var ctl00_Form_InsCommonForm_Phone1 = jQuery('#ctl00_Form_InsCommonForm_Phone1').val(); var ctl00_Form_InsCommonForm_AreaCode2 = jQuery('#ctl00_Form_InsCommonForm_AreaCode2').val(); var ctl00_Form_InsCommonForm_Phone2 = jQuery('#ctl00_Form_InsCommonForm_Phone2').val(); var ctl00_Form_InsCommonForm_Email = jQuery('#ctl00_Form_InsCommonForm_Email').val(); var ctl00_Form_InsCommonForm_Area = jQuery('#ctl00_Form_InsCommonForm_Area').val(); var ctl00_Form_InsCommonForm_sum = jQuery('#ctl00_Form_InsCommonForm_sum').val(); var ctl00_Form_InsCommonForm_age = jQuery('#ctl00_Form_InsCommonForm_age').val(); //jQuery('body').append('
'); //jQuery('#kuku').html('age:'+ctl00_Form_InsCommonForm_age); // insuranceanable var insuranceanable = jQuery('#insuranceanable').attr('checked') == 'checked' ? 1 : 0; if (step == 2) insuranceanable = 0; if (!ctl00_Form_InsCommonForm_age) ctl00_Form_InsCommonForm_age = 0; if (step == 1) { setCookie('firstname',ctl00_Form_InsCommonForm_FirstName, 365); setCookie('lastname',ctl00_Form_InsCommonForm_LastName, 365); } // step 2 //var ctl00_Form_InsCommonForm_Asset = jQuery('#ctl00_Form_InsCommonForm_Asset').val(); //var ctl00_Form_InsCommonForm_Income = jQuery('#ctl00_Form_InsCommonForm_Income').val(); //var ctl00_Form_InsCommonForm_Tz = jQuery('#ctl00_Form_InsCommonForm_Tz').val(); //if (!ctl00_Form_InsCommonForm_Asset) ctl00_Form_InsCommonForm_Asset = ""; //if (!ctl00_Form_InsCommonForm_Income) ctl00_Form_InsCommonForm_Income = ""; //if (!ctl00_Form_InsCommonForm_Tz) ctl00_Form_InsCommonForm_Tz = ""; var soapTemplate = jQuery('#soap-template'); var soapBody = soapTemplate.html() .replace('{LeadId}', lead_id ) .replace('{Step}', step ) .replace('{FirstName}', ctl00_Form_InsCommonForm_FirstName ) .replace('{LastName}', ctl00_Form_InsCommonForm_LastName ) .replace('{Birthday1}', ctl00_Form_InsCommonForm_age ) .replace('{AreaCode0}', ctl00_Form_InsCommonForm_AreaCode1 ) .replace('{Phone0}', ctl00_Form_InsCommonForm_Phone1 ) .replace('{AreaCode1}', ctl00_Form_InsCommonForm_AreaCode2 ) .replace('{Phone1}', ctl00_Form_InsCommonForm_Phone2 ) .replace('{Email}', ctl00_Form_InsCommonForm_Email ) .replace('{Area}', '' ) .replace('{LeadTypeId}', 30 ) .replace('{ActionType}', '' ) .replace('{Summ}', ctl00_Form_InsCommonForm_sum ) .replace('{Asset}', '' ) .replace('{Tz}', '' ) .replace('{Income}', '' ) .replace('{Age}', ctl00_Form_InsCommonForm_age ) .replace('{InsuranceEnable}', insuranceanable ) .replace('{GoogleRefferer}', '' ) .replace('{HttpRefferer}', '' ) .replace('{RemoteAddress}', '3.144.12.29' ) .replace('{RefferalId}', 3 ) .replace('{LeadSourceId}', '1' ); jQuery.post('/wp-ws-3651.php', {xml: soapBody}, function(response) { response = parseInt(response); if (response != 0) { jQuery('#ajax_loader').hide(); jQuery('.min-width').css('opacity','1'); jQuery('#div_loading').remove(); //window.location.href = '/wp-end.php'; jQuery('.bl_form').html('הנתונים נשלחו בהצלחה!
תודה שפניתם אלינו!
'); } if (response == 0) { was_leave = true; // confirm lead jQuery.post('/wp-ws-send-3651.php', {lead_id: lead_id}, function() { window.location.href = '/wp-confirmation.php'; }); } else if (go_step2 == true) { show_step2(response); } else if (need_confirm == true) { jQuery.post('/wp-ws-send-3651.php', {lead_id: response}, function() {}); } }); } function validate_step_1() { //var ctl00_Form_InsCommonForm_ActionType = jQuery('#ctl00_Form_InsCommonForm_ActionType').val(); var ctl00_Form_InsCommonForm_FirstName = jQuery('#ctl00_Form_InsCommonForm_FirstName').val(); var ctl00_Form_InsCommonForm_LastName = jQuery('#ctl00_Form_InsCommonForm_LastName').val(); var ctl00_Form_InsCommonForm_AreaCode1 = jQuery('#ctl00_Form_InsCommonForm_AreaCode1').val(); var ctl00_Form_InsCommonForm_Phone1 = jQuery('#ctl00_Form_InsCommonForm_Phone1').val(); var ctl00_Form_InsCommonForm_AreaCode2 = jQuery('#ctl00_Form_InsCommonForm_AreaCode2').val(); var ctl00_Form_InsCommonForm_Phone2 = jQuery('#ctl00_Form_InsCommonForm_Phone2').val(); var ctl00_Form_InsCommonForm_Email = jQuery('#ctl00_Form_InsCommonForm_Email').val(); //var ctl00_Form_InsCommonForm_Area = jQuery('#ctl00_Form_InsCommonForm_Area').val(); var ctl00_Form_InsCommonForm_sum = jQuery('#ctl00_Form_InsCommonForm_sum').val(); var ctl00_Form_InsCommonForm_age = jQuery('#ctl00_Form_InsCommonForm_age').val(); var errors = false; /*if (!ctl00_Form_InsCommonForm_ActionType || ctl00_Form_InsCommonForm_ActionType == '') { jQuery('#ctl00_Form_InsCommonForm_ActionType_err').parent().show(); errors = true; } else { jQuery('#ctl00_Form_InsCommonForm_ActionType_err').parent().hide(); }*/ if (!ctl00_Form_InsCommonForm_FirstName || ctl00_Form_InsCommonForm_FirstName == '') { jQuery('#ctl00_Form_InsCommonForm_FirstName_err').parent().show(); errors = true; } else { jQuery('#ctl00_Form_InsCommonForm_FirstName_err').parent().hide(); } if (!ctl00_Form_InsCommonForm_LastName || ctl00_Form_InsCommonForm_LastName == '') { jQuery('#ctl00_Form_InsCommonForm_LastName_err').parent().show(); errors = true; } else { jQuery('#ctl00_Form_InsCommonForm_LastName_err').parent().hide(); } if (ctl00_Form_InsCommonForm_AreaCode1 == '') { jQuery('#ctl00_Form_InsCommonForm_AreaCode1_err').parent().show(); errors = true; } else { jQuery('#ctl00_Form_InsCommonForm_AreaCode1_err').parent().hide(); } if (!ctl00_Form_InsCommonForm_Phone1 || ctl00_Form_InsCommonForm_Phone1.length != 7 || !isnum(ctl00_Form_InsCommonForm_Phone1)) { jQuery('#ctl00_Form_InsCommonForm_Phone1_err').parent().show(); errors = true; } else { jQuery('#ctl00_Form_InsCommonForm_Phone1_err').parent().hide(); } if (!ctl00_Form_InsCommonForm_Email || ctl00_Form_InsCommonForm_Email == '' || !validateEmail(ctl00_Form_InsCommonForm_Email)) { jQuery('#ctl00_Form_InsCommonForm_Email_err').parent().show(); errors = true; } else { jQuery('#ctl00_Form_InsCommonForm_Email_err').parent().hide(); } /*if (!ctl00_Form_InsCommonForm_Area || ctl00_Form_InsCommonForm_Area == '') { jQuery('#ctl00_Form_InsCommonForm_Area_err').parent().show(); errors = true; } else { jQuery('#ctl00_Form_InsCommonForm_Area_err').parent().hide(); }*/ if (!ctl00_Form_InsCommonForm_sum || ctl00_Form_InsCommonForm_sum == '' || ctl00_Form_InsCommonForm_sum.length > 14 || !isnum(ctl00_Form_InsCommonForm_sum)) { jQuery('#ctl00_Form_InsCommonForm_sum_err').parent().show(); errors = true; } else { jQuery('#ctl00_Form_InsCommonForm_sum_err').parent().hide(); } if (jQuery('.f_age').css('display') != 'none' && (!ctl00_Form_InsCommonForm_age || !isnum(ctl00_Form_InsCommonForm_age) || ctl00_Form_InsCommonForm_age > 100) ) { jQuery('#ctl00_Form_InsCommonForm_age_err').parent().show(); errors = true; } else { jQuery('#ctl00_Form_InsCommonForm_age_err').parent().hide(); } return errors; } function validate_step_2() { var ctl00_Form_InsCommonForm_Asset = jQuery('#ctl00_Form_InsCommonForm_Asset').val(); var ctl00_Form_InsCommonForm_Income = jQuery('#ctl00_Form_InsCommonForm_Income').val(); var ctl00_Form_InsCommonForm_Tz = jQuery('#ctl00_Form_InsCommonForm_Tz').val(); var errors = false; if (!ctl00_Form_InsCommonForm_Tz || ctl00_Form_InsCommonForm_Tz.length != 9 || !isnum(ctl00_Form_InsCommonForm_Tz)) { jQuery('#ctl00_Form_InsCommonForm_Tz_err').parent().show(); errors = true; } else { jQuery('#ctl00_Form_InsCommonForm_Tz_err').parent().hide(); } if (!ctl00_Form_InsCommonForm_Asset || !isnum(ctl00_Form_InsCommonForm_Asset)) { jQuery('#ctl00_Form_InsCommonForm_Asset_err').parent().show(); errors = true; } else { jQuery('#ctl00_Form_InsCommonForm_Asset_err').parent().hide(); } if (!ctl00_Form_InsCommonForm_Income || !isnum(ctl00_Form_InsCommonForm_Income)) { jQuery('#ctl00_Form_InsCommonForm_Income_err').parent().show(); errors = true; } else { jQuery('#ctl00_Form_InsCommonForm_Income_err').parent().hide(); } return errors; } function isnum(val) { var isnum = /^\d+$/.test(val); return isnum; } function validateEmail(email) { var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; return re.test(email); }