﻿// Functions specific to a site.


(function($) {
	$(document).ready(function() {
		
		$(".expander").click(function(){   
			$(this).next().fadeSliderToggle();
			
			if($(this).hasClass("more")) 
				$(this).removeClass('more').addClass('close');
			else
				$(this).removeClass('close').addClass('more');

			 return false;
		})
		
		//$("#manitoba").parent().trigger('click');
		
		if (location.hash) {
    		//alert(location.hash);
			//$(location.hash).parent().removeClass('more').addClass('close');
			//$(location.hash).parent().next().attr("style","opacity: 1; display: block;");
			$(location.hash).parent().trigger('click');
		}
							   
							   
		$("#accordion").tabs("#accordion .pane", {
			tabs: '.accordian-trigger', 
			effect: 'slide',
			initialIndex: '3'
		});
		
		$("a[rel]").overlay({
			expose: '#202020',
			fixed: false
		});
		
		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(500);
            }
            if (event.type == 'mouseleave')
            {
              //$(".des:not(.color)", this).fadeIn(1000);
              $(".des.color", this).fadeOut(500);
            }
          });
      });
	}); 
	
	
	
	var tabContainers = $('div.tabs > div');
		
		$('div.tabs ul.tabNavigation a').click(function () {
			tabContainers.hide().filter(this.hash).show();
			
			$('.tabs .clear').show();
			$('div.tabs ul.tabNavigation a').removeClass('selected');
			$(this).addClass('selected');
			
			return false;
		}).filter(':first').click();


	
	
})(jQuery);

