﻿function updateDiv1 (){
	//$("title").text("Аванпост");
	var lochref = location.href.replace(/.*\$/, "").replace(/:.*?$/, "");
	$("a#"+lochref+"_but").addClass("selected");
	$(".navigation a[id!='"+lochref+"_but']").removeClass("selected");
	if (location.href.match(/.*ru\/$/)){
		window.location="#:$avanpost"
	 }
	var page = $("#"+lochref+" .sub .page").attr("id");
	$(".mininav li a[href$='"+page+"'], .panel#avanpost .content li a[href$='"+page+"']").parent().addClass("first").siblings("li").removeClass();
	if($(".panel#avanpost .content li").hasClass("first")){$(".panel#avanpost .mininav li").removeClass();}
		if($("a#avanpost_but").hasClass("selected")){$('.carette').css('left', '0px');var actheight = 650 + $("#avanpost.panel .sub").height(); $(".wrapper").height(actheight);}
		if($("a#corporative_but").hasClass("selected")){$('.carette').css('left', '112px');var actheight = 650 + $("#corporative.panel .sub").height(); $(".wrapper").height(actheight);}
		if($("a#birthday_but").hasClass("selected")){$('.carette').css('left', '240px');var actheight = 650 + $("#birthday.panel .sub").height(); $(".wrapper").height(actheight);}
		if($("a#wedding_but").hasClass("selected")){$('.carette').css('left', '357px');
		if($("a#wedding_but").hasClass("selected")){
								var winwidth0 = $(window).width();
								if(900<winwidth0){$(".wrapper").css("height", "12370px");}
								if(1100<winwidth0){$(".wrapper").css("height", "12120px");}
								if(1200<winwidth0){$(".wrapper").css("height", "12000px");}
								if(1300<winwidth0){$(".wrapper").css("height", "11972px");}
								if(winwidth0>1400){$(".wrapper").css("height", "11872px");}
								}
		}
		if($("a#romantic_but").hasClass("selected")){$('.carette').css('left', '470px');var actheight = 650 + $("#romantic.panel .sub").height(); $(".wrapper").height(actheight);}
		if($("a#joke_but").hasClass("selected")){$('.carette').css('left', '580px');var actheight = 650 + $("#joke.panel .sub").height(); $(".wrapper").height(actheight);}
	                  }setInterval('updateDiv1()', 800);
$(window).bind("load", function(){
		var foo = [["avanpost","0"],["corporative","112"],["birthday","240"],["wedding","357"],["romantic","470"],["joke","580"],["cafe","585"]]
		for (var i=0; i<foo.length; i++) {
			$("#" + foo[i][0] + "_but").click(function(){
			$(this).addClass("selected").parent("li").siblings().find("a.selected").removeClass("selected");
			});
		}
		$(".wrapper").css("overflow", "hidden");
	$("#avanpost_but").click(function(){$('.carette').css('left', '0px'); var actheight = 650 + $("#avanpost.panel .sub").height(); $(".wrapper").height(actheight);});
	$("#corporative_but").click(function(){$('.carette').css('left', '112px');var actheight = 650 + $("#corporative.panel .sub").height(); $(".wrapper").height(actheight);});
	$("#birthday_but").click(function(){$('.carette').css('left', '240px');var actheight = 650 + $("#birthday.panel .sub").height(); $(".wrapper").height(actheight);});
	$("#wedding_but").click(function(){
								$('.carette').css('left', '357px');
	});
	$("#romantic_but").click(function(){$('.carette').css('left', '470px');var actheight = 650 + $("#romantic.panel .sub").height(); $(".wrapper").height(actheight);});
	$("#joke_but").click(function(){$('.carette').css('left', '580px');var actheight = 650 + $("#joke.panel .sub").height(); $(".wrapper").height(actheight);});
	$("#cafe_but").click(function(){$('.carette').css('left', '585px');});
	$(".logo").click(function(){
		$(".panel#avanpost .content li").removeClass();
		$(".panel#avanpost .mininav li:first").addClass("first");
		});
});

function updateDiv5 (){
	var lochref = location.href.replace(/.*\$/, "").replace(/:.*?$/, "");
	$(".scroll").scrollTo('div#' + lochref, 300, {axis:'x'});
	if($('.mininav li a[href="/places/avanpost/17"], .mininav li a[href="/places/avanpost/47"]').parent().hasClass("first")){
	$(".bubbleanons").hide();
	$(".sub#avanpostsub").css("margin", "-50px 40px 0 0 !important;");
	}
	else{$(".bubbleanons").show();
	$(".sub#avanpostsub").css("margin", "-50px 360px 0 0 !important;");}
 }setInterval('updateDiv5()', 800);
 
 $(window).bind("resize", function(){
	 
	 if($("a#wedding_but").hasClass("selected")){
								var winwidth0 = $(window).width();
								if(900<winwidth0){$(".wrapper").css("height", "12370px");}
								if(1100<winwidth0){$(".wrapper").css("height", "12120px");}
								if(1200<winwidth0){$(".wrapper").css("height", "12000px");}
								if(1300<winwidth0){$(".wrapper").css("height", "11972px");}
								if(winwidth0>1400){$(".wrapper").css("height", "11872px");}
								}
		
	 });
