$(document).ready(function() {

	// switched_images
	var paircount = 0;
	
	$(".switched_images img").one("load",function(){
		initImage(this);
	})
	.each(function(){
		if(this.complete || (jQuery.browser.msie && parseInt(jQuery.browser.version) == 6))
		$(this).trigger("load");
	}); 

	$(".switched_images").bind("mouseenter mouseleave", function(event) {
		if (event.type == 'mouseenter')
		{
			//$(".des:not(.color)", this).fadeOut(1000);
			$(".des.color", this).fadeIn(250);
			$(this).animate({
				borderColor: '#acacac'
			}, 250);
			$(this).find('h2, p').animate({color: '#666666'}, 250);
		}
		if (event.type == 'mouseleave')
		{
			//$(".des:not(.color)", this).fadeIn(1000);
			$(".des.color", this).fadeOut(250);
			$(this).animate({
				borderColor: '#eaeaea'
			}, 250);
			$(this).find('h2, p').animate({color: '#acacac'}, 250);
		}
	  });

    function initImage(obj)
    {
        obj.onload = null;
        var $newthis = $(obj);
        if ($.browser.msie)
        {
          // You need this only if desaturate png with aplha channel
          $newthis = $newthis.desaturateImgFix();
        }
        // class for easy switch between color/gray version
        $newthis.addClass("pair_" + ++paircount);
        var $cloned = $newthis.clone();
        // reset onload event on cloned object
        $cloned.get(0).onload = null;
        // add cloned after original image, we will switch between
        // original and cloned later
        $cloned.insertAfter($newthis).addClass("color").hide();
        // desaturate original
        $newthis.desaturate();
    };
	
	// оформление ссылок
	$('.tags a').hover(
		function() {
			$(this).animate({color: '#666666', borderBottomColor: '#666666'}, 250);
		},
		function() {
			$(this).animate({color: '#acacac', borderBottomColor: '#acacac'}, 250);
		}
	);
	
	$('.rss a').hover(
		function() {
			$(this).find('span').animate({color: '#666666', borderBottomColor: '#666666'}, 250);
		},
		function() {
			$(this).find('span').animate({color: '#acacac', borderBottomColor: '#acacac'}, 250);
		}
	);
	
	$('.top_menu a, .footer a, .breadcrumbs a, .nav a, .nav input, .left_menu a, .navigation a').hover(
		function() {
			$(this).animate({color: '#666666', borderBottomColor: '#666666'}, 250);
		},
		function() {
			$(this).animate({color: '#acacac', borderBottomColor: '#fff'}, 250);
		}
	);
	
	$('.forms .submit input').hover(
		function() {
			$(this).animate({
				borderColor: '#666'
			}, 250);
		},
		function() {
			$(this).animate({
				borderColor: '#acacac'
			}, 250);
		}
	);
	
	$('.posts img').hover(
		function() {
			$(this).animate({
				borderColor: '#acacac'
			}, 250);
		},
		function() {
			$(this).animate({
				borderColor: '#eaeaea'
			}, 250);
		}
	);

  	$('.posts h3 a, #ShowAddComment a').hover(
		function() {
			$(this).animate({
				borderBottomColor: '#666'
			}, 250);
		},
		function() {
			$(this).animate({
				borderBottomColor: '#fff'
			}, 250);
		}
	);
	
 	$('.news_list li').hover(
		function() {
			$(this).find('p, a').animate({color: '#666666'}, 250);
		},
		function() {
			$(this).find('p, a').animate({color: '#acacac'}, 250);
		}
	); 
});
