/*
 * make by ueno 2010.05.22
 * 
 * swfObjectと併用
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 */

var swfLibrary = {
	state		:null,						//init
	flash		:[],	//flash詰め込み用
	COMMAND		:"#flashChange li a",		//click切り替え用
	myID		:"#flash",					//書き換えエリアID
	imgText		:"",		//代替えIMG
	IDname		:"swfContent",
	width		:890,
	height		:290,
	version		:"10.0.0",
	myTimer		:null
}

$(function(){
	swfState();
});

function swfState(){
	swfLibrary.myTimer = setInterval("setTimer()",12000);
	$("#flashChange li a:eq(0)").hover(
		function(){
			if(swfLibrary.state != "main01.swf"){
				$("#flashChange li a").removeClass("active");
				$("#flashChange li a:eq(0)").addClass("active");
				swfLibrary.state = "main01.swf";
				swfLibrary.imgText = "http://www.c-grip.com/new/img/swf_img01.png";
				swfHtml();
				clearInterval(swfLibrary.myTimer);
				swfLibrary.myTimer = setInterval("setTimer()",12000);
			}
	});
	$("#flashChange li a:eq(1)").hover(
		function(){
			if(swfLibrary.state != "main02.swf"){
				$("#flashChange li a").removeClass("active");
				$("#flashChange li a:eq(1)").addClass("active");
				swfLibrary.state = "main02.swf";
				swfLibrary.imgText = "http://www.c-grip.com/new/img/swf_img02.png";
				swfHtml();
				clearInterval(swfLibrary.myTimer);
				swfLibrary.myTimer = setInterval("setTimer()",12000);
			}
	});
	$("#flashChange li a:eq(2)").hover(
		function(){
			if(swfLibrary.state != "main03.swf"){
				$("#flashChange li a").removeClass("active");
				$("#flashChange li a:eq(2)").addClass("active");
				swfLibrary.state = "main03.swf";
				swfLibrary.imgText = "http://www.c-grip.com/new/img/swf_img03.png";
				swfHtml();
				clearInterval(swfLibrary.myTimer);
				swfLibrary.myTimer = setInterval("setTimer()",12000);
			}
	});
}

function setTimer(){
	if(swfLibrary.state == "main01.swf"){
		$("#flashChange li a").removeClass("active");
		$("#flashChange li a:eq(2)").addClass("active");
		swfLibrary.state = "main03.swf";
		swfLibrary.imgText = "http://www.c-grip.com/new/img/swf_img03.png";
		swfHtml();
	}
	else if(swfLibrary.state == "main02.swf"){
		$("#flashChange li a").removeClass("active");
		$("#flashChange li a:eq(0)").addClass("active");
		swfLibrary.state = "main01.swf";
		swfLibrary.imgText = "http://www.c-grip.com/new/img/swf_img01.png";
		swfHtml();
	}
	else if(swfLibrary.state == "main03.swf"){
		$("#flashChange li a").removeClass("active");
		$("#flashChange li a:eq(1)").addClass("active");
		swfLibrary.state = "main02.swf";
		swfLibrary.imgText = "http://www.c-grip.com/new/img/swf_img02.png";
		swfHtml();
	}
	else if(swfLibrary.state == null){
		$("#flashChange li a").removeClass("active");
		$("#flashChange li a:eq(1)").addClass("active");
		swfLibrary.state = "main02.swf";
		swfLibrary.imgText = "http://www.c-grip.com/new/img/swf_img02.png";
		swfHtml();
	}
}

function swfHtml(){
	$(swfLibrary.myID).html('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+swfLibrary.width+'" height="290"><param name="movie" value="'+swfLibrary.state+'" /><!--[if !IE]>--><object type="application/x-shockwave-flash" data="'+swfLibrary.state+'" width="890" height="290"><!--<![endif]--><div id="swf_img"><img src="'+swfLibrary.imgText+'" alt="" width="890" height="290" /></div><!--[if !IE]>--></object><!--<![endif]--></object>');
}
















