var pblockflag =0;


function getScript(src) {
      document.write('<' + 'script src="' + src + '"' +' type="text/javascript"><' + '/script>');
}


function irandom(min, max) {
    return parseInt(Math.random() * (max - min + 1)+ min);
}


function politic(){

    var text='<!--noindex--><span class="politic">Нажимая на кнопку "Отправить", Вы даете согласие на обработку персональных данных, а также подтверждаете условия <a rel="nofollow" href="/privacy-policy" target=_blank title="Политика конфиденциальности">"Политики конфиденциальности"</a> настоящего сайта.</span><!--/noindex-->';
    jQuery("#comments #submit").before(text);
    jQuery(".es_shortcode_form").after(text);
    jQuery(".wpcf7-submit").before(text);
    jQuery("#es_txt_button_pg").val("Отправить");
    jQuery(".es_textbox_class").attr("placeholder","Введите email...");

} 



function soderganie(){
    //console.log('1');
//return;
	var sod = jQuery("#sod");
	var title = jQuery(".table-of-content__title");
	if(jQuery(title).length === 0){
		return;
	}
	var sodul = jQuery("#sod").find('ul');

	jQuery(title).before('<span class="sodhide"></span>');
    var pic = '<img src="/wp-content/uploads/images/icon_sod.gif" title="Показать/Скрыть">'; 
    jQuery(".sodhide").html(pic);

	jQuery(".sodhide").live("click",function(){
	    if(jQuery(sodul).css("display") == 'block'){
    		jQuery(sodul).hide(100);
	    	jQuery(".sodhide").html(pic);
        }else{
		    jQuery(sodul).show(100);
		    jQuery(".sodhide").html(pic);
	    }			
	})

  /*
  jQuery("article h2").each(function(indx, element){
      jQuery(this).html('<img src="/wp-content/uploads/images/icon_h2.gif" title="Раздел статьи" alt="&nbsp;">'+jQuery(this).html()+'<a href="#sod" border="0"><i class="fa fa-angle-up faicon" title="Вернуться к содержанию"></i></a>');
  });
  jQuery("article h3").each(function(indx, element){
      jQuery(this).html('<img src="/wp-content/uploads/images/icon_h3.gif" title="Подраздел статьи" alt="&nbsp;">'+jQuery(this).html());
  });
*/
  
  jQuery("article blockquote").each(function(indx, element){
	//jQuery(this).html('<i class="fa fa-info-circle fa-5x icon_bigzitata" aria-hidden="true">&nbsp;</i>'+jQuery(this).html());
      jQuery(this).html('<img src="/wp-content/uploads/images/icon_blockquote.png" class="icon_bigzitata" title="Цитата" alt="&nbsp;">'+jQuery(this).html());
  });

    
    var kol_p = 0;
    jQuery("article p").each(function(indx, elements){
		 if(jQuery(elements)[0].tagName == 'P'){
          
            if(kol_p === 0){
               jQuery(elements).after(jQuery("#sod"));
            }
            kol_p++;
  	     }
    })

} 




function addUrl() {   
   var body_element = document.getElementsByTagName('body')[0];var sel; sel = window.getSelection();var pagel = "<br/> - Первоисточник: <a href='"+document.location.href+"'>"+document.location.href+"</a>";   
   var copytext = sel + pagel; var newd = document.createElement('div');newd.style.position='absolute';newd.style.left='-99999px';body_element.appendChild(newd);newd.innerHTML = copytext;sel.selectAllChildren(newd);window.setTimeout(function(){body_element.removeChild(newd);},0);   
} 



var player;
function onYouTubeIframeAPIReady() {
        player = new YT.Player('fc_video_player', {
          height: '394',
          width: '700',
          videoId: '',
          playerVars: { 'autoplay': 0, 'controls': 0,'autohide':1,'wmode':'opaque','origin':document.location.href},
          events: {
            'onReady': onPlayerReady
          }
        });
}
  
function onPlayerReady(event) {
       // event.target.playVideo();
       //console.log('Загружен YT');
}
  

