// sidemenuModule
function menuSide(){

document.write("<h2 class='about'>about</h2>");
document.write("<p>Hello, WORLD!<br />");
document.write("<em>mupiri.com</em> is the online farmland cultivated since 1999 by <a href='/about'>mupiri</a>, a graphic designer/illustrator/FOX freak based in Tokyo. This website was recently re-launched and is still under constraction.<br />");
document.write("<a href='/about'>more</a></p>");

document.write("<a href='http://feeds.feedburner.jp/mupiri' class='rssfeed'>Subscribe my RSS</a>");

document.write("<h2 class='category'>category</h2>");
document.write("<ul class='side-list'>");
document.write("<li><a href='/archive/diary'>Diary</a></li>");
document.write("<li><a href='/archive/freebies'>Freebies</a></li>");
document.write("<li><a href='/archive/updates'>News &amp; Updates</a></li>");
document.write("<li>Inspiration</li>");
document.write("<li>I need to know</li>");
document.write("</ul>");

document.write("<h2 class='mobile'>mobile</h2>");
document.write("<p><img src='/theme_olive/qrcode.gif' width='111' height='111' alt='QR code for mobile' /></p>");

document.write("<h2 class='other'>other posts</h2>");
document.write("<ul class='side-list'>");
document.write("<li><a href='http://www.youtube.com/mupiri' title='YouTube' target='_blank'>YouTube</a></li>");
document.write("<li><a href='http://mixi.jp/show_friend.pl?id=616053' title='mixi' target='_blank'>mixi</a></li>");
document.write("</ul>");

document.write("<h2 class='favs'>friends/favorites</h2>");
document.write("<ul class='side-list'>");
document.write("<li><a href='http://www3.alpha-net.ne.jp/users/murapon/' title='Esmralda Net/this website is the origin of my all. must read!' target='_blank'>Esmralda Net</a></li>");
document.write("<li><a href='http://www.t3.rim.or.jp/~jinjin/' title='Pachinko MANIAC WORLD/does not matter what you like playing PACHINKO or not.' target='_blank'>Pachinko MANIAC WORLD</a></li>");
document.write("<li><a href='http://www.plan-japan.org/' title='Plan Japan/we have some positive means for relief of children.' target='_blank'>Plan Japan</a></li>");
document.write("<li><a href='http://www.unicef.org/' title='UNICEF/we must consider protecting children from hungry, violence, abuse and explotation.' target='_blank'>UNICEF</a></li>");
document.write("<li><a href='http://www.amnesty.org/' title='Amnesty International/we need to learn more about human rights.' target='_blank'>Amnesty International</a></li>");
document.write("<li><a href='http://www.tibet.net/' title='Tibet Net/The Official Website Of The Central Tibetan Adoministration' target='_blank'>Tibet Net</a></li>");
document.write("<li><a href='http://www.riverbendblog.blogspot.com/' title='Baghdad Burning/a real life in baghdad goes on.' target='_blank'>Baghdad Burning</a></li>");
document.write("</ul>");
}

// formModule
function contactMe(){
document.write("<div id='commentform'>");
document.write("<form action='http://vcgi.mmjp.or.jp/cgi-bin/formdecode.cgi' method='post' />");
document.write("<input type='hidden' name='_to' value='mupiri@mupiri.com' />");
document.write("<input type='hidden' name='_subject' value='HATAKE MESSAGE' />");
document.write("<input type='hidden' name='_accept_url' value='http://www.mupiri.com/contact/accept.html' />");
document.write("<label for='name'>name</label><br /><input type='text' name='name' id='name' size='22' /><br />");
document.write("<label for='email'>email</label><br /><input type='text' name='_from' id='email' size='22' /><br />");
document.write("<label for='message'>message</label><br /><textarea name='message' id='message' cols='40' rows='10'></textarea><br />");
document.write("<input name='submit' type='submit' id='submit' value=' ' />");
document.write("</form>");
document.write("</div>");
}

// copyRightModule
function copyRight(){
document.write("<p>&copy; 1999-2008 <em>mupiri.com</em> All rights reserved.</p>");
}


