/*
 * commom.js
 * 
 * @Copyright : 
 * @Author    : 
 * 
 * @History
 *    2008/12/24 : 新規作成
 * 
 */

var g_sDefaultMsg  = "製品を選択後フリーワードを入力してください";		// テキストエリア デフォルトメッセージ

/* 機種一覧画面を開く
 * @param		integer		sParam		パラメータ
 * 
 */
function openModelList(sParam) {
	
	window.open("/support/model.asp?from=" + sParam, "機種選択", "width=858, height=818, menubar=no, toolbar=no, scrollbars=yes");
	
}

/* HELP(別ウインドウ)表示
 * @param	none
 *
 */
function openHelp() {
	
	window.open("/support/help.html", "ヘルプ", "menubar=no, toolbar=no, scrollbars=yes, resizable=yes");
	
}

/* 画面遷移制御
 * @param	string		_screen		画面ID
 * 
 */
function ChangeScreen(_screen) {
	
	var faqURL    = "http://faq.epsondirect.co.jp/faq/";
	var dir_dl    = "dl/app/servlet/";
	var dir_edc   = "edc/app/servlet/";
	var screenID  = "";
	var sPROD   = document.frmModel.PROD.value;
	var sMAIN2  = document.frmModel.MAIN2.value;
	var sFAQ    = document.frmModel.FAQID.value;
	
	// 画面IDのチェック
	if (_screen != "") {
		screenID = _screen;
	} else {
		screenID = document.frmModel.prevScreen.value;
	}
	
	// サポートトップ & 調べる
	if ((screenID == "SUPPORT_TOP") || (screenID == "SHIRABERU_1")){
		// 親画面のリロード
		window.opener.location.reload();
		// 子画面のクローズ
		window.close();
		
	// 製品仕様確認結果(CBコンテンツ)
	} else if (screenID == "SHIRABERU_2") {
		// 遷移先URL/GETパラメータの設定
		window.opener.parent.location.href = faqURL + dir_edc + "qadoc?" + sFAQ;
		// 子画面のクローズ
		window.close();
		
	// ソフトウェアダウンロード一覧(CBコンテンツ)
	} else if (screenID == "DOWNLOAD") {
		// 遷移先URL/GETパラメータの設定
		window.opener.location.href = "transfer.html?id=" + screenID + "&PROD=" + sPROD;
		// 子画面のクローズ
		window.close();
		
	// ソフトウェアダウンロード一覧(CBコンテンツ)
	} else if (screenID == "MANUAL") {
		// 遷移先URL/GETパラメータの設定
		window.opener.location.href = "transfer.html?id=" + screenID + "&PROD=" + sPROD;
		// 子画面のクローズ
		window.close();
		
	// アップグレード
	} else if (screenID == "UPGRADE") {
		// 遷移先URL/GETパラメータの設定
		window.opener.location.href = "transfer.html?id=" + screenID + "&PROD=" + sPROD + "&MAIN2=" + sMAIN2;
		// 子画面のクローズ
		window.close();
		
	// CB FAQトップ(通常検索結果一覧)
	} else if (screenID == "FAQ_TOP") {
		// 遷移先URL/GETパラメータの設定
		window.opener.location.href = "transfer.html?id=" + screenID + "&PROD=" + sPROD;
		// 子画面のクローズ
		window.close();
		
	// FAQランキング
	} else if (screenID == "YOKUARU") {
		// 遷移先URL/GETパラメータの設定
		window.opener.location.href = "transfer.html?id=" + screenID + "&PROD=" + sPROD;
		// 子画面のクローズ
		window.close();
		
	// 新着FAQ
	} else if (screenID == "SHINCHAKU") {
		// 遷移先URL/GETパラメータの設定
		window.opener.location.href = "transfer.html?id=" + screenID + "&PROD=" + sPROD;
		// 子画面のクローズ
		window.close();
		
	// 上記以外
	} else {
		window.close();
	}
	
}

/* 機種選択画面 0.へ
 * @param		string		_type		タイプ
 * 			string		_series		シリーズ
 * 			string		_prod		プロダクトID
 * 			string		_model		モデル
 * 			string		_img		画像URL
 * 			string		_faq		FAQ番号
 * 			string		_main2		MAIN2パラメータ
 * 
 */
