/*
####################################################################################################
# Default JavaScript (Common Function Libraries)
# JavaScript coding: curious epicurean; vincent.
# Copyright (c) 2005 Art Studio Vincent All rights reserved.
####################################################################################################
*/

function setCookie (name, value, expires, path, domain, secure) {
	var curCookie = name + "=" + escape(value) + (expires ? "; expires=" + expires : "") +
	(path ? "; path=" + path : "") + (domain ? "; domain=" + domain : "") + (secure ? "secure" : "");
    document.cookie = curCookie;
}

function getCookie (name) {
    var prefix = name + '=';
    var c = document.cookie;
    var nullstring = '';
    var cookieStartIndex = c.indexOf(prefix);
    if (cookieStartIndex == -1)
		return nullstring;
    var cookieEndIndex = c.indexOf(";", cookieStartIndex + prefix.length);
    if (cookieEndIndex == -1)
		cookieEndIndex = c.length;
	return unescape(c.substring(cookieStartIndex + prefix.length, cookieEndIndex));
}

function deleteCookie (name, path, domain) {
    if (getCookie(name))
		document.cookie = name + "=" + ((path) ? "; path=" + path : "") +
		((domain) ? "; domain=" + domain : "") + "; expires=Thu, 01-Jan-70 00:00:01 GMT";
}

var baseUri = 'http://fillmore-mosrite.jp/';
var blogUri = 'http://fillmore-mosrite.jp/blog/';
var blogID = 2
var gtm = new Date();
var year = gtm.getYear()+1900;
var month = gtm.getMonth()+1;
month = (month < 10) ? '0'+month : month;
var cookieValue = year+'/'+month;

setCookie('AjaxCal'+blogID, cookieValue, '', '/', baseUri);



// reloads the window if Nav4 resized
function reloadPage(init) {
	if (init == true) with (navigator) {
		if ((appName == "Netscape") && (parseInt(appVersion) == 4)) {
			document.pgW = innerWidth;
			document.pgH = innerHeight;
			onresize = reloadPage;
		}
	}
	else if (innerWidth != document.pgW || innerHeight != document.pgH) {
		location.reload();
	}
}
reloadPage(true);

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

function preloadImages() {
	var d = document;
	if (d.images) {
		if (!d.p) d.p = new Array();
		var i, j = d.p.length, a = preloadImages.arguments;
		for (i = 0; i < a.length; i++)
		if (a[i].indexOf("#") != 0) {
			d.p[j] = new Image; d.p[j++].src = a[i];
		}
	}
}

function findObj(n, d) {
	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 = findObj(n,d.layers[i].document);
	if (!x && d.getElementById)
	x = d.getElementById(n);
	return x;
}

function swapImage() {
	var i, j = 0, x, a = swapImage.arguments;
	document.sr = new Array;
	for (i = 0; i < (a.length-2); i += 3)
	if ((x = findObj(a[i])) != null) {
		document.sr[j++] = x;
		if (!x.oSrc) x.oSrc = x.src; x.src = a[i+2];
	}
}

function showHideLayers() {
	var i, p, v, obj, args = showHideLayers.arguments;
	for (i = 0; i < (args.length-2); i += 3)
	if ((obj = findObj(args[i])) != null) {
		v = args[i+2];
		if (obj.style) {
			obj = obj.style;
			v = (v == 'show') ? 'visible' : (v == 'hide') ? 'hidden' : v;
		}
		obj.visibility = v;
	}
}

// display pull down
function displayPullDown(id) {
	var obj =
	(document.getElementById) ? document.getElementById(id).style :
	(document.all) ? document.all(id).style : null;
	obj.display = (obj.display == 'block') ? 'none' : 'block';
}

preloadImages(
);

/* open popup window */
function popupWindow(url, winName, w, h, sb, rs, st) {
	var leftPos, topPos, property;
	leftPos = (screen.availWidth)  ? parseInt((screen.availWidth-w)/2) : 0;
	topPos  = (screen.availHeight) ? parseInt((screen.availHeight-h)/2) : 0;
	property = 'width='+w+',height='+h+',left='+leftPos+',top='+topPos+',';
	property+= 'toolbar=0,location=0,directories=0,menubar=0,';
	property+= 'scrollbars='+sb+',resizable='+rs+',status='+st;
	winName = window.open(url,winName,property);
	self.onBlur = winName.focus();
}



// user-defined object check
// NS4=1, IE4=2, IE5+=3, NS6=4, others=0
var checkObj = document.all?(document.getElementById?3:2):(document.getElementById?4:(document.layers?1:0));

function getWindowXOffset() {
	if (checkObj == 2 || checkObj == 3) {
		return document.body.scrollLeft;
	} else if (checkObj == 1 || checkObj == 4) {
		return window.pageXOffset;
	} else {
		return 0;
	}
}

function getWindowYOffset() {
	if (checkObj == 2 || checkObj == 3) {
		return document.body.scrollTop;
	} else if (checkObj == 1 || checkObj == 4) {
		return window.pageYOffset;
	} else {
		return 0;
	}
}

// Page Scroller
var pageScrollTimer;
function pageScroll(toX,toY,frms,cuX,cuY) {
	if (pageScrollTimer) clearTimeout(pageScrollTimer);
	if (!toX || toX < 0) toX = 0;
	if (!toY || toY < 0) toY = 0;
	if (!cuX) cuX = 0 + getWindowXOffset();
	if (!cuY) cuY = 0 + getWindowYOffset();
	if (!frms) frms = 6;

	cuX += (toX - getWindowXOffset()) / frms;
	if (cuX < 0) cuX = 0;
	cuY += (toY - getWindowYOffset()) / frms;
	if (cuY < 0) cuY = 0;
	posX = Math.floor(cuX);
	posY = Math.floor(cuY);
	window.scrollTo(posX, posY);
	if (posY < 1) {
		window.scroll(0,0);
	} else if (posX != toX || posY != toY) {
		pageScrollTimer = setTimeout("pageScroll("+toX+","+toY+","+frms+","+cuX+","+cuY+")",16);
	} else {
		clearTimeout(pageScrollTimer);
	}
}

function toAnchor(idName) {
	if (checkObj == 1 || checkObj == 2 || checkObj == 3 || checkObj == 4) {
		if (!!idName) {
			anchorX = 0;
			anchorY = getTagTop(idName);
			mouseX = getWindowXOffset();
			mouseY = getWindowYOffset();
			endY = endPositionY();
			if (anchorY < 1) {
				location.hash = idName;
			} else if (anchorY > endY) {
				pageScroll(anchorX,endY,6,mouseX,mouseY);
			} else {
				pageScroll(anchorX,anchorY,6,mouseX,mouseY);
			}
		} else {
			pageScroll(0,0,6);
		}
	} else {
		if (!!idName) {
			location.hash = idName;
		} else {
			location.hash = "top";
		}
	}
}
