MJL.event.add(window, "load", function(event) {
	// MJL に関係するコードはこの中に記述
	//MJL.enable.flash("flash");
	//MJL.enable.window("window");
	MJL.enable.rollover("roll",{disable:"unroll"});
	MJL.enable.tab("tabs");
	//MJL.enable.styleSwitcher("styleSwitcher");
	//MJL.enable.heightEqualizer("equalize");
}, false);

// MJL と無関係なコードはこの先に記述
$(document).ready(function(){

	var _contents = $('#contents');
	var _contents_top = $('#contents.top');
	var _main_contents = $('#main-contents');

	//set height
	$(function(){
		var _seg_column2_01 = $('div.seg-column2-01 .cont', _contents);
		var _block_column2 = $('div.block-column2 .cont', _contents);
		var _block_column3 = $('div.block-column3 .cont', _contents);
		$('.hdg-dynamic02', _seg_column2_01).set_height({items_per_row:2, group_by_parent:'div.seg-column2-01'});
		$('div.block-fix', _seg_column2_01).set_height({items_per_row:2, group_by_parent:'div.seg-column2-01'});
		_seg_column2_01.set_height({items_per_row:2, group_by_parent:'div.seg-column2-01'});
		$('div.seg-column2-02 .cont', _contents).set_height({items_per_row:2, group_by_parent:'div.seg-column2-02'});
		_block_column2.set_height({items_per_row:2, group_by_parent:'div.block-column2'});
		$('.hdg-icon02', _block_column2).set_height({items_per_row:2, group_by_parent:'div.block-column2'});
		$('.hdg-icon03', _block_column2).set_height({items_per_row:2, group_by_parent:'div.block-column2'});
		_block_column3.set_height({items_per_row:3, group_by_parent:'div.block-column3'});
		$('.hdg-icon04', _block_column3).set_height({items_per_row:3, group_by_parent:'div.block-column3'});
		$('ul.col2-list01 li', _contents).set_height({items_per_row:2, group_by_parent:'ul.col2-list01'});
	});

	$(function(){
		$('div.uni-lineup-block', _contents).scrollable({horizontal:true, size:4}); 
		$('div.snap-lineup-block', _contents).scrollable({horizontal:true, size:5}); 
	});

	//eke css
	$(function(){
		/*@cc_on
		$('.hdg-dynamic01-text + .hdg-static02', _contents).css({'margin-top':'0px'});
		$('.hdg-dynamic02 + .hdg-dynamic03', _contents).css({'padding-top':'0px'});
		@*/
		$('table.table-type01 tbody tr:odd', _contents).addClass('odd');
		var _sub_cont_widget01 = $('#sub-contents div.widget-block01');
		$('ul.brief-list01', _sub_cont_widget01).each(function(){$('li:odd', this).addClass('odd');});
		$('ul.brief-list02', _sub_cont_widget01).each(function(){$('li:odd', this).addClass('odd');});
	});

	//top brief hover
	$(function(){
		$('#main-contents .brief-block01', _contents_top).hover(
			function(){$(this).addClass('hover-bg');},
			function(){$(this).removeClass('hover-bg');}
		);
	});

	//top layout fix
	$(function(){
		var _top_contents = $('#top-contents');
		var _tc_height = _top_contents.height();
		var _mv_height = $('div.main-visual', _top_contents).height();
		var _diff_height = _tc_height - (_mv_height + 12);
		var _diff_min_height = _diff_height + 10;
		$('#brief-colmun01', _contents_top).css({'margin-top':'-'+_diff_height+'px', 'min-height':''+_diff_min_height+'px'});
		$('#brief-colmun02', _contents_top).css({'margin-top':'-'+_diff_height+'px', 'min-height':''+_diff_min_height+'px'});
	});

	//search input click
	$(function(){
		var _search_input01 = $('#search-input01');
		_search_input01.each(function(){$(this).attr('value','キーワードを入力');});
		_search_input01.focus(function(){$('#search-input01[value="キーワードを入力"]').removeAttr("value");});
		_search_input01.blur(function(){$('#search-input01[value=""]').attr("value","キーワードを入力");});
	});

	//gnav current
	$(function(){
		//top
		var _pagePath = location.pathname;
		var _global_nav_list = $('#global-nav > ul > li');
		var _gnav_firstlink = $('#global-nav > ul > li:first-child a');
		_gnav_firstlink.each(function(){
			if(_pagePath == '/'){
				$('img', this).attr('src', $('img', this).attr('src').replace('.gif', '_o.gif'));
				$(this).parent().addClass('current unroll');
			}else if(_pagePath == '/top'){
				$('img', this).attr('src', $('img', this).attr('src').replace('.gif', '_o.gif'));
			}
		});
		//under
		_global_nav_list.each(function(){
			var _pagePath = location.pathname.replace(/\/(.*)/,'$1');
			var _pagePathRep = location.pathname.replace(/(.*)\/(.*)/,'$1').split("/")[1];
			var _hrefRep = $('a', this).attr('href').replace(/\/(.*)\//,'$1');
			if(_pagePath == _hrefRep){
				$('img', this).attr('src', $('img', this).attr('src').replace('.gif', '_o.gif'));
				$(this).addClass('current unroll');
			}else if(_pagePathRep == _hrefRep){
				$('img', this).attr('src', $('img', this).attr('src').replace('.gif', '_o.gif'));
				$(this).addClass('current unroll');
			}
		});

		//drop down
		var _not_current = _global_nav_list.not('li.current, li.unroll');
		$('>ul', _global_nav_list).each(function(){
			$('>li:last-child', this).css({'background-image':'none'});
			$('>li:first-child', this).css({'padding-top':'2px'});
		});
		$('#global-nav > ul > li.current').hover(
			function(){$(this).children('ul').css({'left':'0','right':'auto'});},
			function(){$(this).children('ul').css({'left':'-9999px'});}
		);
		_not_current.hover(
			function(){$(this).children('ul').css({'left':'0','right':'auto'}).parent('li').addClass('current');},
			function(){$(this).children('ul').css({'left':'-9999px'}).parent('li').removeClass('current');}
		);
	});

	//add wishlist
	$(function(){
		$('#btn-wish').click(function(){
			var _add_wishlist = $('#add-wishlist');
			_add_wishlist.fadeIn();
			$('#wishlist-close').click(function(){_add_wishlist.fadeOut();});
		});
	});

	//swith image
	$(function(){
		$('div.image-switch', _contents).each(function(){
			$('img', 'ul.switch-list01', this).click(function(){
				var _switch_object = $(this).parents('div.image-switch').find('p.switch-object img');
				var _switch_former = $(this).attr('src');
				var _switch_img = _switch_object.attr('src').replace(/(.*)/, ''+_switch_former+'');
				_switch_object.attr('src', _switch_img);
			});
		});
	});

	//site catalyst onclick
	$(function(){
		$('a[href="http://www.nttdocomo.co.jp/"]', _main_contents).attr("onclick","var s=s_gi('wwwwebuomocom');s.tl(this,'o',document.URL+'_docomo_1');");
		$('a[href="http://answer.nttdocomo.co.jp/4brand/index.html"]', _main_contents).attr("onclick","var s=s_gi('wwwwebuomocom');s.tl(this,'o',document.URL+'_docomo_2');");
		$('a[href="http://www.nttdocomo.co.jp/product/foma/smart/p09a/index.html"]', _main_contents).attr("onclick","var s=s_gi('wwwwebuomocom');s.tl(this,'o',document.URL+'_docomo_P-09A');");
		$('a[href="http://www.nttdocomo.co.jp/product/foma/smart/n09a/index.html"]', _main_contents).attr("onclick","var s=s_gi('wwwwebuomocom');s.tl(this,'o',document.URL+'_docomo_N-09A');");
		$('a[href="http://www.isetan.co.jp/icm2/jsp/store/shinjuku/mens/residence/index.jsp"]', _main_contents).attr("onclick","var s=s_gi('wwwwebuomocom');s.tl(this,'o',document.URL+'_isetan');");
		$('a[href^="http://www.diesel.co.jp/"]', _contents).attr("onclick","var s=s_gi('wwwwebuomocom');s.tl(this,'o',document.URL+'_diesel_top');");
	});

	//no right click
	//$("img").attr({	oncontextmenu:'return false'});

	//bg cache
	/*@cc_on try{document.execCommand('BackgroundImageCache', false, true);}catch(e){} @*/

});

//set height
(function(A){A.fn.set_height=function(P){var G={items_per_row:false,one_height:false,delay:1000,group_by_parent:false};if(P){jQuery.extend(G,P)}if(A("#js_etalon").length){var N=A("#js_etalon").get(0)}else{var N=A("body").append('<span style="position:absolute;left:-9999px;top:0;" id="js_etalon"> </span>').find("#js_etalon").get(0)}var E=function(S,R){for(var Q=0;Q<S.length;Q++){if(S[Q]==R){return }}S.push(R)};var B=this;var F=[];var L=[];var K=[];var J=function(){for(var S=0;S<F.length;S++){var R=0;var T=F[S][0].currentStyle?parseInt(F[S][0].currentStyle.paddingTop)+parseInt(F[S][0].currentStyle.paddingBottom):parseInt(document.defaultView.getComputedStyle(F[S][0],null).getPropertyValue("padding-top"))+parseInt(document.defaultView.getComputedStyle(F[S][0],null).getPropertyValue("padding-bottom"));for(var Q=0;Q<F[S].length;Q++){F[S][Q].style.height="auto";R=Math.max(F[S][Q].offsetHeight-T,R)}for(var Q=0;Q<F[S].length;Q++){F[S][Q].style.height=R+"px"}}};var M=function(){var Y=0;var W=0;var Q=null;var T=null;F[Y]=[];var Z=false;for(var U=0;U<B.length;U++){if(G.group_by_parent){Q=A(B[U]).parents(G.group_by_parent)[0];if(U>0&&Q!=T&&!Z){F[++Y]=[];W=0}T=Q}if(G.items_per_row){B[U].className+=" nb"+parseInt(W%G.items_per_row+1);if(!(W%G.items_per_row)&&W>0){F[++Y]=[];W=0;Z=true}}F[Y][W++]=B[U];Z=false}for(var U=0;U<F.length;U++){if(!F[U][0].offsetHeight){var X=F[U][0];while(X.style.display!="none"){X=X.parentNode}L.push(X)}for(var S=0;S<F[U].length;S++){var V=F[U][S].getElementsByTagName("img");for(var R=0;R<V.length;R++){E(K,V[R].src)}}}};if(B.length){M();var D=N.offsetHeight;var C=setInterval(function(){var S=N.offsetHeight;if(S!=D){D=S;J()}for(var R=0;R<L.length;R++){if(L[R].style.display!="none"){J();L=[];for(var Q=0;Q<F.length;Q++){if(!F[Q][0].offsetHeight){var T=F[Q][0];while(T.style.display!="none"){T=T.parentNode}L.push(T)}}}}},G.delay);J();if(K.length){var H=[];var O=0;for(var I=0;I<K.length;I++){H[I]=document.createElement("img");H[I].onload=function(){O++;if(O==K.length){J()}};H[I].src=K[I]}}}if(navigator.userAgent.match("MSIE 5.5")&&B.length){setTimeout(function(){main(B),0})}return this}})(jQuery);


//slide image
/**
 * jquery.scrollable 0.11. Making HTML elements scroll.
 * 
 * http://flowplayer.org/tools/scrollable.html
 *
 * Copyright (c) 2008 Tero Piirainen (tero@flowplayer.org)
 *
 * Released under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 * 
 * >> Basically you can do anything you want but leave this header as is <<
 *
 * Since  : 0.01 - 03/01/2008
 * Version: 0.11 - 05/29/2008
 */
(function($){
	$.fn.extend({
		scrollable: function(arg1, arg2, arg3){
			return this.each(function(){
				if(typeof arg1 == "string"){
					var el = $.data(this, "scrollable");
					el[arg1].apply(el, [arg2, arg3]);
				}else{
					new $.scrollable(this, arg1, arg2);
				}
			});
		}
	});
	// constructor
	$.scrollable = function(el, opts){
		// store this instance
		$.data(el, "scrollable", this);
		this.init(el, opts); 
	};
	// methods
	$.extend($.scrollable.prototype,{
		init: function(el, config){
			var self = this;
			var opts ={
				size: 5,
				horizontal:false,
				activeClass:'active',
				speed: 300,
				onSeek: null,
				// jquery selectors
				items: '.items',
				prev:'.prev',
				next:'.next',
				navi:'.navi',
				naviItem:'span'
			};
			this.opts = $.extend(opts, config);
			// root / itemRoot
			var root = this.root = $(el);
			var itemRoot = $(opts.items, root);
			if(!itemRoot.length) itemRoot = root;
			// wrap itemRoot.children() inside container
			itemRoot.css({position:'relative', overflow:'hidden', visibility:'visible'});
			itemRoot.children().wrapAll('<div class="__scrollable" style="position:absolute"/>');
			this.wrap = itemRoot.children(":first");
			this.wrap.css(opts.horizontal ? "width" : "height", "200000em");
			this.items = this.wrap.children();
			this.index = 0;
			if(this.index == 0){	$('div.scrollable .prev').addClass('disabled');}
			if(this.items.length <= this.opts.size){	$('div.scrollable .next').addClass('disabled');}
			// set height based on size
			if(opts.horizontal){
				itemRoot.width(opts.size * (this.items.eq(1).offset().left - this.items.eq(0).offset().left) -2);	
			}else{
				itemRoot.height(opts.size * (this.items.eq(1).offset().top - this.items.eq(0).offset().top) -2);
			}
			// mousewheel
			if($.isFunction($.fn.mousewheel)){
				root.bind("mousewheel.scrollable", function(event, delta){
					self.move(-delta, 50);
					return false;
				});
			}
			// keyboard
			$(window).bind("keypress.scrollable", function(evt){
				if($(evt.target).parents(".__scrollable").length){
					if(opts.horizontal && (evt.keyCode == 37 || evt.keyCode == 39)){
						self.move(evt.keyCode == 37 ? -1 : 1);
						return false;
					}
					if(!opts.horizontal && (evt.keyCode == 38 || evt.keyCode == 40)){
						self.move(evt.keyCode == 38 ? -1 : 1);
						return false;
					}
				}
				return true;
			});
			// item.click()
			this.items.each(function(index, arg){
				$(this).bind("click.scrollable", function(){
					self.click(index);
				});
			});
			this.activeIndex = 0;
			// prev
			$(opts.prev, root).click(function(){self.prev()});
			// next
			$(opts.next, root).click(function(){self.next()});
			// navi 			
			$(opts.navi, root).each(function(){
				var navi = $(this);
				var status = self.getStatus();
				// generate new entries
				if(navi.is(":empty")){
					for (var i = 0; i < status.pages; i++){
						var item = $("<" + opts.naviItem + "/>").attr("page", i).click(function(){
							var el = $(this);
							el.parent().children().removeClass(opts.activeClass);
							el.addClass(opts.activeClass);
							self.setPage(el.attr("page"));
						});
						if(i == 0) item.addClass(opts.activeClass);
						navi.append(item);
					}
				// assign onClick events to existing entries
				}else{
					navi.children().each(function(i){
						var item = $(this);
						item.attr("page", i);
						if(i == 0) item.addClass(opts.activeClass);
						
						item.click(function(){
							item.parent().children().removeClass(opts.activeClass);
							item.addClass(opts.activeClass);
							self.setPage(item.attr("page"));
						});
					});
				}
			});
		},
		click: function(index){
			var item = this.items.eq(index);
			var klass = this.opts.activeClass;
			if(!item.hasClass(klass) && (index >= 0 || index < this.items.size())){
				var prev = this.items.eq(this.activeIndex).removeClass(klass);
				item.addClass(klass);
				this.seekTo(index - Math.floor(this.opts.size / 2));
				this.activeIndex = index;
			}
		},
		getStatus: function(){
			var len =  this.items.size();
			var s ={
				length: len, 
				index: this.index,
				size: this.opts.size,
				pages: Math.floor(len / this.opts.size),
				page: Math.floor(this.index / this.opts.size)
			};
			return s;
		},

		// all other seeking functions depend on this generic seeking function
		seekTo: function(index, time){
			if(index < 0){index = 0;}
			if(index == 0){	$('div.scrollable .prev').addClass('disabled');}
			if(index > 0){$('div.scrollable .prev').removeClass('disabled');}
			index = Math.min(index, this.items.length - this.opts.size);
			if(index == this.items.length - this.opts.size){	$('div.scrollable .next').addClass('disabled');}
			if(index < this.items.length - this.opts.size){	$('div.scrollable .next').removeClass('disabled');}
			
			var item = this.items.eq(index);
			if(item.size() == 0) return false;
			this.index = index;
			
			if(this.opts.horizontal){
				var left = this.wrap.offset().left - item.offset().left;
				this.wrap.animate({left: left}, time || this.opts.speed);
			}else{
				var top = this.wrap.offset().top - item.offset().top;
				this.wrap.animate({top: top}, time || this.opts.speed);
			}
			// custom onSeek callback
			if($.isFunction(this.opts.onSeek)){this.opts.onSeek.call(this.getStatus());}
			// navi status update
			var navi = $(this.opts.navi, this.root);
			if(navi.length){
				var klass = this.opts.activeClass;
				var page = Math.round(index / this.opts.size);
				navi.children().removeClass(klass).eq(page).addClass(klass);
			}
			return true;
		},
		move: function(offset, time){this.seekTo(this.index + offset, time);},
		next: function(time){this.move(1, time);},
		prev: function(time){this.move(-1, time);},
		movePage: function(offset, time){this.move(this.opts.size * offset, time);},
		setPage: function(index, time){this.seekTo(this.opts.size * index, time);},
		prevPage: function(time){
			var page = Math.floor(this.index / this.opts.size);
			this.seekTo(this.opts.size * (page-1), time);
		},
		nextPage: function(time){
			var page = Math.floor(this.index / this.opts.size);
			this.seekTo(this.opts.size * (page+1), time);
		},
		begin: function(time){this.seekTo(0, time);},
		end: function(time){this.seekTo(this.items.size() - this.opts.size, time);}
	});
})(jQuery);


