jQuery(document).ready(function(){
	
	jQuery(".link-block a").click(function(){
		jQuery(this).toggleClass('open');
		jQuery(this).parent().next().slideToggle();
		return false;
	});
	jQuery(".price-block a").click(function(){
		jQuery(this).toggleClass('open');
		jQuery(this).parent().next().slideToggle();
		return false;
	});
	jQuery(".price-block a").first().addClass('open');
	jQuery(".price-block div").first().slideDown();
	
	jQuery(".nav li.active a").each(function(){
		var ow = jQuery(this).parent().width();
		jQuery(this).parent().css({'width':ow+'px', 'text-align': 'center'});
	});
	jQuery(".nav a").not('li.active a').hover(function(){
			var ow = jQuery(this).parent().width();
			jQuery(this).stop();
			jQuery(this).parent().css({'width':ow+'px', 'text-align': 'center'});
			jQuery(this).css({'padding':'0'});
			jQuery(this).animate({'font-size': '18px'}, 200);
		},function(){
			jQuery(this).stop();
			jQuery(this).animate({'font-size': '13px'}, 200)
	})
});

jQuery(window).load(function(){
	jQuery(".gallery-block").slides({
		paginationClass: 'button',
		effect: 'fade',
		play: 5000
	});
	jQuery(".gallery-project").slides({
		generatePagination: false,
		effect: 'fade',
		next: 'slides-next'
	});

	var images = jQuery('.gallery img, .news img');
	images.each(function(){
		var img_container = jQuery(this).parent().parent();
		var img2 = Pixastic.process(this, "desaturate");
		img2.onmouseover = function() {
			Pixastic.revert(this);
		}
		//img_container.css('opacity', 1);
		img_container.animate({opacity: 1}, 500);
		img_container.css('filter', 'progid:DXImageTransform.Microsoft.Alpha(opacity=40);')
//		console.log(jQuery(this).parent());
		jQuery(this).bind('mouseout', function(){
			var img2 = Pixastic.process(this, "desaturate");
			img2.onmouseover = function() {
				Pixastic.revert(this);
			}
		});
	});
	var imgs = jQuery('.gallery-project .pagination img');
	imgs.each(function(){
		if(!jQuery(this).parents('li').hasClass('current')){
			var img2 = Pixastic.process(this, "desaturate");
			img2.onmouseover = function() {
				Pixastic.revert(this);
			}
		}
		jQuery(this).bind('mouseout', function(){
			if(!jQuery(this).parents('li').hasClass('current')){
				var img2 = Pixastic.process(this, "desaturate");
				img2.onmouseover = function() {
					Pixastic.revert(this);
				}
			}
		});
		jQuery(this).bind('click', function(){
			jQuery(this).parents('li').siblings().find('img').each(function(){
				var img2 = Pixastic.process(this, "desaturate");
				img2.onmouseover = function() {
					Pixastic.revert(this);
				}
			});
		})
	});

});
