/*2010.01.18 01*/
var d = document, _W = 'http://www.yomiuri.co.jp/';
Number.prototype.fRm = function() { return Math.floor(Math.random() *this); }; 
Array.prototype.write = function(w) { 
	var win = w || window;
	win.document.write(this.join(''));
};
var MFC = false, MCVer = 5;
var fPlug = navigator.mimeTypes&&navigator.mimeTypes['application/x-shockwave-flash']
	? navigator.mimeTypes['application/x-shockwave-flash'].enabledPlugin
	: 0;
var $ = gE = function(e) {
	return typeof e=='string' ? d.getElementById(e) : e;
};
var gEPos = function(id) {
	var e=gE(id), oL=0, oT=0;
	while (e) {
		oL +=e.offsetLeft; oT +=e.offsetTop;
		e=e.offsetParent;
	};
	return {left:oL, top:oT};
};
var gWinSize = function() {
	var de=document.documentElement;
	return {
		w:self.innerWidth || (de&de.clientWidth) || document.body.clientWidth, 
		h:self.innerHeight || (de&de.clientHeight) || document.body.clientHeight
	};
};
var Y1 = { 
	u : navigator.userAgent.toLowerCase(), 
	a : navigator.appName.toLowerCase()
};
Y1={
	ua:{
		os : Y1.u.match(/(win|mac|x11)/) [1] || 'other', 
		opera:Y1.u.match(/opera[\/\s](\d+\.\d+)/)?RegExp.$1:'',
		ie : Y1.u.match(/msie[\/\s](\d+\.\d+);/) ? RegExp.$1 : '', 
		safari : Y1.u.match(/safari/) ? true : false, 
		mozilla : Y1.u.match(/^mozilla[\/\s](\d+\.\d+)/) &&Y1.u.match(/gecko/) &&!Y1.u.match(/netscape/) ? RegExp.$1 : '', 
		netscape : Y1.u.match(/netscape\/(\d+\.\d+)/) 
			? RegExp.$1
			: Y1.a.match(/netscape/) 
				? Y1.u.match(/^mozilla[\/\s](\d+\.\d+)/) 
					? RegExp.$1 : ''
				: '', 
		firefox : Y1.u.match(/firefox\/(\d+\.\d+)/) ? RegExp.$1 : '', 
		macver : Y1.u.match(/mac/) 
			? Y1.u.match(/os\sx/) 
				? 'x' : 'older'
			: '', 
		oldernetscape : false, 
		recent : d.getElementById ? true : false, 
		readParticularCss : function() {}
	},
	rcss : function(f) {
		var a = [];
		a=a.concat('<link rel="stylesheet" type="text/css" href="', _W, 'styles/parts/common_v1_', f, '" />');

		a.write();
	},
	bind : function(bind, func){
		return function(){
			return func.apply(bind, arguments);
		};
	},
	addListener : function(elem, eType, func, cap){
		if (elem.addEventListener) {
			elem.addEventListener (eType, func, cap);
		} else if (elem.attachEvent) {
			elem.attachEvent ('on' + eType, func);
		} else {
			return false;
		}
	},
	gESize : function(id) {
		var e = typeof id=='string' ? $(id) : id, w=0, h=0;
		if (e.clientHeight) {
			w=e.clientWidth;
			h=e.clientHeight;
		} else {
			w=e.style.width;
			h=e.style.height;
		}
		return {w:w, h:h};
	},
	rc : function(n) { 
		var val = '', s = n + '=';
		if(d.cookie.length>0) {  
			o = d.cookie.indexOf(s);
			if(o != -1) {  
				o += s.length;
				e = d.cookie.indexOf(';', o);
				if(e ==- 1) { e = d.cookie.length; } 
				val = unescape(d.cookie.substring(o, e));
			}
		}
		return val;
	}, 
	wc : function(n, val, h) {
		d.cookie = 
			n + '=' + escape(val) + ';expires=' +(h !== null ? new Date((new Date()) .getTime() + h*3600000*24) : '') .toGMTString() + ';path=/;';
	},
	pdwn : function(btn,oL,oT){
		var ul=btn.parentNode.getElementsByTagName('ul')[0], pos=gEPos(btn), ws=gWinSize(), h=btn.clientHeight ? btn.clientHeight : btn.innerHeight, oL=oL||0, oT=oT||0;
		ul.onmouseover=function(){ tgl('on'); };
		ul.onmouseout=btn.onmouseout=function(){ tgl('off');};
		ul.style.left=((pos.left<(ws.w-200) ? pos.left : ws.w-200)+oL)+'px';
		ul.style.top=(pos.top+h+oT)+'px';
		tgl(ul.style.display!='none' ? 'off' : 'on');
		function tgl(s){ ul.style.display = s=='on' ? 'block' : 'none'; }
	},
	pWO : false, 
	po : function(pw, ph, el, et) { 
		var ox = 16, oy = 50 + Math.floor(((el*11) /pw) + 1) * 16;
		pw = pw < 200 ? 200 : pw;
		ph = ph < 50 ? 50 : ph;
		if(Y1.pWO && !pW.closed) { 
			pW.close();
			Y1.pWO = false;
		}
		pW = window.open('', 'photoWin', 'width=' +(pw + ox) + ', height = '+(ph + oy) +', status = no, resizable = no, scrollbars = no');
		pW.focus();
		Y1.pWO = true;
	},
	ys:function(cn) {
		var a = [];
		a=a.concat(
			'<img src="', _W, 'g2/search_bt_web', 
			cn != 'dy'
				? '.gif" alt="ウェブ" style="cursor:pointer"'
				: '_e.gif" alt="Web" style="width:38px;cursor:pointer"',
			' class="b2" onclick="Y1.yst(\'websearch\', \'http://www.yahoo-search.jp/\');return false;" />'
			);
		a.write();
	},
	ys2 : function(cn) { 
		var a = [];
		a=a.concat(
			'<form action="http://www.yahoo-search.jp/" name="websearch" id="websearch" style="margin:0;padding:0;" target="_top"><input type="hidden" value="web" name="rt" /><input type="hidden" value="t" name="ord" /><input type="hidden" value="sjis" name="cs" /><input type="hidden" value="300069" name="id" /><input type="hidden" name="kw" /></form><form action="http://dictionary.yomiuri.co.jp/search/index.aspx" name="dicsearch" id="dicsearch" style="margin:0;padding:0;" target="_top"><input type="hidden" name="queryword" /></form>'
			);
		a.write();
	},
	yst : function(fn, u, cn) { 
		k = d.forms.yolsearch.kw;
		if(cn == 'dy' && k.value.length && !k.value.match(/^[a-zA-Z0-9 ]/)) {
			alert('Please use English keywords for your dictionary search.');
			k.focus();
			k.select();
			return(0);
		}
		f = eval('d.forms.' + fn);
		if (f.kw) f.kw.value = k.value;
		if (f.queryword) f.queryword.value = k.value;
		f.submit();
	},
	ra : function() { 
	},
	hp : function(p) { 
		if(ua.os == 'win'&&ua.ie) { 
			d.write('<span id="oHomePage" style="behavior:url(#default#homepage) "></span>');
			if(!oHomePage.isHomePage('http://www.yomiuri.co.jp/')) {
				if (p=='y3') 
					d.write('<li><a href="javascript:void(1)" id="startpageBtn" onclick="style.behavior=\'url(#default#homepage) \';setHomePage(\'http://www.yomiuri.co.jp/\');"><span>YOLをスタートページへ</span></a></li>');			
				else if (p=='article') 
					d.write('<div style="font-size:70%;padding:5px 15px 5px 0;float:left;"><a href="javascript:void(1);" onclick="style.behavior=\'url(#default#homepage) \';setHomePage(\'http://www.yomiuri.co.jp/\');$(\'hpfromarticle\').innerHTML=\'<img src=http://www.yomiuri.co.jp/g/d_hpfromarticle.gif?0 width=1 height=1 border=0 />\'" class="bl"><img src="/g3/bt_mhp2.gif" width="145" height="13" border="0" alt="YOLをホームページに設定" /></a><span id="hpfromarticle"><img src="http://www.yomiuri.co.jp/g/d.gif" width="1" height="1" border="0" alt="" /></span></div>');
				else 
					d.write('<div style="font-size:70%;padding:7px 15px 10px 5px;float:right;"><a href="javascript:void(1);" onclick="style.behavior=\'url(#default#homepage) \';setHomePage(\'http://www.yomiuri.co.jp/\');$(\'hpfromhome\').innerHTML=\'<img src=http://www.yomiuri.co.jp/g/d_hpfromhome.gif?0 width=1 height=1 border=0 />\'" class="bl"><img src="/g3/bt_mhp1.gif" width="167" height="13" border="0" alt="このページをホームページに設定" /></a><span id="hpfromhome"><img src="http://www.yomiuri.co.jp/g/d.gif" width="1" height="1" border="0" alt="" /></span></div>');
			}
		}
	},
	sts : function(num, corner) { 
		if(num) {
			tPos += num;
			if(tPos > 7) { tPos = 7; return; } else if(tPos < 1) { tPos = 1; return; }
			Y1.wc('YtxtSize2', tPos, 30);
			var s = '' + _W + 'styles/parts/' + ('common' || corner) +  '_v1_txtsize' + tPos + '.css';
			if(d.styleSheets &&(!ua.netscape || ua.netscape == '7.1')) {
				if(ua.ie) {
					d.createStyleSheet(s);
				} else {
					var css=document.createElement('LINK');
					css.rel = "StyleSheet";
					css.type = "text/css";
					css.href = s;
 					var o=document.getElementsByTagName('HEAD').item(0);
 					o.appendChild(css);
				}
				d.getElementById('textsize').style.backgroundPosition = '0 -'+((tPos-1)*15)+'px';
			} else {
				location.reload();
			};
		}
	},
	rb : function() {
		var a = [];
		a=a.concat(
			'<div class="resizebt"><a href="javascript:void(0)" onclick="Y1.sts(+1) "><img src="', _W,
			'g/d.gif" width="63" height="15" alt="文字サイズを大きく" border="0" class="plus2"></a><img src="', _W,
			'g/d.gif" width="20" height="15" alt="" name="textsize" id="textsize" style="background:url(/g2/b_tsize.gif) no-repeat 0 -'+((tPos-1)*15)+'px"><a href="javascript:void(0)" onclick="Y1.sts(-1) "><img src="', _W,
			'g/d.gif" width="17" height="15" alt="文字サイズを小さく" border="0" class="minus"></a></div>'
		);
		a.write();
	},
	nw : function(wn, w, h, rs, sc) {
		if(!wn || !w || !h) return;
		rs = rs || 'no';
		isc = sc || 'yes';
		nwin = window.open('', wn + '', 'width=' + w + ', height=' + h + ', status=no, resizable=' + rs + ', scrollbars=' + sc);
		nwin.focus();
	},
	fIni : function() { 
		if(fPlug) { 
			var w = navigator.plugins['Shockwave Flash'].description.split(' ');
			for(var i = 0; i < w.length; ++i) {
				if(isNaN(parseInt(w[i]))) 
				continue;
				var MPVer = w[i];
			};
			MFC = MPVer >= MCVer;
		} else if(navigator.userAgent&&navigator.userAgent.indexOf('MSIE') >= 0 &&(navigator.appVersion.indexOf('Win') != -1)) {
			d.write('<scr'+'ipt language=VBScript>\non error resume next\nMFC=(IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash." & MCVer))) \n<\/scr'+'ipt\>\n');
		}
	},
	fDef : function(vr, id, su, sca, w, h, qu, sa, sc, bc, al, as, pl, gu, gca, gw, gh, alt, gan, gant, vars, win) {

		var p = '<param name=', uFla = 0, fVer = 0;
		if(navigator.mimeTypes&&navigator.mimeTypes['application/x-shockwave-flash']) {
			var plugin=navigator.mimeTypes['application/x-shockwave-flash'].enabledPlugin;
			if(plugin) fVer = parseInt(plugin.description.substring(plugin.description.indexOf('.') -2));
		} else if(ua.os == 'win'&&ua.ie) {
			try { 
				var a = new ActiveXObject('ShockwaveFlash.ShockwaveFlash');
				if (a) fVer = Math.floor(a.FlashVersion()/0x10000);
			} catch (e) {}
		};
		if(fVer >= vr) uFla = 1;
		if(uFla) {
			var a = [];
			a=a.concat(
				'<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="', w, '" height="', h, 
				'" id="', id, '" align="', al, '">', p, '"allowScriptAccess" value="', as, '" />', p, '"movie" value="', su, 
				sca == 'no'||sca=='random'
					? '?'+(10000000) .fRm()  : '',
				sca && sca != 'yes'
					? '?'+sca : '',
				'" />', p, '"quality" value="', qu, '" />', p, '"scale" value="', sc, '" />', p, '"salign" value="', sa, '" />', p, '"bgcolor" value="', bc, '" />',
				vars
					? p + '"FlashVars" value="' + vars + '" />' : '',
				'<embed src="', su, 
				sca == 'no'||sca == 'random'
					? '?'+(10000000) .fRm()  : '',
				sca && sca != 'yes' 
					? '?'+sca : '',
				'" ',
				vars 
					? 'FlashVars="' + vars + '" '
					: '',
				'quality="', qu, '" scale="', sc, '" salign="', sa, '" bgcolor="', bc, '" width="', w, 
				'" height="', h, '" name="', id, '" align="', al, '" allowScriptAccess="', as, 
				'" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>'
			);
			a.write(win);
		}else if(gu) {
			var a = [];
			a=a.concat(
				gan 
					? '<a href="' + gan + '">' : '',
				'<img src="', gu, 
				gca == 'no'||gca == 'random' 
					? '?'+(10000000) .fRm()  : '',
				gca&&gca != 'yes'
					? '?'+gca : '',
				'" width="', gw, '" height="', gh, '" border="0" name="', id, '" id="', id, '" usemap="#', id, '" alt="', alt, '"', 
				gant
					? ' target="'+gant+'"' : '',
				' />',
			 	gan
					? '</a>' : ''
			);
			a.write(win);
		};
		if(uFla == 0 && pl != 'none') {
			var a = [], anc = '<a href="http://www.macromedia.com/jp/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash&Lang=Japanese">';
			a=a.concat(
				'<table style="margin:5px auto;"><tr><td>', anc,
				'<img src="', _W, 'g2/bt_flashplayer.gif" alt="フラッシュプレイヤーのダウンロード" width="88" height="31" border="0" /></a></td><td style="text-align:left;font-size:84%;">',
				gu
					? 'このほかにフラッシュ版があります。'
					: 'これは、フラッシュコンテンツです。',
				'<br />', anc, '最新のFlash Player</a>が必要です。</td></tr></table>'
			);
			a.write();
		}
	},
	emp : function() {}, 
	init : function() { 
		Y1.fIni();
	}
};

