//【乗換駅・写真リンク】

// グローバル変数
var m_sPhotoAdd = new String;		// 写真のアドレス
var m_iUrlType;						// ページのベースURLタイプ
var m_sBaseUrl1 = new String;		// ページのベースURL1
var m_sBaseUrl2 = new String;		// ページのベースURL2
var m_sBaseUrl3 = new String;		// ページのベースURL3
var m_sCountry  = new String;		// 路線の所属国（日本／台湾）
var m_sCompany  = new String;		// 路線の所属会社
var m_sLineStr  = new String;		// 路線ファイル名
var m_iLineNum;						// 路線ファイル名の通し番号
var m_sStation  = new String;		// 駅名タグ
var m_iHalfWay;						// 出力途中フラグ
var m_TransUrlType;					// 乗り換え路線のURLタイプ
var m_sTransCountry = new String;	// 乗り換え路線の所属国


// 写真のベースフォルダ設定
function SetAddress(iUrlType, sDir)
{
	if (iUrlType == 1){
		m_sPhotoAdd = "";
	} else if (iUrlType == 2) {
		m_sPhotoAdd = "http://roomp.cocolog-nifty.com/photos/" + sDir + "/";
	}
}

// 路線の情報設定
function SetLine(iUrlType, sCountry, sCompany, sLineStr, iLineNum)
{
	m_sBaseUrl1 = "http://homepage3.nifty.com/cava/webtrip/";	// Cavaゾーン
	m_sBaseUrl2 = "http://homepage3.nifty.com/roomp2/webtrip/";	// Pゾーン
	m_sBaseUrl3 = "http://homepage3.nifty.com/roomp/webtrip/";	// P2ゾーン
	m_iUrlType = iUrlType;
	m_sCountry = sCountry;
	m_sCompany = sCompany;
	m_sLineStr = sLineStr;
	m_iLineNum = iLineNum;
}

// 駅名タグの設定
function SetStation(sStation)
{
	m_sStation = sStation;
}

// 乗り換えリンクヘッダ作成
function TransferHead(sType)
{
	document.open();
	if (sType == "関連路線"){
		document.write('<span class="rail">関連路線</span>');
	} else if (sType == "直通"){
		document.write('<li><span class="direct">直通</span>');
	} else if (sType == "ＪＲ"){
		document.write('<li><span class="rail">乗換(ＪＲ)</span>');
	} else if (sType == "国鉄"){
		document.write('<li><span class="rail">乗換(国鉄)</span>');
	} else if (sType == "私鉄"){
		document.write('<li><span class="rail">乗換(私鉄)</span>');
	} else if (sType == "高鉄"){
		document.write('<li><span class="rail">乗換(高鉄)</span>');
	} else if (sType == "台鉄"){
		document.write('<li><span class="rail">乗換(台鉄)</span>');
	} else if (sType == "MRT"){
		document.write('<li><span class="rail">乗換(MRT)</span>');
	} else if (sType == "阿里山"){
		document.write('<li><span class="rail">乗換(阿里山鉄道)</span>');
	} else if (sType == "バス"){
		document.write('<li><span class="bus">乗換(バス)</span>');
	} else if (sType == "航路"){
		document.write('<li><span class="air">乗換(航路)</span>');
	} else if (sType == "下車"){
		document.write('<li><span class="cy">下車</span>');
	} else if (sType == "宿"){
		document.write('<li><span class="hotel">宿</span>');
	}
	document.close();
	m_iHalfWay = 0;
}

// 乗り換えリンクフッタ作成
function TransferFoot()
{
	document.open();
	document.write('</li>');
	document.close();
}

