﻿str=navigator.appName.toUpperCase();
if (str.indexOf("NETSCAPE")>=0) alert("お使いのブラウザでは、拡大・縮小・反転ボタンが機能しないことがあります");

var cookie;
var title;
var font_size;
var ratio;

function change_fontsize(ratio) {
	if (ratio == '*')
		font_size = 100;
	else {
		font_size = parseInt(font_size) + parseInt(ratio);
		if (font_size < 100)
			font_size = 100;
		else if (font_size > 250) 
			font_size = 250;
	}
	
	document.body.style.fontSize = font_size + '%';
}

function setActiveStyleSheet(title) {
	var i, a, main;
	if ( title == '' || title == null) {
		title = 'standard';
	}

	for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
		if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
			a.disabled = true;
			if(a.getAttribute("title") == title) a.disabled = false;
		}
	}
}

function getActiveStyleSheet() {
	var i, a;
	for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
		if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled)
			return a.getAttribute("title");
	}
	return null;
}

window.onload = function(e) {
	cookie   = readCookie("SDLS_fontSize");
	font_size = cookie ? cookie : 100;
	change_fontsize (0);
	cookie = readCookie("SDLS_style");
	title = cookie ? cookie : 'standard';
	setActiveStyleSheet(title);
}

window.onunload = function(e) {
	title = getActiveStyleSheet();
	createCookie("SDLS_style", title, 365);
	createCookie("SDLS_fontSize", font_size, 365);
}

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function CheckFormMail() {
	//****************個別メール内容の取得****************
	var myData = new Array();
	var myArray = new Array('text3', 'text2', 'text1');
	
	for (var i in myArray)
		myData[myArray[i]] = document.sendmail[myArray[i]].value;

	//*******アドレスのチェック***********
	if (myData.text3 == '')	{
		alert ('お名前が入力されていません');
		document.sendmail.text3.focus();
		return false;
	}
	//***********タイトルのチェック***********
	if (myData.text2 == '')	{
		alert ('メールアドレスが入力されていません。');
		document.sendmail.text2.focus();
		return false;
	}
	//***********本文のチェック***********
	if (myData.text1 == '')	{
		alert ('本文が入力されていません。');
		document.sendmail.text1.focus();
		return false;
	}
	//***********確認ダイアログによる確認***********
	return confirm ('下記の内容で送信してよろしいですか？\n\n'
	+ 'お名前：　' + myData.text3 + '\n'
	+ 'アドレス：' + myData.text2 + '\n'
	+ '本文：\n' + myData.text1 + '\n');
}