AD1 ={ 
	adb : [], 
	aB : function(gr, w, h, dir, rot, mH, mV, alt) { 
		gr = gr || 0;
		w = w || 125;
		h = h || 60;
		dir = dir || 'h';
		rot = rot || 'yes';
		mH = mH || 0;
		mV = mV || 0;
		alt = alt || '広告';
		var a = [], n = adb[gr].length, spTdW = Math.floor(18/n), adTdW = Math.floor((100 - spTdW*2) /n);
		if(dir == 'h') a = a.concat('<table class="topbanner" cellspacing="0"><tr><td class="l" width="', spTdW, '%"><img src="', _W, 'g2/ad_banner_bg_l.gif" width="100%" height="', (h + 10), '" border="0" alt="" /></td>');
		for(var i = 0, rn = (1000) .fRm(), pn = new Array(n); i<n; i ++) {
			pn[i] = rot != 'no'
				? rn + i - Math.floor((rn + i) /n) *n : i;
			var swf_click = adb[gr][pn[i]][0] ? adb[gr][pn[i]][0] : '', iSrc = adb[gr][pn[i]][1] ? adb[gr][pn[i]][1] : '', sSrc = adb[gr][pn[i]][2] ? adb[gr][pn[i]][2] : '', dcswf_click = escape(swf_click);
			a=a.concat(
				dir == 'h' 
					? '<td class = "ad" width = "' + adTdW + '%">' : '',
				'<div style="margin:', mV, 'px ', mH, 'px">',
				MFC&&sSrc
					? '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+w+'" height="'+h+'" alt="'+alt+'"><param name="MOVIE" value="'+sSrc+'?clicktag='+dcswf_click+'"><param name="PLAY" value="true"><param name="LOOP" value="true"><param name="QUALITY" value="high"><embed name="flashad" src="'+sSrc+'?clicktag='+dcswf_click+'" width="'+w+'" height="'+h+'" play="true" loop="true" quality="high"></embed></object>'
					: '<a target="_top" href="'+swf_click+'"><img src="'+iSrc+'" width="'+w+'" height="'+h+'" border="0" alt="'+alt+'" /></a>',
				'</div>',
				dir == 'h' ? '</td>' : ''
			);
		};
		if(dir=='h') a = a.concat('<td class="r" width="', spTdW, '%"><img src="', _W, 'g2/ad_banner_bg_r.gif" width="100%" height="', (h + 10), '" border="0" alt="" /></td></tr></table>');
		a.write();
	},
	at : [], 
	at2 : [], 
	aT1 : function(gr, rot, tgt, c)  { 
		AD1.aT(1, gr, rot, tgt, c) 
	 }, 
	aT2 : function(gr, rot, tgt, c)  { 
		AD1.aT(2, gr, rot, tgt, c) 
	},
	aT : function(ty, gr, rot, tgt, c)  { 
		gr = gr || 0;
		rot = rot || 'yes';
		tgt = tgt ? ' target = \"' + tgt + '\"' : ' target=\"_top\"';
		var n = ty == 1 ? AD1.at[gr].length : AD1.at2[gr].length, a=[];
		a = a.concat(
			ty == 1 
			? (c ? '<ul class="' + c + '">' : '<ul>') 
			: (c ? '<div class = "' + c + '">' : '<div>')
		);
		for(var i=0,rn=(1000) .fRm(),pn=new Array(n);i<n;i++) {
			pn[i] = rot!='no' ? rn+i-Math.floor((rn+i) /n) *n : i;
			a = a.concat(
				ty==1
					? '<li class="'+(i%2 ? 'even' : 'odd')+'"><a href="'+AD1.at[gr][pn[i]][0]+'"'+tgt+'>'+AD1.at[gr][pn[i]][1]+'</a></li>'
					: '<div><a href="'+AD1.at2[gr][pn[i]][0]+'"'+tgt+'><span>広告</span>&nbsp;'+AD1.at2[gr][pn[i]][1]+'</a></div>'
			);
		};
		a=a.concat(ty==1?'</ul>':'</div>');
		a.write();
	},

	d2:function(u,sz,mx,aj,aj2) {
		u = u.indexOf('http://') <0 ? 'http://ad.jp.doubleclick.net/adj/'+u : u;
		sz = sz || '300x250';
		mx = mx || 1000000000000000000;
		aj = aj ||(u.indexOf('daiko') >=0 ? 'off' : 'on');
		var a = [];
		a = a.concat('<scr'+'ipt language="JavaScript1.1" src="'+u+';sz='+sz+';ord='+mx.fRm() +'?"\><\/scr'+'ipt\>',
			aj == 'on'&&ua.ie&&sz=='300x250'
				? '<style type="text/css">p.2par{position:relative;left:-2px}</style>' : '',
			aj2!='off'
				? '<style type="text/css">#rect-l{position:relative;left:-5px}</style>' : ''
		);
		a.write();
	}
};
var ua=Y1.ua,readcss=Y1.rcss,readCookie=Y1.rc,writeCookie=Y1.wc,photoWinOpen2=Y1.po,y_search=Y1.ys,y_search2=Y1.ys2,y_submit=Y1.yst,relatedarticle=Y1.ra,homepage=Y1.hp,setTextStyle=Y1.sts,resizebutton=Y1.rb,nw=Y1.nw,flashDef=Y1.fDef,addCss=printNotes=printNotes2=Y1.emp,adb=AD1.adb,adB=AD1.aB,adtxt=AD1.at,adtxt2=AD1.at2,adT=AD1.aT1,adT2=AD1.aT2,dart2=AD1.d2;
var genre=[],tImg=[],tPos=eval(Y1.rc('YtxtSize2')) ||3;
Y1.init();

