$(function() {

//Video gallery dropdown

var description = "";

$(".imagebox").click(function() {
	$(this).attr("title",description);
	$.fancybox({
			'padding'		: 20,
			'autoScale'		: false,
			'width'			: 480,
			'height'		: 360,
			'titleShow'		: true,
			'titlePosition' : 'inside',
			'title'			: this.title,
			'href'			: this.href.replace(new RegExp("([0-9])","i"),'moogaloop.swf?clip_id=$1'),
			'type'			: 'swf',
	});
	return false;
})
.hover(function(){
	description = $(this).attr("title");
	$(this).attr("title","");
}, function(){
	$(this).attr("title",description);
});

//Video gallery images

$("#gallery ").hide();
$("#button_videos a").toggle(function() {
	$("#gallery").slideDown(400);
	$(this).text("Close");
}, function(){
	$("#gallery").slideUp(400);
	$(this).text("Open");
});

$(".imagebox img").hover(function(){
	$(this).stop(true,true).animate({
		opacity: "0.5"
	}, "fast");
}, function(){
	$(this).stop(true,true).animate({
		opacity: "1.0"
	}, "normal");
});

//Banner fading

$("#banner img").hide();

$("#banner img").load(function(evt){
	if ($.browser.msie) {
		$("#loading").hide();
		$(evt.target).show();
	 } else {
		$("#loading").fadeOut(500);
		$(evt.target).delay(500).fadeIn(500);
	 }
});

if($("#banner img")[0].complete){
	if ($.browser.msie) {
		$("#loading").hide();
		$("#banner img").show();
	} else {
		$("#loading").hide();
		$("#banner img").fadeIn(500);
	}
}

});
