// JavaScript Document

// window.onload Event
function addLoadEvent(func){
	var oldonload = window.onload;
	
	if(typeof window.onload != 'function'){
		window.onload = func;
		
	}else{
		window.onload = function(){
			oldonload();
			func();
		}
	}
}


function popup_open(url, w, h, idx){
	var top = 0;
	var left = parseInt(document.body.clientWidth/2-150,10);
	window.open(url, idx, "width="+w+", height="+h+"px, top="+top+"px, left="+left+"px, scrollbars=no");
}

function img_rollover(){
	if(!document.getElementById("img_rollover")) return false;
	var source = document.getElementById("img_rollover").getElementsByTagName("img");
	for(i=0; i<source.length; i++){
		source[i].count = i+1;
		source[i].onmouseover = function(){
			var ant = this.src.split("/");
			var num = ant.length-1
			var tre = ant[num].slice(-7)    // 뒤에서 7글자 추출
			if (tre == "_on.gif")return false;	//  on 이미지 는 return
			this.src = this.src.replace("_off.gif", "_on.gif");
				this.onmouseout = function(){
				this.src = this.src.replace("_on.gif", "_off.gif");
				} // end of onclick
		} // end of onclick
	}
}
addLoadEvent(img_rollover)

var direction_num =10000;
function motion_direction(num){
	clearInterval(func_PhRolling)
	var source = document.getElementById("family_link").getElementsByTagName("div");
	for(i=0; i<source.length; i++){
		source[i].count = i+1;
		source[i].onmouseover = function(){
			clearInterval(func_PhRolling)
				this.onmouseout = function(){
					func_PhRolling = setInterval(motion_direction, 3500)
				} // end of onclick
		} // end of onclick
	}


	var add_num = 1;
	if (num)
	{
		add_num	= num
	}

	direction_num = parseInt(direction_num,10)+parseInt(add_num,10);

	for(i=0; i<source.length; i++){
		source[i].style.display = "none"
	}

	source[direction_num%source.length].style.display = "";
	func_PhRolling = setInterval(motion_direction, 3500)
}


function family_site_move(){
if(!document.getElementById("family_link")) return false;
func_PhRolling = setInterval(motion_direction, 3500)

}
addLoadEvent(family_site_move)


function chan(source){
	document.getElementById("visi_url").value = source.getAttribute("value");
}



function left_menu_over(){
	if(!document.getElementById("left_menu")) return false;
	if(!pageNum) return false;
	var target = document.getElementById("left_menu").getElementsByTagName("img")[pageNum];
	target.src = target.src.replace("_off.gif", "_on.gif");
}
addLoadEvent(left_menu_over)



function business_tab(){
	if(!document.getElementById("business_tab")) return false;
	var source = document.getElementById("business_tab").getElementsByTagName("img");
	for(i=0; i<source.length; i++){
		source[i].count = i+1;
		source[i].onmouseover = function(){
			for(j=0; j<source.length; j++){
				//source[j].src = source[j].src.replace("_on", "_off");
				document.getElementById("business_" + [j+1]).style.display = "none"  ;
			}
			//this.src = this.src.replace("_off", "_on");
			document.getElementById("business_" + [this.count]).style.display = ""  ;
		} // end of onclick
	}
}
addLoadEvent(business_tab)


function business_tab1(){
	if(!document.getElementById("business_tab1")) return false;
	var source = document.getElementById("business_tab1").getElementsByTagName("img");
	for(i=0; i<source.length; i++){
		source[i].count = i+1;
		source[i].onclick = function(){
			for(j=0; j<source.length; j++){
				source[j].src = source[j].src.replace("_on", "_off");
				document.getElementById("business_" + [j+1]).style.display = "none"  ;
			}
			this.src = this.src.replace("_off", "_on");
			document.getElementById("business_" + [this.count]).style.display = ""  ;
		//return false;
		} // end of onclick
	}
}
addLoadEvent(business_tab1)

function test_tab(){
	if(!document.getElementById("test_tab")) return false;
	var source = document.getElementById("test_tab").getElementsByTagName("img");
	for(i=0; i<source.length; i++){
		source[i].count = i+1;
		source[i].onclick = function(){
			for(j=0; j<source.length; j++){
				source[j].src = source[j].src.replace("_on", "_off");
				document.getElementById("test_" + [j+1]).style.display = "none"  ;
			}
			this.src = this.src.replace("_off", "_on");
			document.getElementById("test_" + [this.count]).style.display = ""  ;
		return false;
		} // end of onclick
	}
}
addLoadEvent(test_tab)