var Y2enabled = (Number(Y1.ua.ie)>=6) || (Y1.ua.netscape>=7) || Y1.ua.safari || Y1.ua.firefox || (Y1.ua.opera>=7.5);

/*▼ピックアップ枠*/
Y1.pickup=function(num, bg, w, h){
	this.num = num;
	this.bgcolor = bg;
	this.tW = w;
	this.tH = h;
	this.items = [];
	this.selected = [];
	this.add = function(obj){
		var no=this.items.length;
		this.items[no] = obj;
		if (obj.pos>-1) this.selected[no] = obj.pos;
	};
	this.show = function(){
		d.write(this.getHtml());
	};
	this.getHtml = function(){
		var s='<div class="gfrs" style="background:'+this.bgcolor+'"><table class="inr"><tr>'
		for (var i=0; i< this.num; i++){
			var o = this.items[this.getNum(i)];
			var thumb = o.thumbs[o.thumbs.length.fRm()]
			s+='<td>';
			s+='<table class="gfr2" style="width:'+o.width+'px;">';
			s+='<tr>';
			s+='<td class="ph"><a href="'+o.url+'" style="background:#fff url(/g2/bg_grd_gray11.gif) repeat-x 0 0"><img src="'+thumb+'" alt="" class="photo-ph" border="0" height="'+this.tH+'" width="'+this.tW+'" /></a></td>';
			s+='<td class="tx"><a href="'+o.url+'" class="blk2" style="height:32px;background:#fff url(/g2/bg_grd_gray01.gif) repeat-x 0 17px;padding-top:3px; line-height:130%"><strong>'+o.headline+'</strong><br /><span class="f84" style="color:#666; font-size:95%">'+o.lead+'</span></a></td>';
			s+='</tr>';
			s+='</table>';
			s+='</td>';
		}
		s+='</tr></table></div>'
		return s;
	};
	this.getNum = function(no){
		if (this.selected[no]>-1) return this.selected[no];
		var n = this.items.length.fRm();
		if (!this.items[n].disp) return this.getNum(no);
		for (var i=0; i< this.selected.length; i++){
			if (this.selected[i]==n){
				return this.getNum(no);
				break;
			}
		}
		this.selected[no]=n;
		return n;
	}
}

