var dbgFlg = true;		// trueでデバッグモード
var cntFlg = false;		// trueでカウント有り

var n = location.href.lastIndexOf("/");
if (n != -1)
{
	if (location.href.substring(0, n) == "http://www.system-duo.com")
	{
		dbgFlg = false;
		cntFlg = true;
	}
}

function fncGoIndex() {
  if (dbgFlg == false) {
    window.open("./indexduo.html", "_self");
  } else {
    window.open("./indexCheck.html", "_self");
  }
}

function fncOpen(PW) {
//  if (PW.length == 0) {
//    return;
//  } else {
    if (PW != "indexduo") {
      alert("正しいIDを入力してください。");
      return;
    }
    window.open(PW + ".html", "_self");
//    location.href = "./" + PW + ".html";
//    location.assign("./" + PW + ".html");
//    location.replace("./" + PW + ".html");
//    document.form1.submit();
//  }
}

function fncCheck1() {
//	return false;
}

//----------------------------------------------------------------------
// 曜日index取得（引数'yyyy/mm/dd'有りの時はその日付の曜日）
//----------------------------------------------------------------------
function fncGetWeekIndex(date) {
	buf  = new Date();
	if(arguments.length > 0) {
		if (date != null) {
			buf  = new Date(date);
		}
	}
	return buf.getDay();
}

//----------------------------------------------------------------------
// 曜日取得
//----------------------------------------------------------------------
function fncGetWeekName(ind) {
	if(arguments.length > 0) {
		buf=ind;
	} else {
		buf=8;
	}
	var weekNm = new Array('日','月','火','水','木','金','土', '−') ;
	return weekNm[buf] ;
}

//----------------------------------------------------------------------
// カウンタファイル名の生成
//----------------------------------------------------------------------
function fncMakeCntName(name) {
	strBuf = "cnterr";
	if (arguments.length > 0) {
		if (cntFlg == true) {
			if (dbgFlg == true) {
				strBuf = 'dbg_' + name;
			} else {
				strBuf = name;
			}
		}
	}
	return strBuf;
}


//----------------------------------------------------------------------
// リンク元から、使用するカウンタファイル名を決定する
//----------------------------------------------------------------------
function fncLinkCountChk()
{
	var ExecAddress = "link_other";
	var linkurl = new Array();
	var linkcnt = new Array();

	// リンク元の定義
	linkurl[0] = "http://kyujinkaigi.com";
	linkurl[1] = "http://sainavi.com";
	linkurl[2] = "http://www.databasebank.com/programmers";
	linkurl[3] = "http://www.shigoto.pref.saitama.jp";
	linkurl[4] = "http://nioh.jp";
	linkurl[5] = "http://www.sisia.or.jp";
	linkurl[6] = "http://www.kanto-t.com/~sisiahp";	// [5]と同じ
	linkurl[7] = "http://www.software-job.jp";

	// リンク元に対応するカウンタファイル名の定義
	linkcnt[0] = "link_kyujinkaigi";
	linkcnt[1] = "link_sainavi";
	linkcnt[2] = "link_prog";
	linkcnt[3] = "link_saitama";
	linkcnt[4] = "link_nioh";
	linkcnt[5] = "link_sisia";
	linkcnt[6] = "link_sisia";	// [5]と同じ
	linkcnt[7] = "link_internext";
	
	for(i=0; i < linkurl.length; i++)
	{
		re = new RegExp(linkurl[i], "i");
		if (document.referrer.match(re) ){
			ExecAddress = linkcnt[i];
		}
	}
	return fncMakeCntName(ExecAddress);
}