function setModelInfo(_type, _series, _prod, _model, _img, _faq, _main2) {
	
	// 値のチェック
	if ((_prod != "") && (_faq != "") && (_main2 != "")) {
		// hiddenパラメータに値を設定
		document.frmModel.TYPE.value    = _type;
		document.frmModel.SERIES.value  = _series;
		document.frmModel.PROD.value    = _prod;
		document.frmModel.MODEL.value   = _model;
		document.frmModel.IMG_URL.value = _img;
		document.frmModel.FAQID.value   = _faq;
		document.frmModel.MAIN2.value   = _main2;
		// 機種選択画面へ
		document.frmModel.submit();
	} else {
		return false;
	}
	
}

/* 0'からCBFAQへ
 * @param		string		_prod		プロダクトID
 * 			string		_main2		MAIN2パラメータ
 * 			string		_main3		MAIN3パラメータ
 * 
 */
function setOsInfo(_prod, _main2, _main3) {
	
	var faqURL    = "http://faq.epsondirect.co.jp/faq/";
	var dir_edc   = "edc/app/servlet/";
	
	// 値のチェック
	if ((_prod != "") && (_main2 != "") && (_main3 != "")) {
		// hiddenパラメータに値を設定
		document.form1.PROD.value  = _prod;
		document.form1.MAIN2.value = _main2;
		document.form1.MAIN3.value = _main3;
		// CBFAQへ
		document.form1.action = faqURL + dir_edc + "qasearch"
		document.form1.method = "post";
		document.form1.submit();
	} else {
		return false;
	}
	
}

/* 検索ボタン
 * @param	none
 * 
 */
function changeCBSearch() {
	
	var faqURL    = "http://faq.epsondirect.co.jp/faq/";
	var dir_edc   = "edc/app/servlet/";
	var sQUERY    = document.getElementById("QUERY").value;
	
	// テキストエリアメッセージ
	if (sQUERY == g_sDefaultMsg) {
		// デフォルトメッセージの場合、空文字に
		document.getElementById("QUERY").value = "";
	}
	// CBFAQへ
	document.form1.action = faqURL + dir_edc + "qasearch"
	document.form1.method = "post";
	document.form1.submit();
	
}

/* FAQ番号検索
 * @param	integer		iFlg		検索対象フラグ 0:FAQ番号から検索 / 1:FAQ番号から検索以外
 * 
 */
function changeQADoc(iFlg) {
	
	var faqURL    = "http://faq.epsondirect.co.jp/faq/";
	var dir_edc   = "edc/app/servlet/";
	var sFaqID    = "";
	var sCID      = "";
	
	if (iFlg == 0) {
		if (document.getElementById("dispFaqDoc").disabled == true) {
			return false;
		} else {
			if (iFlg == 0) {
				sCID = encodeURI(document.supportFrm.CONTENTID.value);
				if (sCID != "") {
					location.href = faqURL + dir_edc + "qadoc?" + sCID;
				}
			} else {
				sFaqID = document.getElementById("FAQID").value;
				location.href = faqURL + dir_edc + "qadoc?" + sFaqID;
			}
		}
	} else {
		sFaqID = document.getElementById("FAQID").value;
		location.href = faqURL + dir_edc + "qadoc?" + sFaqID;
	}
	
	return false;
	
}

/* FAQ番号検索
 * @param	none
 * 
 */
function changeQADocSiteMap() {
	
	var faqURL  = "http://faq.epsondirect.co.jp/faq/";
	var dir_edc = "edc/app/servlet/";
	var sFaqID  = document.getElementById("FAQID").value
	
	if (sFaqID != "") {
		location.href = faqURL + dir_edc + "qadoc?" + sFaqID;
	} else {
		return false;
	}
	
}

/* 製造番号検索
 * @param	none
 * 
 */
function changeProdNumber() {
	
	var support1URL = "http://support1.epsondirect.co.jp/prodsearch/prodsearch.asp";
	
	if (document.getElementById("button2").disabled == true) {
		return false;
	} else {
		// CBFAQへ
		document.productSearch.action = support1URL;
		document.productSearch.method = "post";
		document.productSearch.submit();
	}
}

/* FAQランキング
 * @param	none
 * 
 */
function changeFaqRanking() {
	
	var faqURL = "http://faq.epsondirect.co.jp/faq/edc/app/servlet/qaranking";
	var sPROD  = document.getElementById("select").options[document.getElementById("select").selectedIndex].value;
	
	// CBFAQへ
	document.rankingAndNewlist.PROD.value = sPROD;
	document.rankingAndNewlist.action = faqURL;
	document.rankingAndNewlist.method = "post";
	document.rankingAndNewlist.submit();
	
}

/* 新着FAQ
 * @param	none
 * 
 */
