// 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().animate({"opacity": "1"});
		},function() {
		$(this).stop().animate({"opacity": "1"},200);
		$("span[class^=hover]").stop().animate({"opacity": "0"});
	});
});


	$(document).ready(function() {
		/*
		var defaults = {
  			containerID: 'moccaUItoTop', // fading element id
			containerHoverClass: 'moccaUIhover', // fading element hover class
			scrollSpeed: 1200,
			easingType: 'linear' 
 		};
		*/		
		$().UItoTop({ easingType: 'easeOutQuart' });
	});

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();
	$('ul.sf-menu ul li span').css({display:'none'});
	$('.sub_nav li span, .footer-menu li span, .footer-menu ul li ul').css({display:'none'});
	$('.sitemap li span').css({display:'none'});

});

Cufon.replace('h1, h2, h3, .post-info .date, .latest_news .date,', { hover:true, fontFamily: 'Anivers' });
Cufon.replace('h4, h5, h6, .subheader .subdesc, .subheader span, blockquote p, a.button span,', { hover:true });