function video(){

    var tag = document.createElement('script');
    tag.src = "https://www.youtube.com/iframe_api";
    var firstScriptTag = document.getElementsByTagName('script')[0];
    firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);

      var fc_video = jQuery(".fc_video");
      jQuery(fc_video[0]).append('<div id="fc_video_player"></div>');


jQuery(".fc_video").each(function(indx, element){

    jQuery(this).prepend('<div id="fc_videop" class="fc_video_panels"></div>');
    var str=''; 
    var n=1;
    var VideoId = new Array();
    jQuery(this).find(".textvideo").each(function(indx, element){
	jQuery(element).before('<div class="titlevideo"><img src="/wp-content/uploads/images/icon_video2.gif" alt="Видео">Видео</div>');
	jQuery(element).attr('data-nv',n);
	var url=jQuery(element).attr("src");
	var text=jQuery(element).attr("title");
	//jQuery(element).attr("src",url+'&enablejsapi=1');
	jQuery(element).attr("ID",'yvideo'+n);
//console.log('>>'+url);
	var arr_url=url.split('/');
	var url=arr_url[(arr_url.length-1)];
	var arr_url=url.split('?');
	var url=arr_url[0];
	str=str+'<div class="fc_video_panel-wrap"><div class="fc_video_panel" data-url="'+jQuery(element).attr("src")+'" data-n="'+n+'" style="background-image: url(\''+'https://img.youtube.com/vi/'+url+'/hqdefault.jpg'+'\');"><img src="/wp-content/uploads/images/play_video.png"></div><div class="fc_video_panel_text">'+text+'</div></div>';
	//VideoId.push(url);
	jQuery(element).remove();
//	player.cueVideoById(url);
	n++;
  })
  jQuery(this).find(".fc_video_panels").html(str);
})



  jQuery(".fc_video_panel").live("click",function(){

      var url=jQuery(this).attr("data-url");
      if(jQuery(this).closest(".fc_video").find("#fc_video_player").length == 0 ){
	      jQuery(this).closest(".fc_video").append(jQuery("#fc_video_player"));      	
      }	
      var intervalID_quiz = setInterval(function(){
	      jQuery("#fc_video_player").css("cssText","display:block !important;opacity:0");
	      jQuery("#fc_video_player").animate({opacity:1},700);
	      player.cueVideoByUrl(url);
	      player.playVideo();
	        clearInterval(intervalID_quiz);
      },600);

  });

/*  
//jQuery(".fc_video .textvideo").hide();
//var number = jQuery(this).attr("data-n");
//console.log(number)      ;
      //var n='[data-nv='+jQuery(this).attr("data-n")+']';
//console.log(jQuery(n))      ;
      //jQuery(n).css("cssText","display:block !important;opacity:0");
      //jQuery(n).animate({opacity:1},700);
        var intervalIDv = setInterval(function(){
            clearInterval(intervalIDv);
//console.log(player);
    //console.log(VideoId);
             // player.cuePlaylist('_VfSF6D46QE');
 	    },3000);

//  VideoId=VideoId.join();
*/
  
}



function tinfo(){

 if(jQuery(".block_link").length === 0){
	return;
 }
 
 var kol=jQuery("article").html().replace(/<[^>]+>/g,'').length;
 var minut = Math.floor((kol/2100)*1.5);
 var tminut = 'минут';
 if(minut == 1){tminut = 'минута';}
 if(minut == 2 || minut == 3 || minut == 4){tminut = 'минуты';}
 //<i class="fa fa-chevron-right" aria-hidden="true"></i>
// jQuery("article .block_link").html('<div class="blminut"><img src="/wp-content/uploads/images/icon_minut.gif" title="Время чтения" alt="&nbsp;"> '+minut+' '+tminut+' на чтение статьи</div><a class="blphoto" href="#fc_fotos_wrap" >Фото</a><a class="blvideo" href="#fc_videop" title="Видео">Видео</a><a class="blcomment" href="#gcomment" title="Комментарии">Комментарии</a>');
 jQuery("article .block_link").html('<div class="blminut"><img src="/wp-content/uploads/images/icon_minut.gif" title="Время чтения" alt="&nbsp;"> '+minut+' '+tminut+' на чтение статьи</div><a class="blcomment" href="#gcomment" title="Комментарии">Комментарии</a>');

 jQuery("iframe:first").attr("id","fvideo");

 jQuery(".blphoto").live("click",function(){
	//jQuery("article .wp-caption:first a").click();
	jQuery("article .fc_url_all_fotos").click();
	//document.getElementById ('fc_fotos_wrap').scrollintoView (true);
	
 });

} 




