var $j = jQuery.noConflict();
$j(window).load(function() {
$j('.buttonr').raptorize();
//$j(".directions1").colorbox({width:"60%", height:"75%", iframe:true});

});

// ----------------------------------------------------------------------------------------------------------------------------
// DROPDOWN MENU
$j(function() {	
	$j(".menu ul li").each(function(){ $j(this).find("li a:first").css("border-top","none"); });
	$j(".menu ul li").each(function(){ $j(this).find("li a:last").css("border-bottom","none"); });
	$j(".menu ul ").css("display","none");
	$j(".menu li").hover(function(){
		$j(this).find('ul:first').slideDown(50).parent().find("a").addClass("hover");
		$j(this).find('ul ul:first').parent().find('a').removeClass("hover").addClass("subber");
		$j(this).find('ul ul a').removeClass("subber");
		$j(this).find('ul > a').removeClass("hover");
	}, 
	function () {
		$j(this).find('ul:first').fadeToggle(50);
		$j(this).find('ul:first').parent().find("a").removeClass("hover");
	});
	$j("#main-menu ul ul ul a").wrapInner("<span></span>");
	$j("#main-menu ul ul ul li").hover(function(){
		$j(this).find("span:first").stop().animate({paddingLeft:'5px'},{queue:false, duration:100, easing: 'easeInSine'});
	},
	function(){
		$j(this).find("span").stop().animate({paddingLeft:'0px'},{queue:false, duration:100, easing: 'easeOutSine'});
	});
	
});
$j(function() {
	$j(".menu ul li").hover(function(){
		$j(this).find("a").addClass("active");
		$j(this).find("ul li a").removeClass("active");
	}, 
	function () {
		$j(this).find("a").removeClass("active");
	});
});
$j(function(){
 
    $j('a[href*=#]').click(function() {
 
    if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') 
        && location.hostname == this.hostname) {
 
            var $target = $j(this.hash);
 
            $target = $target.length && $target || $j('[name=' + this.hash.slice(1) +']');
 
            if ($target.length) {
 
                var targetOffset = $target.offset().top;
 
                $j('html,body').animate({scrollTop: targetOffset}, 600);
 
                return false;
 
            }
 
        }
 
    });
 
});

// ----------------------------------------------------------------------------------------------------------------------------
// FADEOVER
$j(function(){
	$j(".fadeover").hover(function(){
		$j(this).stop().animate({opacity: "0.25"},500);
	},function(){
		$j(this).stop().animate({opacity: "1"},300);
	});
});


// ----------------------------------------------------------------------------------------------------------------------------
// Fade hover image link Video, Image or Document... ?
$j(function() {
	// Others
	$j("a.hover").addClass("link_blog");
	// Image
	$j("a[href$='.png'].hover, a[href$='.jpg'].hover, a[href$='.jpeg'].hover").removeClass("link_blog").addClass("link_img");
	// Video
	$j("a[href$='.swf'].hover, .hover a[href$='.mov'].hover, a[href$='.rft'].hover").removeClass("link_blog").addClass("link_vid");
	// Docs
	$j("a[href$='.pdf'].hover").removeClass("link_blog").addClass("link_doc");;
});
$j(function() {
	// Others
	$j("a.thumby").addClass("link_blog");
	// Image
	$j("a[href$='.png'].thumby, a[href$='.jpg'].thumby, a[href$='.jpeg'].thumby").removeClass("link_blog").addClass("link_img");
	// Video
	$j("a[href$='.swf'].thumby, .hover a[href$='.mov'].thumby, a[href$='.rft'].thumby").removeClass("link_blog").addClass("link_vid");
	// Docs
	$j("a[href$='.pdf'].thumby").removeClass("link_blog").addClass("link_doc");;
});
$j(function () {
	$j('.pictures_entry div').hide();//hide all the images on the page
});

var i = 0;//initialize
var int=0;//Internet Explorer Fix
$j(function() {//The load event will only fire if the entire page or document is fully loaded
	var int = setInterval("doThis(i)",150);//500 is the fade in speed in milliseconds
});

function doThis() {
		var images = $j('div').length;//count the number of images on the page
		if (i >= images) {// Loop the images
			clearInterval(int);//When it reaches the last image the loop ends
		}
		$j('.pictures_entry div:hidden').eq(0).fadeIn(350);//fades in the hidden images one by one
		i++;//add 1 to the count
}
