
// Delete Error Message
function HideError(){
	return true;
}
window.onerror = HideError;


//文字を可変する為にJS
// OS Browser Info
var mac = (navigator.userAgent.indexOf('Mac') != -1 || navigator.userAgent.indexOf('mac') != -1);
var win = (navigator.userAgent.indexOf('Win') != -1 || navigator.userAgent.indexOf('win') != -1);

var an = navigator.appName;
var ua = navigator.userAgent;
var netscape = (an=="Netscape");
var opr = (ua.indexOf("Opera")!=-1);
var gecko = (ua.indexOf("Gecko")!=-1);
var n6 = (ua.indexOf("Netscape6")!=-1);
var n7 = (ua.indexOf("Netscape7")!=-1);
var ie = (an=="Microsoft Internet Explorer");
var saf = (ua.indexOf("Safari")!=-1);



// Select StyleSheet

csstype = GetCookie('CSSTYPE');
if ( csstype == null )
{
	csstype = '2';
}

ostype = 'win';

if ( saf )
{
	ostype = 'saf';
}
else if ( mac )
{
	ostype = 'mac';
}
//ostype = 'win';
if ( mac )
{
	document.write('<link rel="stylesheet" href="/english/css/os/' + ostype + csstype + '.css" type="text/css">');
	document.write('<link rel="stylesheet" href="/english/css/cmn.css" type="text/css">');

	
	window.onload = S3IMG;
}
else
{
	if ( win && netscape )
	{
		document.write('<link rel="stylesheet" href="/english/css/os/' + ostype + csstype + '.css" type="text/css">');
		document.write('<link rel="stylesheet" href="/english/css/cmn.css" type="text/css">');

	}
	else
	{
		AddLink('style1', '/english/css/os/' + ostype + '1.css');
		AddLink('style2', '/english/css/os/' + ostype + '2.css');
		AddLink('style3', '/english/css/os/' + ostype + '3.css');
		AddLink('style4', '/english/css/cmn.css');


		if( gecko )
		{
			document.write('<META http-equiv="Default-Style" content="style' + csstype + '">');
			document.write('<META http-equiv="Default-Style" content="style4">');

		}
		else
		{
			SLIST = document.styleSheets;
			for ( i = 0; i < SLIST.length; i++)
			{
				SLIST[i].disabled = ((SLIST[i].title != 'style' + csstype) || !SLIST[i].title);
				//alert("SLIST:"+SLIST[i].disabled);
			}
			SLIST[3].disabled = false;

		}
	}

	window.onload = S3IMG;
}



// Netscape 4.x Reload Bug Patch
function reloadPage(init){
	if(init==true) with(navigator){
		if((appName=="Netscape")&&(parseInt(appVersion)==4)){
			document.pgW=innerWidth;
			document.pgH=innerHeight;
			window.onresize=reloadPage;
		}
	}else if(innerWidth!=document.pgW || innerHeight!=document.pgH) location.reload();
}

reloadPage(true);



// images PreLoad
function PreLoad() {
	var d = document;
	if(d.images){
		if(!d.My_IMG) d.My_IMG = new Array();
		var i , j = d.My_IMG.length , a = PreLoad.arguments;
		for(i=0; i<a.length; i++) if (a[i].indexOf("#")!=0){
			d.My_IMG[j] = new Image;
			d.My_IMG[j++].src = a[i];
		}
	}
}





// Get Object
function GetObj(n, d) {
	var p,i,x;
	if(!d) d = document;
	if((p=n.indexOf("?"))>0&&parent.frames.length) {
		d = parent.frames[n.substring(p+1)].document;
		n = n.substring(0,p);
	}
	if(!(x=d[n])&&d.all) x = d.all[n];
	for(i=0; !x&&i<d.forms.length; i++) x = d.forms[i][n];
	for(i=0; !x&&d.layers&&i<d.layers.length; i++) x = GetObj(n,d.layers[i].document);
	if(!x && document.getElementById) x = document.getElementById(n);
	return x;
}



// Swap image
function ChgIMG() {
	var i , j = 0 , x , a = ChgIMG.arguments;
	document.My_sr = new Array;
	for(i=0; i<(a.length-2); i+=3) if ((x=GetObj(a[i]))!=null){
		document.My_sr[j++] = x;
		if(!x.oSrc) x.oSrc = x.src;
		x.src = a[i+2];
	}
}

