/* 
 * var options = {
 * 	menuBx:"#grMenu li",
 * 	home:1,
 * 	aboutus:2,
 * 	services:3,
 * 	works:4,
 * 	labo:5,
 * 	contact:6,
 * 	setTime:500,
 * 	timer:100
 * 	easType:'easeOutCirc',
 * };
 * $(options.menuBx).menuScroll(options);
 * 
 * <ul id="grMenu">
 * 	<li id="vhome"><a href="./index.html">HOME</a></li>
 * 	<li id="aboutus"><a href="./aboutus.html">ABOUT US</a></li>
 * 	<li id="services"><a href="./services.html">SERVICES</a></li>
 * 	<li id="works"><a href="./works.html">WORKS</a></li>
 * 	<li id="labo"><a href="labo.html">LABO</a></li>
 * 	<li id="contact"><a href="contact.html">CONTACT</a></li>
 * </ul>
 * This progrum created by Yohichiroh Kohtani.
 */
 
jQuery.fn.menuScroll = function(info) {

	/*初期設定 autoOW.js で読み込み*/
	info = jQuery.extend({
		menuBx:"#grMenu li",
		home:1,
		aboutus:2,
		services:3,
		works:4,
		labo:5,
		contact:6,
		setTime:500,
		timer:100,
		easType:'easeOutCirc'
	}, info);
	var dsOvTimer = new Array();
	
	return this.each(function(){	

		$(this).hover(
			function() {
				var addLength = $(this).children().attr("clientHeight") /2;
				var target = $(this).attr("id");
				if(target.match(/^v/i)){return false;}
				ovcr(info[target]);
				mOver(target,addLength);
			},
			function() {
				var target = $(this).attr("id");
				if(target.match(/^v/i)){return false;}
				mOver(target,0);
			}
		);

		function mOver(i,add){
			var ell = "#"+i;
			dsOvTimer[i] = setTimeout(
				function(){ 
					$(ell).animate(
						{scrollTop: add}, 
						info.setTime,
						info.easType
					);
				}, info.timer
			);
		}	

		function ovcr(i){
			clearTimeout(dsOvTimer[i]);
		}
	});
};

