jQuery(function(){
	jQuery('#g_menu').droppy();

	// イベント登録
	initEvent();
});

var menuIds = {
	 menuPickup:		{ id: "menuPickup",		target_id: "top_pickup" }
	,menuEvent:			{ id: "menuEvent",		target_id: "event_index" }
	,menuGurmet:		{ id: "menuGurmet",		target_id: "gourmet_index" }
	,menuLadies:		{ id: "menuLadies",		target_id: "ladies_index" }
	,menuCosmetic:		{ id: "menuCosmetic",	target_id: "cosmetic_index" }
	,menuMensSports:	{ id: "menuMensSports",	target_id: "mens_sports_index" }
	,menuBabyKids:		{ id: "menuBabyKids",	target_id: "baby_kids_index" }
	,menuLiving:		{ id: "menuLiving",		target_id: "living_index" }
	,menuCampaign:		{ id: "menuCampaign",	target_id: "campaign_index" }
};
var timer;
var timeFooterMove = 5000;

function initEvent() {
	for( var id in menuIds ) {
		jQuery( "#" + menuIds[id]["id"] ).click( changeIndex );
	}
	jQuery( "div#top_foot p.left" ).click( moveRightFooterLink );
	jQuery( "div#top_foot p.right" ).click( moveLeftFooterLink );

	timer = setInterval( moveLeftFooterLink, timeFooterMove );

}

function changeIndex() {
	var t_id = jQuery( this ).attr( "id" );

	jQuery( ".pickup_contents" ).hide();
	jQuery( ".index_contents" ).hide();
	jQuery( "#" + menuIds[t_id][ "target_id" ] ).show();
}

function moveRightFooterLink() {
	moveFooterLink( true );
}

function moveLeftFooterLink() {
	moveFooterLink( false );
}

function moveFooterLink( isRight ) {
	var move_left = -220;

	if( isRight ) {
		move_left = 0;
	}

	jQuery( "div#footer_link_block ul" ).stop().animate( 
		{ left: move_left + "px" },
		{ duration: "normal", easing: "swing", complete: completeMoveFooterLink( isRight ) }
	 );
}

function completeMoveFooterLink( isRight ) {

	jQuery( "div#footer_link_block ul" ).css( "left", "-110px" );
	lis = jQuery( "div#footer_link_block ul" ).children( "li" );

	if( isRight ) {
		jQuery( jQuery( lis[ 0 ] ) ).before( lis[ lis.length - 1 ] );
	} else {
		jQuery( jQuery( lis[ lis.length - 1 ] ) ).after( lis[ 0 ] );
	}


}


// mac判定してcssの追加処理を行う。
var ua = navigator.userAgent.toUpperCase();
var isMac = false;

if( ua.indexOf( "MAC" ) >= 0 ) {
	isMac = true;
}

if( isMac ) {
	document.write( '<link href="lib/css/style_mac.css" rel="stylesheet" type="text/css" />' );
}

function popupCatalogWindow( url ) {
	var opt = "width=1010, height=650, menubar=no, toolbar=no, scrollbars=no";

	window.open( url, "",  opt );
}

function popupCatalogWindow2( url ) {
	var opt = "width=1010, height=740, menubar=no, toolbar=no, scrollbars=no";

	window.open( url, "",  opt );
}


function popupDisplayGalleryWindow( url ) {
	var opt = "width=950, height=640, menubar=no, toolbar=no, scrollbars=no, resizable=yes";

	window.open( url, "",  opt );
}

