/******************************
* グローバルメニュー画像読み込み処理【アルファ用】
*******************************/
if(document.images) {
	//画像保存フォルダ名
	dImgPath = "/www/dslr/images/common/";
	productName = "dslr/";
	currentPage = 1000;		// dummy No.
	
	var aImg = new Array();

	//****** ATTENTION!! ***********************************
	//メニュー項目一覧(aMenuList)とページ識別情報(aPathList)は
	//データが連動してますのでメニュー追加時は、両方に追加してください！
	//また、並び順をあわせてください！
	//******************************************************
	
	//メニュー項目一覧
	var aMenuList = new Array(
		"gm_info",			/*  1. 重要なお知らせ			*/
		"gm_products",		/*  2. 製品別サポート			*/
		"gm_qa",			/*  3. Ｑ＆Ａ					*/
		"gm_download",		/*  4. ソフトウェアダウンロード				*/
		"gm_update",		/*   . 本体アップデート情報				*/
		"gm_soft",			/*  5. 付属ソフトウェア				*/
		"gm_benri",		/*  6. パソコンとつなぐ			*/
		"gm_search",		/*  7. キーワード検索			*/
		"gm_manual",		/*  8. 取説ダウンロード 		*/
		"gm_battery",		/*  9. バッテリーについて		*/
		"gm_accy",			/* 10. アクセサリーの互換情報	*/
		"gm_repair",		/* 11. 修理サービス				*/
		"gm_inquiry",		/* 12. お問い合わせ				*/
		"gm_konica",		/* 13. コニカミノルタ			*/
		"gm_benri",			/* 14. かんたんガイド			*/
		"gm_glossary",		/* 15. 用語集					*/
		"gm_ms",			/* 16. メモリースティックについて	*/
		"gm_mypage",		/* 17. マイページ				*/
		"gm_os",			/* 18. Windows 7 / Vista 対応状況	*/
		"gm_setupmov",			/*  xx. セットアップ動画ガイド	*/
		"gm_benri",			/*  7. ブルーレイ/DVDを作る	*/
		"lm_bt_top",			/* 19. 製品別トップページ		*/
		"lm_bt_info",			/* 20. Q&A						*/
		"lm_bt_qa",			/* 20. Q&A						*/
		"lm_bt_download",			/* 21. ダウンロード				*/
		//"lm_bt_soft",			/* 22. ソフトウェア				*/
		"lm_bt_attsoft",			/* 22. ソフトウェア				*/
		//"lm_bt_pccon",		/* 23. パソコンとつなぐ			*/
		"lm_bt_pcimport",		/* 23. パソコンとつなぐ			*/
		"lm_bt_acc",			/* 24. アクセサリーの互換情報	*/
		"lm_bt_osinfo",		/* 25. 対応OS	*/
		"lm_bt_customer_camera",		/* 26. カスタマー登録(カメラ)	*/
		"lm_bt_customer_lenz"			/* 27. カスタマー登録(レンズ)	*/

	);
	
	//メニューに対応したページ識別情報(パス)を設定
	var aPathList = new Array(
		"information/",
		"products/",
		"qa/",
		"download/",
		"update/",
		"software/",
		"pcconnect/",
		"alphasearch.cgi",
		"gm_manual",
		"battery/",
		"accy/",
		"repair_service/",
		"inquiry/",
		"gm_konica",
		"benri/",
		"glossary/",
		"memorystick/",
		"gm_mypage",
		"gm_os",
		"movie/",
		"disc/",
		"index.html",
		"information.html",
		"qa.html",
		"download.html",
		"software.html",
		"pcconnect.html",
		"accy.html",
		"lm_bt_osinfo",
		"lm_bt_customer_camera",
		"lm_bt_customer_lenz"	
	);

	//メニュー項目一覧
	var aImgList = new Array(
    "sat01",
    "sat02",
    "sat03",
    "sat04"

	);

	//画像読込み
	for(i = 0 ; i < aImgList.length; i++){
		dNum = i
		aArray = aImg;

		aArray[dNum] = new Array();
		aArray[dNum][0] = new Image();
		aArray[dNum][0].src = dImgPath + aImgList[i] + ".gif";
		aArray[dNum][1] = new Image();
		aArray[dNum][1].src = dImgPath + aImgList[i] + "_on.gif";
	}

}

