	$(document).ready(function() {
	var selected = "selected";
	var act = "<li class=\"act\"></li>";
	$("#menu li#"+selected).find("span").show();
	$("#menu li a:first-child").not("span a").before("<div class=\"dd\"></div>");


	$("#menu li").hover(function() { //Hover over event on list item
		if (this.id != selected) {
			$(this).find("a:first").addClass("act");
			$(this).find("span").show(); //Show the subnav
			$("#menu li#"+selected).find("span").hide();
		}
		/*$(this).siblings().stop().fadeTo(400,0.4);*/

	} , function() { //on hover out…
			$(this).find("a:first").removeClass("act");
			$("#menu li#"+selected).find("span").show();
			$("#menu li#"+selected).find("div").show();
	});
	
	$("#vg").show().animate({opacity: '0'}).delay(800).animate({opacity: '0.3',right: '0'});
	$("#vg").hover(function() {
    	$(this).stop().animate({opacity: '1'}, 200);
	} , function () {
		$(this).stop().animate({opacity: '0.3'}, 200);
	});

	var sliderHeight = "110px";
	$('.acc_container:first').each(function () {
		var current = $(this);
		current.attr("box_h", current.height());
	});

	$('.acc_container').hide();

	if($('.acc_container').hasClass('selected')){
		$('.acc_container.selected').addClass('active').show().prev().addClass('active');
		$('.acc_container:first').not('.invis').addClass('desc').css('height',sliderHeight).show();			
	} else {
		$('.acc_trigger:first').addClass('active').parent().show();
		$('.acc_trigger:first').not('.invis').parent().addClass('desc');
		$('.acc_trigger:first').hide();
	}
	
	$('.acc_trigger').click(function(){
		if($(this).hasClass("active")){
			$(this).removeClass("active");
			if($(this).parent().hasClass("desc")){
				$(this).parent().animate({"height": sliderHeight}, {duration: "fast" });
			} else {				
				$(this).next().slideUp("fast");
			}			
		}else{			
			if($(this).parent().hasClass("desc")){
				var open_height = $(this).parent().attr("box_h") + "px";
				$(this).parent().animate({"height": open_height}, {duration: "fast"});
				$('.acc_trigger').not(':first').removeClass('active').next().slideUp("fast");
				$(this).addClass("active");
				$('.acc_trigger:first').hide();
			} else {
				$('.acc_trigger:first').parent().not('.invis').animate({"height": sliderHeight}, {duration: "fast" });
				$('.acc_trigger:first').removeClass('active');				
				$('.acc_trigger').not(':first').removeClass('active').next().slideUp("fast");
				$(this).next().slideDown("fast");
				$(this).addClass("active");
				$('.acc_trigger:first').show();
			}
		}
		return false;
	});
	
	$('.acc_trigger:first').bind({mouseenter:function(){
		if($(this).hasClass("active")) {
			$(this).addClass("hover");
			$(this).find(".but").addClass("close");
		} else {
			$(this).find(".but").addClass("open");
		}
	},mouseleave:function(){
			$(this).removeClass("hover");
			$(this).find(".but").removeClass("close");
			$(this).find(".but").removeClass("open");
	}
	});
	
	$(".case").mouseenter(function(){
		$(this).find("img").stop().animate({
			opacity:0.8
		},300).end().find(".viewcasestudy").fadeIn("fast")
	}).mouseleave(function(){
		$(this).find("img").stop().animate({
			opacity:1
		},150).end().find(".viewcasestudy").fadeOut("fast")
	});
    
    $(function() {
        $("#top").scrollToTop({speed:1000,ease:"easeOutCubic",start:500});

    });		
	});