function plink(){

	var n=0;
	jQuery(".repelink_bitnet").find("a").each(function(indx, element){
		jQuery(element).attr("md","2"+n);
		n=n+1;
	});
	
	n=1;
	jQuery("article .ap").each(function(indx, element){
	       jQuery(element).addClass("cl");
		jQuery(element).attr("md","3"+n);
		n=n+1;
	});
	n=1;
	jQuery("aside .wpp-list a").each(function(indx, element){
	       jQuery(element).addClass("cl");
		jQuery(element).attr("md","4"+n);
		n=n+1;
	});
    
	var one = jQuery(".perelink-horizontal-item");
	if(jQuery(one).length <=1){
		return;
	}
	var h2=jQuery("article h2"); // все H2
	var flag=0;
	var element_p;
	var kol_p = 0;
	var e_h2;
	var pos_p;
	jQuery(h2).each(function(indx, element){
		var p=  jQuery(element).nextUntil("h2"); // C H2 до след H2 считаем сколько  P
		kol_p = 0;
		jQuery(p).each(function(indx, elements){
		 if(jQuery(elements)[0].tagName == 'P'){
			kol_p++;
		 }
		});
		if(flag === 0){
			if(kol_p >1){
			   e_h2=element;	
			   flag=1;
			   pos_p = Math.ceil(kol_p/2)-1; // !!! какой  P использовать
			}
		}
	});

    var p=  jQuery(e_h2).nextAll("p"); // все P после выбранного H2
    var p=  jQuery(p)[pos_p]; // В середину

    //jQuery(p).before('<!--noindex--><div class="perelinktext"><img src="/wp-content/uploads/images/icon_prosmotr.gif" title="Посмотрите ещё">Посмотрите ещё</div><!--/noindex-->');
    jQuery(p).before('<!--noindex--><div class="perelinktext"></div><!--/noindex-->');

	var z=0
	jQuery(one).each(function(indx, element){
	   if(z == 6){
//console.log(jQuery(jQuery(element).find("img")).attr("src"));
	       //var img= jQuery(jQuery(element).find("img")).attr("src");
//	       jQuery(".perelinktext").append('<div class="perelink-horizontal-item"><div class="perelink-img" style="background:url('+img+')"></div><div class="perelink-a-wrap">'+jQuery(element).html()+'<div class="perelink_view">Посмотреть</div></div></div>');
	       //jQuery(element).html(jQuery(element).find("img").clone());
	       //jQuery(element).remove();
	       jQuery(".perelinktext").append(jQuery(element));
	    }	
	  z++;
	});
	jQuery(".perelinktext").find("a").attr("target","_blank")
    jQuery(".perelinktext, .repelink_bitnet").find("a").addClass("cl");
	jQuery(".perelinktext").find("a").attr("md","1");

    // ССЫЛКА ПОКАЗВАТЬ ЕЩЕ - КЛОНИРУЕМ 
    jQuery(".groupmore").live("click",function(){
        jQuery(".perelink-horizontal").append(jQuery(".perelinktext .perelink-horizontal-item").clone());	
	    jQuery(".perelink-horizontal .perelink-horizontal-item").animate({opacity: 1}, 1000);
	    jQuery(".groupmore").hide();
    })


} 



function form_find(){
 
   jQuery("#mainnav .fa-search").live("click",function(){
	jQuery(".yform").show();
   });

   jQuery(".yform .fa-close").live("click",function(){
	jQuery(".yform").hide();
   });
} 





function pblock(){


   var shag=2000;
   if(device.mobile()){
       var shag=1000;
    }

   var width = jQuery(window).width();

   jQuery(".pblock_close").live("click",function(){
        jQuery(".pblock").hide();
        pblockflag =1;
   })

  jQuery(window).scroll(function(){
 	 if(pblockflag == 0){
	   var footer = jQuery("#footer").offset().top;
	   var t = jQuery(window).scrollTop();
	   if(t > shag  ){
		jQuery(".pblock").css("cssText", "display:block!important;");
	 }
}
   });	

} 