// scrollerModule
Scroller = {
	// control the speed of the scroller.
	// dont change it here directly, please use Scroller.speed=50;
	speed:10,

	// returns the Y position of the div
	gy: function (d) {
		gy = d.offsetTop
		if (d.offsetParent) while (d = d.offsetParent) gy += d.offsetTop
		return gy
	},

	// returns the current scroll position
	scrollTop: function (){
		body=document.body
	    d=document.documentElement
	    if (body && body.scrollTop) return body.scrollTop
	    if (d && d.scrollTop) return d.scrollTop
	    if (window.pageYOffset) return window.pageYOffset
	    return 0
	},

	// attach an event for an element
	// (element, type, function)
	add: function(event, body, d) {
	    if (event.addEventListener) return event.addEventListener(body, d,false)
	    if (event.attachEvent) return event.attachEvent('on'+body, d)
	},

	// kill an event of an element
	end: function(e){
		if (window.event) {
			window.event.cancelBubble = true
			window.event.returnValue = false
      		return;
    	}
	    if (e.preventDefault && e.stopPropagation) {
	      e.preventDefault()
	      e.stopPropagation()
	    }
	},
	
	// move the scroll bar to the particular div.
	scroll: function(d){
		i = window.innerHeight || document.documentElement.clientHeight;
		h=document.body.scrollHeight;
		a = Scroller.scrollTop()
		if(d>a)
			if(h-d>i)
				a+=Math.ceil((d-a)/Scroller.speed)
			else
				a+=Math.ceil((d-a-(h-d))/Scroller.speed)
		else
			a = a+(d-a)/Scroller.speed;
		window.scrollTo(0,a)
	  	if(a==d || Scroller.offsetTop==a)clearInterval(Scroller.interval)
	  	Scroller.offsetTop=a
	},
	// initializer that adds the renderer to the onload function of the window
	init: function(){
		Scroller.add(window,'load', Scroller.render)
	},

	// this method extracts all the anchors and validates then as # and attaches the events.
	render: function(){
		a = document.getElementsByTagName('a');
		Scroller.end(this);
		window.onscroll
	    for (i=0;i<a.length;i++) {
	      l = a[i];
	      if(l.href && l.href.indexOf('#') != -1 && ((l.pathname==location.pathname) || ('/'+l.pathname==location.pathname)) ){
	      	Scroller.add(l,'click',Scroller.end)
	      		l.onclick = function(){
	      			Scroller.end(this);
		        	l=this.hash.substr(1);
		        	 a = document.getElementsByTagName('a');
				     for (i=0;i<a.length;i++) {
				     	if(a[i].name == l){
				     		clearInterval(Scroller.interval);
				     		Scroller.interval=setInterval('Scroller.scroll('+Scroller.gy(a[i])+')',10);
						}
					}
				}
	      	}
		}
	}
}
// invoke the initializer of the scroller
Scroller.init();


