$().ready(function() {
	
	$('a[rel=gallery]').colorbox();
	
	 $('a[rel=gallery]').hover(
  function () {
    $(this).children("img").before($("<div class='bb'></div>"));
  }, 
  function () {
    $(this).children(".bb").remove();
  }
);
	
	jQuery('#client_carousel').jcarousel();
	
	(function ($) {
$.fn.vAlign = function() {
return this.each(function(i){
var h = $(this).height();
var oh = $(this).outerHeight();
var mt = (h + (oh - h)) / 2;
$(this).css("margin-top", "-" + mt + "px");
$(this).css("top", "50%");
$(this).css("position", "relative");
});
};
})(jQuery);

$(".jcarousel-skin-tango .jcarousel-item a").vAlign();


$(".news_button a, .news ul li dl dd a").click(function(){
	$(".news li.active").show();
	$(".news li.active").next().hide();								 
	$(".news li.active").removeClass("active");										
											
	$(this).parents("li").addClass("active");
	$(this).parents("li").hide();
	$(this).parents("li").next().fadeIn("slow");
	});


$(".news div.close a").click(function(){
	$(".news li.active").fadeIn("slow");
	$(".news li.active").next().hide();								 
	$(".news li.active").removeClass("active");
	
	$(this).parents("li").hide();
	$(this).parents("li").prev().fadeIn("slow");
	$(this).parents("li").prev().removeClass("active");
	});
	
$(".services div.news_button a, .services ul li dl dt a").click(function(){
	$(".services li.active").show();
	$(".services li.active").next().hide();								 
	$(".services li.active").removeClass("active");										
											
	$(this).parents("li").addClass("active");
	$(this).parents("li").hide();
	$(this).parents("li").next().fadeIn("slow");
	});


$(".services div.close a").click(function(){
	$(".services li.active").fadeIn("slow");
	$(".services li.active").next().hide();								 
	$(".services li.active").removeClass("active");
	
	$(this).parents("li").hide();
	$(this).parents("li").prev().fadeIn("slow");
	$(this).parents("li").prev().removeClass("active");
	});

$show = false;
$index = 999;
$("div.portfolio-block div.clients-block a").click(function(){
	
	if ($(this).parent().index() != $index) $show = true;
	 $index = $(this).parent().index();
	if ($show) 
		{
			if ($(this).parents("div.portfolio-block").find("div.photos-block").eq($index).html()!="")
			{
		        $(this).parents("div.portfolio-block").find("div.default").hide();
				$(this).parents("div.portfolio-block").find("div.photos-block").hide();
				$(this).parents("div.portfolio-block").find("div.photos-block").eq($index).show();
			}
			else {
				$(this).parents("div.portfolio-block").find("div.photos-block").hide();
			}
			
		}	
});

});
