var dateObj = new Date();
d = dateObj.getMonth()+1;

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_openBrWindow(theURL,winName,features) { //v2.0
  var win=window.open(theURL,winName,features);
  win.focus();
}


function smartOver() {
	smartRollover('wrap');
}
function smartRollover(idName) {
	if(document.getElementsByTagName) {
		var images = document.getElementById(idName).getElementsByTagName("img");
		for(var i=0; i < images.length; i++) {

			if(images[i].getAttribute("src").match(/_off\./))
			{
			fileName = new Array(images[i].getAttribute("src").replace("_off.", "_on."));
			preImages = new Array();
			for (j=0; j<fileName.length; j++)
			{
				preImages[j] = new Image();
				preImages[j].src = fileName[j];		//「_on」の画像をプリロード
			}

				images[i].onmouseover = function() {
					this.setAttribute("src", this.getAttribute("src").replace("_off.", "_on."));	//マウスオーバーで_off→_on
				}
				images[i].onmouseout = function() {
					this.setAttribute("src", this.getAttribute("src").replace("_on.", "_off."));	//マウスが離れたら_on→_off
				}
			}
		}
		var inputs = document.getElementById(idName).getElementsByTagName("input");
		for(var i=0; i < inputs.length; i++) {

			if(inputs[i].getAttribute("src").match(/_off\./))
			{
			fileName = new Array(inputs[i].getAttribute("src").replace("_off.", "_on."));
			preImages = new Array();
			for (j=0; j<fileName.length; j++)
			{
				preImages[j] = new Image();
				preImages[j].src = fileName[j];		//「_on」の画像をプリロード
			}

				inputs[i].onmouseover = function() {
					this.setAttribute("src", this.getAttribute("src").replace("_off.", "_on."));	//マウスオーバーで_off→_on
				}
				inputs[i].onmouseout = function() {
					this.setAttribute("src", this.getAttribute("src").replace("_on.", "_off."));	//マウスが離れたら_on→_off
				}
			}
		}
	}
}
if(window.addEventListener) {
	window.addEventListener("load", smartOver, false);	//実行
}
else if(window.attachEvent) {
	window.attachEvent("onload", smartOver);
}
else{
	window.onload = smartOver;
}


// サイドバー用メルマガ関連
{
	var type01="";
	var type02="";
	var type03="";
	var type04="";
	var type05="";
	var type06="";
	var type_all="";
	function MelmagaJunp(url) {
		JumpHtmlWithParam(
			url,
			"hissu_email",document.getElementById("hissu_email").value,
			"type01",type01,
			"type02",type02,
			"type03",type03,
			"type04",type04,
			"type05",type05,
			"type06",type06,
			"type_all",type_all
		);
	}
	function JumpHtmlWithParam() {
		var str = "";
		//str += "<a href='";
		str += arguments[0];
		for (i = 1; i < arguments.length; i+=2) {
			var kugiri = (i==1) ? "?" : "&";
			str += kugiri+arguments[i+0]+"="+escape(arguments[i+1]);
		}
		//str += "'>";
		location.href=(str);
		//	document.write(str);
	}
	function TypeSeletion(selectobj) {
		var i = selectobj.selectedIndex;
		i = i - 1;
		
		type_all = (i==0)     ?  "全体一括配信登録" : "";
		type01 = (i==0||i==1) ?  "BEE APPLE （りんご） メルマガ配信希望" : "";
		type02 = (i==0||i==2) ?  "BEE CHERRY （さくらんぼ） メルマガ配信希望" : "";
		type03 = (i==0||i==3) ?  "BEE RICE （お米） メルマガ配信希望" : "";
		type04 = (i==0||i==4) ?  "石焼き芋 メルマガ配信希望 （冬季のみ配信）" : "";
		type05 = (i==0||i==5) ?  "テラ農業 メルマガ配信希望" : "";
		type06 = (i==0||i==6) ?  "石井通信" : "";
	}
}
// ログイン関連
{
	function ReadCookie(key) {
		var sCookie = document.cookie;
		var aData = sCookie.split(";");
		var oExp = new RegExp(" ", "g");
		key = key.replace(oExp, "");
		var i = 0;
		while (aData[i]) {
			var aWord = aData[i].split("=");
			aWord[0] = aWord[0].replace(oExp, "");
			if (key == aWord[0]) return decodeURIComponent(aWord[1]);
			if (++i >= aData.length) break;
		}
		return "";
	}
	function GetMyName() {
		var str = ReadCookie("myNAME");
		if (str=="undefined") str = null;
		return str;
	}
	function DispLoginInfo(toppath) {
		if (GetMyName()) {
			document.getElementById("nowlogin").style.display  = "block";
			document.getElementById("nowlogout").style.display = "none";
			document.getElementById("nowlogin").innerHTML = "ようこそ<b>"+GetMyName()+"</b>さん<br>現在ログイン中です<br><div align='right'><a href='"+toppath+"login.cgi?mode=logout'>[ログアウト]</a></div>";
		}else{
			//document.getElementById("nowlogin").style.display  = "none";
			//document.getElementById("nowlogout").style.display = "block";
		}
	}
}

