$(document).ready(function() {
									
	$(".menu img[class!='h']").hover(function() {
		$(this).css('background-position', '0px -30px');
	}, function() {
		$(this).css('background-position', '0px 0px');
	});
	
	$(".rollover").hover(function() {
		$('img', this).attr('src', $('img', this).attr('src').replace(/\./g, "_h."));
	}, function() {
		$('img', this).attr('src', $('img', this).attr('src').replace(/\_h/g, ""));
	});
	
	$(".imgs a").click(function() {
		var tmp = $(this).find('img').attr('src').split('/'); tmp = tmp[tmp.length - 1];
		tb_show($(this).find('img').attr('alt'), $(this).attr('href') + '/' + tmp, false, 470, 445);
		return false;
	});
	
	$(".imgs img[class='frame']").hover(function() {
		$(this).prev().addClass('hover');
	}, function() {
		$(this).prev().removeClass('hover');
	});

	if(typeof(atumb) != 'undefined') {
	interval = setInterval("autoplay()", delay);
	$(".bnr2, .bnr3").css('opacity', 0);
	$(".tumbs div").hover(function() {
		sl = $(this).attr('class').replace('tumb', '');
		clearInterval(interval); autoplay();
	}, function() { interval = setInterval("autoplay()", delay); });
	}
});

var interval;
var delay = 4000;
function slide(num) {
	$(".mainimgs div[class!='bnr" + num + "']").css('z-index', 0);
	$(".mainimgs div.bnr" + num).css('z-index', 10);
	$(".mainimgs div.bnr" + num).animate({ opacity:1 }, 300, function() {
		$(".mainimgs div[class!='bnr" + num + "']").css('opacity', 0);
	});
	$(".tumbs a").removeClass('sel');
	$(".tumbs div.tumb" + num + " a").addClass('sel');
}

var sl = 1;
function autoplay() {
	if(sl > atumb) sl = 1;
	slide(sl);
	sl ++;
}

var allm;
var curm;
var heig;
var lang;
	
function initpics(allm2, curm2, heig2) {
	allm = allm2;
	curm = curm2;
	heig = heig2;
	$("#nxt").click(function() {
		if(curm < allm) {
			$(".images").animate({top: '-=' + heig + 'px'});
			curm ++;
		}
		return false;
	});
	$("#prv").click(function() {
		if(curm > 0) {
			$(".images").animate({top: '+=' + heig + 'px'});
			curm --;
		}
		return false;
	});
}

function validate(form, lang) {
	var ret = true;
	$("#" + form + " input[accesskey],select[accesskey]").each(function() {
		var val = $(this).val();
		switch($(this).attr('accesskey')) {
			case 'e' :
				if(!/^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/.test(val)) {
					ret = false;
					$(this).parent().addClass('err');
				}
			break;
			default :
				if(val == '') {
					ret = false;
					$(this).parent().addClass('err');
				}
			break;
		}
	});
	if(ret == false) {
		if(lang == 'en') alert('Please fill all (*) marked fields!');
		else alert('入力エラーがありました。必須項目を必ず入力してください。');
	}
	return ret;
}

function resets(form) {
	$(':input','#' + form).not(':button, :submit, :reset, :hidden').val('').removeAttr('checked').removeAttr('selected');
}