/************************************************/
var AD2 = {
	impAserver:		'http://as.yl.impact-ad.jp',
	blankgif:			'AEYL',
	yoldomain:		'yomiuri.co.jp',
	impArnd:			Math.round(Math.random() * 100000000),
	impApid:			Math.floor(Math.random() * 100000000),
	impAcn:				'IMPASEG',
	impAco:				document.cookie,
	impAseg:			'',
	analyzeBTACookie:	function() {
		var impApos = this.impAco.indexOf(this.impAcn + '=');
		var impAseg = (impApos != -1) ? this.impAco.substring(impApos + this.impAcn.length + 1, (this.impAco.indexOf(';',impApos) != -1) ? this.impAco.indexOf(';', impApos) : this.impAco.length) : null;
		this.impAseg = (impAseg) ? unescape(impAseg) : '';
	},
	getTxtGifIcon:		function(_g) {
		if(_g == 'pr'){
			return '<img src="http://www.yomiuri.co.jp/g2/ad_ic.gif" width="27" height="14" border="0" alt="PR" class="ic" />';
		}else if(_g == 'prdy'){
			return '<img src="http://www.yomiuri.co.jp/g2/ad_ic2.gif" width="27" height="14" border="0" alt="AD" class="ic" />';
		}
	},
	rOrder:				function(_l) {
		var i = _l.length;
		while (--i) {
			var j = Math.floor(Math.random() * (i+1));
			if(i==j) continue;
			var k=_l[i]; _l[i]=_l[j]; _l[j]=k;
		}
		return _l;
	},
	createiPSSZ:	function(_a) {
		if(/TEXT/.test(_a.a) || /KOMACHI\.HATSUGEN[0-9]{2}/.test(_a.a)){
			return 'TEXT';
		}else{
			return _a.w + 'X' + _a.h;
		}
	}
};
try{
	if(((document.domain != ('www.'+AD2.yoldomain)) || (new RegExp("[^www\.]" + AD2.yoldomain).test(document.domain))) || (window.parent != window && !(new RegExp(document.domain).test(document.referrer)))){
		document.domain = AD2.yoldomain;
	}
	if(!parent.impApid_rndxxx) parent.impApid_rndxxx = AD2.impApid;
	AD2.impApid = parent.impApid_rndxxx;
}catch(e){
}
AD2.analyzeBTACookie();


