// JavaScript Document

//-----------------------------------------------------------------------------------------

// zebra efect

//-----------------------------------------------------------------------------------------

$(document).ready(function(){
	$(".zebraList tr").addClass("zebra01");
	$(".zebraList tr:nth-child(even)").addClass("zebra02");
});

//-----------------------------------------------------------------------------------------

// input focus

//-----------------------------------------------------------------------------------------
$(document).ready(function() {  
    $('input.inputText[title]').each(function() {  
	if ($(this).attr('type') != 'password') {
	    if($(this).val() === '') {  
	            $(this).val($(this).attr('title'));   
	    }  
		$(this).focus(function() {
	    	if($(this).val() == $(this).attr('title')) {  
	        	$(this).val('').addClass('focused');
	        }
	    });  
	    $(this).blur(function() {  
	    	if($(this).val() === '') {  
	        	$(this).val($(this).attr('title')).removeClass('focused');
	        }
	    });
	}else{
		if($(this).val() === '') {
			dummy = $('#' + this.id + '-text');
	        $(this).hide();
		    dummy.show();
	        dummy.val(dummy.attr('title'));
		    this.dummy = dummy;
        }  
		var real = this;
		this.dummy.focus(function() {
            $(this).hide();
		    $(real).show();
		    $(real).focus();
	    });
	    $(this).blur(function() {  
			if($(this).val() === '') {  
			$(this).hide();
			this.dummy.show();
			this.dummy.val(this.dummy.attr('title')).removeClass('focused');
	    	}
	    });
	}
});
	//textarea
    $('textarea.inputText[title]').each(function() {  
        if($(this).val() === '') {  
            $(this).val($(this).attr('title'));   
        }  
          
        $(this).focus(function() {  
            if($(this).val() == $(this).attr('title')) {  
                $(this).val('').addClass('focused');      
            }  
        });  
        $(this).blur(function() {  
            if($(this).val() === '') {  
                $(this).val($(this).attr('title')).removeClass('focused');
            }
        });  
    });  
});

//-----------------------------------------------------------------------------------------

//イメージクラス変更

//-----------------------------------------------------------------------------------------
$(function () {
	$('#av_select_box img').hover(function () {
		$('#av_select_box img').removeClass("hover");
		$(this).animate({opacity: 1.0}, 250 );
		$(this).addClass("hover");
	},
	function() {
		$(this).stop().animate({opacity: 0.4}, 300 );	
		$('#av_select_box .active').stop().animate({opacity: 1.0}, 5 );	
	});

	$('#av_select_box img').click(function () {
		$('#av_select_box img').removeClass("active");
		$('#av_select_box img').removeClass("hover");
		$('#av_select_box img').animate({opacity: 0.4}, 0 );
		$(this).addClass("active");
		$(this).animate({opacity: 1.0}, 0 );
	});
});

//-----------------------------------------------------------------------------------------

//アバター変更

//-----------------------------------------------------------------------------------------
$(function () {
	$('#head input').click(function () {
		$('#head img').animate({opacity: 0.6}, 0);
		$(this).prev().animate({opacity: 1.0}, 0);
	});
	
	$('#clothes input').click(function () {
		$('#clothes img').animate({opacity: 0.6}, 0);
		$(this).prev().animate({opacity: 1.0}, 0);
	});
});

//IE label check
//$(function () {
//	var ua = $.browser;
//	if(ua.msie) {
//    	function inputFocus(inputId){
//			$('#' + inputId).focus().click();
//    	}
//	$('label').click(function(){
//    	var labelFor = $(this).attr('for');
//		inputFocus(labelFor);
//		//value値 確認
//		alert( $("input[@name='a']:checked").val() );		
//    });
//	}
//});


//-----------------------------------------------------------------------------------------

//Full Caption Sliding

//-----------------------------------------------------------------------------------------
$(document).ready(function(){
	//To switch directions up/down and left/right just place a "-" in front of the top/left attribute
	$('.boxgrid.captionfull').hover(function(){
		$(".cover", this).stop().animate({top:'0px'},{queue:false,duration:300});
	}, function() {
		$(".cover", this).stop().animate({top:'178px'},{queue:false,duration:200});
	});
});

//-----------------------------------------------------------------------------------------

//slideToggle

//-----------------------------------------------------------------------------------------
$(document).ready(function() {
	$(".slide dt").hover(function(){
		$(this).css("cursor","pointer");
		$(this).addClass("hover");
	},function(){
		$(this).css("cursor","default");
		$(this).removeClass("hover");
		});
	$(".slide dd").css("display","none");
	$(".slide dt").click(function(){
		$(this).next().slideToggle("fast");
		});
});

//-----------------------------------------------------------------------------------------

//タブ切り替え

//-----------------------------------------------------------------------------------------
// ボタン数
var id_max = "10";

// ボックスID
var bpref = "box";

// ボックス数
var hpref = "bottan";

// プログラム
function seltab(selected) {
	for (i = 0; i <= id_max; i++) {
		if (! document.getElementById(bpref + i)) continue;
		if (i == selected) {
			document.getElementById(bpref + i).style.display = "block";
			document.getElementById(bpref + i).style.position = "";
			document.getElementById(hpref + i).className = "open";
		} else {
			document.getElementById(bpref + i).style.display = "none";
			document.getElementById(bpref + i).style.position = "absolute";
			document.getElementById(hpref + i).className = "close";
		}
	}
}

//-----------------------------------------------------------------------------------------

//トップページ バーチャル英会話教室が選ばれる理由 ボックスの高さ調整

//-----------------------------------------------------------------------------------------
$(function () {
	$("body.top#index ul.sec04 li").autoHeight({column:2});

});
//-----------------------------------------------------------------------------------------

//初めての方への表示・非表示

//-----------------------------------------------------------------------------------------
$(function () {
	$("body#mypage div#main div.beginner-guide div.content").hide();

	$("body#mypage div#main div.beginner-guide p.link-show a").click(function () {
		$("body#mypage div#main div.beginner-guide div.content").show();
	});

	$("body#mypage div#main div.beginner-guide div.content p.link-hide a").click(function () {
		$("body#mypage div#main div.beginner-guide div.content").hide();
	});
});

