//var _url = "http://localhost/arm-s/";
//var _url = "http://www.arm-s.net/demo/";
var _url = "http://www.arm-s.net/";

$(document).ready(function(){
	
	/* *** rollover *** */
	var targetImgs = $('img');
		
	targetImgs.each(function()
	{
		if(this.src.match('_off'))
		{
			
			this.rollOverImg = new Image();
			this.rollOverImg.src = this.getAttribute("src").replace("_off", "_on");
			$(this.rollOverImg).css({position: 'absolute', opacity: 0});
			$(this).before(this.rollOverImg);
			
			$(this.rollOverImg).mousedown(function(){
				$(this).stop().animate({opacity: 0}, {duration: 0, queue: false});
			});
			
			$(this.rollOverImg).hover(function(){
				$(this).animate({opacity: 1}, {duration: 200, queue: false});
			},
			function(){
				$(this).animate({opacity: 0}, {duration: 200, queue: false});
			});
			
		}
	});
	
	/* *** Information Toggle *** */
	$("#Information h2").click(function(){
		$("#Information ul").slideToggle("normal");
	});
	
	/* *** ChildMenu Toggle *** */
	$(".hasChild span").click(function(){
		var parent = $(this).closest("li");
		var mode = parent.attr("class");
		if(mode.match("close")){
			parent.removeClass("close");
			parent.addClass("open");
			$(this).css("background-image","url("+_url+"images/subnav_arrow_open.png)");
		}else if(mode.match("open")){
			parent.removeClass("open");
			parent.addClass("close");
			$(this).css("background-image","url("+_url+"images/subnav_arrow_close.png)");
		}
		parent.children("ul").slideToggle("normal");
	});
	
	/* *** OpenContainer *** */
	$(".OpenContainer .btn").click(function(){
		var parent = $(this).next(".content");
		var mode = $(this).attr("class");
		if(mode.match("close")){
			$(this).removeClass("close");
			$(this).addClass("open");
			$(this).css("background-image","url("+_url+"images/toggle_arrow_open.png)");
		}else if(mode.match("open")){
			$(this).removeClass("open");
			$(this).addClass("close");
			$(this).css("background-image","url("+_url+"images/toggle_arrow_close.png)");
		}
		parent.slideToggle("normal");
	});
	
});

/* *** DetailFlashChange *** */
function ChangeSWF(swf,me) {
	$("#FlashTab .tab1 img").attr("src",$("#FlashTab .tab1 img").attr("src").replace("_current", "_up"));
	$("#FlashTab .tab2 img").attr("src",$("#FlashTab .tab2 img").attr("src").replace("_current", "_up"));
	$("#FlashTab .tab3 img").attr("src",$("#FlashTab .tab3 img").attr("src").replace("_current", "_up"));
	//$(this).attr("src",$(this).attr("src").replace("_up", "_current"));
	//var file_name = $(this).attr("class");
	//var swf_path = _url + "wp/wp-content/uploads/" + file_name + ".swf";
	$(me).attr("src",$(me).attr("src").replace("_up", "_current"));
	var swf_path = swf;
	var flashCode = "";
	flashCode ='<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="780" height="500" id="viewer" align="middle">';
	flashCode +='<param name="movie" value="'+_url+'product/viewer.swf" />';
	flashCode +='<param name="bgcolor" value="#ffffff" />';
	flashCode +='<param name="wmode" value="window" />';
	flashCode +='<param name="scale" value="showall" />';
	flashCode +='<param name="menu" value="false" />';
	flashCode +='<param name="FlashVars" value="myVar='+swf_path+'" />';
	flashCode +='<param name="allowScriptAccess" value="sameDomain" />';
	flashCode +='<!--[if !IE]>-->';
	flashCode +='<object type="application/x-shockwave-flash" data="'+_url+'product/viewer.swf" width="780" height="500">';
	flashCode +='<param name="movie" value="'+_url+'product/viewer.swf" />';
	flashCode +='<param name="bgcolor" value="#ffffff" />';
	flashCode +='<param name="wmode" value="window" />';
	flashCode +='<param name="scale" value="showall" />';
	flashCode +='<param name="menu" value="false" />';
	flashCode +='<param name="FlashVars" value="myVar='+swf_path+'" />';
	flashCode +='<param name="allowScriptAccess" value="sameDomain" />';
	flashCode +='<!--<![endif]-->';
	flashCode +='<a href="http://www.adobe.com/go/getflash"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Adobe Flash Player を取得" /></a>';
	flashCode +='<!--[if !IE]>-->';
	flashCode +='</object>';
	flashCode +='<!--<![endif]-->';
	flashCode +='</object>';
	$("#DetailFlash").html(flashCode);
}