AD2.init = function(_o) {
	// parameters
	this.iPSparam = {
		site:	_o.site,
		area:	_o.area,
		width:	_o.width || '',
		height:	_o.height || '',
		oencjp:	_o.oencjp || 'SJIS',
		order:	_o.order || '',
		random:	_o.random || false,
		admax:	_o.admax || 0,
		dispads: new Array(),
		banid:	_o.banid || ''
	};
	if(this.iPSparam.area.indexOf(',') > 0){
		this.iPSparam.area = (this.iPSparam.area).split(',');
		this.iPSparam.admax = (this.iPSparam.area).length;
	}
	
	// create targets
	var impAtarget = '';
	if(this.iPSparam.admax == 1){
		impAtarget = '/AAMB0';
		impAtarget += '/SITE=' + this.iPSparam.site;
		impAtarget += '/AREA=' + this.iPSparam.area;
		impAtarget += '/AAMSZ=' + AD2.createiPSSZ({a:this.iPSparam.area, w:this.iPSparam.width, h:this.iPSparam.height});
		impAtarget += '/OENCJP=' + this.iPSparam.oencjp;
	}else if(this.iPSparam.admax > 1){
		var impAtargets = new Array(this.iPSparam.admax);
		var buf;
		for(var i=0; i<this.iPSparam.admax; i++){
			impAtargets[i] = '/AAMB' + i;
			impAtargets[i] += '/SITE=' + this.iPSparam.site;
			buf = (typeof(this.iPSparam.area)=='string')? this.iPSparam.area : this.iPSparam.area[i];
			impAtargets[i] += '/AREA=' + buf;
			impAtargets[i] += '/AAMSZ=' + AD2.createiPSSZ({a:this.iPSparam.area, w:this.iPSparam.width, h:this.iPSparam.height});
			impAtargets[i] += '/OENCJP=' + this.iPSparam.oencjp;
		}
		impAtarget = impAtargets.join('');
	}
	
	// add BTA param
	impAtarget = (this.impAseg.match(/^[\w\/=]+$/)) ? '/' + this.impAseg + impAtarget : impAtarget;
	
	// get advertise
	document.write('<scr');
	document.write('ipt src="' + AD2.impAserver + '/bservers/AAMALL/acc_random=' + AD2.impArnd + '/pageid=' + AD2.impApid + impAtarget+'">');
	document.write('</scr');
	document.write('ipt>');
	// --
};