/******************************
* カレントページの画像を反転させる処理（<BODY onLoad="initImage()">で使用）
*******************************/
function initImage() {

	// ページのURLを取得
    strURL = document.URL;
//	strURL = "http://lprweb2.cv.sony.co.jp/www/dslr/products/dsc-p7/osinfo.html"	// for DEBUG
//	alert(strURL.substr(strURL.lastIndexOf(productName) + productName.length));		// for DEBUG
	// productName以下のパスを切り出す処理
	lastName = strURL.substr(strURL.lastIndexOf(productName) + productName.length);

	// ローカルページとの混同防止
	if( lastName == "index.html" ) {		// トップページ（/www/dslr/index.html）
	//	alert("トップページかもね？");		// for DEBUG
		currentPage = 1000;					// インデックスNo.をクリア(Dummy)
		return;
	}

	ignoreFlag = 0;
	// 製品別ローカルページでなければ…
	if( lastName.indexOf("products/dslr-") == -1 && lastName.indexOf("products/dskit-") == -1 &&
		lastName.indexOf("products/nex-") == -1 && lastName.indexOf("products/slt-") == -1 &&
		lastName.indexOf("products/benri") == -1 &&
		lastName != "index.html" && lastName.indexOf("alphasearch.cgi") == -1 ) {
//		lastName != "index.html" && lastName != "alphasearch.cgi" ) {
		// 最初の"/"から後半をトリミングする
		lastName = lastName.substr(0, lastName.indexOf("/") + 1);
		ignoreFlag = 1;					// ローカルメニューを無視
	}
	else {	// ローカルページの場合は最後のファイル名を取り出す
//		if( lastName.indexOf("products/benri") == -1 ) {
		if( lastName.indexOf("products/benri") == -1 && lastName.indexOf("alphasearch.cgi") == -1 ) {
			lastName = lastName.substr(lastName.lastIndexOf("/") + 1);
		}
	}

	//2006.07.10 add by Fujihara
	//ソフトウェアページのアンカー対応 "#"以降は削除
	if (lastName.indexOf("#")){
		lastName = lastName.replace(/#.*/, "");
	}

	//2007.10.19 add by Fujihara
	//RSSのクエリー対応 "?"以降は削除
	if (lastName.indexOf("?")){
		lastName = lastName.replace(/\?.*/, "");
	}

//	alert(lastName);					// for DEBUG

	imgNum = 1000;


/**************************
//2006.05.23 M.Fujihara コメントアウト
//「トップ」を反転させるためコメントアウト
	// 製品別トップページ（ローカルページ）は「製品別サポート」ボタンを反転させておく
	if( lastName == "index.html" ) {		// 製品別トップページ
		currentPage = 2;					// 「製品別サポート」のインデックスNo.を設定
		lastName = "products";				// 名前も偽称
	}
**************************/

	//2006.01.25 add by Fujihara
	//パソコンとつなぐ
	if ( lastName.substring(-1, 10) == "pcconnect_" ){
		//currentPage = 22;					// ローカル「パソコンとつなぐ」のインデックスNo.を設定
		lastName = "pcconnect.html";		// 名前も偽称
	}

/**************************
//2006.05.23 M.Fujihara コメントアウト
	// Q&A検索結果ページ対策（暫定）
//alert(lastName.substring(-1, 3));
	if( lastName == "qa/" || lastName.substring(-1, 3) == "qa/" ) {				// Q&Aページ
		currentPage = 3;					// 「Q&A」のインデックスNo.を設定
		lastName = "qasearch/";				// 名前も偽称
	}
**************************/
	// Q&Aインデックスページ対策（暫定）
	if( lastName.indexOf("qa_") != -1 ) {	// Q&Aインデックスページ
		//currentPage = 16;					// ローカル「Q&A」のインデックスNo.を設定
		lastName = "qa.html";				// 名前も偽称
	}
	// アクセサリー互換情報 キーワード検索ページ対策（暫定）
	if( lastName.indexOf("accy/alphasearch.cgi") != -1 ) {	// キーワード検索ページ
		//currentPage = 6;					// キーワード検索のインデックスNo.を設定
		lastName = "accy/";			// 名前も偽称
	}
	// キーワード検索ページ対策（暫定）
	if( lastName.indexOf("alphasearch.cgi") != -1 ) {	// キーワード検索ページ
		//currentPage = 6;					// キーワード検索のインデックスNo.を設定
		lastName = "alphasearch.cgi";			// 名前も偽称
	}
	// 簡単ガイドページ対策（暫定）
	if( lastName.indexOf("products/benri") != -1 ) {	// 簡単ガイドインデックスページ
		//currentPage = 10;					// 「簡単ガイド」のインデックスNo.を設定
		lastName = "benri/";				// 名前も偽称
	}
/**************************
//2006.07.04 M.Fujihara コメントアウト
	// Q&A末端ページ対策（暫定）
	if( lastName == "solution/" || lastName.substring(-1, 9) == "solution/" ) {		// Q&A末端ページ
		//currentPage = 3;					// 「Q&A」のインデックスNo.を設定
		lastName = "qasearch/";				// 名前も偽称
	}
**************************/
	// パス(ファイル名)の比較＆インデックスNo.の取り出し
	for(n = 0; n < aPathList.length; n++) {
		if(aPathList[n] == lastName) {
			//alert("(" + n + ") " + aPathList[n]);		// for DEBUG
			imgNum = n;
			break;
		}
	}

	currentPage = imgNum;				// インデックスNo.をカレントページとする

	//alert(currentPage);					// for DEBUG
	//alert(imgNum);						// for DEBUG

//	sleep(1);
	// カレントページのメニューボタンの見た目をハイライトする
	if(currentPage != 1000) {
		if ( document.getElementById(aMenuList[imgNum]) ) {
			//document.images[aMenuList[imgNum]].src = aImg[imgNum][1].src;
/**************************
//2011.01.11 T.Matsuo コメントアウト
			document.getElementById(aMenuList[imgNum]).style.backgroundColor = "#C8C8F1";
**************************/
//**************************
//2011.01.11 T.Matsuo 追加
			var targetElmA = document.getElementById(aMenuList[imgNum]).getElementsByTagName('a')[0];
			targetElmA.style.color = '#000000';
			targetElmA.style.fontWeight = 'bold';
//**************************
		}
	}
}

/******************************
* Sleep
*******************************/
//function sleep(num) {
//	window.setTimeout("sleep()", 1000);
//}

/******************************
* 画像ファイル差し替え
*******************************/
function chgimg(dName, dNum) {
	
	if(document.images) {
		for(i = 0 ; i < aImgList.length; i++){
			if(aImgList[i] == dName){
				dImgNum = i;
				break;
			}
		}

/************		
		// カレントページと同じ番号の場合は画像入れ替えをしない
		if(dImgNum == currentPage) {
			return;								// 関数を抜ける
		}
************/		
		
		// 画像入れ替え
		document.images[dName].src = aImg[dImgNum][dNum].src;
	}
}

/******************************
* ポップアップウィンドウを開く
*******************************/
function NewWinOpen(dUrl,dName,dWidth,dHeight,dEtc){
	dStatus = "width=" + dWidth + ",height=" + dHeight + ",resizable=yes";
	
	if(dEtc != ""){
		dStatus += "," + dEtc;
	}
	
	newwin = window.open(dUrl, "_blank", dStatus);
//	newwin = window.open(dUrl, dName, dStatus);
	newwin.focus();
	return false;
	
}

/******************************
* ご意見の確認ダイアログ
*******************************/

function msg(){
if(window.confirm('いただいたご意見・ご要望に対して当社より回答することはできませんので、あらかじめご了承ください。')) {
  window.location.href = "/cgi-bin/alpha/feedback/index.cgi";
//return true;
} else return false;
}

/******************************
* DIアンケートフォーム　アンケート１のサブミット
*******************************/
function SetQ1Val(val) {

	document.q1.satisfaction.value = val;

	document.q1.submit();
	return false;

}

/******************************
* DIアンケートフォーム　アンケート２のサブミット
*******************************/
function CheckQ2Form() {

	//理由
	var find_flag = 0;
	if (document.q2.detail.length) {
		for (i = 0; i < document.q2.detail.length; i++) {
			if (document.q2.detail[i].checked) {
				find_flag = 1;
			}
		}
	}
	if ( ! find_flag ) {
		document.q2.detail[0].focus();
		alert("理由を選択してください");
		return(false);
	}


	// コメント
	if (document.q2.message.value == ""){
		//document.q2.message.focus();
		//alert("コメントを入力してください");
		//return false;
	}
	else {

		str = document.q2.message.value;
		for (i = 0; i < str.length; i++) {
			ch = str.charCodeAt( i );
			if ( ch >= 65382 && ch <= 65439 ) {
				alert("コメントに半角カタカナを使用しないでください。");
				return(false);
			}
		}

		// コメント 文字数
		len_message = jstrlen(document.q2.message.value)
		//alert("len_message:" + len_message);
		if (len_message > 2000){
			alert("コメントの文字数がオーバーしてます。\n最大は全角で1000文字(2000バイト)です。");
			document.q2.message.focus();
			return false;
		}
	}

	document.q2.submit();
	return false;

}

//===============================
//文字数カウント（日本語を 2文字でカウント）
//===============================
function jstrlen(str) {
   len = 0;
   i = 0;
   str = escape(str);
   for (i = 0; i < str.length; i++, len++) {
      if (str.charAt(i) == "%") {
         if (str.charAt(++i) == "u") {
            i += 3;
            len++;
         }
         i++;
      }
   }
   return len;
}


