
/*
ššštsuikaššš
// GLOBAL
if(typeof aa=="undefined")var aa={};
if(typeof aa.v=="undefined")aa.v={};
if(typeof aa.f=="undefined")aa.f={};
if(typeof aa.f.form=="undefined")aa.f.form={};
if(typeof aa.l=="undefined")aa.l={};
ššštsuikaššš
*/

/*ššštsuikaššš*/
//aa.v.sr=(new Date()).getTime();
//aa.v.url=location.href;
//aa.v.canonicalUrl='http://'+location.host + location.pathname.toString().replace(/index.*/, 'index\.htm');
//aa.v.shortUrl;
//aa.v.ref=document.referrer;
//aa.v.loadcontents=new Array();
//aa.v.loadlist=new Array();
//aa.v.ad=new Array();
//aa.v.consoleLog="off";
//aa.v.dir=location.pathname.split("/");
//aa.v.dir[0]=location.host;
//aa.v.imp_cnt = new Array();
//aa.v.domain=location.host;
//aa.v.subdomain=(aa.v.domain.search(/allabout\.co\.jp/) != -1) ? aa.v.domain.match(/(.*?)\.?allabout\.co\.jp/)[1] : '';
//aa.v.ylp_flg=0;
//aa.v.ad_dir2 = 'M';
//aa.v.enqClickCount = 1;
/*ššštsuikaššš*/

//
// prototype extentions
//

/*
ššštsuikaššš
String.prototype.Trim=function(){
	return this.replace(/^\s+|\s+$/g,'');
}
String.prototype.splitTrim=function(t){
	return this.Trim().split(new RegExp('\\s*'+t+'\\s*'));
}
String.prototype.escapeHTML=function(){
	var i,e={'&':'&amp;','<':'&lt;','>':'&gt;','"':'&quot;'},t=this;
	for(i in e)t=t.replace(new RegExp(i,'g'),e[i]);
	return t;
}
String.prototype.unescapeHTML=function(){
	var i,e={'&lt;':'<','&gt;':'>','&amp;':'&','&quot;':'"'},t=this;
	for(i in e)t=t.replace(new RegExp(i,'g'),e[i]);
	return t;
}
String.prototype.isEmail=function(){
	var rx=new RegExp("\\w+([-+.\']\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*");
	var matches=rx.exec(this);
	return(matches != null && this == matches[0]);
}
String.prototype.isURL=function(){
	var rx=new RegExp("http(s)?://([\\w-]+\\.)+[\\w-]+(/[\\w-\\+ ./?%:&=#\\[\\]]*)?");
	var matches=rx.exec(this);
	return(matches != null && this == matches[0]);
}
String.prototype.contains=function(t){
	return this.indexOf(t) >= 0 ? true : false;
}
ššštsuikaššš
*/

