/* rolloverimg */
function rollOverImg(elId, tagName) {
	var el = document.getElementById(elId).getElementsByTagName(tagName);

	for (i=0; i<el.length; i++) {
		  if (el[i].src.substring(el[i].src.indexOf(".gif"))
				||el[i].src.substring(el[i].src.indexOf("_on.gif"))) {
				el[i].onmouseover = changeOver;
				el[i].onclick = changeOver;

				
				el[i].parentNode.onfocus = changeFocus;
				el[i].onmouseout = changeOut;
		}
	}
}

function buttonOverImg(elId, tagName) {
	var el = document.getElementById(elId).getElementsByTagName(tagName);
	for (i=0; i<el.length; i++) {
		  if (el[i].src.substring(el[i].src.indexOf(".gif"))
				||el[i].src.substring(el[i].src.indexOf("_on.gif"))) {
				el[i].onmouseover = changeOver;
				//el[i].parentNode.onfocus = changeFocus;
				el[i].onmouseout = changeOut;
		}
	}
}

function changeOver() {
	this.src=this.src.replace(".gif", "_on.gif");
}

function changeOut() {
  this.src=this.src.replace("_on.gif", ".gif");
}

function changeFocus() {
  this.childNodes[0].src=this.childNodes[0].src.replace("_on.gif", ".gif");
}

function tabContents(tabContainerID, tagName) {
	var tabContainer = document.getElementById(tabContainerID);
	var tabAnchor = tabContainer.getElementsByTagName(tagName);
	var i = 0;
	for(i=0; i<tabAnchor.length; i++) {
		if (tabAnchor.item(i).className == "tablist")
			thismenu = tabAnchor.item(i);
		else
			continue;
		thismenu.container = tabContainer;
		thismenu.targetEl = document.getElementById(tabAnchor.item(i).href.split("#")[1]);
		thismenu.targetEl.style.display = "none";
		thismenu.imgEl = thismenu.getElementsByTagName("img").item(0);
		thismenu.onclick = function tabMenuClick() {
			currentmenu = this.container.current;
			if (currentmenu == this)
				return false;
			if (currentmenu) {
				currentmenu.targetEl.style.display = "none";
				if (currentmenu.imgEl) {
					currentmenu.imgEl.src = currentmenu.imgEl.src.replace(/_on.gif$/, ".gif");
					currentmenu.imgEl.src = currentmenu.imgEl.src.replace(/_on.png$/, ".png");
				} else {
					currentmenu.className = currentmenu.className.replace(" selected", "");
				}
			}
			this.targetEl.style.display = "";
			if (this.imgEl) {
				this.imgEl.src = this.imgEl.src.replace(/.gif$/, "_on.gif");
				this.imgEl.src = this.imgEl.src.replace(/.png$/, "_on.png");
			} else {
				this.className += " selected";
			}
			this.container.current = this;
			return false;
		};
		if (!thismenu.container.first) thismenu.container.first = thismenu;
	}
	if (tabContainer.first)	tabContainer.first.onclick();
}

/* recent data scrole*/
function initMoving(target, position, topLimit, btmLimit) {
	    if (!target)
	        return false;

	    var obj = target;
	    obj.initTop = position;
	    obj.topLimit = topLimit;
	    obj.bottomLimit = document.documentElement.scrollHeight - btmLimit;

	    obj.style.position = "absolute";
	    obj.top = obj.initTop;
	    obj.left = obj.initLeft;

	    if (typeof(window.pageYOffset) == "number") {
	        obj.getTop = function() {
	            return window.pageYOffset;
	        }
	    } else if (typeof(document.documentElement.scrollTop) == "number") {
	        obj.getTop = function() {
	            return document.documentElement.scrollTop;
	        }
	    } else {
	        obj.getTop = function() {
	            return 0;
	        }
	    }

	    if (self.innerHeight) {
	    	obj.getHeight = function() {
	            return self.innerHeight;
	        }
	    } else if(document.documentElement.clientHeight) {
	        obj.getHeight = function() {
            return document.documentElement.clientHeight;
	        }
	    } else {
	        obj.getHeight = function() {
	            return 500;
	        }
	    }

	    obj.move = setInterval(function() {
	        if (obj.initTop > 0) {
	            pos = obj.getTop() + obj.initTop;
	        } else {
	            pos = obj.getTop() + obj.getHeight() + obj.initTop;
	            pos = obj.getTop() + obj.getHeight() / 2 - 15;
	        }

	        if (pos > obj.bottomLimit)
	            pos = obj.bottomLimit;
	        if (pos < obj.topLimit)
	            pos = obj.topLimit;

	        interval = obj.top - pos;
	        obj.top = obj.top - interval / 3;
	        obj.style.top = obj.top + "px";
	    }, 30)
	}



// family site
function familysite(familyID) {
	var title = document.getElementById(familyID).getElementsByTagName('h5')[0].getElementsByTagName('a')[0];
	var family_list = document.getElementById('family_list');
	family_list.style.display = "none";

	var option = family_list.getElementsByTagName('a');
	title.onclick = function() {
		if (family_list.style.display == "block") {
			family_list.style.display = "none";
		} else {
			family_list.style.display = "block";
		}
		this.onmouseout = function(){
			family_list.style.display = "none";
		}
		return false;
	}
	family_list.onmouseover = function(){
		this.style.display = "block";
	}
	family_list.onmouseout = function(){
		this.style.display = "none";
	}
	for (i=0; i < option.length; i++){
		option[i].onfocus = function(){
			family_list.style.display = "block";
		}
		option[option.length-1].onblur = function(){
			family_list.style.display = "none";
		}
	}
}


function closeMrix(target) {
		var matrix = document.getElementById(target);
		var openbar = document.getElementById('open');
		
		matrix.style.display = "none";
		openbar.style.display ="block";
		
	}
function openMrix(target) {
		var matrix = document.getElementById(target);
		var openbar = document.getElementById('open');
		
		matrix.style.display = "block";
		openbar.style.display ="none";
		
	}


// search select

function search_option () {

	var title = document.getElementById('search_value');

	var value = title.childNodes[0].nodeValue;

	var list = document.getElementById('option_list');

	var list_option = list.getElementsByTagName('a');

	title.onclick = function () {

		list.style.display = "block";

		return false; 

	}

	list.onmouseover = function() {

		this.style.display = "block";

	}

	list.onmouseout = function() {

		this.style.display = "none";

	}

	for (i=0; i < list_option.length; i++) {

		list_option[i].onclick = function () {

			title.childNodes[0].nodeValue = this.childNodes[0].nodeValue;

			list.style.display = "none";

			return false;

		}

	}

}

function isNumber(ch) {
	var numUnicode = ch.charCodeAt(0);
	
	if(48<=numUnicode && numUnicode <= 57) return true;
	return false;
}