function fixed_list(){

    if(device.mobile()){
    	return;
    }
    jQuery(".list2").css("display","none");
	var flag=0;
	var intervalID1 = setInterval(function(){

           if(flag==0){
	            jQuery(".list1").queue(function () {
                    jQuery(this).animate({opacity: 0},1000);	 
                    jQuery(this).hide();   
                    jQuery(this).dequeue();   
                }) 
		        jQuery(".list2").queue(function () {
                    jQuery(this).css("opacity",0);   
                    jQuery(this).show();   
		            jQuery(this).animate({opacity: 1},1000);	 
                    jQuery(this).dequeue();   
                }) 
                flag=1;
            }else{
		        jQuery(".list2").queue(function () {
		            jQuery(this).animate({opacity: 0},1000);	 
                    jQuery(this).hide();   
                    jQuery(this).dequeue();   
                }) 
		        jQuery(".list1").queue(function () {
                    jQuery(this).css("opacity",0);   
                    jQuery(this).show();   
		            jQuery(this).animate({opacity: 1},1000);	 
                    jQuery(this).dequeue();   
                }) 
                flag=0;			
            }
//		clearInterval(intervalID1);
 	},25000);
 
} 


function set_url_target_context(){
        
    jQuery('article a').each(function(indx, element){
	   var href = jQuery(element).attr("href");   
	   if(href != undefined){
//console.log('href_: '+href);	   
//console.log('indexOf: ' + href.indexOf('#'));
    	   if(!jQuery(element).attr("data-slb-active")){
        	    if(href.indexOf('#') < 0) {
            	    jQuery(element).attr("target","_blank");
        	    }
    	    }
	   }
	});
	jQuery('#sod a').each(function(indx, element){
	   jQuery(element).removeAttr("target");
	   
	});
	
    
}

set_url_target_context();


function experts($){
 
   $(".block_autor strong, .block_autor .portfolio").live("click",function(){
       
       var u =$(this).closest(".block_autor").attr("data-u");
//console.log(u);
       window.open(u,'_blank');

   })
   $(".block_public li").live("click",function(){
       
       var u =$(this).attr("data-u");
//console.log(u);
       window.open(u,'_blank');

   })
   
   $("article .block_link").append('<a class="blcomment" href="#gexpert" title="Эксперт статьи">Эксперт статьи</a>');
   $(".block_public li").append('<i class="fa fa-external-link fa-fw" style="margin-left:5px;" aria-hidden="true"></i>');
   $("#с_menu").append('<li><a class="blcomment" href="#glitra" title="Литература">Литература</a></li>');
    
}

/**
 * МОДУЛЬ ОПРОСА 
 */
function chained_quiz($){
    
    //console.log('012');
    //console.log($(".chained-quiz").find("img").length);
    $(".chained-quiz").before('<div class="chained-quiz-title titlesidebar topros"><div>Тест</div></div>');
    
    $(".chained-quiz-choice").live("click",function(){
    
        //$(".chained-quiz-choice").css("opacity","0");
        $(".chained-quiz-choice").hide();
    
    	var intervalID_quiz = setInterval(function(){
    
//console.log($(".chained-quiz").find("img").length);
        
        if($(".chained-quiz").find("img").length === 0) {
            
            $(".chained-quiz-choice").css("display","block");
            
        }
        //$(".chained-quiz-choice").css("opacity","1").animate({opacity: 1}, 2000);
        $(".chained-quiz-choice").show();
        clearInterval(intervalID_quiz);
 	    },600);
    })
    
    
    
}
//soderganie();


tinfo();


plink();


//video();


document.oncopy = addUrl;  


jQuery.noConflict();
jQuery(document).ready(function($) {

    headtitle($);
    
	politic();

    
    form_find(); 
    
    
    pblock();


    
    fixed_list();
    
    
//    experts($);

    
    chained_quiz($)
    
    fc_like($);
    
    fc_rating($);
  
    fc_images($);

    set_gorod($);
	
    set_reklama($); 	

    set_image_for_error($);
    

});