// tooltipModule
var GLT = {
	// Customization parameters
	titleClassName : "glt-elm",	
	topImagePath : "/theme_olive/tooltip_top.gif",
	bottomImagePath : "/theme_olive/tooltip_bottom.gif",
	suppressAltTooltipsInIE : true,
	timeBeforeShow : 500,
	titleOffsetX : 10,
	titleOffsetY : -10,
	fadeInTitle : true,
	fadeOutTitle : true,
	fadeStartLevel : 0.5,
	originalFadeLevel : 0.9,
	fadeIncrement : 0.1,
	timePerFadeStep : 100,
	
	// GLT parameters
	titleElm : null,
	titleTextElm : null,
	titleTopImage : null,
	titleBottomImage : null,
	elementsWithTitles : null,
	currentElm : null,
	currentTitle : "",
	currentFadeLevel : 0,
	fadeTimer : null,
	
	init : function (){
		if(document.getElementById){
			this.elementsWithTitles = getElementsByAttribute(document, "*", "title");
			if(this.elementsWithTitles.length > 0){
				this.titleElm = document.createElement("div");
				this.titleElm.className = this.titleClassName;
				if(this.topImagePath){
					this.titleTopImage = document.createElement("img");
					this.titleTopImage.setAttribute("src", this.topImagePath);
					this.titleElm.appendChild(this.titleTopImage);
				}				
				this.titleTextElm = document.createElement("p");
				this.titleElm.appendChild(this.titleTextElm);
				if(this.bottomImagePath){
					this.titleBottomImage = document.createElement("img");
					this.titleBottomImage.setAttribute("src", this.bottomImagePath);
					this.titleElm.appendChild(this.titleBottomImage);
				}
				document.body.appendChild(this.titleElm);
				this.useMSFilter = typeof this.titleElm.style.filter != "undefined";
				this.applyEvents();
			}			
		}
	},
	
	applyEvents : function (){
		var oElm;
		var strClassName;
		for(var i=0; i<this.elementsWithTitles.length; i++){
			oElm = this.elementsWithTitles[i];
			if(this.suppressAltTooltipsInIE){
				oElm.setAttribute("alt", "");
			}
			oElm.onmouseover = GLT.mouseOverElm;
			oElm.onmouseout = GLT.mouseOutElm;
		}
	},
	
	mouseOverElm : function (oEvent){
		var oEvent = (typeof oEvent != "undefined")? oEvent : event;
		if(typeof GLT != "undefined"){
			GLT.startTimer(this, oEvent);
			oEvent.cancelBubble = true;
			oEvent.returnValue = false;
			if(oEvent.stopPropagation){
				oEvent.stopPropagation();
			}
		}
	},
	
	mouseOutElm : function (oEvent){
		var oEvent = (typeof oEvent != "undefined")? oEvent : event;
		if(typeof GLT != "undefined"){
			GLT.hideTitle(this, oEvent);
		}
	},
	
	startTimer : function (oElm, oEvent){
		if(!this.currentElm || this.currentElm != oElm || this.fadeTimer > 0){
			if(this.fadeTimer){
				clearTimeout(this.fadeTimer);
			}	
			if(this.currentElm){
				this.hideTitle(null, false, true);
			}
			this.currentElm = oElm;
			this.currentTitle = this.currentElm.getAttribute("title");
			this.currentElm.setAttribute("title", "");
			this.currentX = oEvent.clientX;
			this.currentY = oEvent.clientY;
			this.fadeTimer = setTimeout("GLT.showTitle()", GLT.timeBeforeShow);
		}
    },
	
	stopTimer : function (oElm){
		clearTimeout(GLT.fadeTimer);
    },
	
	showTitle : function (){
		this.setTitlePos();
		this.titleTextElm.innerHTML = this.currentTitle;
		this.titleElm.style.visibility = "visible";
		if(this.fadeInTitle){
			this.currentFadeLevel = this.fadeStartLevel;
			this.fadeIn();
		}
	},
	
	hideTitle : function (oElm, oEvent, forceHide){		
		if(this.currentElm && (oElm || forceHide)){
			var bIsChildOfCurrentElm = false;
			if(typeof oEvent != "undefined" && typeof oEvent == "object"){
				var oEventTarget = (typeof oEvent.relatedTarget != "undefined")? oEvent.relatedTarget : oEvent.toElement;
				if(oEventTarget){
					while(!bIsChildOfCurrentElm && oEventTarget && oEventTarget.nodeName && oEventTarget.nodeName.search(/body/i) == -1){
						if(oEventTarget == oElm){
							bIsChildOfCurrentElm = true;
							break;
						}
						oEventTarget = oEventTarget.parentNode;
					}
				}
			}
			if(!bIsChildOfCurrentElm){
				this.stopTimer();
				if(this.fadeOutTitle && (typeof forceHide == "undefined" || !forceHide)){
					this.fadeOut();
				}
				else{
					clearTimeout(this.fadeTimer);
					this.currentElm.setAttribute("title", this.currentTitle);
					this.currentElm = null;
					this.titleElm.style.visibility = "hidden";
				}
			}
		}
	},
	
	setTitlePos : function (){	
		var arrScroll = this.getWinSizeAndScroll();
		var intTitleElmWidthAndPos = this.titleElm.offsetWidth + this.currentX + this.titleOffsetX;
		var intDiff = intTitleElmWidthAndPos - arrScroll[0];
		var intX = (intDiff > 0)? (this.currentX - intDiff) : (this.currentX + this.titleOffsetX);
		this.titleElm.style.left = intX + arrScroll[2] + "px";
		this.titleElm.style.top = this.currentY + arrScroll[3] + this.titleOffsetY + "px";
	},
	
	fadeIn : function (fadeOut){
		this.currentFadeLevel = this.currentFadeLevel + this.fadeIncrement;
		if(this.currentFadeLevel < this.originalFadeLevel){
			this.fadeTimer = setTimeout("GLT.fadeIn()", GLT.timePerFadeStep);
		}
		else{
			this.currentFadeLevel = this.originalFadeLevel;
			clearTimeout(this.fadeTimer);
		}
		this.setFade();
	},
	
	fadeOut : function (){
		this.currentFadeLevel = this.currentFadeLevel - this.fadeIncrement;
		if(this.currentFadeLevel > this.fadeStartLevel){
			this.fadeTimer = setTimeout("GLT.fadeOut()", GLT.timePerFadeStep);
		}
		else{
			this.currentFadeLevel = this.originalFadeLevel;
			this.hideTitle(null, false, true);
		}
		this.setFade();
	},
	
	setFade : function (){
		// This line is b/c of a floating point bug in JavaScript
		this.currentFadeLevel = Math.round(this.currentFadeLevel * 10) / 10;
		if(this.titleElm){
			if(this.useMSFilter){
				this.titleElm.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=" + (this.currentFadeLevel * 100) + ")";
			}
			else{
				this.titleElm.style.opacity = this.currentFadeLevel;
			}
		}
	},
	
	getWinSizeAndScroll : function (){
		var intWidth = document.body.offsetWidth;
		var intHeight = (typeof window.innerHeight != "undefined")? window.innerHeight : (document.documentElement && document.documentElement.clientHeight > 0)? document.documentElement.clientHeight : document.body.clientHeight;		
		var intXScroll = (typeof window.pageXOffset != "undefined")? window.pageXOffset : document.body.scrollLeft;		
		var intYScroll = (typeof window.window.pageYOffset != "undefined")? window.window.pageYOffset : (document.documentElement && document.documentElement.scrollTop > 0)? document.documentElement.scrollTop : document.body.scrollTop;
		return [intWidth, intHeight, intXScroll, intYScroll];
	},
	
	closeSession : function (oEvent){		
		this.removeEvent(window, "load", function(){GLT.init();}, false);
		GLT = null;
		delete GLT;
	},
	
	addEvent : function (oObject, strEvent, oFunction, bCapture){
		if(oObject){
			if(oObject.addEventListener){
				oObject.addEventListener(strEvent, oFunction, bCapture);
			}
			else if(window.attachEvent){
				oObject.attachEvent(("on" + strEvent), oFunction)
			}
		}
	},

	removeEvent : function (oObject, strEvent, oFunction, bCapture){
		if(oObject){
			if(oObject.removeEventListener){
				oObject.removeEventListener(strEvent, oFunction, false);
			}
			else if(window.detachEvent){
				oObject.detachEvent(("on" + strEvent), oFunction)
			}
		}
	}
};
// ---
GLT.addEvent(window, "load", function(){GLT.init();}, false);
// ---
// Utility functions
// ---
function getElementsByAttribute(oElm, strTagName, strAttributeName, strAttributeValue){
	var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName);
	var arrReturnElements = new Array();
	var oAttributeValue = (typeof strAttributeValue != "undefined")? new RegExp("(^|\\s)" + strAttributeValue + "(\\s|$)") : null;
	var oCurrent;
	var oAttribute;
	for(var i=0; i<arrElements.length; i++){
		oCurrent = arrElements[i];
		oAttribute = oCurrent.getAttribute && oCurrent.getAttribute(strAttributeName);
		if(typeof oAttribute == "string" && oAttribute.length > 0){
			if(typeof strAttributeValue == "undefined" || (oAttributeValue && oAttributeValue.test(oAttribute))){
				arrReturnElements.push(oCurrent);
			}
		}
	}
	return arrReturnElements;
}
// ---
if(typeof Array.prototype.push != "function"){
	Array.prototype.push = ArrayPush;
	function ArrayPush(value){
		this[this.length] = value;
	}
}
// ---

