function setCookie(name,value,expires,path,domain,secure){if(expires){expires=expires*1000*3600*24}var today=new Date();var expires_date=new Date(today.getTime()+(expires));document.cookie=name+"="+escape(value)+((expires)?"; expires="+expires_date.toGMTString():"")+((path)?"; path="+path:"")+((domain)?"; domain="+domain:"")+((secure)?"; secure":"")};function getCookie(name){var matches=document.cookie.match(new RegExp("(?:^|; )"+name.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g,'\\$1')+"=([^;]*)"));return matches?decodeURIComponent(matches[1]):false};function showList(oThis){$(oThis).parent().next().slideDown(500);$(oThis).addClass('name_info_cur');$(oThis).unbind('click').bind('click',function(){hideList(this);return false})};function hideList(oThis){$(oThis).parent().next().slideUp(500);$(oThis).removeClass('name_info_cur');$(oThis).unbind('click').bind('click',function(){showList(this);return false})};$(document).ready(function(){if($("#dl_select_city").length){var over=$("a[rel='#dl_select_city']").overlay({top:'30%',closeOnClick:false,effect:'apple'});var api_over=over.overlay();var scroll=$("#scroll").scrollable({speed:250});var api_scroll=scroll.scrollable();api_over.onBeforeLoad(function(event,i){if($("select[id=region_id] option").size()==0){$('#region_id').html('<option>загрузка...</option>');$.get('../get_regions.php',"region_id=0",function(result){if(result.type=='error'){return(false)}else{var options='';$(result.regions).each(function(){options=options+'<option value="'+$(this).attr('id')+'">'+$(this).attr('title')+'</option>'});$('#region_id').html(options)}},"json");$("#finish").addClass("disable").css("background-position","0px 0px")}else{api_scroll.begin(0);$("#region_id option:selected").removeAttr("selected")}});api_scroll.onBeforeSeek(function(event,i){if(i==0){$("#region_id option:selected").removeAttr("selected");$("#finish").addClass("disable").css("background-position","0px 0px")}});$('#region_id').change(function(){var region_id=$(this).val();$.get('../get_regions.php',"region_id="+region_id,function(result){if(result.type=='error'){return(false)}else{var options='';$(result.regions).each(function(){options=options+'<option value="'+$(this).attr('id')+'">'+$(this).attr('title')+'</option>'});$('#city_id').html(options)}},"json");api_scroll.next()});$('#city_id').change(function(){$("#finish").removeClass("disable").css("background-position","0px 84px")});$("#finish").hover(function(){if(!$(this).hasClass('disable'))$(this).css("background-position","0px 56px")},function(){if(!$(this).hasClass('disable'))$(this).css("background-position","0px 84px")});$("#finish").mousedown(function(){if(!$(this).hasClass('disable'))$(this).css("background-position","0px 28px")});$("#dl_select_city form").submit(function(e){if(!$("#finish").hasClass('disable')){var city=getCookie('city');var city_new=$('#city_id').val();if(city!=city_new)$("#finish").addClass('submit');setCookie('city',city_new,365);api_over.close()}return e.preventDefault()});api_over.onClose(function(event,i){if($("#finish").hasClass('submit')){window.location.reload(true)}})};if($("#dl_callback").length){var over=$("a[rel='#dl_callback']").overlay({top:'30%',closeOnClick:false,effect:'apple'});var api_over_callback=over.overlay();api_over_callback.onBeforeLoad(function(event,i){$("#finish_callback").addClass("disable").css("background-position","0px 0px");$("#dl_callback #page2").hide();$("#dl_callback #page3").hide();$("#dl_callback #page1").show();$("#caller_telephon").css("border-color","red");$("#dl_callback input[type='text']").val('');$("#dl_callback textarea").val('')});api_over_callback.onLoad(function(event,i){$("#caller_telephon").focus()});$("#caller_telephon").mask("8 (999) 999 9999",{placeholder:"x",completed:function(){$(this).css("border-color","white");$("#finish_callback").removeClass("disable").css("background-position","0px 84px")}});$("#finish_callback").hover(function(){if(!$(this).hasClass('disable'))$(this).css("background-position","0px 56px")},function(){if(!$(this).hasClass('disable'))$(this).css("background-position","0px 84px")});$("#finish_callback").mousedown(function(){if(!$(this).hasClass('disable'))$(this).css("background-position","0px 28px")});$("#dl_callback form").submit(function(e){if(!$("#finish_callback").hasClass('disable')){$("#dl_callback #page1").hide();$("#dl_callback #page2").fadeIn("normal");$.post('../callback.php',{'caller_telephon':$("#caller_telephon").val(),'caller_name':$("#caller_name").val(),'caller_wish':$("#caller_wish").val()},function(result){if(result.type=='error'){$("#dl_callback #page2").hide();$("#caller_result").html('Ошибка. Повторите запрос.');$("#dl_callback #page3").fadeIn("normal");return(false)}else{$("#dl_callback #page2").hide();api_over_callback.close()}},"json")}return e.preventDefault()})}});