// Reset image
function ResetIMG() {
	var i , x , a = document.My_sr;
	for(i=0; a&&i<a.length&&(x=a[i])&&x.oSrc; i++) x.src = x.oSrc;
}



// Sub Window Open
function WinOpen(URL,WN,F) {
	if(sbwin_closed(window.WN)){
		newwin = window.open(URL,WN,F);
		newwin.focus();
	}else{
		newwin.location.href = URL;
		newwin.focus();
	}
}

function sbwin_closed(winVar) {
	var ua = navigator.userAgent;
	if( !!winVar ){
		if( gck || ( ua.indexOf('MSIE 4')!=-1 && ua.indexOf('Win')!=-1 ) ) return winVar.closed;
		else return typeof winVar.document != 'object';
	}else return true;
}

// Pop Up Window
function PopUpWindow(URL,Wname,Wwidth,Wheight){
window.open(URL,Wname,"width="+Wwidth+",height="+Wheight+",scrollbars=yes,resizable=yes,toolbar=no,location=no,directories=no,status=yes,top=0,left=0")
}


// Get Cookie
function GetCookie(NAME)
{
	str = NAME + '=';
	val = null;
	c = document.cookie + ';';
	p = c.indexOf(str);
	if (p != -1)
	{
		p_st = p + str.length;
		p_ed = c.indexOf(';', p_st);
		val = unescape(c.substring(p_st, p_ed));
	}
	return val;
}


// Set Cookie
function SetCookie(NAME, VALUE, EXP, PATH, DOMAIN)
{
	c = NAME + '=' + escape(VALUE) + ';';
	if ( EXP > 0 )
	{
		dt = new Date();
		dt.setTime(dt.getTime()+(EXP * 1000));
		c = c + ' expires=' + dt.toGMTString() + ';';
	}
	if ( PATH != '' )
	{
		c = c + ' path=' + PATH + ';';
	}
	if ( DOMAIN != '' )
	{
		c = c + ' domain=' + DOMAIN + ';';
	}
	document.cookie = c;
}


// Set CSS
function SetStyleSheet(TYPE)
{
	csstype = TYPE;
	SetCookie('CSSTYPE', csstype, 30*24*60*60, '/', '');

	if ( mac )
	{
		window.location.reload();
	}
	else
	{
		if ( win && netscape )
		{
			window.location.reload();
		}
		else
		{
			if ( !document.styleSheets ) return;
			for ( i = 0; i < SLIST.length; i++)
			{
				SLIST[i].disabled = ((SLIST[i].title != 'style' + csstype) || !SLIST[i].title);
			}

			SLIST[3].disabled = false;

		}
	}
	S3IMG();
}



function ExChgIMG(NAME, IMG)
{
	if ( (x=GetObj(NAME)) != null )
	{
		x.src = IMG;
	}
}

function S3IMG()
{
	ExChgIMG('cmn_bt_003', '/english/cmn_img/' + ( csstype == '3' ? 'btn_txt_dai_on.gif' : 'btn_txt_dai.gif' ));
	ExChgIMG('cmn_bt_002', '/english/cmn_img/' + ( csstype == '2' ? 'btn_txt_chu_on.gif' : 'btn_txt_chu.gif' ));
	ExChgIMG('cmn_bt_001', '/english/cmn_img/' + ( csstype == '1' ? 'btn_txt_sho_on.gif' : 'btn_txt_sho.gif' ));
}

function AddLink(TITLE, URL)
{
	if ( document.all )
	{
		var nLink = document.createStyleSheet(URL);
		nLink.title = TITLE;
		nLink.disabled = true;
	}
	else if ( document.styleSheets )
	{
		var nLink = document.createElement('LINK');
		nLink.rel = 'alternate stylesheet';
		nLink.type = 'text/css';
		nLink.href = URL;
		nLink.title = TITLE;
		var oHEAD = document.getElementsByTagName('HEAD').item(0);
		oHEAD.appendChild(nLink);
	}
}
function SSINIT()
{
	if ( gecko )
	{
		SLIST = document.styleSheets;
		SetStyleSheet(csstype);
	}
	S3IMG();
}

str = location.search;
str = str.substring(1,str.length);
if (str == "print") {
	document.write('<link href="/english/css/preview.css" rel="stylesheet" type="text/css"><link href="/english/css/print.css" rel="stylesheet" type="text/css" media="print">');
}

function printPage() {
	p_win = window.open(document.URL + '?print','insatsu','width=616,height=700,scrollbars=yes,menubar=yes');
}

// E N D