
/*---------------------------------------------------------------*/

document.getElementsByClassName = function(ClassName,tagName){
	if(!(this.all || this.getElementsByTagName)) return false;
	var elements=new Array();
	var allElements,i,len;

	if(tagName) allElements= this.getElementsByTagName(tagName) || this.all.tags(tagName);
	else allElements=this.all || this.getElementsByTagName("*");
	for(i=0,len=allElements.length; i<len; i++){
		if(allElements[i].className==ClassName) elements[elements.length]=allElements[i];
	}
	return elements;
}

/*---------------------------------------------------------------*/

function setMouseOver(){
	if(!document.getElementById) return false;
	var i;
	var imgElm =  document.getElementsByClassName("navi","IMG");
	for(i=0;i<imgElm.length;i++){
		if(imgElm[i]==null || imgElm[i].src=="undefined" || !imgElm[i].parentNode.href){
		}else{
			imgElm[i].onmouseover = function(){
				if(!this.src) return false;
				this.imgOrg = this.src;
				var imgSrc;
				imgSrc = this.imgOrg.substr(0,this.imgOrg.lastIndexOf("."));
				imgExt = this.imgOrg.substr(this.imgOrg.lastIndexOf("."));
				this.src = imgSrc + "_o" + imgExt;
			}
			imgElm[i].onmouseout = function(){
				if(!this.imgOrg) return false;
				this.src = this.imgOrg;
			}
		}
	}
}

/*---------------------------------------------------------------*/

function insertCSSRule(selector,styleSet){
	if(!document.getElementById) return false;
	var stlSht=document.styleSheets;
	var lastSht;
	if(stlSht.length){
		lastSht=stlSht[stlSht.length-1];
		if(document.all) lastSht.addRule(selector,styleSet);
		else lastSht.insertRule(selector+"{"+styleSet+"}",lastSht.cssRules.length);
	}
}

/*---------------------------------------------------------------*/

function popwin(url){
	var newwin = window.open(url,'tegami','width=572,height=550,scrollbars=yes,resizable=yes,toolbar=no,directories=no,location=no,menubar=no,status=no');
	newwin.focus();
}

function popPhoto(url){
	var newwin = window.open(url,'popup','width=462,height=495,scrollbars=yes,resizable=yes,toolbar=no,directories=no,location=no,menubar=no,status=no');
	newwin.focus();
}

/*---------------------------------------------------------------*/

function showComment(){
	if(!document.getElementById) return false;
	var entB = document.getElementById("entryBody");
	var comB = document.getElementById("commentBody");
	var comF = document.getElementById("commentForm");

	if((typeof comF == "object") && comF.style) comF.style.display = "block";
	if((typeof entB == "object") && entB.style) entB.style.display = "none";
	if((typeof comB == "object") && comB.style) comB.style.display = "none";
}
function hideComment(){
	if(!document.getElementById) return false;
	var entB = document.getElementById("entryBody");
	var comB = document.getElementById("commentBody");
	var comF = document.getElementById("commentForm");
	
	if((typeof comF == "object") && comF.style) comF.style.display = "none";
	if((typeof entB == "object") && entB.style) entB.style.display = "block";
	if((typeof comB == "object") && comB.style) comB.style.display = "block";
}
function checkComment(){
	if(location.href.indexOf('#commentForm')!=-1){
		showComment();
	}
}


/*---------------------------------------------------------------*/

function disable_links_outline() {
	var blur = function () { this.blur() };
	for (var i = 0; i < document.links.length; i++)
	document.links[i].onfocus = blur;
}

/*---------------------------------------------------------------*/


function printPromotion(){
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" height="308" width="700"><param name="movie" value="topImage.swf" /><param name="quality" value="best" />	<param name="play" value="true" /><embed height="308" pluginspage="http://www.macromedia.com/go/getflashplayer" src="topImage.swf" type="application/x-shockwave-flash" width="700" quality="best" play="true"></embed> </object>');
}

/*---------------------------------------------------------------*/

function addEvent(obj,handle,lstnr) {
	if(obj.addEventListener){
		obj.addEventListener(handle,lstnr,false);
	}else if(obj.attachEvent){
		handle = "on" + handle;
		var oldfunc = obj[handle];
		if(typeof oldfunc != "function"){
			obj[handle] = lstnr;
		}else{
			obj.attachEvent(handle,lstnr);
		}
	}else{ // MacIE
		handle = "on"+handle;
		var oldfunc = obj[handle];
		if(typeof oldfunc != "function"){
			obj[handle] = lstnr;
		}else{
			obj[handle] = function(){oldfunc();lstnr();};
		}
	}
}
window.addOnload = function(lstnr){
	addEvent(window,'load',lstnr);
}
window.addOnload(setMouseOver);
window.addOnload(checkComment);
window.addOnload(disable_links_outline);
/*---------------------------------------------------------------*/
