//--------------------------------------
// Define parameters.
	// Cookie defines.
var cookie_key			= "plalaTopPage";
var cookie_expire_day	= 365;

	// Escape agent defines.
var escape_agent_num	= 6;
var escape_agent		= new Array(escape_agent_num);

for (index = 0; index < escape_agent_num; index++) {
	escape_agent[index] = new Array(3);
}

escape_agent[0][0] = "AVE-Front/2.5";
escape_agent[0][1] = "";
escape_agent[0][2] = "http://www.plala.or.jp/access/";

escape_agent[1][0] = "AveFront/2.5";
escape_agent[1][1] = "";
escape_agent[1][2] = "http://www.plala.or.jp/access/";

escape_agent[2][0] = "iBOX";
escape_agent[2][1] = "";
escape_agent[2][2] = "http://www.plala.or.jp/access/";

escape_agent[3][0] = "WebTV";
escape_agent[3][1] = "";
escape_agent[3][2] = "http://www.plala.or.jp/access/";

escape_agent[4][0] = "MSIE 3";
escape_agent[4][1] = "";
escape_agent[4][2] = "http://www.plala.or.jp/access/";

escape_agent[5][0] = "NN 2";
escape_agent[5][1] = "";
escape_agent[5][2] = "http://www.plala.or.jp/access/";

	// Top page defines.
var plala_top_page		= "index.html";
var plala_default_page	= "index.shtml";
var plala_top_menu_num	= 9;
var plala_top_menu		= new Array(plala_top_menu_num);
var select_error_msg	= "トップページに設定するページを選択してください。";

for (index = 0; index < plala_top_menu_num; index++) {
	plala_top_menu[index] = new Array(3);
}

plala_top_menu[0][0] = "MSN";
plala_top_menu[0][1] = "お奨めポータル「MSNぷららバージョン」";
plala_top_menu[0][2] = "http://www.msn.co.jp/plala/";

plala_top_menu[1][0] = "GOO";
plala_top_menu[1][1] = "お奨めポータル「gooぷららバージョン」";
plala_top_menu[1][2] = "http://plala.goo.ne.jp/plalatop/";

plala_top_menu[2][0] = "ACCESS";
plala_top_menu[2][1] = "個人向けISP「ぷららアクセスページ」";
plala_top_menu[2][2] = "http://www.plala.or.jp/access/";

plala_top_menu[3][0] = "PHONE";
plala_top_menu[3][1] = "市外電話サービス「ぷららフォン」";
plala_top_menu[3][2] = "http://www.009191.com/";

plala_top_menu[4][0] = "BROADBAND";
plala_top_menu[4][1] = "ブロードバンドコンテンツ「ぷらら.TV」";
plala_top_menu[4][2] = "http://plala.tv/";

plala_top_menu[5][0] = "BIZ";
plala_top_menu[5][1] = "法人向けISP「ビジネスぷらら」";
plala_top_menu[5][2] = "http://biz.plala.or.jp/";

plala_top_menu[6][0] = "ACADEMIC";
plala_top_menu[6][1] = "学校向けサービス「学園都市」";
plala_top_menu[6][2] = "http://biz.plala.or.jp/school/";

plala_top_menu[7][0] = "PLAPARA";
plala_top_menu[7][1] = "ショッピング「ぷららパラダイスforyou」";
plala_top_menu[7][2] = "http://www.plapara.com/";

plala_top_menu[8][0] = "SELECT_CLEAR";
plala_top_menu[8][1] = "トップページ設定変更/クリアをする";
plala_top_menu[8][2] = "choice.html";
//--------------------------------------
	// Set Cookie.
function setPlalaTopPageCookie(selectPage) {
	if (selectPage.page.value == '') {
		alert(select_error_msg);
    	return false;
	}
	var today = new Date();
		// Set expire 356 days. (1 Year)
	var expires = new Date(today.getTime() + (cookie_expire_day * 86400000));
			// Support Macintosh & Netscape 4.7
//	var new_page = selectPage.page.value;
	var new_page = document.forms[0].elements[0].options[selectPage.page.selectedIndex].value;
		// Not set path, domain and secure.
//											alert('Cookieの値は '+'key='+cookie_key+', value='+new_page+', expires='+expires);
	return Set_Cookie(cookie_key, new_page, expires);
}
	// Get Cookie.
