$(document).ready(function() {

	$("input#interest").focus(function(){
		if (this.value=="Car you are interested in") this.value="";
        }
		);
    $("input#interest").blur(function(){
		if (this.value=="") this.value="Car you are interested in";
        }
		);


	$("input#your-name").focus(function(){
		if (this.value=="Your name") this.value="";
        }
		);
    $("input#your-name").blur(function(){
		if (this.value=="") this.value="Your name";
        }
		);


	$("input#your-email").focus(function(){
		if (this.value=="Email") this.value="";
        }
		);
    $("input#your-email").blur(function(){
		if (this.value=="") this.value="Email";
        }
		);


	$("input#phone").focus(function(){
		if (this.value=="Phone") this.value="";
        }
		);
    $("input#phone").blur(function(){
		if (this.value=="") this.value="Phone";
        }
		);


	$("textarea#comments").focus(function(){
		if (this.value=="Additional comments") this.value="";
        }
		);
    $("textarea#comments").blur(function(){
		if (this.value=="") this.value="Additional comments";
        }
		);



jQuery('#slider').nivoSlider({
		effect:'fade',
		slices:8,
		animSpeed:1000, //Slide transition speed
        pauseTime:5000,
        startSlide:0, //Set starting Slide (0 index)
        directionNav:false, //Next & Prev
        directionNavHide:false, //Only show on hover
        controlNav:false, //1,2,3...
        controlNavThumbs:false, //Use thumbnails for Control Nav
        controlNavThumbsFromRel:false, //Use image rel for thumbs
        controlNavThumbsSearch: '.jpg', //Replace this with...
        controlNavThumbsReplace: '_thumb.jpg', //...this in thumb Image src
        keyboardNav:true, //Use left & right arrows
        pauseOnHover:false, //Stop animation while hovering
        manualAdvance:false, //Force manual transitions
        captionOpacity:1, //Universal caption opacity
        beforeChange: function(){},
        afterChange: function(){},
        slideshowEnd: function(){}, //Triggers after all slides have been shown
        lastSlide: function(){}, //Triggers when last slide is shown
        afterLoad: function(){} //Triggers when slider has loaded
	});

$(".for_sale .switched_images img").addClass("des");
$("img.des").bind("load", function() {
                var img = $(this);
                if ($.browser.msie) img = img.desaturateImgFix();
                img.desaturate();
        });

$("img.des").each(function() { initImage(this);});

$(".ngg-galleryoverview div.ngg-gallery-thumbnail-box:eq(2),.ngg-galleryoverview div.ngg-gallery-thumbnail-box:eq(5),.ngg-galleryoverview div.ngg-gallery-thumbnail-box:eq(8)").addClass( "nomr" );
$(".ngg-galleryoverview div.ngg-gallery-thumbnail-box:eq(11),.ngg-galleryoverview div.ngg-gallery-thumbnail-box:eq(14),.ngg-galleryoverview div.ngg-gallery-thumbnail-box:eq(17)").addClass( "nomr" );
$(".ngg-galleryoverview div.ngg-gallery-thumbnail-box:eq(20),.ngg-galleryoverview div.ngg-gallery-thumbnail-box:eq(23),.ngg-galleryoverview div.ngg-gallery-thumbnail-box:eq(26)").addClass( "nomr" );
$(".ngg-galleryoverview div.ngg-gallery-thumbnail-box:eq(29),.ngg-galleryoverview div.ngg-gallery-thumbnail-box:eq(32),.ngg-galleryoverview div.ngg-gallery-thumbnail-box:eq(35)").addClass( "nomr" );


});


var paircount = 0;

      /* If you want to desaturate after page loaded - use onload event
       * of image.
      */
      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();
      };

      $(function(){

        $('.xxx').data('desaturate', {'level':0.5});

        $(".switched_images").bind("mouseenter mouseleave", function(event) {
            if (event.type == 'mouseenter')
            {
              //$(".des:not(.color)", this).fadeOut(1000);
              $(".des.color", this).fadeIn(250);
            }
            if (event.type == 'mouseleave')
            {
              //$(".des:not(.color)", this).fadeIn(1000);
              $(".des.color", this).fadeOut(250);
            }
          });
      });