// 乗り換えリンク作成
function TransferLink(sCompany, sLineStr, Num, sLineMoji)
{
	TransferLinkSub(sCompany);
	
	var HrefStr = new String;
	HrefStr = '<a href="';

	if (Num == 99){		// 工事中のページ
		sLineStr = m_sBaseUrl2 + "construct";
	} else if (m_TransUrlType == m_iUrlType){
		if (m_sCountry == m_sTransCountry){
			if (m_sCompany == sCompany){
				if (m_sLineStr == sLineStr){
					if (m_iLineNum == Num){	//全て同じなら何もしない
						return;
					} else {
					}
				} else {
					HrefStr = HrefStr + '../' + sLineStr+ '/';
				}
			} else {
				if (m_sLineStr != ''){
					if (sLineStr != '' && sCompany != 'link'){
						HrefStr = HrefStr + '../../' + sCompany + '/' + sLineStr + '/';
					} else {
						HrefStr = HrefStr + '../../' + sCompany + '/';
					}
				} else {
					if (sLineStr != '' && sCompany != 'link'){
						HrefStr = HrefStr + '../' + sCompany + '/' + sLineStr + '/';
					} else {
						HrefStr = HrefStr + '../' + sCompany + '/';
					}
				}
			}
		} else {
			if (m_sLineStr != ''){
				if (sLineStr != '' && sCompany != 'link'){
					HrefStr = HrefStr + '../../../' + m_sTransCountry + '/' + sCompany + '/' + sLineStr + '/';
				} else {
					HrefStr = HrefStr + '../../../' + m_sTransCountry + '/' + sCompany + '/';
				}
			} else {
				if (sLineStr != '' && sCompany != 'link'){
					HrefStr = HrefStr + '../../' + m_sTransCountry + '/' + sCompany + '/' + sLineStr + '/';
				} else {
					HrefStr = HrefStr + '../../' + m_sTransCountry + '/' + sCompany + '/';
				}
			}
		}
	} else {
		if (m_TransUrlType == 1){
			HrefStr = HrefStr + m_sBaseUrl1;
		} else if (m_TransUrlType == 2){
			HrefStr = HrefStr + m_sBaseUrl2;
		} else if (m_TransUrlType == 3){
			HrefStr = HrefStr + m_sBaseUrl3;
		}
		if (sLineStr != '' && sCompany != 'link'){
			HrefStr = HrefStr + m_sTransCountry + '/' + sCompany + '/' + sLineStr + '/';
		} else {
			HrefStr = HrefStr + m_sTransCountry + '/' + sCompany + '/';
		}
	}

	if (sLineStr != ''){
		HrefStr = HrefStr + sLineStr;
	} else {
		HrefStr = HrefStr + sCompany;
	}

	if (Num != 0 && Num != 99){
		HrefStr = HrefStr + Num;
	}
	HrefStr = HrefStr + '.html#' + m_sStation + '">' + sLineMoji + '</a>';
	if (m_iHalfWay == 1){
		HrefStr =  '・' + HrefStr;
	}

	document.open();
	document.write(HrefStr);
	document.close();
	m_iHalfWay = 1;
}

function TransferLinkSub(sCompany)
{
	// 既定値
	m_TransUrlType = 2;
	m_sTransCountry = 'japan';

	// 会社ごとにURLタイプと会社を設定
	if (sCompany == "jrhokkaido")
		{	m_TransUrlType = 1; m_sTransCountry = 'japan';	}
	else if (sCompany == "jrwest" || sCompany == "jrshikoku" || sCompany == "jrkyushu" ||
		sCompany == "toyamachiho" || sCompany == "kurobekyokoku" || sCompany == "hokuetsu" ||
		sCompany == "hankyu" ||
		sCompany == "hanshin" || sCompany == "nishikigawa" || sCompany == "osakashi" ||
		sCompany == "kobekosoku" || sCompany == "nankai" || sCompany == "katakami" ||
		sCompany == "iyo" || sCompany == "asakaigan" ||  sCompany == "keifuku" ||
		sCompany == "toyamalrt" || sCompany == "hokuriku" || sCompany == "manyosen" ||
		sCompany == "noto" ||
		sCompany == "hisatsuorange" || sCompany == "shimabara" || sCompany == "saganokanko")
		{	m_TransUrlType = 3; m_sTransCountry = 'japan';	}
	else if (sCompany == "tnr" || sCompany == "taipeimrt" || sCompany == "gaosyongmrt" ||
		sCompany == "alishan")
		{	m_TransUrlType = 2; m_sTransCountry = 'taiwan';	}
	else if (sCompany == "topics" || sCompany == "topics/airport"){
		if (m_sCountry == "japan" && m_iUrlType == 1){
				m_TransUrlType = 1;
		} else if (m_sCountry == "japan" && m_iUrlType != 1){
				m_TransUrlType = 3;
		} else if (m_sCountry == "taiwan") {
				m_TransUrlType = 2;
		}
		m_sTransCountry = m_sCountry;
	}
	else if (sCompany == "link"){
		if (m_sCountry == "japan"){
				m_TransUrlType = 1;
		} else if (m_sCountry == "taiwan") {
				m_TransUrlType = 2;
		}
	}
}

