// JavaScript Document

/* fancybox */

$(document).ready(function() {

	/* This is basic - uses default settings */
	
	$("a.fancybox").fancybox({
		'autoScale'			: true,
		'transitionIn'		: 'none',
		'transitionOut'		: 'none'
	});
	
	/* Using custom settings */
	
	$("a#inline").fancybox({
		'hideOnContentClick': true
	});

	/* Apply fancybox to multiple items */
	
	$("a.group").fancybox({
		'transitionIn'	:	'elastic',
		'transitionOut'	:	'elastic',
		'speedIn'		:	600, 
		'speedOut'		:	200, 
		'overlayShow'	:	false
	});

	$("a[rel=fb_group]").fancybox({
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'titlePosition'		: 'inside',
		'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
		return 'サンプル画面 ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '';
		}
	});
	$("a[rel=fb_group2]").fancybox({
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'titlePosition'		: 'inside',
		'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
		return 'サンプル画面 ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '';
		}
	});
	$("a[rel=fb_group3]").fancybox({
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'titlePosition'		: 'inside',
		'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
		return 'サンプル画面 ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '';
		}
	});

	$("a.fancybox_html_s").fancybox({
		'width'				: '50%',
		'height'			: '60%',
		'autoScale'			: false,
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'type'				: 'iframe'
	});

	$("a.fancybox_html").fancybox({
		'width'				: '75%',
		'height'			: '75%',
		'autoScale'			: false,
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'type'				: 'iframe'
	});

	$("a.fancybox_html_l").fancybox({
		'width'				: '90%',
		'height'			: '90%',
		'autoScale'			: false,
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'type'				: 'iframe',
		'titleShow'			: false
	});
	
	

	//dl.slideでのスライドメニュー
	//CSSの設定
	$("dl.slide dt").css("cursor","pointer"); //dt要素のカーソルをポインターに変更
	$("dl.slide dd").css("display","none"); //最初のdd要素以外を非表示
	
	$("dl.slide dt.opend+dd").css("display","block"); //opendクラスが指定されている場合は開く
	$("dl.slide dt.opend .img-off").css("display","none");
	$("dl.slide dt.opend .img-on").css("display","block");
	
	//dt要素がクリックされたときの動作
	$("dl.slide dt").click(function(){
		if($("+dd",this).css("display")=="none"){ //クリックされたdt要素に隣接するdd要素が非表示だった場合
			$("+dd",this).slideDown("fast"); //クリックされたdt要素に隣接するdd要素をスライドダウンで表示
		} else {
			$("+dd",this).slideUp("fast"); //クリックされたdt要素に隣接するdd要素が表示されていた場合、スライドアップで非表示
		}
	});

  //menuのハイライト
  
  if($('#left-menu') != null){
    var link;
    var path_arr = document.URL.split('/');
    path_arr.shift();
    path_arr.shift();
    path_arr.shift();

    //#hogeの除去
    path_arr[path_arr.length-1] = path_arr[path_arr.length-1].replace(/#.*/, "");
  
    //console.log("path_arr = " + path_arr[path_arr.length-1]);

    //index対策
    if(path_arr[path_arr.length-1] == "" || path_arr[path_arr.length-1] == "index.shtml"){
	    path_arr[path_arr.length-1] = "./";
    }

    link=$('#left-menu').find('a[href='+path_arr[path_arr.length-1]+']');
    if(link.length){
	  link.addClass('active');
    } 

/*
    link=$('#left-menu').find('a[href^='+path_arr[path_arr.length-1]+']');
    if(link.length){
	  link.addClass('active');
    }  
*/
}




	
});


$(function($) {
	var postfix = '_on';
	$('a img.h_img2').not('[src*="'+ postfix +'."]').each(function() {
		var img = $(this);
		var src = img.attr('src');
		var src_on = src.substr(0, src.lastIndexOf('.'))
		           + postfix
		           + src.substring(src.lastIndexOf('.'));
		$('<img>').attr('src', src_on);
		img.hover(function() {
			img.attr('src', src_on);
		}, function() {
			img.attr('src', src);
		});
	});
});