function experts($){
 
   $(".block_autor strong, .block_autor .portfolio").live("click",function(){
       
       var u =$(this).closest(".block_autor").attr("data-u");
//console.log(u);
       window.open(u,'_blank');

   })
   $(".block_public li").live("click",function(){
       
       var u =$(this).attr("data-u");
//console.log(u);
       window.open(u,'_blank');

   })
   
   $("article .block_link").append('<a class="blcomment" href="#gexpert" title="Эксперт статьи">Эксперт статьи</a>');
   $(".block_public li").append('<i class="fa fa-external-link fa-fw" style="margin-left:5px;" aria-hidden="true"></i>');
   $("#с_menu").append('<li><a class="blcomment" href="#glitra" title="Литература">Литература</a></li>');
    
}

function headtitle($){

   if(!device.mobile()){
//	$("#mainnav").prepend($("#header").html());
   }	

}


function fc_rating($){
     if($(".fc_rating").length>0){
         fc_rating_load($);
    	 $(".fc_zvezdae").live("mouseover",function(){
    	     var i=$(this).attr("data-i");
    	     var fc_zvezda_img= $(this).closest(".fc_zvezda_img");
    	     $(fc_zvezda_img).find(".fc_zvezdap").removeClass('fc_zvezdap').addClass('fc_zvezdae');
    	     var imgs = $(fc_zvezda_img).find(".fc_zvezdae");
             var t=0;
             if($(fc_zvezda_img).attr("data-fix") == 0 ){ 
        	     $(imgs).each(function(indx, element){
        	        if( t <= i) {
//console.log('i='+i+' '+'t='+t);        	         
        	            $(element).removeClass('fc_zvezdae');
        	            $(element).removeClass('fc_zvezdap');
                        $(element).addClass('fc_zvezdai');
        	        }
                    t++;
                 });
             }
    	 });         
         $(".fc_zvezdai,.fc_zvezdap").live("mouseout",function(){
             var i=$(this).attr("data-i");
             var fc_zvezda_img= $(this).closest(".fc_zvezda_img");
    	     var imgs = $(fc_zvezda_img).find(".fc_zvezdai");
    	     if($(fc_zvezda_img).attr("data-fix") == 0 ){ 
        	     $(imgs).each(function(indx, element){
        	            $(element).removeClass('fc_zvezdai');
        	            $(element).removeClass('fc_zvezdap');
                        $(element).addClass('fc_zvezdae');
                 });
    	     }
         });
         $(".fc_zvezdai").live("click",function(){
            $(this).closest(".fc_zvezda_img").attr("data-fix",1);
            var idrt= $(this).closest(".fc_type_box").attr("data-idrt");
            var rating=$(this).attr("data-i");
            $(this).closest(".fc_zvezda_box").find(".fc_zvezda_text").html('Сохранение вашего голоса...');
            $.ajax({
    	           url: "/aa.php",
    	           type: "POST",
    	 	       data:"action=save&idrt="+idrt+"&idp="+$("#pi").attr("data-pi")+"&r="+rating,
    	           success: function(data){
    	                fc_rating_load($);   	 
    	           }
    	    });
         });     
         
         $(".fc_zvezda_img").live("mouseleave",function(){
             var fc_zvezda_img= $(this);
    	     var imgs = $(fc_zvezda_img).find(".fc_zvezdae");
    	     var kz=$(fc_zvezda_img).attr("data-kz");
    	     var pl=$(fc_zvezda_img).attr("data-pl");
//console.log(kz + ' ' + pl );
    	     if($(fc_zvezda_img).attr("data-fix") == 0 ){ 
    	         var t=1;
        	     $(imgs).each(function(indx, element){
        	           if(t<=kz){
        	            $(element).removeClass('fc_zvezdae');
        	            if(t == kz && pl>0){
        	                $(element).addClass('fc_zvezdap');
        	            }else{
                            $(element).addClass('fc_zvezdai');
        	            }
        	           }
        	            $(element).addClass('fc_zvezdae');
        	           t++;
                 });
    	     }
         })     
         
    }
}

