/**
 * NAZE Site Eyecatch Controller
 * Date: 05/22/2009
 * @author xe-que design works
 * @version 1.0
 *
 */
imgTemp = new Image();
imgDisplay = false;
TOPEYECATCH_TRANIMG  = "./wp-content/themes/naze_act2/images/bg-top-eyecatch2.jpg";
TOPEYECATCH_TRANTIME = 8000;
TOPEYECATCH_FADETIME = 2000;

$(document).ready(function(){
	$("#eyecatch-anchor-db").hover(
		function(){
			$("#eyecatch-anchor-db").css("width","380px");
			$("#eyecatch-panel-navi").stop();
			$("#eyecatch-panel-db").stop();
			$("#eyecatch-panel-navi").animate({left:"327px"});
			$("#eyecatch-panel-db").animate({left:"517px"});
		},
		function(){
			$("#eyecatch-anchor-db").css("width","190px");
			$("#eyecatch-panel-navi").stop();
			$("#eyecatch-panel-db").stop();
			$("#eyecatch-panel-db").animate({left:"707px"});
			$("#eyecatch-panel-navi").animate({left:"517px"});
		}
	);
	$("#eyecatch-anchor-navi").hover(
		function(){
			$("#eyecatch-anchor-navi").css("width","380px");
			$("#eyecatch-panel-navi").stop();
			$("#eyecatch-panel-navi").animate({left:"327px"});
		},
		function(){
			$("#eyecatch-anchor-navi").css("width","190px");
			$("#eyecatch-panel-navi").stop();
			$("#eyecatch-panel-navi").animate({left:"517px"});
		}
	);
	$("#eyecatch-anchor-db").click(function(){this.blur();});
	$("#eyecatch-anchor-navi").click(function(){this.blur();});

/* transition disable 090529 xe-que
	$(imgTemp).load(function () {
		$('#eyecatch-panel-base').css("background","url(" + $(this).attr('src') + ")").css("opacity","0");
		setTimeout(eyecatchTransition, TOPEYECATCH_TRANTIME);
	}).attr('src', TOPEYECATCH_TRANIMG);
*/

	// image changing at local
	$('#eyecatch-panel-base').css("background","url(./wp-content/themes/naze_act2/images/bg-top-eyecatch_" + Math.floor(Math.random()*2+1) + ".jpg" + ")");

});


function eyecatchTransition() {
	if (imgDisplay) {
		$('#eyecatch-panel-base').animate({opacity : 0}, TOPEYECATCH_FADETIME, "linear", function(){setTimeout(eyecatchTransition, TOPEYECATCH_TRANTIME);});
		imgDisplay = false;
	} else {
		$('#eyecatch-panel-base').animate({opacity : 1}, TOPEYECATCH_FADETIME, "linear", function(){setTimeout(eyecatchTransition, TOPEYECATCH_TRANTIME);});
		imgDisplay = true;
	}
}


// image changing at local - (preload)
function preload(imgs){
 for(var i = 0; i < imgs.length; i++){
   var imgObj = new Image();
   imgObj.src = "./wp-content/themes/naze_act2/images/" + imgs[i];
 }
}
preload(["bg-top-eyecatch_1.jpg", "bg-top-eyecatch_2.jpg"]);