function getPlalaTopPageCookie() {
		// Not set path, domain.
	return Get_Cookie(cookie_key);
}
	// Delete Cookie.
function deletePlalaTopPageCookie() {
		// Not set path, domain.
	return Delete_Cookie(cookie_key);
}
	// Set cookie.
function Set_Cookie(key, value, expires, path, domain, secure) {
	document.cookie = key + "=" + escape(value) +
		((expires) ? ";expires=" + expires.toGMTString() : "") +
		((path) ? ";path=" + path : "") + 
		((domain) ? ";domain=" + domain : "") +
		((secure) ? ";secure" : "");
	return true;
}
	// Get cookie.
function Get_Cookie(key) {
	var start = document.cookie.indexOf(key + "=");
	var len = start + key.length + 1;
	if ((!start) && (key != document.cookie.substring(0, key.length))) {
		return null;
	}
	if (start == -1) {
		return null;
	}
	var end = document.cookie.indexOf(";", len);
	if (end == -1) {
		end = document.cookie.length;
	}
	return unescape(document.cookie.substring(len, end));
}
	// Delete cookie.
function Delete_Cookie(key, path, domain) {
	if (Get_Cookie(key)) document.cookie = key + "=" +
		((path) ? ";path=" + path : "") +
		((domain) ? ";domain=" + domain : "") +
		";expires=Thu, 01-Jan-1970 00:00:01 GMT";
	return true;
}

function select_plala_top(comment1, comment2, button) {
	document.write("<form name='selectPageForm' method='GET' action='");
	document.write(plala_default_page);
	document.write("' onSubmit='return setPlalaTopPageCookie(this);'>");
	document.write("<td bgcolor='#FFFFFF' class='t12' align='right' valign='top'>");
	document.write(comment1);
	document.write("<select name='page'>");
	for (index = 0; index < plala_top_menu_num; index++) {
		document.write("<option value=");
		document.write(plala_top_menu[index][0]);
		document.write(">");
		document.write(plala_top_menu[index][1]);
		document.write("</option>");
	}
	document.write("</select>");
	document.write(comment2);
	document.write("<input type='submit' value=");
	document.write(button);
	document.write(">");
	document.write("</td>");
	document.write("</form>");
}

function clear_plala_top(button) {
	document.write("<form name='clearPageForm' method='GET' action='");
	document.write(plala_default_page);
	document.write("' onSubmit='return deletePlalaTopPageCookie();'>");
	document.write("<input type='submit' value=");
	document.write(button);
	document.write(">");
	document.write("</form>");
}

function check_escape_jump() {
//											alert('navigator.CodeName='+navigator.CodeName+
//													'\n navigator.appName='+navigator.appName+
//													'\n navigator.appVersion='+navigator.appVersion+
//													'\n navigator.userAgent='+navigator.userAgent+
//													'\n navigator.platform='+navigator.platform);
	for (index = 0; index < escape_agent_num; index++) {
		if (navigator.userAgent.indexOf(escape_agent[index][0]) >= 0) {
			if (escape_agent[index][1] == "") {
				window.location.replace(escape_agent[index][2]);
				return true;
			}
			else {
				;
			}
		}
	}
	return false;
}

function jump_plala_top() {
	check_escape_jump();
	var cookie_value = getPlalaTopPageCookie();
//											alert('getPlalaTopPageCookieの戻り値は '+'new_page='+new_page);
	for (index = 0; index < plala_top_menu_num; index++) {
		if (plala_top_menu[index][0] == cookie_value) {
			window.location.replace(plala_top_menu[index][2]);
			return true;
		}
	}
//	window.location.replace(plala_default_page);
	return false;
}