function fc_rating_load($){
    
         $(".fc_rating").css("opacity","0.3");
         $.ajax({
    	           url: "/aa.php",
    	           type: "POST",
    	 	       data:"action=rating&idr="+$(".fc_rating").attr("data-idr")+"&idp="+$("#pi").attr("data-pi"),
    	           success: function(data){
    	        	 $(".fc_rating").html(data);
    	        	 $(".fc_rating").css("opacity","1");
    	        	 
                      var sum_rating=0;    	        	 
    	        	  $(".fc_type_box").each(function(indx, element){
    	        	      sum_rating+=$(this).find("span").html()*1;
    	        	  })    
    	        	  $(".fc_rating_foto").html(Math.round10(sum_rating/$(".fc_type_box").length,-1));
    	        	 
    	           }
    	 });
    
}

function fc_like($){
    if($(".fc_rating_dn").length>0){
         fc_like_load($);
    }     
         $(".fc_rating_yes,.fc_rating_no").live("click",function(){
             var fc_rating_dn=$(this).closest(".fc_rating_dn");
             var cl=$(this).attr("class");
             $(cl).css("opacity","0.3");
             $(".fc_rating_dn").css("opacity","0.3");
             var dn=0;
             if($(this).attr("class") == "fc_rating_yes"){
                 dn=1;
             }
             $.ajax({
        	           url: "/aa.php",
        	           type: "POST",
        	 	       data:"action=slike&idp="+$("#pi").attr("data-pi")+"&dn="+dn,
        	           success: function(data){
        	        	 fc_like_load($);
        	        	 $(".fc_rating_dn").css("opacity","1");
        	           }
        	 });
         })
    
    
    if($(".fc_url_all_fotos").length>0){
        
       $(".fc_fotos_wrap").attr("id","fc_fotos_wrap");
       $(".fc_url_all_fotos").live("click",function(){
           
           if($(".fc_fotos_wrap").css("display") == "none"){
               window.location.hash="#fc_fotos_wrap";
               $(".fc_fotos_wrap").show(500);
           }else{
               $(".fc_fotos_wrap").hide(500);
           }
           
       }) 
       
       if(device.mobile()){
           $(".fc_fotos_wrap").before($(".fc_url_all_fotos"));
       }       
        
    }    
    
    $(".fc_ozenka_like_no").live("click",function(){
        $(".fc_rating_no").click();
        $(".fc_ozenka_info").html("<div class=\"fc_ozenka_vopros\">Почему не понравилась наша статья? Оставьте комментарий.</div>"+$("#comments").html());
    })    
    $(".fc_ozenka_like_yes").live("click",function(){
        $(".fc_rating_yes").click();
        $(".fc_ozenka_info").html("<div class=\"fc_ozenka_vopros\">Спасибо, за оценку!</div>");
    })    
    $(".fc_ozenka_like_malo").live("click",function(){
        $(".fc_ozenka_info").html("<div class=\"fc_ozenka_vopros\">Что бы Вы еще хотели узнать? Оставьте комментарий.</div>"+$("#comments").html());
    })    
    
    
    
    
}

function fc_like_load($){
    
    $(".fc_rating_dn").css("opacity","0.3");
         $.ajax({
    	           url: "/aa.php",
    	           type: "POST",
    	 	       data:"action=like&idp="+$("#pi").attr("data-pi")+"&n="+$(".fc_rating_dn").attr("data-n")+"&d="+$(".fc_rating_dn").attr("data-d"),
    	           success: function(data){
    	        	 data = data.split('!==!');
    	        	 //$(".fc_rating_foto").html(data[0]);
    	        	 $(".fc_rating_no").html(data[0]);
    	        	 $(".fc_rating_yes").html(data[1]);
    	        	 $(".fc_rating_dn").css("opacity","1");
    	           }
    	 });
}