$(document).ready(function(){

/*
ššštsuikaššš
	// ADD HOVER STATE
	$('ul.recent li.large, ul.archive li, ul.recent li.small div.top, ul.recent li.small div.bottom, div.autoStyle ul, #feature .galNavi li, div.brandWrap, body.brandHistory div.photo div').hover(function() {
		$(this).addClass('hover');
		$(this).find('p.more a').addClass('hover');
	},function(){
		$(this).removeClass('hover');
		$(this).find('p.more a').removeClass('hover');
	});
	$('div.search input.searchButton, form.enq img, form.enq input.enqButton').hover(function() {
		$(this).css('opacity', '0.7');
	},function(){
		$(this).css('opacity', '1');
	});
	$('.seriesCassette li:even').addClass('even');
	// ENQ
	$('form.enq :radio').click(function(){
		var fs = $(this).parents('fieldset');
		var findNotice = $(fs).find('.notice');
		var nextBtn = $(fs).find('img');
			if ( $(findNotice).is(':visible') ) {
				$(findNotice).css('display', 'none');
				$(nextBtn).css('display', 'block');
			}
	});
	$('form.enq img.enqNext').click(function() {
		var thisThis = $(this);
		var path = $(this).parents('fieldset');
		if ( $(path).hasClass('required') ) {
			var n = $(path).find('input:checked').length;
			if (n < 1) {
				$(path).find('.notice').css('display','block');
				$(thisThis).css('display', 'none');
ššštsuikaššš
*/
			/* IF n less than 1 */
/*
ššštsuikaššš
			} else { 
				$(path).fadeOut();
				$(path).next('fieldset').css('display','block')
				aa.v.enqClickCount++;
				$('#showCount .enqClickCount').text(aa.v.enqClickCount);
			}
ššštsuikaššš
*/
		/* IF required */ 
/*
ššštsuikaššš
		} else {
			$(path).fadeOut();
			$(path).next('fieldset').css('display','block')
			aa.v.enqClickCount++;
			$('#showCount .enqClickCount').text(aa.v.enqClickCount);
		}
	});


	$('form.enq img.enqBack').click(function() {
		var path = $(this).parents('fieldset');
		$(path).fadeOut();
		$(path).prev('fieldset').css('display','block');
	});
	aa.v.countFieldset = $('form.enq fieldset').length;
	$('#showCount .countFieldset').text(aa.v.countFieldset);
	$('#showCount .enqClickCount').text(aa.v.enqClickCount);
	// CATEGORY FIRST
	$('body.category div.middleCassette li:first').addClass('first');
	// SHUFFLE BY CLASS NAME
	// CAUTION: display: none; to .shufflebody
	// shufflecount
	$(".shufflebody").each(function(){
		var classitems = $(this).attr("class");
		var indexcount = classitems.indexOf("shufflecount");
		var viewitemcount = 0;
		if(indexcount>0){
			viewitemcount = parseInt(classitems.slice(indexcount+12));
		}
		var a=new Array();
		$(this).find(".shuffleitem").each(function(){
			a.push($(this).clone());
			$(this).remove();
		});
		if(a.length>1){
			a=aa.f.aryShuffle(a);
		}
		if( (viewitemcount == 0) || (viewitemcount > a.length) ){
			viewitemcount=a.length;
		}
		for(var i=0;i<viewitemcount;i++){
			$(this).append(a[i]);
		}
		$(this).css("display","block");
	});

	// SBM
	$('#articleFooter .detailInfo li a').click(function() {
		var url;
		var sbm  = $(this).parent('li').attr('class');
		var title = $('title').text();
		if (sbm == 'tweetbm') {
			aa.f.bitly_ajax();
			return false;
		} else if (sbm == 'hatenabm') {
			url = 'http://b.hatena.ne.jp/entry/'+aa.v.canonicalUrl;
		} else if (sbm == 'yahoobm') {
			url = 'http://bookmarks.yahoo.co.jp/action/bookmark?t='+encodeURIComponent(title)+'&u='+aa.v.canonicalUrl;
		} else if (sbm == 'newsingbm') {
			url = 'http://newsing.jp/add?url='+encodeURIComponent(aa.v.canonicalUrl);
		} else if (sbm == 'livedoorbm') {
			url = 'http://clip.livedoor.com/redirect?link='+aa.v.canonicalUrl+'&title='+encodeURIComponent(title)+'&ie=utf8';
		} else if (sbm == 'deliciousbm') {
			url = 'http://delicious.com/save?v=5&amp;noui&amp;jump=close&amp;url='+encodeURIComponent(aa.v.canonicalUrl)+'&amp;title='+encodeURIComponent(title);
		} else if (sbm == 'izabm') {
			url = 'http://www.iza.ne.jp/bookmark/add/regist/back/'+aa.v.canonicalUrl;
		}
		if (sbm != 'tweetbm') { $(this).attr('href',url); }
	});
	// Engagement
	$('#articleFooter .engagement li a').click(function() {
		var display = '#articleFooter .detailInfo .' + $(this).attr('href');
		var thisClass = $(this).attr('href');
	if (!$(this).parents('li').hasClass('current')) {
		$('#articleFooter .engagement li').removeClass('current');
		$('.detailInfo div').css('display','none');
		$(display).css('display','block');
		$(this).parents('li').addClass('current');
	}
	return false;
	});
	// RENSAI BKN
	var li_items = $('#rensai .backnumber ul li').length;
ššštsuikaššš
*/

/*
ššštsuikaššš
if (li_items > 7) {
		$('#rensai .backnumber ul li:eq(5)').nextUntil('#rensai .backnumber ul li:last').wrapAll('<li class="wr"><ul class="hide"></ul></li>').end();
		$('#rensai .backnumber ul[class!=hide]').append('<li class="append"><em><span class="replace">more</span></em></a></li>');
			$('#rensai .backnumber ul li.append').hover(function() {
				$(this).css('opacity', '0.7');
			},function(){
				$(this).css('opacity', '1');
			});
		$('#rensai .backnumber ul li.append').click(function() {
			$('#rensai .backnumber ul.hide').slideDown(600);
			$('#rensai .backnumber ul li.append').fadeOut(600);
			return false;
		});
	}
	// RIGHT COL LAST
	$('#right_box .regular li:last').addClass('last');


// RIGHT CAROUSEL
	$("#right_box .arrow").hover(

	function () {
		$(this).children('div').children('img').css( 'opacity','0.7' );
		$(this).css('background-color','#FFDBDB');
	}, 

	function () {
		$(this).children('div').children('img').css( 'opacity','1.0' );
		$(this).css('background-color','#F2F2F2');
	}
	);
ššštsuikaššš
*/

	if ($('#navi').length != 0) {
		$('#navi div.scrollable').scrollable({
			vertical:true,
			size: 7,								//©©©©©©©©©©©©©©©©©©©©©@li‚Ì”
			speed: 1000							//©©©©©©©©©©©©©©©©©©©©©@ƒXƒNƒ[ƒ‹ƒXƒs[ƒh
		}).circular().autoscroll({
			api: true,
			interval: 3000					//©©©©©©©©©©©©©©©©©©©©©@“®‚«‚ªŽ~‚Ü‚éŽžŠÔ
		});
	// RIGHT BIGGER LINK
		/*
		2010.10.13 saito==============================
		$('#navi .regular .items li').biggerlink();
		==============================================
		*/
		// BACK NUMBER PAGE BIGGER LINK
	}
/*
ššštsuikaššš
	else if ($('#rensai').length != 0) {
		$('#rensai .bn li').biggerlink();
	} else if ($('#tips').length != 0) {
		$('#tips #list li').biggerlink();
	}
// DOM READY END
ššštsuikaššš
*/
});

