//<![CDATA[
var headerTabNo		= 0;
var headerTabWord	= new Array();
	headerTabWord[0]='店名検索';
	headerTabWord[1]='キーワード検索';
	headerTabWord[2]='Google検索';

//*===============================================================
//○初期化
//*===============================================================
$( document ).ready(
	function() {
		//□タブ
		$('#container-event'          ).tabs({ fxFade: true, fxSpeed: 'fast' });
		$('#container-shimindengonban').tabs({ fxFade: true, fxSpeed: 'fast' });
		$('#container-shinchaku'      ).tabs({ fxFade: true, fxSpeed: 'fast' });
		//□フィッシュアイ
		$('#fisheye').Fisheye( {
				items       : 'a',
				itemsText   : 'span',
				container   : '.fisheyeContainter',
				maxWidth    : 23,
				itemWidth   : 60,
				proximity   : 64,
				halign      : 'center'
			} );
		//□拡大・縮小
		$( 'a.closeEl1' ).bind( 'click' , toggleContent1 );
		$( 'a.closeEl2' ).bind( 'click' , toggleContent2 );
		//□ソート
		$( 'div.groupWrapper' ).Sortable( {
				accept      : 'groupItem',
				helperclass : 'sortHelper',
				activeclass : 'sortableactive',
				hoverclass  : 'sortablehover',
				handle      : 'div.itemHeader',
				opacity		: 0.5,
				tolerance   : 'pointer',
				onHover     : function() {
						if ( $( '#tooltip.fancy' ) != null ) {
							$( '#tooltip.fancy' ).css( 'display' , 'none'   );
						}
					},
				onOut       : function() {
						if ( $( '#tooltip.fancy' ) != null ) {
							$( '#tooltip.fancy' ).css( 'display' , 'inline' );
						}
					},
				onChange    : function( ser ) {},
				onStart     : function() {
//						$.iAutoscroller.start( this , document.getElementsByTagName( 'body' ) );
					},
				onStop      : function() {
//						$.iAutoscroller.stop();
						
						var sortItem=[];
						var sort_new_01 = $( '#event'           ).offsetTop();
						var sort_new_02 = $( '#shimindengonban' ).offsetTop();
						var sort_new_03 = $( '#prInfo'          ).offsetTop();
						var sort_new_04 = $( '#shinchaku'       ).offsetTop();
						sortItem.push( 'sort_new_01' );
						sortItem.push(  sort_new_01  );
						sortItem.push( 'sort_new_02' );
						sortItem.push(  sort_new_02  );
						sortItem.push( 'sort_new_03' );
						sortItem.push(  sort_new_03  );
						sortItem.push( 'sort_new_04' );
						sortItem.push(  sort_new_04  );
						
						//□Cookie保存
						createCookie( 'sortItem1' , sortItem , 90 );
					}
			} );
		//□ツールチップ
		$( 'div.itemHeader' ).Tooltip( {
				track		: true,
				delay		: 0,
				showURL		: false,
				opacity		: 1,
				fixPNG		: true,
				extraClass	: 'fancy',
				top			: 0,
				left		: 5
			} );
		
		//□ソート
		$( 'div.groupWrapperOld' ).Sortable( {
				accept      : 'groupItem2',
				helperclass : 'sortHelper',
				activeclass : 'sortableactive',
				hoverclass  : 'sortablehover',
				handle      : 'div.itemHeader',
				opacity		: 0.5,
				tolerance   : 'pointer',
				onHover     : function() {},
				onOut       : function() {},
				onChange    : function( ser ) {},
				onStart     : function() {
						$.iAutoscroller.start( this , document.getElementsByTagName( 'body' ) );
					},
				onStop      : function() {
						$.iAutoscroller.stop();
						
						var sortItem=[];
						var sort_old_01 = $( '#ranking'         ).offsetTop();
						var sort_old_02 = $( '#eLibrary'        ).offsetTop();
						var sort_old_03 = $( '#osusumeInfo'     ).offsetTop();
						var sort_old_04 = $( '#osusumeContents' ).offsetTop();
						var sort_old_05 = $( '#book'            ).offsetTop();
						sortItem.push( 'sort_old_01' );
						sortItem.push(  sort_old_01  );
						sortItem.push( 'sort_old_02' );
						sortItem.push(  sort_old_02  );
						sortItem.push( 'sort_old_03' );
						sortItem.push(  sort_old_03  );
						sortItem.push( 'sort_old_04' );
						sortItem.push(  sort_old_04  );
						sortItem.push( 'sort_old_05' );
						sortItem.push(  sort_old_05  );
						
						//□Cookie保存
						createCookie( 'sortItem2' , sortItem , 90 );
					}
			} );
			
		//□キーワードイベント
		$( '#keyword' ).bind( 'click'      , function() {
				var defaultKeyword = headerTabWord[headerTabNo];
				
				if ( $( '#keyword'	).val() == defaultKeyword ) {
					$( '#keyword'	).val( '' );
				}
				$( '#keyword'	).css( 'color' , '#000000'		);
			} );
		$( '#keyword' ).bind( 'mouseout'   , function() {
				if ( $( '#keyword'	).val() == '' ) {
					var defaultKeyword = headerTabWord[headerTabNo];
					
					$( '#keyword'	).val( defaultKeyword			);
					$( '#keyword'	).css( 'color' , '#aaaaaa'		);
				}
			} );
		
		//□キーワードタブ
		$( '#searchStorename'	).bind( 'click'   , function() {
				$( '#searchStorename'	).addClass		( 'active' );
				$( '#searchKeyword'		).removeClass	( 'active' );
				$( '#searchGoogle'		).removeClass	( 'active' );
				headerTabNo = 0;
				$( '#mode'	).val( headerTabNo );
				if ( $( '#keyword'	).val() == headerTabWord[1] || $( '#keyword'	).val() == headerTabWord[2] ) {
					$( '#keyword'	).val( headerTabWord[0] );
				}
				$( '#formKeyword' ).gid().action = '/search.asp';
				$( '#formKeyword' ).gid().method = 'post';
			} );
		$( '#searchKeyword'		).bind( 'click'   , function() {
				$( '#searchStorename'	).removeClass	( 'active' );
				$( '#searchKeyword'		).addClass		( 'active' );
				$( '#searchGoogle'		).removeClass	( 'active' );
				headerTabNo = 1;
				$( '#mode'	).val( headerTabNo );
				if ( $( '#keyword'	).val() == headerTabWord[0] || $( '#keyword'	).val() == headerTabWord[2] ) {
					$( '#keyword'	).val( headerTabWord[1] );
				}
				$( '#formKeyword' ).gid().action = '/search.asp';
				$( '#formKeyword' ).gid().method = 'post';
			} );
		$( '#searchGoogle'		).bind( 'click'   , function() {
				$( '#searchStorename'	).removeClass	( 'active' );
				$( '#searchKeyword'		).removeClass	( 'active' );
				$( '#searchGoogle'		).addClass		( 'active' );
				headerTabNo = 2;
				$( '#mode'	).val( headerTabNo );
				if ( $( '#keyword'	).val() == headerTabWord[0] || $( '#keyword'	).val() == headerTabWord[1] ) {
					$( '#keyword'	).val( headerTabWord[2] );
				}
				$( '#formKeyword' ).gid().action = 'http://www.google.co.jp/search';
				$( '#formKeyword' ).gid().method = 'get';
			} );
			
		//□アイテムクリックイベント
		closeEI1( 'event'           );
		closeEI1( 'shimindengonban' );
		closeEI1( 'shinchaku'       );
		
		closeEI2( 'ranking'         );
		closeEI2( 'eLibrary'        );
		closeEI2( 'osusumeInfo'     );
		closeEI2( 'osusumeContents' );
		closeEI2( 'book'            );
	}
);


