var submit_caption="Рассчитать стоимость полиса"; var form=document.request_form; function submit_release() { document.getElementById('id_submit').disabled=""; document.getElementById('id_submit').value=submit_caption; } function load_companies(_all) { form.geo_city_id.disabled="disabled"; $('#id_submit').attr("disabled","disabled"); $("#id_comp_column_1").html("Загружается список компаний...

"); $('#id_comp_column_2').html(""); $('#id_comp_column_3').html(""); $.post( '/php_includes/request_v2/jquery_actions.php', { iaction: "get_companies", all: _all, insurance: form.insurance.value, geo_city_id: form.geo_city_id.value }, function(data) { try { var res=JSON.parse(data); } catch (error) { alert("Системная ошибка!\n\n"+data); return; } if (res['result']=='ok') { $("#id_comp_column_1").html(""); for (i=1;i<=3;i++) { var obj = $("#id_comp_column_"+i); for (z=0;z
'); } $(obj).find("input[type=checkbox]").bind("click",function(){ if (this.checked) $("label[for='"+this.id+"']").addClass("bold"); else $("label[for='"+this.id+"']").removeClass("bold"); }); } if (res['all']==0) { $("#id_comp_column_3").append('
Все компании
'); } form.geo_city_id.disabled=""; $('#id_submit').attr("disabled",""); } } ); } function city_changed() { if (form.geo_city_id.value==0) { $("#id_comp_column_1").html("Необходимо указать город

"); $('#id_comp_column_2').html(""); $('#id_comp_column_3').html(""); }else { load_companies(0); } } function companies_show_all(geo_city_id,insur_href) { load_companies(1); } form.geo_city_id.onchange=city_changed; /*Инициируем обновление списка компаний*/ form.geo_city_id.onchange(); /* Подготовка к отправке формы - формируем массив выделенных компаний */ function prepare_send(empty_error) { document.getElementById('id_submit').disabled="disabled"; document.getElementById('id_submit').value="Идет обработка..."; } function disable_form() { for (var i=0;i0) $(this).hide(); else { $(this).find("input[type=button]").hide(); } i++; }); $("#id_region_id").bind("change",function(){ if ($("#id_region_id").val()==0) { $("#id_city_id").empty().attr("disabled","disabled").append(""); return; } $("#id_region_id").attr("disabled","disabled"); $("#id_city_id").empty().attr("disabled","disabled").append(""); $("#id_submit").attr("disabled","disabled"); $.post( '/php_includes/request_v2/jquery_actions.php', { action: "change_region", insur_href: document.request_form.insurance.value, region_id: $("#id_region_id").val() }, onChangeRegion ); }); $("#id_region_id").trigger("change"); /*Инициализируем форму отправки мобильника*/ $("#jq_message_enter_phone input[type=text]").bind("keydown",function(ev){ if (in_array(ev.keyCode,[35,36,37,39,8,9,46,48,49,50,51,52,53,54,55,56,57,96,97,98,99,100,101,102,103,104,105])) { if (in_array(ev.keyCode,[48,49,50,51,52,53,54,55,56,57,96,97,98,99,100,101,102,103,104,105])) { if ($(this).val().length>=$(this).attr("maxdigits")) { return false; } }else { } }else { return false; } }); $("#jq_message_enter_phone input[type=text]").bind("keyup",function(ev){ if (in_array(ev.keyCode,[48,49,50,51,52,53,54,55,56,57,96,97,98,99,100,101,102,103,104,105])) { if ($(this).val().length>=$(this).attr("maxdigits")) { $("#"+$(this).attr("next")).focus(); } } }); $("#jq_message_enter_phone form").bind("submit",function(){ $(this).find("input[type=submit]").attr("disabled","disabled"); $("#jq_message_enter_phone div.error").hide(100); $.post( '/php_includes/request_v2/jquery_actions.php', { iaction: "request_send", insurance: document.request_form.insurance.value, params: $("#id_request_form").formSerialize(), sub_action: 1, id_hash: $("#jq_message_enter_phone input[name=id_hash]").val(), phone_1: $(this).find("input[name=phone_1]").val(), phone_2: $(this).find("input[name=phone_2]").val(), phone_3: $(this).find("input[name=phone_3]").val(), phone_4: $(this).find("input[name=phone_4]").val() }, function(data) { try { var res=JSON.parse(data); } catch (error) { alert("Системная ошибка!\n\n"+data); return; } /*if (res['code']=='2') { var temp=''; for (i=0;i'; $("#id_error").html("В процессе обработки запроса возникли следующие ошибки:
"+temp).show(); $("#id_submit").attr("disabled",""); }*/ if (res['code']=='5') { showShadow("jq_message_wrong_phone","jq_message_enter_phone"); } if (res['code']=='6') { showShadow("jq_message_captcha","jq_message_enter_phone"); $("#jq_message_captcha input[name=id_hash]").val(res['id_hash']); $("#jq_message_captcha img").attr("src","/php_includes/kcaptcha/index.php?PHPSESSID=f4c0241c63bf96323e8daf2ceb1f1f7a"); } if (res['code']=='7') { $("#jq_message_enter_phone div.error").html("Некорректно введен номер телефона

").show(100); $("#jq_message_enter_phone input[type=submit]").attr("disabled",""); } if (res['code']=='8') { $("#jq_message_enter_phone div.error").html("Некорректный код сотового оператора

").show(100); $("#jq_message_enter_phone input[type=submit]").attr("disabled",""); } if (res['code']=='100') { document.location=res['redirect']; } }); return false; }); }); function in_array(needle, haystack, strict) { var found = false, key, strict = !!strict; for (key in haystack) { if ((strict && haystack[key] === needle) || (!strict && haystack[key] == needle)) { found = true; break; } } return found; } function onChangeRegion(xml) { selector=$("#id_city_id"); selector.empty().append(""); items=eval("("+xml+")"); for (i=0;i'+items[i][1]+''); $("#id_region_id").attr("disabled",""); selector.attr("disabled",""); $("#id_submit").attr("disabled",""); $("#id_comp_column_1").html("Необходимо указать город

"); $('#id_comp_column_2').html(""); $('#id_comp_column_3').html(""); } function send_form() { /* Дизейблим форму */ $("#id_submit").attr("disabled","disabled"); $("#id_error").hide(); $.post( '/php_includes/request_v2/jquery_actions.php', { iaction: "request_send", insurance: form.insurance.value, params: $("#id_request_form").formSerialize() }, function(data) { try { var res=JSON.parse(data); } catch (error) { alert("Системная ошибка!\n\n"+data); return; } if (res['code']=='2') { var temp=''; for (i=0;i'; $("#id_error").html("В процессе обработки запроса возникли следующие ошибки:
"+temp).show(); $("#id_submit").attr("disabled","").val("Рассчитать стоимость полиса"); } if (res['code']=='3') { showShadow("jq_message_agent",""); } if (res['code']=='4') { showShadow("jq_message_enter_phone",""); $("#jq_message_enter_phone input[name=id_hash]").val(res['id_hash']); } } ); } function retry_phone() { $("#jq_message_enter_phone input[type=text]").val(""); $("#jq_message_enter_phone input[type=submit]").attr("disabled",""); showShadow("jq_message_enter_phone","jq_message_wrong_phone"); } function captcha_send(sender) { $(sender).find("input[type=submit]").attr("disabled","disabled"); $(sender).find(".error").hide(100); $.post( '/php_includes/request_v2/jquery_actions.php', { iaction: "request_send", insurance: form.insurance.value, id_hash: $(sender).find("input[name=id_hash]").val(), params: $("#id_request_form").formSerialize(), sub_action: 2, captcha_code: $(sender).find("input[name=captcha_code]").val() }, function(data) { try { var res=JSON.parse(data); } catch (error) { alert("Системная ошибка!\n\n"+data); return; } /*if (res['code']=='2') { var temp=''; for (i=0;i'; $("#id_error").html("В процессе обработки запроса возникли следующие ошибки:
"+temp).show(); $("#id_submit").attr("disabled",""); }*/ if (res['code']=='8') { $(sender).find("input[name=captcha_code]").val("").focus(); $(sender).find("input[type=submit]").attr("disabled",""); $('#jq_message_captcha img').attr('src',$('#jq_message_captcha img').attr('src')+'&rand='+Math.random()*5000); $(sender).find(".error").html("Неверно введен код. Попробуйте еще раз.

").show(100); } if (res['code']=='100') { document.location=res['redirect']; } } ); } /* Относится к TB_Window */ function getPageSize(){ var de = document.documentElement; var w = window.innerWidth || self.innerWidth || (de&&de.clientWidth) || document.body.clientWidth; var h = window.innerHeight || self.innerHeight || (de&&de.clientHeight) || document.body.clientHeight; arrayPageSize = [w,h]; return arrayPageSize; } function tb_detectMacXFF() { var userAgent = navigator.userAgent.toLowerCase(); if (userAgent.indexOf('mac') != -1 && userAgent.indexOf('firefox')!=-1) { return true; } } function showShadow(block_id,old_block_id) { if (typeof document.body.style.maxHeight === "undefined") {//if IE 6 $("body","html").css({height: "100%", width: "100%"}); $("html").css("overflow","hidden"); if (document.getElementById("TB_HideSelect") === null) {//iframe to hide select elements in ie6 $("body").append("
"); } }else{//all others if(document.getElementById("TB_overlay") === null){ $("body").append("
"); } } if(tb_detectMacXFF()){ $("#TB_overlay").addClass("TB_overlayMacFFBGHack");//use png overlay so hide flash }else{ $("#TB_overlay").addClass("TB_overlayBG");//use background and opacity } $("#"+block_id).css("z-index",101); var scr_size = getPageSize(); var wid = $("#"+block_id).width(); var hei = $("#"+block_id).height(); var yScroll = $.browser.msie ? document.documentElement.scrollTop : self.pageYOffset; $("#"+block_id).css("z-index","500").css({"left":((scr_size[0]-wid)/2),"top":(yScroll+(scr_size[1]-hei)/2)}); if (old_block_id.length>0) $("#"+old_block_id).hide(); $("#"+block_id).show(); /*Ставим фокус*/ if (block_id=="jq_message_enter_phone") $("#"+block_id).find("input[name=phone_1]").focus(); if (block_id=="jq_message_captcha") $("#"+block_id).find("input[name=captcha_code]").focus(); } function hideShadow(block_id) { /*$('#jq_'+cat_type+'_categories_block input.cancel').click(); $("#TB_imageOff").unbind("click"); $("#TB_closeWindowButton").unbind("click");*/ $("#TB_window").fadeOut("fast",function(){$('#TB_window,#TB_HideSelect').trigger("unload").unbind().remove();}); $("#TB_load").remove(); if (typeof document.body.style.maxHeight == "undefined") {//if IE 6 $("body","html").css({height: "auto", width: "auto"}); $("html").css("overflow",""); } $('#'+block_id).hide(); $("#TB_overlay").trigger("unload").unbind().hide(); $("#TB_overlay").attr("id","trash"); $("#trash").remove(); /*document.onkeydown = ""; document.onkeyup = "";*/ return false; }