// JavaScript Document
$(function(){
//プリロード
	var buttonImg=$('#wrapper img[src*="_off"]');
	buttonImg.each(function()
		{
			plImg=$(this).attr("src").split("_");
			if(plImg.length==3){
				crtFileType=plImg[2].split(".");
					$(this).attr("src",plImg[0]+"_"+plImg[1]+"_on."+crtFileType[1]);
					$(this).attr("src",plImg[0]+"_"+plImg[1]+"_off."+crtFileType[1]);
			}
			else if(plImg.length==2){
				crtFileType=plImg[1].split(".");
					$(this).attr("src",plImg[0]+"_on."+crtFileType[1]);
					$(this).attr("src",plImg[0]+"_off."+crtFileType[1]);
			}
		});
//ロールオーバー
	buttonImg.hover(
		function(){
			crtImg=$(this).attr("src").split("_");
			if(crtImg.length==3){
				crtFileType=crtImg[2].split(".");
				$(this).attr("src",crtImg[0]+"_"+crtImg[1]+"_on."+crtFileType[1]);
			}else if(crtImg.length==2){
				crtFileType=crtImg[1].split(".");
				$(this).attr("src",crtImg[0]+"_on."+crtFileType[1]);
			}
		},
		function(){
			crtImg=$(this).attr("src").split("_");
			if(crtImg.length==3){
				crtFileType=crtImg[2].split(".");
				$(this).attr("src",crtImg[0]+"_"+crtImg[1]+"_off."+crtFileType[1]);
			}else if(crtImg.length==2){
				crtFileType=crtImg[1].split(".");
				$(this).attr("src",crtImg[0]+"_off."+crtFileType[1]);
			}
		});
	
	//検索ボックスを選択したとき初期値を削除
	$("#search_form .text").click(function(){
		$(this).val("");
	});
	//埋込のinputクリックで全選択
	$("#movie_desc .site_tag #textfield").click(function(){
		$(this).select();
	});

	//文字コード、動画サイズ
	$('input[name="char_code"]:radio , input[name="movie_size"]:radio').click(function(){
		var str = $("#textfield").val();
		var str_val = str.split("/char.");
		var char_code = $('input[name="char_code"]:checked').val();
		var movie_size = $('input[name="movie_size"]:checked').val();
		$("#movie_desc .site_tag #textfield").val(str_val[0] + '/char.' +char_code + '/size.' + movie_size + '.html"></script>');
	});
	
	//すべての歌詞を表示
	$("#all_spell #sp_button a").click(function(){
		if(  $("#all_spell #sp_spell").css("display") == "none"){
			$("#all_spell #sp_spell").css("display","block");
		}
		else{
			$("#all_spell #sp_spell").css("display","none");
		}
		return false;
	});
	
});

