$(document).ready(function() { 
	
	var frameNav;
	
	$("#frame_nav ul.gal_nav li").hoverIntent(function() {
		frameNavOver(this);
		$(this).find("ul").animate({height: 'show',opacity:0.80},"normal","easeOutExpo");
			//.slideToggle();
	}, function() {		
		frameNavOut(this);
		$(this).find("ul").animate({height: 'hide',opacity: 'hide'},"fast");
			//.slideToggle();
	});
	
	$("#frame_nav ul.gal_nav li a").click(function() {
		// currently don't do anything on click.
		return false;
	});
	
	$("#frame_nav ul.gal_nav li ul li a").click(function() {
		$("#featured_content").hide();
		$("#featured_content").css("background","url("+$(this).attr("href")+") no-repeat top left");
		$("#featured_content").fadeIn(700);		
		
		$("#featured_content .details h2").html($(this).siblings(".feature_title").attr("value"));
		$("#featured_content .details p").replaceWith($(this).siblings(".feature_description").html());
		$("#featured_content .details span a").attr("href",$(this).siblings(".feature_url").attr("value"));
		$("#featured_content .details span a").html($(this).siblings(".feature_link").attr("value"));
		$("#featured_content .details").hide();
		
		// dont' do anything
		return false;
	});	
	
	$("#image_carousel li a").click(function() {
		$("#image_frame .details h2").html($(this).siblings(".image_title").attr("value"));
		$("#image_frame .details p").replaceWith($(this).siblings(".image_caption").html());
		$("#image_frame .details").hide();
		return false;
	});
	
	$("#featured_content, #image_frame").hoverIntent(function() {
		$(this).find(".details_bg .db_middle").css("height",$(this).find(".details").outerHeight());		
		
		$(this).find(".details_bg").animate({top: 0},"slow","easeOutBounce",function() {
			$(this).parent().find(".details").css("visibility","visible").css("opacity",1);	
		});		
	}, function() {		
		var ttop = parseInt($(this).find(".details").outerHeight()) + 25;
		
		$(this).find(".details").animate({opacity:0},"fast",function() {	
			$(this).parent().find(".details_bg").animate({top: -ttop},"fast","easeInExpo",function() {
				$(this).parent().find(".details").show().css("visibility","hidden");	
			});		
		});		
	});
	
	if (ie6desuka() == true && isIE6() == true) {
		// alert("hai, ie6 desu. stop using IE6");
		$("body").append("<div id='ie6_shi-ne'></div>");
	}
	
	if (isIE6() == true) {
		// alert("isIE6.");
	}
	
});

function frameNavOver(thisEl) {
	$(thisEl).find("div.fade").animate({opacity:"toggle"},"fast","easeOutQuad",
		function() {    				
			$(this).siblings("a").animate({top:-3},"fast");
		}
	);	    			
}

function frameNavOut(thisEl) {	
	$(thisEl).find("div.fade").animate({opacity:"toggle"},"fast","easeOutQuad",
		function() {
			$(this).siblings("a").animate({top:0},"fast");
		}
	);    			
}

/* quick check of browser type */
function isIE6() {
	if (window.XMLHttpRequest) {
	// IE 7, mozilla, safari, opera 9
		return false;
	} else {
	// IE6, older browsers
		return true;
	}
}

function ie6desuka() {
	var s = navigator.userAgent.toLowerCase();
	var isIE6 = /*@cc_on!@*/false && ( parseInt( s.match( /msie (\d+)/ )[1] ) >= 6 );
	return isIE6;
}