AD2.cAds = function() {
	// check returnd advertise
	var impAbs = new Array(this.iPSparam.admax);
	for(var i=0; i<this.iPSparam.admax; i++){
		eval('impAbs[' + i + '] = (typeof(AAMB' + i + ') != "undefined") ? AAMB' + i + ' : "";');
		impAbs[i] = (impAbs[i].indexOf(AD2.blankgif) == -1) ? impAbs[i] : '';
	}
	
	// delete trash ads
	var i=0;
	do{
		if(impAbs[i] == ''){
			impAbs.splice(i, 1)
		}else{
			i++;
		}
		
	}while(typeof(impAbs[i]) != 'undefined');
	
	// rotation order
	if(impAbs.length > 0 && this.iPSparam.random){
		impAbs = this.rOrder(impAbs);
	}
	
	if(impAbs.length > 0){
		var banid = this.iPSparam.banid;
		
		if(banid.length > 0){
			if (window.addEventListener) { //for W3C DOM
				window.addEventListener("load", function(){
								var display=(/table/i.test(document.getElementById(banid).tagName))?'table':'block';
								document.getElementById(banid).style.display = display;}, false
								);
			} else if (window.attachEvent) { //for IE
				window.attachEvent("onload", function(){
								document.getElementById(banid).style.display = 'block';}
								);
			}
		}
		
	}else{
		var banid = this.iPSparam.banid;
		
		if(banid.length > 0){
			if (window.addEventListener) { //for W3C DOM
				window.addEventListener("load", function(){
								document.getElementById(banid).style.display = 'none';}, false
								);
			} else if (window.attachEvent) { //for IE
				window.attachEvent("onload", function(){
								document.getElementById(banid).style.display = 'none';}
								);
			}
			
		}
	}
	this.iPSparam.dispads = impAbs;
	
};



