// スタイルシート（ブラウザの判別）
var ua = navigator.userAgent;
var na = navigator.appName;
var ve = navigator.appVersion;

var Win = (ua.indexOf ("Win") != -1);
var Mac = (ua.indexOf ("Mac") != -1);
var Explorer = (na.indexOf ("Explorer") != -1);
var Netscape= (na.indexOf ("Netscape") != -1);
var Opera = (ua.indexOf ("Opera") != -1);
var Safari = (ua.indexOf ("Safari") != -1);

if (Explorer) {
    if (ua.indexOf ("MSIE 3") != -1) { var Version = "3"; }
    else if (ua.indexOf ("MSIE 4") != -1) { var Version = "4"; }
    else if (ua.indexOf ("MSIE 5") != -1) { var Version = "5"; }
    else if (ua.indexOf ("MSIE 6") != -1) { var Version = "6"; }
    else { var Version = "7"; }
} else {
    var Version = ve.charAt(0);
}

if (Safari) { type = "pixel"; }
else if (Mac && Opera && Version == "5") { type = "error"; }
else if (Opera) { type = "pixel"; }
else if (Win && Explorer && Version == "6") { type = "win_ie6"; }
else if (Win && Explorer && Version == "7") { type = "win_ie7"; }
else if (Win && Explorer && Version != "6") { type = "error"; }
else if (Win && Netscape && Version == "4") { type = "error"; }
else if (Mac && Explorer && Version != "5" && Version != "6") { type = "error"; }
else if (Mac && Explorer && Version == "5") { type = "pixel"; }
else if (Mac && Explorer && Version == "6") { type = "pixel"; }
else if (Mac && Netscape && Version == "5") { type = "mac_nn6"; }
else if (Mac && Netscape && Version == "4") { type = "error"; }
else { type = "pixel" }

path = "";
pn = window.location.pathname;
pn = pn.substr (1);
pn = pn.split ("/");
p = pn.length - 3; // ドメインから下の階層数+1
for (i=0; i<p; i++) {
    path += "../";
}

//document.write("<div>" + pn.length + pn + "</div>");
//document.write("<div>" + path + "</div>");
//document.write("<div>" + ua + "</div>");

// 未対応ブラウザ
if (type == "error") { location.href = path + type + ".html"; }
path += "css/";
// テキスト関連CSS
document.write ("<link rel=\"stylesheet\" href=\"" + path + type + ".css\" type=\"text/css\" media=\"screen,print\">");
// レイアウト関連CSS
if (Win) {
    document.write ("<link rel=\"stylesheet\" href=\"" + path + "layout.css\" type=\"text/css\" media=\"screen\">");
} else {
    document.write ("<link rel=\"stylesheet\" href=\"" + path + "layout.css\" type=\"text/css\" media=\"screen,print\">");
}
// プリント用CSS
if (Win) {
    document.write ("<link rel=\"stylesheet\" href=\"" + path + "win_print.css\" type=\"text/css\" media=\"print\">");
}

// 初期設定
function firstInit () {
    imgArray = firstInit.arguments;
    overImg = new Array ();
    
    for (i=0; i<(imgArray.length); i++) {
        overImg[i] = new Image().src = imgArray[i];
    }
}

// ロールオーバー処理
function changeImages (imgId, imgSrc) {
    if (document.getElementById) {
        document.getElementById(imgId).src = imgSrc;
    }
}

// トップページランダムフォト
function topPhoto () {
    // 設定（書きかえ箇所）
    var photoNum = 3; // フォト枚数
    photoAlt = new Array ('航海気象コンテンツサービス「VP」のご案内', '航空事業者支援サービス「SKY」のご案内', '携帯コンテンツサービス「MOBILE」のご案内'); // ALTテキスト
    photoLink = new Array ('services/sea/vp/', 'services/sky/sky/', 'services/living/mobile/'); // リンク先
    // 設定終わり
    photoNo  = Math.floor (Math.random() * photoNum) + 1;
    var photoNo2 = photoNo - 1;
    if (photoNo < 10) {
        photoNo = "0" + photoNo;
    }
    document.write ("<div id=\"topPhoto\"><a href=\"" + photoLink[photoNo2] + "\"><img src=\"img/top_photo_" + photoNo + "_left.jpg\" width=\"196\" height=\"365\" alt=\"" + photoAlt[photoNo2] + "\" /><img src=\"img/top_photo_" + photoNo + "_right.jpg\" width=\"556\" height=\"365\" alt=\"" + photoAlt[photoNo2] + "\" /></a></div>");
}

// ポップアップ
function popWin (path,addPath,w,h) {
    popwin = window.open(path + "js/pop.html?addPath=" + addPath + "","pop","width=" + w + ", height=" + h + ", toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no");
    wx = w;
    wy = h;
    x  = (screen.availWidth -  wx) / 2;
    y  = (screen.availHeight - wy) / 2;
    popwin.moveTo(x,y);
}

// ポップアップ画面描画
function popWrite () {
    var add = window.location.search.split ("=");
    document.write ("<a href=\"javascript:window.close ();\"><img src=\"" + add[1] + "\" alt=\"\" /></a>\n");
}

// レイヤー表示
function showLayer (layerId) {
    if (document.getElementById) {
        document.getElementById(layerId).style.visibility = "visible";
    }
}

// レイヤー非表示
function hideLayer (layerId) {
    if (document.getElementById) {
        document.getElementById(layerId).style.visibility = "hidden";
    }
}

// スクロール
function scroller(ps){
		scroller_up(ps,250);
}
	
function scroller_up(ps,y){
	y = y + (ps - y)*.1;
	window.scroll(0,y);
	if (((ps - y) <= .5)&&((ps - y) >= -.5))
	{					
		y = ps;
	}else{
		setTimeout("scroller_up("+ps+","+y+")",1);
	}
}

function scroller_e(ps){
	y = 1;
	kyoukai = ps*.5;
	while(y <= kyoukai)
	{
		window.scroll(0,y);
		y = y + (y*.05);
	// speed
    }
	while(y != ps)
	{
		window.scroll(0,y);
		y = y + (ps-y)*.05;
		// speed
		if (((ps - y) <= .5)&&((ps - y) >= -.5))
		{					
			y = ps;
		}		
	}
}

//ポップアップ（リンク元HTMLで窓サイズ等オプション＜others＞設定）
function openpop(page,name,w,h,others){
    var prm="";
    others=""+others;
    if (others.search(/t/i) != -1) {	//t:toolbar
        prm += ",toolbar=yes";
    }
    if (others.search(/l/i) != -1) {	//l:location
        prm += ",location=yes";
    }
    if (others.search(/s/i) != -1) {	//s:status
        prm += ",status=yes";
    }
    if (others.search(/m/i) != -1) {	//m:menubar
        prm += ",menubar=yes";
    }
    if (others.search(/b/i) != -1) {	//b:scrollbars
        prm += ",scrollbars=yes";
    }
    if (others.search(/r/i) != -1) {	//r:resizable
        prm += ",resizable=yes";
    }
    window.open(page,name,"directories=no,width="+w+",height="+h+prm);
}
function stword(word){
    window.status = word;
    return true;
}


//ポップアップ 採用ページ　地図用
function openwin()
{
	window.open("access_mk.html","map","width=500,height=550");
}
function openwin2()
{
	window.open("access_mtg.html","map","width=500,height=680");
}
