/* ---------------------------------------------------------------------------------------------- */
/* コントロール                                                                                   */
/* ---------------------------------------------------------------------------------------------- */

jQuery ( document ) . ready

	(

	function ()

		{

		/* ---- */
		/* body */
		/* ---- */

		jQuery ( 'body' ) . addClass ( 'ajax' );

		/* -------- */
		/* div.body */
		/* -------- */

		jQuery ( 'body.index div.body' ) . append ( '<div class="advice"><h2>Advice</h2><p>メニューの上でマウスホイールをコロコロするとクルクルします。</p><ul><li><a href="#menu_up" title="上がる" name="menu_up" id="menu_up">上がる</a></li><li><a href="#menu_down" title="下がる" name="menu_down" id="menu_down">下がる</a></li></ul></div>' );

		/* -------- */
		/* div.menu */
		/* -------- */

		/* 表示アイテム数 */

		var item_visible = 3;

		/* アイテム一つあたりの高さ（単位：px） */

		var item_length_px = 24;

		/* アイテム一つあたりの高さ（単位：em） */

		var item_length_em = 1.5;

		var position = 0;
		var item_number = jQuery ( 'div.menu a' ) . size ();
		var max_length = item_number - item_visible;

		jQuery ( 'div.menu' ) . css

			(

				{

				height:	item_length_em * item_visible + 'em'

				}

			);

		/* ブラウザ分岐 | Internet Explorer */

		if ( navigator . appName === 'Microsoft Internet Explorer' )

			{

			jQuery ( 'div.menu' ) . css

				(

					{

					height:	item_length_px * item_visible + 'px'

					}

				);

			}

		/* Mouse Wheel Extension */

		jQuery ( 'div.menu' ) . mousewheel

			(

			function ( event , delta )

				{

				/* ブラウザ分岐 | Opera */

				if ( window . opera )

					{

					delta = -delta;

					}

				if ( delta > 0 )

					{

					if ( position > 0 )

						{

						/* ブラウザ分岐 | Internet Explorer */

						if ( navigator . appName === 'Microsoft Internet Explorer' )

							{

							jQuery ( 'div.menu ol' ) . animate

								(

									{

									top:	'+=' + item_length_px + 'px'

									}

								,

									{

									duration:	50

									}

								);

							}

						/* ブラウザ分岐 | モダンブラウザ */

						else

							{

							jQuery ( 'div.menu ol' ) . animate

								(

									{

									top:	'+=' + item_length_em + 'em'

									}

								,

									{

									duration:	50

									}

								);

							}

						position --;

						}

					}

				else if ( delta < 0 )

					{

					if ( position < max_length )

						{

						/* ブラウザ分岐 | Internet Explorer */

						if ( navigator . appName === 'Microsoft Internet Explorer' )

							{

							jQuery ( 'div.menu ol' ) . animate

								(

									{

									top:	'-=' + item_length_px + 'px'

									}

								,

									{

									duration:	50

									}

								);

							}

						/* ブラウザ分岐 | モダンブラウザ */

						else

							{

							jQuery ( 'div.menu ol' ) . animate

								(

									{

									top:	'-=' + item_length_em + 'em'

									}

								,

									{

									duration:	50

									}

								);

							}

						position ++;

						}

					}

				return false;

				}

			);

		/* ---------- */
		/* div.advice */
		/* ---------- */

		jQuery ( 'div.advice a#menu_up' ) . click

			(

			function ()

				{

				if ( position > 0 )

					{

					/* ブラウザ分岐 | Internet Explorer */

					if ( navigator . appName === 'Microsoft Internet Explorer' )

						{

						jQuery ( 'div.menu ol' ) . animate

							(

								{

								top:	'+=' + item_length_px + 'px'

								}

							,

								{

								duration:	50

								}

							);

						}

					/* ブラウザ分岐 | モダンブラウザ */

					else

						{

						jQuery ( 'div.menu ol' ) . animate

							(

								{

								top:	'+=' + item_length_em + 'em'

								}

							,

								{

								duration:	50

								}

							);

						}

					position --;

					}

				return false;

				}

			);

		jQuery ( 'div.advice a#menu_down' ) . click

			(

			function ()

				{

				if ( position < max_length )

					{

					/* ブラウザ分岐 | Internet Explorer */

					if ( navigator . appName === 'Microsoft Internet Explorer' )

						{

						jQuery ( 'div.menu ol' ) . animate

							(

								{

								top:	'-=' + item_length_px + 'px'

								}

							,

								{

								duration:	50

								}

							);

						}

					/* ブラウザ分岐 | モダンブラウザ */

					else

						{

						jQuery ( 'div.menu ol' ) . animate

							(

								{

								top:	'-=' + item_length_em + 'em'

								}

							,

								{

								duration:	50

								}

							);

						}

					position ++;

					}

				return false;

				}

			);

		/* ------------ */
		/* div.contents */
		/* ------------ */

		jQuery ( 'div.contents pre code:even' ) . addClass ( 'even' );

		}

	);
