// when the DOM is ready
$(function () {
  var img = new Image();
  
  // wrap our new image in jQuery, then:
  $(img)
    // once the image has loaded, execute this code
    .load(function () {
      // set the image hidden by default    
      $(this).hide();
    
      // with the holding div #loader, apply:
      $('loading')
        // remove the loading class (so no background spinner), 
        .removeClass('loading')
        // then insert our image
        .append(this);
    
      // fade our image in to create a nice effect
      $(this).fadeIn();
    })
    
    // if there was an error loading the image, react accordingly
    .error(function () {
      // notify the user that the image could not be loaded
    })
    
    // *finally*, set the src attribute of the new image to our image
    .attr('src', '');
});

$(document).ready(function(){
	$("a[rel^='prettyPhoto']").each(function() {	
		var $image = $(this).contents("img");
			$hoverclass = 'hover_video';

	if($(this).attr('href').match(/(jpg|gif|jpeg|png|tif)/)) 
	$hoverclass = 'hover_image';
		
	if ($image.length > 0)
	{	
		var $hoverbg = $("<span class='"+$hoverclass+"'></span>").appendTo($(this));
		
			$(this).bind('mouseenter', function(){
			$height = $image.height();
			$width = $image.width();
			$pos =  $image.position();		
			$hoverbg.css({height:$height, width:$width, top:$pos.top, left:$pos.left});
		});
	}

});	

$("a[rel^='prettyPhoto']").contents("img").hover(function() {
		$(this).stop().animate({"opacity": "0.2"}, 200);
		$("span[class^='hover']").stop().show();
		},function() {
		$(this).stop().animate({"opacity": "1"},200);
		$("span[class^='hover']").stop().hide();
	});
});

function sys_toggle() {
	jQuery(".toggle_content").hide(); 

	jQuery("h5.toggle").toggle(function(){
		jQuery(this).addClass("active");
		}, function () {
		jQuery(this).removeClass("active");
	});

	jQuery("h5.toggle").click(function(){
		jQuery(this).next(".toggle_content").slideToggle();
	});
}

jQuery(function(){
	sys_toggle();

});


Cufon.replace('h1, h2, h3, h4, h5, h6,', { hover:true});
