﻿//スマートフォン NHK共通ライブラリ ver 1.3.4(2011/11/17)
var nol_com={
	 resourcePath:null
	,base:null
	,putCSS:function(){
		if(!this.puttedCSS){
			document.write('<link rel="stylesheet" type="text/css" href="'+this.resourcePath+'css/nol_common.css" />');
			this.puttedCSS=true;
		}
	}
	,puttedCSS:false
	,returnDesignTypes:function(c){
		var t={'blue':'A','white':'C'};
		var r=t[c];
		if(!r)r=t['blue'];
		return r;
	}
	,topc_callbackH:function(){alert('topc_callback is undefined!!');}
	,topc_callbackF:function(){alert('topc_callback is undefined!!');}
	,tosp_callback:function(){alert('tosp_callback is undefined!!');}
	,y:undefined
	,s:20
	,tohead:function(){
		var y = document.body.scrollTop || document.documentElement.scrollTop;
		this.toheadCore(y);
	}
	,toheadCore:function(y,s){
		if (s) this.s = s;
		this.y = parseInt(y-y*2/this.s);
		scrollTo(0, this.y);
		if (this.y > 0) setTimeout('nol_com.toheadCore(nol_com.y, nol_com.s)', 1);
	}
	,getCookie:function(key){
		var t=document.cookie.split(';');
		var u;
		for(var i=0;i<t.length;i++){
			u=t[i].split('=');
			if(this.trim(u[0])==key){
				if(u.length==2){
					return decodeURIComponent(this.trim(u[1]));
				}
				else if(u.length==1){
					return '';
				}
			}
		}
		return '';
	}
	,trim:function(s){
		return s.replace(/^\s+|\s+$/g, '');
	}
	,browser:(function(){
		var ua=navigator.userAgent,apn=navigator.appName,apv=navigator.appVersion,o={};
		o.isIE=(apn.search(/internet explorer/i)>-1?1:0);
		o.isOpera=(ua.search(/opera/i)>-1?1:0);
		if(o.isOpera)o.isIE=false;
		o.iPhone=(apv.search(/iphone/i)>-1);
		o.iPod=(apv.search(/ipod/i)>-1);
		o.iPad=(apv.search(/ipad/i)>-1);
		o.iOS=(o.iPhone||o.iPod||o.iPad);
		o.Android=(ua.search( /(Android )(\d+\.\d+)/i ) > -1);
		o.AndroidVer=(o.Android)?parseFloat(RegExp.$2):0;
		o.BlackBerry=(ua.search(/blackberry/i)>-1&&ua.search(/webkit/i)>-1&&ua.search(/mobile/i)>-1);
		o.isSafari=(apv.search(/safari/)>-1?1:0);
		o.iev=-1;
		if(o.isIE){
			var re=new RegExp('MSIE ([0-9]{1,}[\.0-9]{0,})');
			if(re.exec(ua)!=null)o.iev=parseFloat(RegExp.$1);
		}
		return o;
	})()
	,getFlashVersion:function(){
		var myver=[0,0,0],i,t=[],n=navigator;
		if(typeof n.plugins!='undefined' && typeof n.plugins['Shockwave Flash']=='object'){
			for(i=0;i<n.mimeTypes.length;i++){
				if(n.mimeTypes[i].type=='application/x-shockwave-flash'){
					t=n.mimeTypes[i].enabledPlugin.description.match(/\d+/gi);
				}
			}
			/*
			for(i=0;i<navigator.plugins.length;i++){
				if(navigator.plugins[i].description.search(/flash/gi)>-1){
					t=navigator.mimeTypes[i].enabledPlugin.description.match(/\d+/gi);
				}
			}
			*/
		}
		else if(typeof window.ActiveXObject!='undefined'){//IE
			for(i=7;i<30;i++){
				eval("try {var res=new ActiveXObject('ShockwaveFlash.ShockwaveFlash."+i+"')}catch(e){error=e};");
				if(res){
					t=res.GetVariable('$version').match(/\d+/gi);
				}
			}
		}
		for(i=0;i<3;i++){
			if(t[i]!=undefined)myver[i]=t[i];
		}
		return myver;
	}
	,chkLimitedVersion:function(lmver){
		var myver=nol_com.getFlashVersion();
		if(myver[0]>lmver[0]){
			return true;
		}
		else if(myver[0]==lmver[0]){
			if(myver[1]>lmver[1]){
				return true;
			}
			else if(myver[1]==lmver[1]){
				if(myver[2]>=lmver[2]){
					return true;
				}
			}
		}
		return false;
	}
	,chkFlashVideo:function() {
		var lmver=[10,1,0];//major,minor,rel
		if(nol_com.browser.Android&&nol_com.browser.AndroidVer<2.2)return false;
		return nol_com.chkLimitedVersion(lmver);
	}
	,runGlobal:function(){
		this.base=(location.protocol=='https:')?'https://www.nhk.or.jp':'http://www3.nhk.or.jp';
		this.resourcePath=this.base+'/common/sp/';
	}
};
nol_com.runGlobal();
function nol_getDeviceType(){
	//戻り値 配列 [0]:smart/tablet/other, [1]:type, [2]:flash, [3]:os
	var ua=navigator.userAgent;
	var r=new Array(4);
	if(ua.search(/iphone/i)>-1){
		r=['smart','iphone',false,'ios'];
	}
	else if(ua.search(/ipod/i)>-1){
		r=['smart','ipod',false,'ios'];
	}
	else if(ua.search(/ipad/i)>-1){
		r=['tablet','ipad',false,'ios'];
	}
	else if(ua.search(/android/i)>-1&&ua.search(/webkit/i)>-1){
		if(ua.search(/mobile/i)>-1){
			r=['smart','androidmobile',false,'android'];
		}
		else{
			r=['tablet','androidtablet',false,'android'];
		}
	}
	else if(ua.search(/blackberry/i)>-1&&ua.search(/webkit/i)>-1&&ua.search(/mobile/i)>-1){
		r=['smart','blackberry',false,'ohter'];
	}
	else if(ua.search(/windows phone/i)>-1&&ua.search(/msie/i)>-1){
		r=['other','windowsphone',false,'other'];
	}
	else if(ua.search(/^docomo/i)>-1){
		r=['mobile','imode',false,'other'];
	}
	else if(ua.search(/^kddi/i)>-1||ua.search(/^up\.browser/i)>-1){
		r=['mobile','ezweb',false,'other'];
	}
	else if(ua.search(/^softbank/i)>-1||ua.search(/^vodafone/i)>-1||ua.search(/^mot/i)>-1){
		r=['mobile','sb',false,'other'];
	}
	else{
		r=['other','other',false,'other'];
	}
	r[2]=nol_com.chkFlashVideo();
	return r;
}

