$(document).ready(function(){
	
	// seotool tabs
	$('#seotools').tabs({ fxFade: true, fxSpeed: 'fast' });

	// dropdown menu
	$("#nav").droppy();

	// ref acodion
	$(".ac_body").hide();
	$(".ac_header").click(function(){
		$(this).next().slideToggle("fast");
		return false;
	});
	$(".ac_header").hover(
		function(){
			$(this).css("color","#1a76ff");
		},
		function(){
			$(this).css("color","black");
		}
	);
	// round_corner
	$('.round_corner').corner({
		tl: { radius: 4 }, // 左上コーナーの半径
		tr: { radius: 4 }, // 右上コーナーの半径：falseで設定なし
		bl: { radius: 4 }, // 左下コーナーの半径：falseで設定なし
		br: { radius: 4 }, // 右下コーナーの半径
		antiAlias: true, // アンチエイリアス：trueで設定あり
		autoPad: true, // パディング処理：trueで設定あり
		validTags: ["div"]	// 対象要素
	}); 

	$('.round_corner_tool').corner({
		tl: { radius: 4 },
		tr: { radius: 4 },
		bl: { radius: 4 },
		br: { radius: 4 },
		antiAlias: true,
		autoPad: true,
		validTags: ["div"]
	});
	
	$('.round_corner_footerlink').corner({
		tl: { radius: 4 },
		tr: { radius: 4 },
		bl: { radius: 4 },
		br: { radius: 4 },
		antiAlias: true,
		autoPad: true,
		validTags: ["div"]
	});

	// 広告のランダム切替設定
	$('ul#recommend_dir').innerfade({
		animationtype: 'fade',
		speed: 1000,
		timeout: 12000,
		type: 'random',
		containerheight: '60px'
	});

	$('ul#center_banner').innerfade({
		animationtype: 'fade',
		speed: 1000,
		timeout: 12000,
		type: 'random',
		containerheight: '80px'
	});

	$('ul#adsense_300_250').innerfade({
		animationtype: 'slide',
		speed: 500,
		timeout: 15000,
		type: 'sequence',
		containerheight: '250px',
		html_id: 'icon_'
	});
	
	// facebox
	$('a[rel*=facebox]').facebox()
	
});

function appendCSS( file ){  
	var link = document.createElement('link');	
	with( link ) {	
		href = file;  
		type = 'text/css';	
		rel  = 'stylesheet';  
	}  
	var head = document.getElementsByTagName('head');  
	head.item(0).appendChild( link);
}

function select_dir( list_num){
	var elements = $("#recommend_dir").children();
	cnt = ++elements.length;
	
	for( i=1; i < cnt; i++){
		if( i.toString().match( list_num)){
			$("#dir_li_"+ list_num).slideDown(300);
		} else {
			$( "#dir_li_"+ i.toString() ).hide();
		}
	}
}

function forward_adsense( type, list_num){
	$('ul#adsense_300_250').innerfade({
		animationtype		: 'slide',
		speed			: 500,
		timeout			: 15000,
		type				: type,
		containerheight	: '250px',
		html_id			: 'icon_',
		current			: list_num
	});
}
function select_adsense( list_num){
	clearTimeout( timeout );
	forward_adsense( 'sequence', list_num);
	
	// 繰り返し回数設定
	var elements = $("#adsense_300_250").children();
	cnt = ++elements.length;
	
	for( i=1; i < cnt; i++){
		img_num = i.toString();
		if( img_num.match( "^"+ list_num +"$")){
			$( "#cr_icon_"+ img_num).show();
			$( "#df_icon_"+ img_num).hide();
			$( "#adsense_li_"+ img_num).slideDown( 300);
		} else {
			$( "#df_icon_"+ img_num).show();
			$( "#cr_icon_"+ img_num).hide();
			$( "#adsense_li_"+ img_num).hide();
		}
	}
}
