
(function($){

	$(document).ready(function(){

		// rollover.
		$('img.over, input.over').each(function(){
			// preload image.
			var img = new Image();
			img.src = this.src.replace(/^(.+)(\.[a-z]+)$/, '$1-over$2');
			$(this)
				// store the image sources.
				.data('image', {
					defaultSrc: this.src,
					hoverSrc: img.src
				})
				.hover(
					function(){
						this.src = $(this).data('image').hoverSrc;
					},
					function(){
						this.src = $(this).data('image').defaultSrc;
					}
				);
		});
		
		$('.fontsizeswitcher .li01').click(
			function(){
				setActiveStyleSheet('small'); return false;
			}
		);
		$('.fontsizeswitcher .li02').click(
			function(){
				setActiveStyleSheet('default'); return false;
			}
		);
		$('.fontsizeswitcher .li03').click(
			function(){
				setActiveStyleSheet('large'); return false;
			}
		);

		// status current.
		$('#area img.on').each(function(){
			this.src = this.src.replace(/^(.+)(\.[a-z]+)$/, '$1-over$2');
		});

		$('#gnavi .subnavi').hide();

		
		$('#gnavi > ul > li').hover(
			function(){
				$(this).children('.subnavi').stop().show();
			},
			function(){
				$(this).children('.subnavi').stop().hide();
			}
		);
		

		// open link as '_blank'.
		$('a[rel=external]').click(function(){					
			window.open(this.href, '_blank');
			return false;
		});

		$('#content a.popup').click(function(){					
			window.open(this,'_blank','toolbar=no,status=yes,location=no,directories=no,scrollbars=yes,width=600,height=650');
			return false;
		});

		$('#gnavi a.popup').click(function(){					
			window.open(this,'allergen','toolbar=no,status=yes,location=no,directories=no,scrollbars=yes,width=420,height=530');
			return false;
		});

		$('#content a.cm_popup').click(function(){					
			window.open(this,'allergen','toolbar=no,status=yes,location=no,directories=no,scrollbars=yes,width=965,height=650');
			return false;
		});

	});

	/*Use Object Detection to detect IE6*/ var m = document.uniqueID /*IE*/ && document.compatMode /*>=IE6*/ && !window.XMLHttpRequest /*<=IE6*/ && document.execCommand ; try{ if(!!m){ m("BackgroundImageCache", false, true) /* = IE6 only */ } }catch(oh){}; 

})(jQuery);