AD2.dBanner = function(_n,_p) {
	_n = (_n) ? _n : 0;
	if(typeof(_p) != 'undefined' && _p == 'prect') document.write('<style type="text/css">#rect-l{position:relative;left:-5px}</style>');
	if((typeof(this.iPSparam.dispads[_n])) != 'undefined'){
		this.iPSparam.dispads[_n] = this.iPSparam.dispads[_n].replace("<!--", "<!--\n");
		document.write(this.iPSparam.dispads[_n]);
	}
};


AD2.dRBadge = function(_o) {
	_o.m = (_o.m) ? _o.m : 0;
	var str = new Array();
	
	for(var i=0; i<(this.iPSparam.dispads).length; i++){
		if(typeof(this.iPSparam.dispads[i]) != 'undefined'){
			this.iPSparam.dispads[i] = this.iPSparam.dispads[i].replace("<!--", "<!--\n");
			str.push('<div style="margin:' + _o.m + 'px;">' + this.iPSparam.dispads[i] + '</div>');
		}
	}
	document.write(str.join(''));
};


AD2.dText1 = function(_o) {
	_o.s = (_o.s) ? _o.s : '';
	_o.imga = (typeof(_o.imga) != 'undefined') ? _o.imga : true;
	var prgif = AD2.getTxtGifIcon(_o.s);
	var str = new Array();
	
	for(var i=0; i<(this.iPSparam.dispads).length; i++){
		if(typeof(prgif) != 'undefined'){
			if(_o.imga){
				this.iPSparam.dispads[i] = (this.iPSparam.dispads[i]).replace(/(<a [^>]*>)/, "$1" + prgif);
			}else{
				this.iPSparam.dispads[i] = (this.iPSparam.dispads[i]).replace(/(<a [^>]*>)/, prgif + "$1");
			}
		}
		str.push(this.iPSparam.dispads[i]);
		
		if(typeof(this.iPSparam.dispads[i+1]) != 'undefined')
			str.push('<div class="line-s1-b"><img src="/g/d.gif" width="1" height="1" alt="" /></div>');
	}
	document.write(str.join(''));
};


