﻿var mmOpenContainer = null;
var mmOpenMenus = null;
var mmHideMenuTimer = null;

function MM_menuStartTimeout(hideTimeout) {
	mmHideMenuTimer = setTimeout("MM_menuHideMenus()", hideTimeout);	
}

function MM_menuHideMenus() {
	MM_menuResetTimeout();
	if(mmOpenContainer) {
		var c = document.getElementById(mmOpenContainer);
		c.style.visibility = "inherit";
		mmOpenContainer = null;
	}
	if( mmOpenMenus ) {
		for(var i in mmOpenMenus) {
			var m = document.getElementById(mmOpenMenus[i]);
			m.style.visibility = "hidden";			
		}
		mmOpenMenus = null;
	}
}

function MM_menuHideSubmenus(menuName) {
	if( mmOpenMenus ) {
		var h = false;
		var c = 0;
		for(var i in mmOpenMenus) {
			if( h ) {
				var m = document.getElementById(mmOpenMenus[i]);
				m.style.visibility = "hidden";
			} else if( mmOpenMenus[i] == menuName ) {
				h = true;
			} else {
				c++;
			}
		}
		mmOpenMenus.length = c+1;
	}
}

function MM_menuOverMenuItem(menuName, subMenuSuffix) {
	MM_menuResetTimeout();
	MM_menuHideSubmenus(menuName);
	if( subMenuSuffix ) {
		var subMenuName = "" + menuName + "_" + subMenuSuffix;
		MM_menuShowSubMenu(subMenuName);
	}
}

function MM_menuShowSubMenu(subMenuName) {
	MM_menuResetTimeout();
	var e = document.getElementById(subMenuName);
	e.style.visibility = "inherit";
	if( !mmOpenMenus ) {
		mmOpenMenus = new Array;
	}
	mmOpenMenus[mmOpenMenus.length] = "" + subMenuName;
}

function MM_menuResetTimeout() {
	if (mmHideMenuTimer) clearTimeout(mmHideMenuTimer);
	mmHideMenuTimer = null;
}

function MM_menuShowMenu(containName, menuName, xOffset, yOffset, triggerName) {
	MM_menuHideMenus();
	MM_menuResetTimeout();
	MM_menuShowMenuContainer(containName, xOffset, yOffset, triggerName);
	MM_menuShowSubMenu(menuName);
}

function MM_menuShowMenuContainer(containName, x, y, triggerName) {	
	var c = document.getElementById(containName);
	var s = c.style;
	s.visibility = "inherit";
	
	mmOpenContainer = "" + containName;
}

function newMark(y,m,d)
{
	oldDay = new Date(y+"/"+m+"/"+d);
	newDay = new Date();
	n = (newDay - oldDay)/(1000*60*60*24);
	if ((n <= 4) && (n > 0)) document.write("<span class=\"icon\">更新</span>");
}

function book_pcOpener(URL){
	w = window.open(URL,"","fullscreen=1,scrollbars");
		w.focus();

//			w = window.open(URL,"book_pc","fullscreen=1,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes");

	}
function book_pdaOpener(URL) {
		w2 = window.open(URL,"book_pda","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,width=400,height=490");
		w2.focus();
	}

function getCountDownDay( dyear, dmonth, ddate,mode ){
    
    today     = new Date( );         // 現在の時を取得するオブジェクト生成
    monthName = new Array("Jan","Feb","Mar","Apr","May","Jun",
                          "Jul","Aug","Sep","Oct","Nov","Dec");
    endDay    = monthName[dmonth-1] + " " + ddate + "," + dyear;
                                     // 指定した日付
    endToday  = new Date(endDay);    // 指定した日付のオブジェクト生成
    dayCount  = 24 * 60 * 60 * 1000; // 一日
    countDay  = (endToday.getTime() - today.getTime()) / dayCount;
                                     // 日付の差分を求める

    if(mode){
	    r_date_img = '<a href="http://e-morning.jp/chi" target="_blank"><img alt="アニメ化" src="./image/main_chich_cnt_0.gif" width="160" height="240" /></a>';
    }else{
	if(Math.ceil(countDay) == 11 ){
	    r_date_img = '<a href="http://e-morning.jp/chi/" ><img alt="" src="./morning/image/001.jpg" width="311" height="180" /></a>';
	}
	else if(Math.ceil(countDay) == 12 ){
	    r_date_img = '<a href="http://e-morning.jp/chi/" ><img alt="" src="./morning/image/001.jpg" width="311" height="180" /></a>';
	}
	else if(Math.ceil(countDay) == 13 ){
	    r_date_img = '<a href="http://e-morning.jp/chi/" ><img alt="" src="./morning/image/001.jpg" width="311" height="180" /></a>';
	}
	else if(Math.ceil(countDay) == 3 ){
	    r_date_img = '<a href="http://e-morning.jp/chi/" ><img alt="" src="./morning/image/001.jpg" width="311" height="180" /></a>';
	}
	else if(Math.ceil(countDay) == 4 ){
	    r_date_img = '<a href="http://e-morning.jp/chi/" ><img alt="" src="./morning/image/001.jpg" width="311" height="180" /></a>';
	}
	else if(Math.ceil(countDay) == -3 ){
	    r_date_img = '<a href="http://e-morning.jp/chi/" ><img alt="" src="./morning/image/001.jpg" width="311" height="180" /></a>';
	}
	else if(Math.ceil(countDay) == -4 ){
	    r_date_img = '<a href="http://e-morning.jp/chi/" ><img alt="" src="./morning/image/001.jpg" width="311" height="180" /></a>';
	}
	else{
	    r_date_img = '<a href="http://e-1day.jp/morning/magazine/"  ><img alt="サイトマップ" src="/morning/image/001.jpg" width="311" height="180" /></a>';
	}
    }
    return (r_date_img);    // 切り上げる
}


// おりたたみ

function change(Name){
tMenu=(document.all)?document.all(Name).style:document.getElementById(Name).style;
if(tMenu.display == "none" ){
tMenu.display = "block";
} else {
tMenu.display = "none";
}
}

/************** ロールオーバー090430移転時追加 **************/

function initRollovers() {
if (!document.getElementById) return

var aPreLoad = new Array();
var sTempSrc;
var aImages = document.getElementsByTagName('img');

for (var i = 0; i < aImages.length; i++) { 
if (aImages[i].className == 'imgover') {
var src = aImages[i].getAttribute('src');
var ftype = src.substring(src.lastIndexOf('.'), src.length);
var hsrc = src.replace(ftype, '_over'+ftype);

aImages[i].setAttribute('hsrc', hsrc);

aPreLoad[i] = new Image();
aPreLoad[i].src = hsrc;

aImages[i].onmouseover = function() {
sTempSrc = this.getAttribute('src');
this.setAttribute('src', this.getAttribute('hsrc'));
} 

aImages[i].onmouseout = function() {
if (!sTempSrc) sTempSrc = this.getAttribute('src').replace 
('_o'+ftype, ftype);
this.setAttribute('src', sTempSrc);
}
}
}
}

window.onload = initRollovers;