// 戻り先の設定
function ToBack(iType)
{
	document.open();
	document.write("<hr>");
	if (iType != 2){	// 2009/08/08 リンク集向けにトップに戻らないページ用の処理を追加
		document.write("[");
		document.write('<a href="http://homepage3.nifty.com/roomp/" target="_top">');
		document.write("ＲＯＯＭ「Ｐ」トップへ");
		document.write("</a>]");
	}
/* 2009/04/25 WebTripトップページを統合
	if (iType != 1){
		document.write("[");
		document.write("Web Tripトップへ".link("http://homepage3.nifty.com/roomp2/webtrip/top.html"));
		document.write("]");
	}
*/
	document.write("[");
	document.write('<A HREF="javascript:history.back()">戻る</A>]');
	document.close();
}

// メイン写真
function MainPhoto(sFilename, sCaption, sClass)
{
	if (sFilename == "")
		return;
	
	var Address = m_sPhotoAdd + sFilename;
	document.open();
	document.write('<a href="'); 	document.write(Address); 	document.write('">');
	document.write('<img alt="');	document.write(sCaption);
	document.write('" title="');	document.write(sCaption);
	document.write('" src="');		document.write(Address);
	document.write('" class="');	document.write(sClass);		document.write('"></a>');
	document.close();
}

// サブ写真
function SubPhoto(sFilename, sCaption)
{
	if (sFilename == "")
		return;
	
	var Address = m_sPhotoAdd + sFilename;
	var Class = "sta2";
	document.open();
	document.write('<a href="');	document.write(Address);	document.write('">');
	document.write('<img alt="');	document.write(sCaption);
	document.write('" title="');	document.write(sCaption);
	document.write('" src="');		document.write(Address);
	document.write('" class="');	document.write(Class);	document.write('"></a>');
	document.close();
}

// 見出し表示
function Headline(iType, sTitle, sKana, sClass)
{
	if (sTitle == "")
		return;

	var Tag1 = new String;
	var Tag2 = new String;
	
	if (iType == 2){
		Tag1 = "<h2>"; Tag2 = "</h2>";
	} else if (iType == 3 && (sClass == "food" || sClass == "japanese" || sClass == "shop" || sClass == "goods")){
		Tag1 = '<h3 ' + 'class="' + sClass + '">'; Tag2 = "</h3>"; Tag2 = "</h3>";
	} else if (iType == 3){
		Tag1 = '<h3>'; Tag2 = "</h3>";
	}

	document.open();
	document.write(Tag1);	document.write(sTitle);
	document.write('<b>');	document.write(sKana);	document.write('</b>');
	document.write(Tag2);
	document.close();
}

// リンク集メニューの作成
function Link_menu(iType, sFilename, sName, sTitle)
{
	var BaseUrl = new String;
	
	if (iType == 1){
		BaseUrl = 'http://homepage3.nifty.com/cava/webtrip/japan/link/';
	}
	
	document.open();
	document.write('<p><a href="');	document.write(BaseUrl);
	document.write(sFilename);	document.write('.html#');
	document.write(sName);	document.write('">');
	document.write(sTitle);	document.write('</a></p>');
	document.close();
}

// *** ここから旧バージョン ***

// 写真エリアの表示
function PhotoLink(iType, Dir, Filename, Caption, Class)
{
	var Address = new String;
	
	if (iType == 1){
		Address = Filename;
	} else if (iType == 2) {
		Address = "http://roomp.cocolog-nifty.com/photos/" + Dir + "/" + Filename;
	}

	document.open();
	document.write('<a href="');
	document.write(Address);
	document.write('">');
	document.write('<img alt="');
	document.write(Caption);
	document.write('" title="');
	document.write(Caption);
	document.write('" src="');
	document.write(Address);
	document.write('" class="');
	document.write(Class);
	document.write('"></a>');
	document.close();
}

// サブ画像の表示
function SubImg(iType, Dir, Filename, Caption)
{
	var Address = new String;
	var Class   = new String;
	
	if (iType == 1){
		Address = Filename;
	} else if (iType == 2) {
		Address = "http://roomp.cocolog-nifty.com/photos/" + Dir + "/" + Filename;
	}
	Class = "sta2";

	document.open();
	document.write('<a href="');
	document.write(Address);
	document.write('">');
	document.write('<img alt="');
	document.write(Caption);
	document.write('" title="');
	document.write(Caption);
	document.write('" src="');
	document.write(Address);
	document.write('" class="');
	document.write(Class);
	document.write('"></a>');
	document.close();
}
