// jQuery for quinkawithayawn.com
// by Daisuke Futaki

function slideSwitch(){

	var $active = $("#frame-slide img.active");

	if( $active.length == 0 ) $active = $("#frame-slide img:last");

	var $next =  $active.next().length ? $active.next() : $("#frame-slide img:first");

	$active.addClass("last-active");

	$next.css({opacity: 0.0}).addClass("active").animate({opacity: 1.0}, 1250, function(){
		$active.removeClass("active last-active");
	});

}


$(function(){

// fade in-out at home

	var firstDivId = $("div:first").attr("id");

	if( firstDivId == "opening" ){

		var opin = setTimeout(
			function(){
				$("#opening").fadeIn(1300);
			}, 1300);
		var opout = setTimeout(
			function(){
				$("#opening").fadeOut(1500);
			}, 3600);
		var contin = setTimeout(
			function(){
				$(".content-body").fadeIn(1500);
			}, 5200);
	}else{
		$(".content-body").fadeIn(1500);
	}

// transition inside the frame stitch

	setInterval( "slideSwitch()", 7500 );


// top lamp nav

	var url = location.href;
	var cid = url.indexOf("cid");
	var eid = url.indexOf("eid");

	if( ( cid != -1 ) || ( eid != -1 ) ){

		var h2Txt = $(".entry:first h2 a").text();

		if( h2Txt == "live/events" ){
			$("body").attr("id","live");
		}else if( h2Txt == "discography" ){
			$("body").attr("id","discography");
		}else if( h2Txt == "works" ){
			$("body").attr("id","works");
		}else if( h2Txt == "media" ){
			$("body").attr("id","media");
		}

	}

// fancybox

	$(".entry a:has(img)").fancybox();

// recommendations no image replacement

	$(".amazon-item img").each(function(){

		var imgSrc = $(this).attr("src");

		if( imgSrc.indexOf("THUMBZZZ") != -1 ){
			$(this).attr("src","http://www.daisukefutaki.com/qy/img/no-image.png");
		}

	});


});
