/*
 *  Main application JavaScript (frontend)
 *
 *  Author: Yelena Vassilenko
 *  Email:  yelena.vassilenko@gmail.com
 *
 */
var prev_lang,curr_box,is_first_time=!0;$.address.change(function(a){var c;"ru"!=prev_lang&&"en"!=prev_lang&&(prev_lang="no");c=$("#central-wrapper").length?"ok":"no";$.ajax({url:location.pathname+"?page="+a.path+"&prev_lang="+prev_lang+"&central="+c,dataType:"json",async:!1,error:function(a){handler(a.responseText)},success:function(a){handler(a)}})});$("a").click(function(){$.address.value($(this).attr("href"))}); var handler=function(a){""!=a.menu&&($("#menu").html(a.menu),$(".drop_about li a").mouseenter(function(){!1==$(this).hasClass("selected")&&(!1!=$(this).is(":animated")&&$(this).stop(),$(this).animate({fontSize:"14px"},200))}),$(".drop_about li a").mouseleave(function(){!1==$(this).hasClass("selected")&&(!1!=$(this).is(":animated")&&$(this).stop(),$(this).animate({fontSize:"12px"},200))}),$(".menu li:not('.not-main-li')").children("a").mouseenter(function(){!1==$(this).hasClass("selected")&&(!1!=$(this).is(":animated")&& $(this).stop(),$(this).animate({fontSize:"22px"},400))}),$(".menu li:not('.not-main-li')").children("a").mouseleave(function(){!1==$(this).hasClass("selected")&&(!1!=$(this).is(":animated")&&$(this).stop(),$(this).animate({fontSize:"19px"},400))}),$(".menu li:not('.not-main-li')").children("a").click(function(){!1==$(this).hasClass("selected")&&(!1!=$(this).is(":animated")&&$(this).stop(),$(this).animate({fontSize:"19px"},300))}),$(".menu li a").each(function(){$(this).attr("href",$(this).attr("href").replace("http://adm-arch.ru", ""))}));$(".menu li a").each(function(){$(this).attr("href")=="/#!/"+a.lang+"/"+a.page?($(this).addClass("selected"),$(this).parents().children("a").addClass("selected"),$(this).parents().children("a").removeAttr("style")):$(this).removeClass("selected")});var c=0,e=!1;$(".menu li:not(.not-main-li)").each(function(){var a=$(this).parent(".menu").children("li:not(.not-main-li)").children("a").hasClass("selected");if(!0==$(this).children().hasClass("drop_about"))if(!0==$(this).children("a").hasClass("selected")){$(this).animate({left:165* -c},1E3,function(){$(this).children(".drop_about").slideDown(700)});e=!0;var d=0,b=!1,f=$(this).children(".drop_about").children().children().hasClass("selected");$(this).children(".drop_about").children().each(function(){!0==$(this).children().hasClass("selected")?($(this).animate({top:-28*d},800),b=!0):(!1==b&&!0==f?$(this).animate({top:28},800):$(this).animate({top:0},800),d+=1)})}else $(this).children(".drop_about").slideUp(100),!1==e&&!0==a?$(this).animate({left:165},1E3):$(this).animate({left:0}, 1E3),c+=1});$(".languages a").removeAttr("href");$(".languages a").removeClass("selected");$("#"+a.lang).attr("href",a.lang_url);var b="ru";"ru"==a.lang&&(b="en");$("#"+b).addClass("selected",a.lang_url);$("#"+b).stop();$("#"+b).removeAttr("style");prev_lang=a.lang;setTimeout(function(){$("h1").html(a.title);if(""!=a.context)$(".context").fadeOut("fast",function(){$(".context").html(a.context);$("#link-block-1").length?showBox(1):$("#link-block-2").length?showBox(2):$("#link-block-3").length&&showBox(3); $(".context").fadeIn("slow",function(){$(".v-bond-hover").length&&($(".v-bond-slide a").mouseenter(function(){var a=$(this).attr("id").split("-")[1];!1!=$("#h2-"+a).is(":animated")&&$("#h2-"+a).stop();!1!=$("#img-"+a).is(":animated")&&$("#img-"+a).stop();$("#img-"+a).attr()!=$("#img-hidden2-"+a).attr("src")&&$("#img-"+a).attr("src",$("#img-hidden2-"+a).attr("src"));$("#h2-"+a).animate({fontSize:"14px",opacity:1},200);$("#img-"+a).animate({width:"142px"},200)}),$(".v-bond-slide a").mouseleave(function(){var a= $(this).attr("id").split("-")[1];!1!=$("#h2-"+a).is(":animated")&&$("#h2-"+a).stop();!1!=$("#img-"+a).is(":animated")&&$("#img-"+a).stop();$("#img-"+a).attr()!=$("#img-hidden1-"+a).attr("src")&&$("#img-"+a).attr("src",$("#img-hidden1-"+a).attr("src"));$("#h2-"+a).animate({fontSize:"12px",opacity:0.5},200);$("#img-"+a).animate({width:"130px"},200)}),$(".filter-objects a").mouseenter(function(){!1==$(this).hasClass("selected")&&(!1!=$(this).is(":animated")&&$(this).stop(),$(this).animate({fontSize:"14px", opacity:1},200))}),$(".filter-objects a").mouseleave(function(){!1==$(this).hasClass("selected")&&(!1!=$(this).is(":animated")&&$(this).stop(),$(this).animate({fontSize:"12px",opacity:0.5},200))}),$(".v-bond-hover").bond({orientation:"vert",wrapperSelector:".v-bond-wrapper",boxSelector:".v-bond-box",slideSelector:".v-bond-slide",maxSpeed:3}));loadCenter()})});else if(""!=a.item_block)$("#object-wrapper").fadeOut("fast",function(){$("#object-wrapper").html(a.item_block);setTimeout(function(){$("#link-block-1").length? (showBox(1),is_first_time=!0):$("#link-block-2").length?showBox(2):$("#link-block-3").length&&showBox(3);$("#object-wrapper").fadeIn("slow",function(){loadCenter()})},800)});else if(""!=a.image_block){var b;$("#link-block-1").hasClass("selected")?b=$("#photos-block-1"):$("#link-block-2").hasClass("selected")&&(b=$("#photos-block-2"));b.fadeOut("fast",function(){$("a.more").html()==more2&&($(".about_case_2").hide(),$("a.more").html(more1));b.html(a.image_block).fadeIn("slow")})}},500);$.address.title(a.title)}; function loadCenter(){$(".h-bond-hover").length&&($(".h-bond-hover").bond({orientation:"horz",wrapperSelector:".h-bond-wrapper",boxSelector:".h-bond-box",slideSelector:".h-bond-slide",maxSpeed:3}),$(".h-bond-slide a").mouseenter(function(){var a=$(this).attr("id").split("-")[1];!1!=$("#img_s-"+a).is(":animated")&&$("#img_s-"+a).stop();$("#img_s-"+a).attr()!=$("#img-s-hidden2-"+a).attr("src")&&$("#img_s-"+a).attr("src",$("#img-s-hidden2-"+a).attr("src"));$("#img_s-"+a).animate({height:"55px"},500)}), $(".h-bond-slide a").mouseleave(function(){var a=$(this).attr("id").split("-")[1];!1!=$("#img_s-"+a).is(":animated")&&$("#img_s-"+a).stop();$("#img_s-"+a).attr()!=$("#img-s-hidden1-"+a).attr("src")&&$("#img_s-"+a).attr("src",$("#img-s-hidden1-"+a).attr("src"));$("#img_s-"+a).animate({height:"51px"},500)}));$(".h-bond-hover-2").length&&($(".h-bond-hover-2").bond({orientation:"horz",wrapperSelector:".h-bond-wrapper-2",boxSelector:".h-bond-box-2",slideSelector:".h-bond-slide-2",maxSpeed:3}),$(".h-bond-slide-2 a").mouseenter(function(){var a= $(this).attr("id").split("-")[1];!1!=$("#img_s2-"+a).is(":animated")&&$("#img_s2-"+a).stop();$("#img_s2-"+a).attr()!=$("#img-s2-hidden2-"+a).attr("src")&&$("#img_s2-"+a).attr("src",$("#img-s2-hidden2-"+a).attr("src"));$("#img_s2-"+a).animate({height:"54px"},500)}),$(".h-bond-slide-2 a").mouseleave(function(){var a=$(this).attr("id").split("-")[1];!1!=$("#img_s2-"+a).is(":animated")&&$("#img_s2-"+a).stop();$("#img_s2-"+a).attr()!=$("#img-s2-hidden1-"+a).attr("src")&&$("#img_s2-"+a).attr("src",$("#img-s2-hidden1-"+ a).attr("src"));$("#img_s2-"+a).animate({height:"51px"},500)}));$(".about_case li a").mouseenter(function(){!1==$(this).parent().hasClass("selected")&&(!1!=$(this).is(":animated")&&$(this).stop(),$(this).animate({fontSize:"14px",opacity:1},200))});$(".about_case li a").mouseleave(function(){!1==$(this).parent().hasClass("selected")&&(!1!=$(this).is(":animated")&&$(this).stop(),$(this).animate({fontSize:"12px",opacity:0.5},200));$(".about_case li a").removeAttr("style")});$("#scheme-block a").mouseenter(function(){!1== $(this).hasClass("selected")&&(!1!=$(this).is(":animated")&&$(this).stop(),$(this).animate({fontSize:"14px"},200))});$("#scheme-block a").mouseleave(function(){!1==$(this).hasClass("selected")&&(!1!=$(this).is(":animated")&&$(this).stop(),$(this).animate({fontSize:"12px"},200));$("#scheme-block a").removeAttr("style")});$("a.more").mouseenter(function(){!1!=$(this).is(":animated")&&$(this).stop();$(this).animate({fontSize:"14px",opacity:1},200)});$("a.more").mouseleave(function(){!1!=$(this).is(":animated")&& $(this).stop();$(this).animate({fontSize:"12px",opacity:0.5},200)})}$(function(){$(".languages li a").mouseenter(function(){!1==$(this).hasClass("selected")&&(!1!=$(this).is(":animated")&&$(this).stop(),$(this).animate({opacity:1,fontSize:"16px"},300))});$(".languages li a").mouseleave(function(){!1==$(this).hasClass("selected")&&(!1!=$(this).is(":animated")&&$(this).stop(),$(this).animate({opacity:0.6,fontSize:"12px"},300))})}); function showBox(a){$(".about_case ul li").removeClass("selected");$("#link-block-"+a).addClass("selected");1==a?($("a.more").html()==more2&&($(".about_case_2").hide(),$("a.more").html(more1)),$("#scheme-block").hide(),$(".h-bond-hover-2").hide(),$("#photos-block-2").hide(),$("#photos-block-1").fadeIn("fast"),$(".h-bond-hover").fadeIn("fast")):2==a?($("a.more").html()==more2&&($(".about_case_2").hide(),$("a.more").html(more1)),$(".h-bond-hover").hide(),$("#scheme-block").hide(),$("#photos-block-1").hide(), $("#photos-block-2").fadeIn("fast"),$(".h-bond-hover-2").fadeIn("fast",function(){!0==is_first_time&&($(".h-bond-hover-2").bond({orientation:"horz",wrapperSelector:".h-bond-wrapper-2",boxSelector:".h-bond-box-2",slideSelector:".h-bond-slide-2",maxSpeed:5}),is_first_time=!1)})):3==a&&($("a.more").html()==more2&&($(".about_case_2").hide(),$("a.more").html(more1)),$(".h-bond-hover").hide(),$(".h-bond-hover-2").hide(),$("#photos-block-1").hide(),$("#photos-block-2").hide(),$("#scheme-block").fadeIn("fast"), $("#link-scheme-1").length?showBox2(1):$("#link-scheme-2").length&&showBox2(2))} function showBox2(a){1==a?($("a.more").html()==more2&&($(".about_case_2").hide(),$("a.more").html(more1)),$(".about_case_2").hide(),$("#link-scheme-2").removeClass("selected"),$("#scheme-district").hide(),$("#scheme-city").fadeIn("fast"),$("#link-scheme-1").addClass("selected")):2==a&&($("a.more").html()==more2&&($(".about_case_2").hide(),$("a.more").html(more1)),$(".about_case_2").hide(),$("#link-scheme-1").removeClass("selected"),$("#scheme-city").hide(),$("#scheme-district").fadeIn("fast"),$("#link-scheme-2").addClass("selected"))} function toggleDescription(){$(".about_case_2").is(":visible")?($(".about_case_2").hide(),curr_box.show(),$("a.more").html(more1)):(curr_box=$("#photos-block-1").is(":visible")?$("#photos-block-1"):$("#photos-block-2").is(":visible")?$("#photos-block-2"):$("#scheme-city").is(":visible")?$("#scheme-city"):$("#scheme-district").is(":visible")?$("#scheme-district"):$(this),$("#photos-block-1").hide(),$("#photos-block-2").hide(),$("#scheme-city").hide(),$("#scheme-district").hide(),$(".about_case_2").show(), $("a.more").html(more2))};
