// プラットフォーム・ブラウザごとのフォントスタイル読込
var plat = (navigator.userAgent.indexOf("Win") >= 0) ;
if(plat) {
	document.write('<link rel="stylesheet" href="http://www.kyodonews.jp/common/css/font_win.css" type="text/css" media="all">');
}else{
	var plat = (navigator.userAgent.indexOf("Safari") >= 0) ;
	if(plat) {
		document.write('<link rel="stylesheet" href="http://www.kyodonews.jp/common/css/font_safari.css" type="text/css" media="all">');
		document.write('<style type="text/css">div#member div.block { font-size:10px; }</style>');		
	}else
	{
		document.write('<link rel="stylesheet" href="http://www.kyodonews.jp/common/css/font_mac.css" type="text/css" media="all">');
		document.write('<style type="text/css">div#member div.block { font-size:10px; }</style>');
		}
}

var plat = (navigator.userAgent.indexOf("Opera") >= 0) ;
if(plat) {
	document.write('<link rel="stylesheet" href="http://www.kyodonews.jp/common/css/font_opera.css" type="text/css" media="all">');
}else{}

// ポップアップ
function popupgallery(filename,winname) {
newWin=window.open(filename,winname,"width=640,height=640,menubar=1,scrollbars=1,toolbar=1,resizable=1,status=1");
}

function popupmovie(filename,winname) {
newWin=window.open(filename,winname,"width=640,height=540,menubar=1,scrollbars=1,toolbar=1,resizable=1,status=1");
}

function PrintPage(){
	if(document.getElementById || document.layers){
		window.print();	
	}
}

// フォントサイズ・ボタン変更
// サイズリスト
SizeList = new Array (108,124);
BGurl = new Array ('http://www.kyodonews.jp/common/images/common_btn_fsizem_on.gif','http://www.kyodonews.jp/common/images/common_btn_fsizel_on.gif');
Activesize = new Array ('span#default','span#large');

//デフォルトサイズのインデックス数
DefaultKey = 0;

//タグに挿入するID名
BodyID = "main";

if(GetCookie("KyodoappsFSS") == "none"){
	key = DefaultKey;
}else{
	key = Number(GetCookie("Kyodoapps"));
}
document.writeln('<style type="text/css">');
document.writeln('#'+BodyID+'{font-size: '+SizeList[key]+'%;}');
document.writeln('</style>');
document.writeln('<style type="text/css">');
document.writeln('div#header div#fsize '+Activesize[key]+'{background:url('+BGurl[key]+') top left no-repeat;}');
document.writeln('</style>');

function cgfont(value){
	if(value=="large"){
		key = 1;
	}else if(value=="default"){
		key = 0;
	}
	size = SizeList[key] + "%";
	image  = BGurl[key];
	bgid = value;
	if(document.all){
		document.all(BodyID).style.fontSize = size;
	}
	if(document.getElementById){
		document.getElementById(BodyID).style.fontSize = size;
	}
	WriteCookie("KyodoappsFSS",key);
	document.getElementById("large").style.backgroundImage = "url(http://www.kyodonews.jp/common/images/common_btn_fsizel.gif)";
	document.getElementById("default").style.backgroundImage = "url(http://www.kyodonews.jp/common/images/common_btn_fsizem.gif)";
	document.getElementById(bgid).style.backgroundImage = "url("+image+")";
}


function WriteCookie(name,value){
	tmp = name+"="+value+";";
	tmp += "expires=Fri, 31-Dec-2030 23:59:59;";
	tmp += "path=/;";
	document.cookie = tmp;
}

function GetCookie(value){

	data = document.cookie+";";
	tmp = data.indexOf(value,0);
	if(tmp != -1){
		size = data.substring(tmp,data.length);
		start = size.indexOf("=",0);
		end = size.indexOf(";",start);
		return(unescape(size.substring(start+1,end)));
	}else{
		return "none";
	}
}

// 汎用ロールオーバー
function smartRollover() {  
    if(document.getElementsByTagName) {  
        var images = document.getElementsByTagName("img");  
        for(var i=0; i < images.length; i++) {  
            if(images[i].getAttribute("src").match("_off."))  
            {  
                images[i].onmouseover = function() {  
                    this.setAttribute("src", this.getAttribute("src").replace("_off.", "_on."));  
                }  
                images[i].onmouseout = function() {  
                    this.setAttribute("src", this.getAttribute("src").replace("_on.", "_off."));  
                }  
            }  
        }  
    }  
}  
if(window.addEventListener) {  
    window.addEventListener("load", smartRollover, false);  
}  
else if(window.attachEvent) {  
    window.attachEvent("onload", smartRollover);  
} 

// プリント
function PrintPage(){
	if(document.getElementById || document.layers){
		window.print();
	}
}

// このページの最初へ
function backToTop() {
	var x1 = x2 = x3 = 0;
	var y1 = y2 = y3 = 0;
	if (document.documentElement) {
		x1 = document.documentElement.scrollLeft || 0;
		y1 = document.documentElement.scrollTop || 0;
	}
	if (document.body) {
		x2 = document.body.scrollLeft || 0;
		y2 = document.body.scrollTop || 0;
	}
	x3 = window.scrollX || 0;
	y3 = window.scrollY || 0;
	var x = Math.max(x1, Math.max(x2, x3));
	var y = Math.max(y1, Math.max(y2, y3));
	window.scrollTo(Math.floor(x / 1.4), Math.floor(y / 1.4));
	if (x > 0 || y > 0) {
		window.setTimeout("backToTop()", 10);
	}
}

// 検索フォーム初期テキスト
function cText(obj){
if(obj.value==obj.defaultValue){
obj.value="";
}
}

// フォーム切り替え
function cngForm() {
	document.getElementById("area_pp").style.display = "none";
	document.getElementById("area_form").style.display = "block";
}