AD2.dTextDiv = function(_o) {
	_o.s = (_o.s) ? _o.s : '';
	_o.e = (_o.e) ? _o.e : false;
	_o.imga = (typeof(_o.imga) != 'undefined') ? _o.imga : true;
	var str = new Array();
	
	for(var i=0; i<(this.iPSparam.dispads).length; i++){
		if(_o.e){
			this.iPSparam.dispads[i] = (this.iPSparam.dispads[i]).replace(/(<a [^>]*>)/, "$1<span>広告</span>&nbsp;");
		}
		str.push('<div>' + this.iPSparam.dispads[i] + '</div>');
	}
	document.write(str.join(''));
};


AD2.dTextLi = function(_o) {
	_o.s = (_o.s) ? _o.s : '';
	_o.e = (_o.e) ? _o.e : false;
	_o.imga = (typeof(_o.imga) != 'undefined') ? _o.imga : true;
	_o.o = (_o.o) ? _o.o : false;
	_o.j = (_o.j) ? _o.j : false;
	var str = new Array();
	
	for(var i=0; i<(this.iPSparam.dispads).length; i++){
		var li = '<li>';
		if(_o.o){
			li = li.replace('>', ' class="' + (i%2 ? 'even' : 'odd') + '">');
		}
		if(_o.j){
			this.iPSparam.dispads[i] = (this.iPSparam.dispads[i]).replace(/(<a [^>]*)>/, "$1 class=\"h\">");
		}
		str.push(li + this.iPSparam.dispads[i] + '</li>');
	}
	document.write(str.join(''));
};


AD2.dPrWeekly = function(_o) {
	for(var i=0; i<(this.iPSparam.dispads).length; i++){
		document.write(this.iPSparam.dispads[i]);
	}
};