var bacActive = 0;var iBanner_count=0;var iBanner_now=1;var TimeInterval;jQuery(document).ready(function(){	  $("div.gallery-dish div.wrapp div.holder a").lightBox();	  $("a.mylightbox").lightBox();      $("div.cheme a").lightBox();      $("table.tovar-gallery a").lightBox();	  jQuery('div.inform-box a[id^=detail-text-]').click(function(){	  	var result=this.id.match(/detail-text-(\d+)/);	  	if(jQuery('#info-'+result[1]).css("display")=='none'){	  		jQuery('#info-'+result[1]).css("display", "block");	  		$(this).html('Свернуть подробное описание');	  		}	  	else {jQuery('#info-'+result[1]).css("display", "none");	  	$(this).html('Развернуть подробное описание');	  	}	  	return false;	  });      jQuery("form.advert-form input:radio").click(function(){      	   if(this.value=='1'){      	   	  jQuery('#header-form').html('Пост в авторскую колонку');      	   	  jQuery('#image-block').css("display", "none");      	   }else{      	   	  jQuery('#header-form').html('Особое мнение');      	   	  jQuery('#image-block').css("display", "block");      	   }      	});      jQuery("div.gallery-dish div.wrapp div.holder").jcarousel({        scroll: 1,        initCallback: mycarousel_initCallback,        // This tells jCarousel NOT to autobuild prev/next buttons        buttonNextHTML: null,        buttonPrevHTML: null     });	 /*     jQuery("#navigation li").hover(function(){     	if(jQuery(this).attr("class")!="active")jQuery("#navigation li.active").attr("class", "active active-state");      	}, function() {             jQuery("#navigation li.active.active-state").attr("class", "active");       })	  */      jQuery("#navigation li.active.active-state").hover(function(){      	  jQuery(this).attr("class", 'active');      });      jQuery("#navigation li.active.active-state ul li").hover(function(){      	  jQuery("#navigation li.active.active-state").attr("class", 'active');      });       jQuery("#navigation li.active ul li").hover(function(){      	  jQuery("#navigation li.active.active-state").attr("class", 'active');      });    jQuery("form.advert-form ul#advert-type input:radio").click(function(){      	   if(this.value=='32'){				jQuery('.advert-form #advert-data #advestate-props').css("display","block");				jQuery('.advert-form #advert-data #work-props').css("display","none");      	   	  jQuery('#adv-estate').css("display", "block");      	   	  jQuery('#advert-type-1').attr("class", "active");      	   	  jQuery('#adv-estate-block').css("display", "block");      	   	  jQuery('#advert').css("display", "none");      	   	  //jQuery('#advert-type-2').attr("class", "");			  jQuery('#adv-rezume').css("display", "none");			  jQuery('#adv-vacancies').css("display", "none");      	   }		   if(this.value=='31'){				jQuery('.advert-form #advert-data #advestate-props').css("display","block");				jQuery('.advert-form #advert-data #work-props').css("display","none");      	   	  jQuery('#adv-estate').css("display", "none");      	   	  jQuery('#advert-type-1').attr("class", "");      	   	  jQuery('#adv-estate-block').css("display", "none");      	   	  jQuery('#advert').css("display", "block");      	   	  //jQuery('#advert-type-2').attr("class", "active");			  jQuery('#adv-rezume').css("display", "none");			  jQuery('#adv-vacancies').css("display", "none");      	   }		   if(this.value=='33'){				jQuery('.advert-form #advert-data #advestate-props').css("display","none");				jQuery('.advert-form #advert-data #work-props').css("display","block");			  jQuery('#advert').css("display", "none");      	   	  jQuery('#adv-estate').css("display", "none");      	   	  jQuery('#adv-estate-block').css("display", "none");      	   	  jQuery('#adv-rezume').css("display", "none");			  jQuery('#adv-vacancies').css("display", "block");      	   }		   if(this.value=='34'){				jQuery('.advert-form #advert-data #advestate-props').css("display","none");				jQuery('.advert-form #advert-data #work-props').css("display","block");			  jQuery('#advert').css("display", "none");      	   	  jQuery('#adv-estate').css("display", "none");      	   	  jQuery('#adv-estate-block').css("display", "none");      	   	  jQuery('#adv-rezume').css("display", "block");			  jQuery('#adv-vacancies').css("display", "none");      	   }      	});      	jQuery('#all-advert').click(function(){           jQuery('div.person-section div[id^=advert-list-]').each(function(){                  jQuery(this).attr("class", "inform-box");      	    });      	    jQuery('#all-advert-span').detach();      	   return false;      	});      	jQuery('ul.tabs-link li[id^=tabs-]').click(function(){      		var tabs=this.id.match(/tabs-(\w+)/);      		if(jQuery('div.tabs-section#tab-'+tabs[1]+'').length>0){      			 jQuery('div.tabs-section').each(function(){      			 	 jQuery(this).css("display", "none");      			 });      			 jQuery('ul.tabs-link a').each(function(){      			 	 jQuery(this).attr("class", "");      			 });                jQuery('div.tabs-section#tab-'+tabs[1]+'').css("display", "block");                jQuery('ul.tabs-link li#tabs-'+tabs[1]+' a').attr("class", "active");      		}           return false;      	});      	jQuery('div.promo-gallery-bar.big-gallery a.next').click(function(){      		var active = jQuery("div.promo-gallery-bar.big-gallery div.hold div.new-catalog-block.active");      		if($(active).next().length){      			var next = $(active).next();      			$(active).removeClass("active");                $(next).addClass("active");      		}            return false;      	});      	jQuery('div.promo-gallery-bar.big-gallery a.prev').click(function(){      		var active = jQuery("div.promo-gallery-bar.big-gallery div.hold div.new-catalog-block.active");      		if($(active).prev().length){      			var prev = $(active).prev();      			$(active).removeClass("active");                $(prev).addClass("active");      		}            return false;      	});		var nextAvailable = true;      	jQuery('div.promo-gallery-bar.best-gallery a.next').click(function(){      		//var active = jQuery("div.promo-gallery-bar.best-gallery div.hold div.best-catalog-block.active");			var active = jQuery(this).parent().find("div.best-catalog-block.active");      		if($(active).next().length && nextAvailable){      			var next = $(active).next();      			$(active).removeClass("active");                $(next).addClass("active");				if(!$(active).next().next().length)					nextAvailable = false;      		}            return false;      	});      	jQuery('div.promo-gallery-bar.best-gallery a.prev').click(function(){      		//var active = jQuery("div.promo-gallery-bar.best-gallery div.hold div.best-catalog-block.active");			var active = jQuery(this).parent().find("div.best-catalog-block.active");      		if($(active).prev().length){      			var prev = $(active).prev();      			$(active).removeClass("active");                $(prev).addClass("active");								nextAvailable = true;      		}            return false;      	});      	      	      	jQuery('.news-section .switcher#classic_switcher li').click(function(){			var id=parseInt(jQuery(this).attr("id").substr(7));			var next = id*3-2;						clearInterval(TimeInterval);				if(next > iBanner_count)				next = 1;				change_ibanner_classic(next);			TimeInterval = setInterval('_start_ibanner()', 5000);			return false;		});				jQuery('.news-section .switcher#modern_switcher li').click(function(){			var id=parseInt(jQuery(this).attr("id").substr(7));						clearInterval(TimeInterval);						var now = iBanner_now;				change_ibanner(id);			TimeInterval = setInterval('_start_ibanner()', 5000);						return false;		});				jQuery('div.news-section ul.news-menu li').mouseover(function() {						next = parseInt($(this).attr('id').substr(13));			clearInterval(TimeInterval);			change_ibanner(next);			iBanner_now = next;		});				jQuery('div.news-section ul.news-menu li').mouseout(function() {			TimeInterval = setInterval('_start_ibanner()', 10000);//			clearInterval(TimeInterval);//			alert(iBanner_now);//			change_ibanner_classic(iBanner_now);//			_circle_ibanner();//			change_ibanner(next);//			TimeInterval = setInterval('_start_ibanner()', 5000);//			change_ibanner(iBanner_now);//			_circle_ibanner();		});		$('#interact-banner').ready(function(){			$('div.news-section div.news-holder .holder-block').each(function(){				iBanner_count++;			});			iBanner_now = 1;			if(iBanner_count > 1){				TimeInterval = setInterval('_start_ibanner()', 5000);			}		});				jQuery("form.search-form input[type='text']").click(function(){			jQuery(this).val("");		});				jQuery("#navigation>li").hover(function(){			if(jQuery(this).hasClass('active'))				return false;						//if(jQuery(this).parents().)						jQuery("#navigation li.active span").css("height","55px");		},				function(){			jQuery("#navigation li.active span").css("height","57px");		});						//Блок подписки на новости		jQuery("form[name='SIMPLE_FORM_5'] .inputtext").click(function(){			jQuery(this).val("");		});		jQuery("form[name='SIMPLE_FORM_5'] .btn-subscribe").click(function(e){			var btn = jQuery(this);			var email = jQuery("form[name='SIMPLE_FORM_5'] .inputtext").attr("value");			$.post("/bitrix/restoranoff-adds/import/subscribe.php", "email="+email, function(data){				jQuery("form[name='SIMPLE_FORM_5'] p").html(data);				if(data!='Заполните поле корректно' && data!='Вы уже подписаны на рассылку')					jQuery(btn).hide();			});			return false;		});					//СТАТИСТИКА КЛИКОВ ПО ТОВАРАМ		jQuery(".statistic").click(function(){			var id=jQuery(this).attr("id");						var re = /\d+/g; 			var element = id.match(re);			var type = id.substr(0,id.search("_"));						$.post('/bitrix/restoranoff-adds/ajax/stat_click.php', 'ELEMENT_ID='+element+"&TYPECODE="+type);		});				jQuery('a.btn-basket').click(function(){			var id = jQuery(this).attr('id');			if($('#ADD2BASKET_'+id).size())			{				$('#ADD2BASKET_'+id).submit(); 				return false;			}		});});function _start_ibanner(){	clearInterval(TimeInterval);	if(jQuery("#interact-banner .news-menu").size())		_cicle_ibanner_classic();	else		_circle_ibanner();}function _circle_ibanner(){	var now = iBanner_now;	var next = now + 1;	if(next > iBanner_count)		next = 1;			change_ibanner(next);	TimeInterval = setInterval('_start_ibanner()', 5000);}function _cicle_ibanner_classic(){	var now = iBanner_now;	var next = now + 1;		if(next > iBanner_count)		next = 1;		change_ibanner_classic(next);		TimeInterval = setInterval('_start_ibanner()', 5000);}function change_ibanner(next){	var now = iBanner_now;	$('#ibanerr-block-' + now).attr("class", "holder-block");	$('#ibanerr-block-' + next).addClass("active");	jQuery(".news-section .switcher#modern_switcher .active").removeClass("active");	jQuery(".news-section .switcher#modern_switcher #switch_"+next).addClass("active");	iBanner_now = next;}function change_ibanner_classic(next){			var now = iBanner_now;			if(iBanner_count <= 3)			{				$('#ibanner-link-' + now).attr("class", "")				var text = $('#ibanner-link-' + now).text();				$('#ibanner-link-' + now+' a').html('<span>' + text + '</span>');				$('#ibanerr-block-' + now).attr("class", "holder-block");						var text = $('#ibanner-link-' + next).text();//				$('#ibanner-link-' + next).html('<span>' + text + '</span>');				$('#ibanner-link-' + next).attr("class", "active");				$('#ibanerr-block-' + next).addClass("active");				if(bacActive == 0)				{					$.post("/show.php",{url: document.location.pathname, slow: 1});					bacActive = 1;				}				iBanner_now = next;			}			else			{				//активный в начале				var from = next;				var to = next+2;				var tmp = next%3;				//активный посерёдке				if(tmp==2)				{					from = next-1;					to = next+1;				}				//в конце				if(tmp==0)				{					from=next-2;					to=next;				}				to = (to<=iBanner_count)? to: iBanner_count;				//alert(from+" "+to);				for(var i=1;i<=iBanner_count;i++)				{					if(i>=from && i<=to)						$('ul.news-menu #ibanner-link-'+i).attr("class","");					else						$('ul.news-menu #ibanner-link-'+i).attr("class", "hidden");				}				//установим нижний переключатель				var switch_pos = Math.ceil(next/3);				for(var i=1;i<=iBanner_count;i++)				{					if(i==switch_pos)					{						// send statistic show						if(bacActive != i)						{							$.post("/show.php",{url: document.location.pathname, slow: i});						}						$('.switcher #switch_'+i).attr("class","active");					}					else						$('.switcher #switch_'+i).attr("class","");				}						var text = $('#ibanner-link-' + now).text();				$('#ibanner-link-' + now+' a').html('<span>' + text + '</span>');				$('#ibanerr-block-' + now).attr("class", "holder-block");						var text = $('#ibanner-link-' + next).text();				$('#ibanner-link-' + next+" a").html('<span>' + text + '</span>');				$('#ibanner-link-' + next).attr("class", "active");				$('#ibanerr-block-' + next).addClass("active");				iBanner_now = next;			}}function mycarousel_initCallback(carousel) {    jQuery('div.gallery-dish ul.switcher li').bind('click', function() {        carousel.scroll(jQuery.jcarousel.intval(jQuery(this).text()));        $('div.gallery-dish ul.switcher li').each(function(){        	   $(this).attr("class", "");        	});        $(this).addClass("active");        return false;    });    jQuery('div.gallery-dish .next').bind('click', function() {    	var active=$('div.gallery-dish ul.switcher li.active').text();    	var cnt=$('div.gallery-dish ul.switcher li').size();    	if(parseInt(active)!=parseInt(cnt)){    	var count=0; var result=false;    	$('div.gallery-dish ul.switcher li').each(function(){    		   count++;    		   if(result)$(this).addClass("active");    		   else $(this).attr("class", "");        	   if(count==active){result=true;}        	   else result=false;        	});        var trm=carousel.next();        }        return false;    });    jQuery('div.gallery-dish .prev').bind('click', function() {    	var active=$('div.gallery-dish ul.switcher li.active').text();    	if(parseInt(active)>1){    	var count=0; var result=false;    	$('div.gallery-dish ul.switcher li').each(function(){    		   count++;        	   if((count+1)==active)$(this).addClass("active");        	   else $(this).attr("class", "");        	});        carousel.prev();        }        return false;    });};$(document).ready(function() {	$("#list_fd").css("width","200000px");});
