// detect browser type
var dom = (document.getElementById) ? true : false;
var ns4 = (document.layers && !dom) ? true : false;
var ie4 = (document.all && !dom) ? true : false;

// show element
function show(id) {
	if (ns4) {
		if (document.layers[id]) {
			document.layers[id].visibility = "show";
			document.layers[id].display = "block";
		}
	} else if (ie4) {
		if (document.all[id]) {
			document.all[id].style.visibility = "visible";
			document.all[id].style.display = "block";
		}
	} else if (dom) {
		if (document.getElementById(id)) {
			document.getElementById(id).style.visibility = "visible";
			document.getElementById(id).style.display = "block";
		}
	}
}

// hide element
function hide(id) {
	if (ns4) {
		if (document.layers[id]) {
			document.layers[id].visibility = "hide";
			document.layers[id].display = "none";
		}
	} else if (ie4) {
		if (document.all[id]) {
			document.all[id].style.visibility = "hidden";
			document.all[id].style.display = "none";
		}
	} else if (dom) {
		if (document.getElementById(id)) {
			document.getElementById(id).style.visibility = "hidden";
			document.getElementById(id).style.display = "none";
		}
	}
}

// hide multiple div, beginning with 'pre' as prefix and a number
function hideMulti(pre, start, end) {
	var s, i;
	for (i=start; i<=end; i++) {
		s = pre+''+i;
		hide(s);
	}
}

// show a div if it is visible, hide it if it is hidden
function toggle(id) {
	if (ns4) {
		if (document.layers[id]) {
			if (document.layers[id].visibility == "hide" || document.layers[id].display == "none")
				show(id);
			else
				hide(id);
		}
	} else if (ie4) {
		if (document.all[id]) {
			if (document.all[id].style.visibility == "hidden" || document.all[id].style.display == "none")
				show(id);
			else
				hide(id);
		}
	} else if (dom) {
		if (document.getElementById(id)) {
			if (document.getElementById(id).style.visibility == "hidden" || document.getElementById(id).style.display == "none")
				show(id);
			else
				hide(id);
		}
	}
}

/*--------------------------------------------------------------------------*
 *  
 *  footerFixed.js
 *  
 *  MIT-style license. 
 *  
 *  2007 Kazuma Nishihata [to-R]
 *  http://blog.webcreativepark.net
 *  
 *--------------------------------------------------------------------------*/

new function(){
	
	var footerId = "footer";
	//メイン
	function footerFixed(){
		// 15/01/2008 OB: add test if footer exists before manipulating it
		var footerEl = null;
		footerEl = document.getElementById(footerId);
		if (footerEl) {
			//ドキュメントの高さ
			var dh = document.getElementsByTagName("body")[0].clientHeight;
			//フッターのtopからの位置
			footerEl.style.top = "0px";
			var ft = footerEl.offsetTop;
			//フッターの高さ
			var fh = footerEl.offsetHeight;
			//ウィンドウの高さ
			if (window.innerHeight){
				var wh = window.innerHeight;
			}else if(document.documentElement && document.documentElement.clientHeight != 0){
				var wh = document.documentElement.clientHeight;
			}
			if(ft+fh<wh){
				footerEl.style.position = "relative";
				footerEl.style.top = (wh-fh-ft-1)+"px";
			}
		}
	}
	
	//文字サイズ
	function checkFontSize(func){
	
		//判定要素の追加	
		var e = document.createElement("div");
		var s = document.createTextNode("S");
		e.appendChild(s);
		e.style.visibility="hidden"
		e.style.position="absolute"
		e.style.top="0"
		document.body.appendChild(e);
		var defHeight = e.offsetHeight;
		
		//判定関数
		function checkBoxSize(){
			if(defHeight != e.offsetHeight){
				func();
				defHeight= e.offsetHeight;
			}
		}
		setInterval(checkBoxSize,1000)
	}
	
	//イベントリスナー
	function addEvent(elm,listener,fn){
		try{
			elm.addEventListener(listener,fn,false);
		}catch(e){
			elm.attachEvent("on"+listener,fn);
		}
	}

	addEvent(window,"load",footerFixed);
	addEvent(window,"load",function(){
		checkFontSize(footerFixed);
	});
	addEvent(window,"resize",footerFixed);
	
}

// clear default value in forms
function doClear(theText) {
	if (theText.value == theText.defaultValue) {
		theText.value = "";
	}
}
// undo clear of default value
function undoClear(theText) {
	if (theText.value == "") {
		theText.value = theText.defaultValue;
	}
}

/* popup */

var sUserAgent = navigator.userAgent.toLowerCase();
var isIE = document.all?true:false;
var isNS4 = document.layers?true:false;
var isOp = (sUserAgent.indexOf('opera')!=-1)?true:false;
var isMoz = (sUserAgent.indexOf('mozilla/5')!=-1 && sUserAgent.indexOf('opera')==-1 && sUserAgent.indexOf('msie')==-1)?true:false;

// ****************************************************************
// Example use:
//   <a href="/foo.htm" onclick="return pop(this,'survey');" title="Survey opens a new window.">Take our survey!</a>
//   <a href="/foo.htm" onclick="return pop(this,'','width=200,height=200');" title="Opens a new window.">Foo</a>
//   <a href="/foo.htm" onclick="return pop(this);" title="Opens a new window.">Foo</a>
// ****************************************************************
function pop(oAnchor,sWindow,sProps){
	var sUrl = '';
	if(oAnchor.getAttribute) sUrl = oAnchor.getAttribute('href');
	if(sUrl=='' && isIE) sUrl = window.event.srcElement.getAttribute('href');
	if(sUrl=='') sUrl = oAnchor.href;
	var sWindowName = sWindow?sWindow:'_blank';
	if(!sProps) sProps = 'width=640,height=480,scrollbars,resizable,toolbar,status,menubar,location';
	if(sUrl) var oPopup = window.open(sUrl,sWindowName,sProps);
	if(oPopup && !isOp) oPopup.focus();
	return (oPopup)?false:true;
}