function nol_visitedPcTop(){
	//戻り値 真偽値 true:StayPC, false:notStayPC
	var s=nol_com.getCookie('nol');
	if(s!=''){
		try{
			eval('var t='+s);
			if(t&&t.smp&&t.smp=='0'){
				return true;
			}
		}
		catch(e){
			return false;
		}
	}
	return false;
}

function nol_showSpCmnHeader(cf){
	nol_com.putCSS();
	var m={};
	m.dtype=nol_com.returnDesignTypes(cf.design);

	if(cf.callback)nol_com.topc_callbackH=cf.callback;

	if(cf.pgParam&&cf.pgParam!=''){
		m.pgParam='http://cgi4.nhk.or.jp/hensei/sp/program/c.cgi' + ((cf.pgParam.charAt(0)!='?')?'?':'')+cf.pgParam;
	}
	else{
		m.pgParam='http://cgi4.nhk.or.jp/hensei/sp/program/index.cgi';
	}

	var ht='';
	ht+='<div id="nol_header" class="nol_header_'+m.dtype.toUpperCase()+'">';
	ht+='<p class="nol_logo"><a href="http://www.nhk.or.jp/"><img src="'+nol_com.resourcePath+'img/logo_nhkonline_'+m.dtype.toLowerCase()+'.png" alt="NHK ONLINE" width="72" height="28" /></a></p>';
	ht+='<ul id="nol_menu">';
	if(cf.hidePgbtn!=true)ht+='<li><a href="'+m.pgParam+'">番組表</a></li>';
	if(cf.hideTopc!=true)ht+='<li><a href="#" onclick="nol_com.topc_callbackH();return false;">PC版</a></li>';
	ht+='</ul></div>';

	if(cf.returnHTML==true)return ht;
	else document.write(ht);
}
function nol_showSpCmnFooter(cf){
	nol_com.putCSS();
	var m={};
	m.dtype=nol_com.returnDesignTypes(cf.design);

	if(cf.callback)nol_com.topc_callbackF=cf.callback;

	var ht='';
	//nol_contentsFooter
	ht+='<div id="nol_contentsFooter" class="nol_contentsFooter_'+m.dtype.toUpperCase()+'">';
	if(cf.pgBlock==true){
		//nol_broadcastList
		ht+='<div id="nol_broadcastList">';
		ht+='<p class="nol_h">NHK番組一覧</p>';
		ht+='<ul id="nol_broadcastMenu">';
		ht+='<li><a href="http://www.nhk.or.jp/bs/sp/">BS</a></li>';
		ht+='<li><a href="http://www.nhk.or.jp/r1/smart/">R1</a></li>';
		ht+='<li><a href="http://www.nhk.or.jp/r2/">R2</a></li>';
		ht+='<li class="nol_last"><a href="http://www.nhk.or.jp/fm/">FM</a></li>';
		ht+='</ul>';
		ht+='<ul>';
		ht+='<li><a href="http://www3.nhk.or.jp/toppage/navi/sp/news.html">ニュース/報道</a></li>';
		ht+='<li><a href="http://www3.nhk.or.jp/toppage/navi/sp/sports.html">スポーツ</a></li>';
		ht+='<li><a href="http://www3.nhk.or.jp/toppage/navi/sp/info.html">情報/ワイドショー</a></li>';
		ht+='<li><a href="http://www3.nhk.or.jp/toppage/navi/sp/drama.html">ドラマ</a></li>';
		ht+='<li><a href="http://www3.nhk.or.jp/toppage/navi/sp/music.html">音楽</a></li>';
		ht+='<li><a href="http://www3.nhk.or.jp/toppage/navi/sp/variety.html">バラエティ</a></li>';
		ht+='<li><a href="http://www3.nhk.or.jp/toppage/navi/sp/movie.html">映画</a></li>';
		ht+='<li><a href="http://www3.nhk.or.jp/toppage/navi/sp/anime.html">アニメ/特撮</a></li>';
		ht+='<li class="small"><a href="http://www3.nhk.or.jp/toppage/navi/sp/documentary.html">ドキュメンタリー/教養</a></li>';
		ht+='<li><a href="http://www3.nhk.or.jp/toppage/navi/sp/theater.html">劇場/公演</a></li>';
		ht+='<li><a href="http://www3.nhk.or.jp/toppage/navi/sp/education.html">趣味/教育</a></li>';
		ht+='<li><a href="http://www3.nhk.or.jp/toppage/navi/sp/fukushi.html">福祉</a></li>';
		ht+='<li><a href="http://www3.nhk.or.jp/toppage/navi/sp/children.html">キッズ</a></li>';
		ht+='<li><a href="http://www3.nhk.or.jp/toppage/navi/sp/gogaku.html">語学</a></li>';
		ht+='<li><a href="http://www3.nhk.or.jp/toppage/navi/sp/zenkoku.html">全国のNHK</a></li>';
		ht+='</ul>';
		ht+='</div>';
	}
	ht+='<p class="nol_infotx">※ご利用の機種によっては、コンテンツが正常にご覧になれないものもあります。その場合はパソコンよりPC版ホームページをご覧ください</p>';
	ht+='<p class="nol_pageTop">▲<a href="#" onclick="nol_com.tohead();return false;">ページトップへ戻る</a></p>';
	ht+='<ul class="nol_pmMenu" id="nol_pcBtn2">';
	if(cf.hideTopc!=true)ht+='<li><a href="#" onclick="nol_com.topc_callbackF();return false;">PC版はこちら</a></li> ';
	ht+='<li><a href="http://www.nhk.or.jp/">NHKトップへ</a></li>';
	ht+='</ul>';
	if(cf.hideFooterLink!=true){
		ht+='<ul id="nol_footerLink">';
		ht+='<li><a href="http://www.nhk.or.jp/css/sp/">ご意見・お問い合わせ</a></li>';
		ht+='<li><a href="http://www.nhk.or.jp/privacy/sp/">NHKにおける個人情報保護について</a></li>';
		ht+='<li><a href="http://www3.nhk.or.jp/toppage/nhk_info/sp/copyright.html">放送番組と著作権</a></li>';
		ht+='<li><a href="http://www3.nhk.or.jp/toppage/sp/notice.html">NHKオンライン利用上のご注意</a></li>';
		ht+='</ul>';
	}
	ht+='</div>';
	//footer
	ht+='<div id="nol_footer" class="nol_footer_'+m.dtype.toUpperCase()+'">';
	ht+='<div class="nol_inner">';
	ht+='<p class="nol_copyright"><img src="'+nol_com.base+'/topmenu/1103_img/logo_footer.gif" alt="日本放送協会" />Copyright';
	ht+='NHK(Japan Broadcasting Corporation) All rights reserved. 許可なく転載することを禁じます。</p>';
	ht+='</div>';
	ht+='</div>';
	if(cf.returnHTML==true)return ht;
	else document.write(ht);
}
function nol_showSpLead(cf){
	if(cf.callback){nol_com.tosp_callback=cf.callback;}
	var ht='<p style="background:-moz-linear-gradient(top, #9d9d9d, #5e5c5c); background:-webkit-gradient(linear, left top, left bottom, from(#9d9d9d), to(#5e5c5c)); margin:0; padding:0; width: 100%; min-width:990px; border: none;">';
	ht+='<a onclick="nol_com.tosp_callback();return false;" href="#" style="padding: 30px 0; text-align: center; font-size: 46px; font-weight: bold; display: block; text-shadow: #333 3px 3px 5px; color: #FFF; margin: 0; text-decoration: none; border: none; width: 100%;">スマートフォン版はこちら</a></p>';
	if(cf.returnHTML==true)return ht;
	else if(cf.directDraw==true) document.write(ht);
	else{
		var dm=document.createElement('div');
		dm.innerHTML=ht;
		dm=dm.getElementsByTagName('p')[0];
		document.body.insertBefore(dm, document.body.firstChild);
	}
}