(function() {
function decimalAdjust(type, value, exp) {
    // Если степень не определена, либо равна нулю...
    if (typeof exp === 'undefined' || +exp === 0) {
      return Math[type](value);
    }
    value = +value;
    exp = +exp;
    // Если значение не является числом, либо степень не является целым числом...
    if (isNaN(value) || !(typeof exp === 'number' && exp % 1 === 0)) {
      return NaN;
    }
    // Сдвиг разрядов
    value = value.toString().split('e');
    value = Math[type](+(value[0] + 'e' + (value[1] ? (+value[1] - exp) : -exp)));
    // Обратный сдвиг
    value = value.toString().split('e');
    return +(value[0] + 'e' + (value[1] ? (+value[1] + exp) : exp));
  }
// Десятичное округление к ближайшему
  if (!Math.round10) {
    Math.round10 = function(value, exp) {
      return decimalAdjust('round', value, exp);
    };
  }
})();  

function  fc_images($){

	if($(".fc_fotos_wrap").length == 0){
		return;
	}
	if($(".fc_all_fotos").html() != ''){
		return;
	}
	$("article .wp-caption").each(function(indx, element){
//console.log($(this).find("img"));
		$(".fc_all_fotos").append($(this).find("img").clone());
	   
	});

}


function set_gorod($){

//	console.log('set_gorod');
	$(".choice_city").live("click",function(){
		//hide_all_menu($);
		$(".ucity").hide(400);
		$("#wsesfon").css('display','block');
		$(".menu_city").css("display","block");
		$("#close_menu_city").css("display","block");
		$(".menu_city").css("top","10px");
		$("#close_menu_city").css("top","15px");
		$(".menu_city").css("left",$(window).width()/2 - $(".menu_city").width()/2);
		$("#close_menu_city").css("left",$(window).width()/2 + $(".menu_city").width()/2 - $("#close_menu_city").width() - 20);
		$(".menu_city").height($(window).height() - 20);
	})

	$(".menu_city li").live("click",function(){
		$(".ucity").hide(400);
		var fl=0;
		var ul = $(this).next('ul');
		var h= $(ul).height();
		$(ul).height(0);
		$(ul).css("display","block");
		$(ul).animate({height: h}, 500);
	})

	$("#wsesfon, #close_menu_city").live("click",function(){
		$("#wsesfon").css('display','none');
		$(".menu_city").css("display","none");
		$("#close_menu_city").css("display","none");
		//$("#close_menu_city").css("left",0);
	})

var intervalID_f = setInterval(function(){
//		var h=jQuery("#framef").contents();
//		console.log('h='+h);

             clearInterval(intervalID_f);
      },5000);

//$('#framef').load(function(){
//  console.log($(this).contents());
//});
 
}

function set_reklama($){

return;

   if(device.mobile()){  

	$("#framef").before('<div data-la-block="626156ca-ff4c-49ca-a26d-5da8bf269ece"></div>');
	$("#framef").after('<div data-la-block="b8288ada-da90-454a-b595-bce8eea159b4"></div>');
   }else{

	$("#framef").before('<div data-la-block="5c59036f-dbdc-4e1a-888c-413564e9e047"></div>');
	$("#framef").after('<div data-la-block="5cb34374-cca6-45b2-a110-8e7798e7a3e8"></div>');
       $("article").append('<div data-la-block="a600a42d-7c8a-4cff-8d6f-56ca820afbba"></div>');

    }

	$("article h2:last-of-type").before('<div data-la-block="fb06bd5f-beb5-41a4-a533-381356c48a42"></div>');
	$("article").append('<div data-la-block="f3ed3d98-1f77-4d17-9d15-acec3b53a0bd"></div>');
}


function set_image_for_error($){



return;
//$('#framef').load(function(){
//  console.log($(this));
//});

  if($("#framef").length >0){

	window.framef.onload = function(){
	  console.log('Фрейм готов получать');
	  console.log($("#framef").contents());
		if($("#framef").html() == ''){
			console.log('Пусто');
			save_view_img($);
		}else{
			if($("#framef .neterror").length>0){
				console.log('ERROR');
				save_view_img($);
			}
		}
	}	
   }
}

function save_view_img($){


  	       var idf = $("#framef").attr("data-idf");

		if(idf ==''){
			return;
		}

             $.ajax({
        	           url: "/aa.php",
        	           type: "POST",
       	 	    data:"m=1&idf="+idf,
        	           success: function(data){
				console.log('Save');	
	      	           }
        	 });


}