/*
ššštsuikaššš
// UNWRAP
(function($) {
	$.fn.unwrap = function(expr) {
		return this.each(function(){
			$(this).parents(expr).eq(0).after(this).remove();
		});
	}
})(jQuery);


// NEXT-UNTIL
//    $('h1').each(function(index) {
//      $(this).nextUntil('h1').wrapAll('<div class="fade"></div>').end()
//      .prependTo($(this).next());
//    });
(function($){
	$.fn.nextUntil = function(expr, rec){
		var helpFunction = function($obj, expr){
			var $siblings = $obj.nextAll();
			var end = $siblings.index( $siblings.filter(expr) );
			if(end===-1) return $('');
			return $siblings.slice(0, end);
		}
		var retObject = new Array();
		this.each(function(){
			$.merge(retObject, helpFunction($(this), expr));
		});
		return $(retObject);
	}
})(jQuery);
// BACKGROUND-POSITION
(function($) {
	$.extend($.fx.step,{
		backgroundPosition: function(fx) {
			if (fx.state === 0 && typeof fx.end == 'string') {
				var start = $.curCSS(fx.elem,'backgroundPosition');
				start = toArray(start);
				fx.start = [start[0],start[2]];
				var end = toArray(fx.end);
				fx.end = [end[0],end[2]];
				fx.unit = [end[1],end[3]];
			}
			var nowPosX = [];
			nowPosX[0] = ((fx.end[0] - fx.start[0]) * fx.pos) + fx.start[0] + fx.unit[0];
			nowPosX[1] = ((fx.end[1] - fx.start[1]) * fx.pos) + fx.start[1] + fx.unit[1];
			fx.elem.style.backgroundPosition = nowPosX[0]+' '+nowPosX[1];
			
			function toArray(strg){
				strg = strg.replace(/left|top/g,'0px');
				strg = strg.replace(/right|bottom/g,'100%');
				strg = strg.replace(/([0-9\.]+)(\s|\)|$)/g,"$1px$2");
				var res = strg.match(/(-?[0-9\.]+)(px|\%|em|pt)\s(-?[0-9\.]+)(px|\%|em|pt)/);
				return [parseFloat(res[1],10),res[2],parseFloat(res[3],10),res[4]];
			}
		}
	});
})(jQuery);


// VERTICAL ALIGN
(function ($) {
$.fn.vAlign = function() {
	return this.each(function(i){
	var ah = $(this).height();
	var ph = $(this).parent().height();
	var mh = (ph - ah) / 2;
	$(this).css('margin-top', mh);
	});
};
})(jQuery);


// PRELOAD IMAGE
// USAGE $.preloadImages("top1_2.jpg", "top1_1.jpg");
(function($){
	$.fn.preload = function() {
	for(var i = 0; i<arguments.length; i++) {
		jQuery("<img>").attr("src", arguments[i]);
	}
	}
})(jQuery);
jQuery.preloadImages = function() {
	for(var i = 0; i<arguments.length; i++) {
	jQuery("<img>").attr("src", arguments[i]);
	}
}
// Bit.ly AJAX CALL
aa.f.bitly_ajax = function() {
	var longurl = encodeURIComponent(aa.v.canonicalUrl);
	var login = "aatwitter";
	var apikey = "R_de0d17b657ad9ef83c93d3a7b4cd9259";
	var version = "2.0.1";
	var url;
	var title;
	if (aa.v.dir[1]=='s') {
		title = $('.breadCrumb .title').text();
	} else if (aa.v.dir[1]=='r') {
		title = $('.breadCrumb .title').text();
	} else if (aa.v.dir[1]=='tips') {
		title = $('.breadCrumb .pageTitle').text();
	}
	$.ajax({
		url: 'http://api.bit.ly/shorten?'+'version='+version+'&'+'longUrl='+longurl+'&'+'login='+login+'&'+'apiKey='+apikey+'&'+''
		,async: false
		,dataType: 'jsonp'
		,scriptCharset: 'utf-8'
		,timeout: 5000
		,success: function(data){
			aa.v.shortUrl = data.results[aa.v.canonicalUrl].shortUrl;
			url = 'http://twitter.com/home?status='+encodeURIComponent(title+' | '+aa.v.shortUrl+' [via @allabout_men]');
			window.open(url);
		}
	});
}
// BELOW FROM common.js
// SHUFFLE
aa.f.aryShuffle=function(ary){
	if(ary.length<2)return ary;
	var i=ary.length;
	while(--i){
		var j=Math.floor(Math.random()*(i+1));
		if(i==j)continue;
		var k=ary[i];
		ary[i]=ary[j];
		ary[j]=k;
	}
	return ary;
}

//
// by cookie.js
//
aa.v.orig_cookie = document.cookie;
aa.f.ReadAllCookie=function(str){
	var c=new Object();
	var aryCookie = str=="fresh" ? document.cookie.toString().split(";") : aa.v.orig_cookie.toString().split(";");
	for(var idx in aryCookie){
		var aryCookieItem = aryCookie[idx].split("=");
		if(!aryCookieItem[1])aryCookieItem[1]="";
		c[aryCookieItem[0].Trim()]=aryCookieItem[1].Trim();
	}
	return c;
}
aa.f.ReadOldCookie=function(str){
	return aa.f.ReadAllCookie()[str];
}
aa.f.ReadCookie=function(str) {
	return aa.f.ReadAllCookie("fresh")[str];
}
aa.f.SetCookie=function(name,value,expdays,domain,path,seccon){
	var str = "";
	if(name) str += name.Trim() + "=" + value.Trim();
	if(expdays){
		var d=new Date();
		d.setTime(d.getTime()+1000*60*60*24*expdays);
		str+="; expires="+d.toGMTString();
	}
	if(domain)str+="; domain=" + domain;
	if(path)str+="; path="   + path;
	if(seccon && location.protocol == "https:")str+="; secure";
	if(name)document.cookie = str;
}
aa.f.ClearAllCookie=function(domain,path){
	var cookies = aa.f.ReadAllCookie();
	for(var c in cookies){
		aa.f.CookieClear(c, domain, path);
	}
}
aa.f.CookieClear=function(name,domain,path){
	aa.f.SetCookie(name, "", -10000, domain, path);
}
// parseError
aa.f.isParseError = function isParseError(doc){
	return (doc.parseError!=null&&doc.parseError.errorCode!=0)||(doc.documentElement.tagName=='parsererror'&&doc.documentElement.namespaceURI=='http://www.mozilla.org/newlayout/xml/parsererror.xml')||(doc.documentElement == null);
}
ššštsuikaššš
*/