//*===============================================================
//○タブ.拡大縮小
//*===============================================================
function closeEI1( eid ) {
	if( readCookie( 'closeEI_' + eid ) == 'false' ) {
		$( '#itemContent_' + eid ).BlindUp( 100 );
		$( '#closeEI_' + eid ).html( '<img src="./images/open.gif" border="0" />' );
	}
}
function closeEI2( eid ) {
	if( readCookie( 'closeEI_' + eid ) == 'false' ) {
		$( '#itemContent_' + eid ).BlindUp( 100 );
		$( '#closeEI_' + eid ).html( '<img src="./images/open02.gif" border="0" />' );
	}
}


//*===============================================================
//○タブ.拡大縮小
//*===============================================================
var toggleContent1 = function( e ) {
	var targetContent = $( 'div.itemContent' , this.parentNode.parentNode );
	
	if ( targetContent.css( 'display' ) == 'none' ) {
		$( this ).html( '<img src="./images/close.gif" border="0" />' );
		createCookie( this.id , true  , 90 );
	} else {
		$( this ).html( '<img src="./images/open.gif" border="0" />' );
		createCookie( this.id , false , 90 );
	}
	targetContent.BlindToggleVertically( 500 , null , 'bounceout' );
	return false;
};
var toggleContent2 = function( e ) {
	var targetContent = $( 'div.itemContent' , this.parentNode.parentNode );
	
	if ( targetContent.css( 'display' ) == 'none' ) {
		$( this ).html( '<img src="./images/close02.gif" border="0" />' );
		createCookie( this.id , true  , 90 );
	} else {
		$( this ).html( '<img src="./images/open02.gif" border="0" />' );
		createCookie( this.id , false , 90 );
	}
	targetContent.BlindToggleVertically( 500 , null , 'bounceout' );
	return false;
};


//*===============================================================
//○別ウインドウを開く
//*===============================================================
function openwin( url ) {
	w = window.open( url , 'win' , 'width=800,status=no,scrollbars=yes,directories=no,menubar=no,resizable=yes,toolbar=no' );
}
//]]>
