/*

lastupdate:2011/02/01

*/
var add = {
	winkRollover:function(){
		$('a.wink img').mouseover(function(){
			$(this).css({
				opacity:0.2
			});
			$(this).fadeTo('slow',1);
		});
	},
	
	currentOpen:function(){
		$('#navi ul ul').hide();
		$('#navi .current').parents().show();
		$('#navi .current').parent().children().show();
	},
	
	defText:function(){
		var txtField = $("#headerR input");
		var defTxt = 'サイト内検索';
		var valTxt = txtField.val();
		var txtColor = '#44545E';
		
		if(!valTxt){
			txtField.val(defTxt).css("color",txtColor);
		}
		
		txtField.focus(function(){
			if(this.value == defTxt){
				$(this).val("").css("color","#333");
			}
		});
		
		txtField.blur(function(){
			if(this.value == ""){
				$(this).val(defTxt).css("color",txtColor);
			}else{
				$(this).css("color","#333");
			}
		});
	},
	
	opaRollover:function(){
		$('div#bannerArea a img').hover(function(){
			$(this).css('opacity', 0.7);
		},function(){
			$(this).css('opacity', 1);
		}
		);
	},
	
	tabClick:function(){
		$('#tab li a').click(function(){
			$('#tab li a').removeClass('active');
			$(this).addClass('active');
		});
	},
	
	mapHover:function(){
		var $tab = $('.routeTab a');
		var $routeNav = $('.routeNav');
		var defHref = $routeNav.next().find('img').attr('src');
		
		$tab.click(function(){
			defHref = $($(this).attr('href')+' .routeMap img').attr('src');
		});
		
		$routeNav.find('a').click(function(){
			return false;
		});
		
		$routeNav.find('a').hover(
			function(){
				$(this).closest('.routeNav').next().find('img').attr('src',$(this).attr('href'));
			},
			function(){
				$(this).closest('.routeNav').next().find('img').attr('src',defHref);
			}
		);
	},
	
	mapHoverTop:function(){
		
		defImgSet();
		
		$('#groupNavi h2').click(function(){
			
			
			$('#groupNavi .groupBox tr').bind('mouseover',function(){
				var $this = $('th a',this);
				var href = $this.attr('href');
				$this.closest('.groupBox').find('.mapCanvas img').attr('src',href);
				$(this).addClass('hover');
			});
			
			$('#groupNavi .groupBox tr').bind('mouseout',function(){
				$(this).removeClass('hover');
			});
			
			$('#groupNavi .groupBox tr').bind('click',function(){
				var href = $('.mapImg a',this).attr('href');
				location = href;
			});
			
						
			$('#groupNavi .groupBox th a').bind('click',function(e){
				e.preventDefault();
			});

			
		});
		
		$('#groupNavi .tabNav a').bind('click',function(){
			defImgSet();
		});
		
		function defImgSet(){
			$('#groupNavi .groupBox').each(function(){
				var $this = $(this);
				var $img = $this.find('.mapCanvas img');
				var href = $this.find('tr:eq(0) th a').attr('href');
				$img.attr('src',href);
			});
		}
		
	},
	
	removeAnchor:function(selector){
		$(selector).each(function(){
			var $self = $(this);
			var $a = $('a',$self);
			var text = $a.html();
			$a.remove();
			$self.prepend(text);
		});
	}
	

	
	
}

$(function(){
	//add.winkRollover();
	add.currentOpen();
	add.defText();
	add.opaRollover();
	add.tabClick();
	add.mapHover();
	$('#tab li:eq(0) a').click();
	add.removeAnchor('.remove');
	add.mapHoverTop();
	
	$('#groupNavi h2').toggle(
		function(){
			$('#groupNavi').css({float:'right'}).animate({width:'100%'},500);
			$('#groupNaviInner').delay( 500 ).slideDown(500,function(){
				$('#groupNavi').addClass('groupNaviON');
			});
			
		},
		function(){
			$('#groupNavi').removeClass('groupNaviON');
			$('#groupNaviInner').slideUp(500);
			$('#groupNavi').css({float:'right'}).delay( 500 ).animate({width:'300px'},500);

		}
	);
	
	$('input[name=len],input[name=wid],input[name=hei]').bind('blur mouseup keyup',function(){
		$('input[name=volume]').val(
			$('input[name=len]').val() * $('input[name=wid]').val() * $('input[name=hei]').val()	
		);
	});
	
});


window.onload = function(){
	//$('').flatHeights();
}