function changeNewlistFaq() {
	
	var faqURL = "http://faq.epsondirect.co.jp/faq/edc/app/servlet/newlist";
	var sPROD  = document.getElementById("select").options[document.getElementById("select").selectedIndex].value;
	
	// CBFAQへ
	document.rankingAndNewlist.PROD.value = sPROD;
	document.rankingAndNewlist.action = faqURL;
	document.rankingAndNewlist.method = "post";
	document.rankingAndNewlist.submit();
	
}


/* 新着のダウンロードをチェック
 * @param	none
 * 
 */
function changeDownload() {
	
	var faqURL = "http://faq.epsondirect.co.jp/faq/dl/app/servlet/newlist";
	
	// CBFAQへ
	document.supportFrm.action = faqURL;
	document.supportFrm.method = "post";
	document.supportFrm.submit();
	
}

/* FAQランキング及び新着FAQ画像の切り替え
 * @param	integer		iScID		画面ID 0:サポートトップ / 1:調べる
 *
 */
function changeSelected(iScID) {
	
	var sDir  = "../";
	var sImg  = "";
	var sPROD = document.getElementById("select").options[document.getElementById("select").selectedIndex].value;
	
	if (sPROD == "") {
		document.getElementById("bt_ranking").src = ((iScID == 0) ? "" : sDir) + "images/bt_ranking_g.gif";
		document.getElementById("bt_new").src     = ((iScID == 0) ? "" : sDir) + "images/bt_new_g.gif";
		document.getElementById("bt_ranking").style.cursor = "default";
		document.getElementById("bt_new").style.cursor     = "default";
		document.getElementById("a_ranking").disabled = true;
		document.getElementById("a_new").disabled     = true;
	} else {
		document.getElementById("bt_ranking").src = ((iScID == 0) ? "" : sDir) + "images/bt_ranking.gif";
		document.getElementById("bt_new").src     = ((iScID == 0) ? "" : sDir) + "images/bt_new.gif";
		document.getElementById("bt_ranking").style.cursor = "auto";
		document.getElementById("bt_new").style.cursor     = "auto";
	}
	
}

/* 機種選択メニュー
 * @param	integer		iFlg		遷移先フラグ 0:FQAランキング / 1:新着FAQ
 * 
 */
function checkSelected(iFlg) {
	
	var sPROD = document.getElementById("select").options[document.getElementById("select").selectedIndex].value;
	
	if (sPROD == 0) {
		return false;
	} else {
		if (iFlg == 0) {
			changeFaqRanking();
		} else {
			changeNewlistFaq();
		}
	}
	
}

/* FAQ番号から検索時の表示ボタンの押下可不可制御
 * @param	none
 * 
 */
function ctrlDispButton() {
	
	var sFaqID = document.supportFrm.CONTENTID.value;
	
	if (sFaqID.length != 0) {
		document.getElementById("dispFaqDoc").disabled = false;
	} else {
		document.getElementById("dispFaqDoc").disabled = true;
	}
}

/* 製造番号入力欄が未入力時、ボタンを押下不可に
 * @param	none
 * 
 */
function ctrlProdSearchButton() {
	
	var sProdNum = document.productSearch.productnumber.value;
	
	if (sProdNum.length != 0) {
		document.getElementById("button2").disabled = false;
	} else {
		document.getElementById("button2").disabled = true;
	}
	
}

/* フリーワード入力欄のデフォルトメッセージの表示制御
 * @param	integer		iActFlg		フラグ 0:onfocus時/1:onblur時
 * 
 */
function ctrlTextArea(iActFlg) {
	
	var sQUERY      = document.getElementById("QUERY").value;
	
	if (sQUERY == g_sDefaultMsg) {
		if (iActFlg == 0) {
			document.getElementById("QUERY").value = "";
			document.getElementById("QUERY").style.color = "#000000";
		}
	} else if (sQUERY == "") {
		if (iActFlg == 1) {
			document.getElementById("QUERY").value = g_sDefaultMsg;
			document.getElementById("QUERY").style.color = "#999999";
		}
	}
}

/* onload時、フリーワード入力欄のデフォルトメッセージのフォント色を変更
 * @param	none
 * 
 */
function setFontColor() {
	
	var sQUERY      = document.getElementById("QUERY").value;
	
	if (sQUERY == g_sDefaultMsg) {
		document.getElementById("QUERY").style.color = "#999999";
	} else {
		document.getElementById("QUERY").style.color = "#000000";
	}
	
}