//----------------------------------------------------------------------
// index.htmlにfreamesetタグ部分を書き込む
//----------------------------------------------------------------------
function fncCreateFrame()
{
	document.writeln('<frameset rows="0,0,103,*" framespacing="0" border="0" frameborder="0" onload="fncGoChk()" oncontextmenu="return false;">');

		if (cntFlg == true) {
			strBuf = fncLinkCountChk();		// カウンタファイル名の取得

			// リンク元別のカウントアップcgi（合計）
			document.write('<frame src="/freecgi2/Count.cgi?md=8&ft=0&sh=N&df=');
			document.write(strBuf);
			document.writeln('" name="cnt1" scrolling="no" noresize frameborder="0" marginheight="1" marginwidth="1"></frame>');

			// リンク元別のカウントアップcgi（曜日別）
			strBuf = strBuf + fncGetWeekIndex();
			document.write('<frame src="/freecgi2/Count.cgi?md=8&ft=0&sh=N&df=');
			document.write(strBuf);
			document.writeln('" name="cnt2" scrolling="no" noresize frameborder="0" marginheight="1" marginwidth="1"></frame>');
		} else {
			document.writeln('<frame src="" name="cnt1" scrolling="no" noresize frameborder="0" marginheight="1" marginwidth="1"></frame>');
			document.writeln('<frame src="" name="cnt2" scrolling="no" noresize frameborder="0" marginheight="1" marginwidth="1"></frame>');
		}

		document.writeln('<frame src="header.html" name="header" scrolling="no" noresize frameborder="0" marginheight="1" marginwidth="1"></frame>');
		document.writeln('<frame src="top.html" name="main"  scrolling="yes" frameborder="0" marginheight="1" marginwidth="1"></frame>');
	
		document.writeln('<noframes>');
			document.writeln('<body>');
				document.writeln('こちらは株式会社デュオのホームページです。大変申し訳ありませんが、frame対応のブラウザでご覧ください。<br><br>');
				document.writeln('株式会社デュオ<br>');
				document.writeln('〒330-0845<br>');
				document.writeln('さいたま市大宮区吉敷町(きしきちょう)１−１０３　大宮大鷹(おおたか)ビル ２０７<br>');
				document.writeln('TEL　048-647-0101<br>');
				document.writeln('FAX　048-647-9535<br>');
			document.writeln('</body>');
		document.writeln('</noframes>');
	document.writeln('</frameset>');
	return;
}

//----------------------------------------------------------------------
// ページ別のカウントアップcgi部分を書き込む
//----------------------------------------------------------------------
function fncCreatePage(page)
{
	if (arguments.length > 0) {
		if (cntFlg == true) {
			strBuf = fncMakeCntName(page);		// カウンタファイル名の取得

			// ページ別のカウントアップcgi（合計）
			document.write('<img src="/freecgi2/Count.cgi?md=8&ft=0&sh=N&df=');
			document.write(strBuf);
			document.writeln('" height="0%" width="0%">');

			// ページ別のカウントアップcgi（曜日別）
			if ((page == 'saiyou') ||
				(page == 'top')) {
				strBuf = strBuf + fncGetWeekIndex();
				document.write('<img src="/freecgi2/Count.cgi?md=8&ft=0&sh=N&df=');
				document.write(strBuf);
				document.writeln('" height="0%" width="0%">');
			}
		}
	}
	if (dbgFlg == true) {
		document.writeln("<font color='red'><b>（Debug）</b></font>");
	}
}

//----------------------------------------------------------------------
// トップページ表示用のチェック
//----------------------------------------------------------------------
function fncGoChk() {

/*----- 以下、未使用ロジック -----
	var strTemp = new String();
	var strArg = new String();
	var nLength;
	strTemp = location.search;
	nLength = strTemp.length;
	strArg = strTemp.substring(1, nLength);
	alert (strArg);
	if (strArg != "1") {
		alert("ページを表示できません。（ルート不正）");
		window.history.back();
		return(false);
	}
------------------------------*/
	return;
}

/*----------------------------
function fncNoLightClick() {
  alert('err');
  return(false);
}
-----------------------------*/

function mdown(e) {
//  if (navigator.appName == "Microsoft Internet Explorer") {
//    if (event.button == 2) {
//      //alert("右クリックは使用できません");
//      fncNoChk();
//      return(false);
//    }
//  } else if (navigator.appName == "Netscape") {
//    if (e.which == 3) {
//      //alert("右クリックは使用できません");
//      return(false);
//    }
//  }
}

function fncNoChk()
{
//	event.cancelBubble = true;
//	event.returnValue = false;
}

//IEのマウスイベントキャプチャ
if (document.all) {
//  document.oncontextmenu = fncNoChk;
//  document.onmousedown = mdown;
}

//NNのマウスイベントキャプチャ
if (document.layers) {
//  window.onmousedown = mdown;
//  window.captureEvents(Event.MOUSEDOWN);
}


