/* 레이어 SHOW/HIDE **********************************************************************/
function showdiv(targetEl, uniqid) {
	try{
		var targetBack = document.getElementById(targetEl + "Back");
		targetBack.style.height = window.document.body.clientHeight;
		
		if(targetEl=='cConsultSearch' || targetEl=='cConsultSitemap')	changeLeft(2);
	}catch(e){}
	if(document.getElementById(targetEl)) document.getElementById(targetEl).style.display="block";
}
function hidediv(targetEl) {
	try{
		var targetBack = document.getElementById(targetEl + "Back");
		targetBack.style.height = '10';
		
		if(targetEl=='cConsultSearch' || targetEl=='cConsultSitemap')	changeLeft(1);
	}catch(e){}
	if(document.getElementById(targetEl)) document.getElementById(targetEl).style.display="none";
}


/* 아이프레임사이즈 **********************************************************************/
function iframeResize(iframe_id) {
	var h = (self.innerHeight) ? document.documentElement.offsetHeight : document.body.scrollHeight;
	try{
		parent.document.getElementById(iframe_id).style.height = h+"px";
	}catch(e){}
}


/* FAQ **********************************************************************/
var old_menu = '';
function changeLayer(getMenu) {
	var submenu = document.getElementById(getMenu);
	if( old_menu != submenu ) {
		if( old_menu !='' ) {
			old_menu.style.display = 'none';
		}
		submenu.style.display = 'block';
		old_menu = submenu;
	} else {
		submenu.style.display = 'none';
		old_menu = '';
	}
}


/* 팝업띄우기 **********************************************************************/
function popupWin(filename,winname,width,height,scroll,left,top)	{
	window.open("" + filename + "","" + winname +"","scrollbars=" + scroll + ",toolbar=no,location=no,directories=no,width=" + width + ",height=" + height + ",resizable=no,mebar=no,left=" + left + ",top=" + top + ""); 
}


/* 텍스트 이미지 점선테두리 없애기 **********************************************************************/
function bluring(){ 
	if(event.srcElement.tagName=="A"||event.srcElement.tagName=="IMG") document.body.focus(); 
} 
document.onfocusin=bluring; 

function Onclick_Href(url){
	location.href=url;
}


/* flashWrite(파일경로, 가로, 세로[, 변수][,배경색][,윈도우모드]) transparent / window / opaque ****************************/
function flashWrite(url,w,h,vars,bg,win){
	
	var id=url.split("/")[url.split("/").length-1].split(".")[0]; //id는 파일명으로 설정
	if(vars==null) vars='';
	if(bg==null) bg='#FFFFFF';
	if(win==null) win='transparent';


	// 플래시 코드 정의
	var flashStr= "	<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000'";
		flashStr+="			codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,124,0'";
		flashStr+="			width='"+w+"'";
		flashStr+="			height='"+h+"'";
		flashStr+="			id='"+id+"'";
		flashStr+="			align='middle'>";

		flashStr+="		<param name='allowScriptAccess' value='always' />";
		flashStr+="		<param name='movie' value='"+url+"' />";
		flashStr+="		<param name='FlashVars' value='"+vars+"' />";
		flashStr+="		<param name='wmode' value='"+win+"' />";
		flashStr+="		<param name='menu' value='false' />";
		flashStr+="		<param name='quality' value='high' />";
		flashStr+="		<param name='bgcolor' value='"+bg+"' />";
	
	
		flashStr+="		<embed src='"+url+"'";
		flashStr+="		       flashVars='"+vars+"'";
		flashStr+="		       wmode='"+win+"'";
		flashStr+="		       menu='false'";
		flashStr+="		       quality='high'";
		flashStr+="		       bgcolor='"+bg+"'";
		flashStr+="		       width='"+w+"'";
		flashStr+="		       height='"+h+"'";
		flashStr+="		       name='"+id+"'";
		flashStr+="		       align='middle'";
		flashStr+="		       allowScriptAccess='always'";
		flashStr+="		       type='application/x-shockwave-flash'";
		flashStr+="		       pluginspage='http://www.macromedia.com/go/getflashplayer' />";
		flashStr+=" </object>";

	// 플래시 코드 출력	
	document.write(flashStr);
}

/* 탑링크 ****************************/
function OnTop(){
	window.scrollTo(0,0);
}


/* 텝스타일 ******************************************************************/
function initTabMenu(tabContainerID) {
	var tabContainer = document.getElementById(tabContainerID);
	var tabList = tabContainer.getElementsByTagName("li");
	var tabAnchor = tabContainer.getElementsByTagName("a");
	var i = 0;

	for(i=0; i<tabList.length; i++) {
		if (tabList.item(i).className == "")
			thismenu = tabList.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;

			if (currentmenu) {
				currentmenu.targetEl.style.display = "none";
				if (currentmenu.imgEl) {
					currentmenu.imgEl.src = currentmenu.imgEl.src.replace("_on.gif", ".gif");
				} else {
					currentmenu.className = currentmenu.className.replace("on", "");
				}
			}

			this.targetEl.style.display = "block";
			if (this.imgEl) {
				this.imgEl.src = this.imgEl.src.replace(".gif", "_on.gif");
			} else {
				this.className += "on";
			}
			this.container.current = this;

			return false;
		};

		if (!thismenu.container.first)
			thismenu.container.first = thismenu;
	}
	if (tabContainer.first)
		tabContainer.first.onclick();
}


function initTab(tabMenuID){
	var tabMenuEl = document.getElementById(tabMenuID);
	var tabMenuClass = tabMenuEl.className;
	var tabList = tabMenuEl.getElementsByTagName("li");
	var i = 0;

	for(i=0; i<tabList.length; i++) {
		tabList[i].onmouseover = function () {
			tabMenuEl.className = this.className;
		}
		tabList[i].onmouseout = function () {
			tabMenuEl.className = tabMenuClass;
		}
	}
}


/* 퀵배너 ******************************************************************/
function initMoving(target, topPosition, topLimit, btmLimit) {
	if (!target)
		return false;

	var obj = target;
	obj.initTop = topPosition;
	obj.topLimit = topLimit;
	obj.bottomLimit = document.documentElement.scrollHeight - btmLimit;

	obj.style.position = "absolute";
	obj.top = obj.initTop;
	obj.left = obj.initLeft;
	obj.style.top = obj.top + "px";

	obj.getTop = function() {
		if (document.documentElement.scrollTop) {
			return document.documentElement.scrollTop;
		} else if (window.pageYOffset) {
			return window.pageYOffset;
		} else {
			return 0;
		}
	}
	obj.getHeight = function() {
		if (self.innerHeight) {
			return self.innerHeight;
		} else if(document.documentElement.clientHeight) {
			return document.documentElement.clientHeight;
		} else {
			return 500;
		}
	}
	obj.move = setInterval(function() {
		//pos = obj.getTop() + obj.getHeight() - 150;
		pos = obj.getTop() + topPosition;

		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)
}

//1. 1.5초의 인터벌을 두고 자동롤링
//2. 좌우측 버튼을 통해 수동으로 동작가능
//3. 마우스 오버시 롤링순간멈춤 마우스아웃시 롤링시작

var Rolling=function(cid,count,interval,n) {
	this.cid = cid;
	this.count = count;	
	this.n = (n)?n:"1";
	this.onchange = null;

	for(var k=1; k<=this.count; k++) document.getElementById(this.cid+"_"+k).style.display="none";
	document.getElementById(this.cid+"_"+this.n).style.display="block";

	this.div = document.getElementById(this.cid);//전체div
	this.div.onmouseover=function(){this.isover=true; }
	this.div.onmouseout=function() {this.isover=false;}
	this.btn_next = document.getElementById("btn_"+this.cid+"_next");
	this.btn_prev = document.getElementById("btn_"+this.cid+"_prev");

	var self=this;
	if(this.btn_next) this.btn_next.onclick=function(){self.next() }
	if(this.btn_prev) this.btn_prev.onclick=function(){self.prev() }
	if(interval>0) setInterval(function(){self.play()}, interval);
}
Rolling.prototype = {
	play : function() {
		if(this.div.isover) return;
		this.next();
	},
	change :function(){
		if(this.onchange) this.onchange();
	},
	prev :function(){
		document.getElementById(this.cid+"_"+this.n).style.display="none";
		this.n=(this.n==1)?this.count:--this.n;
		document.getElementById(this.cid+"_"+this.n).style.display="block";
		this.change();
	},
	next :function(){
		document.getElementById(this.cid+"_"+this.n).style.display="none";
		this.n=(this.n==this.count)? 1:++this.n;
		document.getElementById(this.cid+"_"+this.n).style.display="block";
		this.change();
	},
	random : function() {
		var rn=Math.round((this.count-1)*Math.random());
		for(var i=0;i<rn;i++) this.next();
	}
};

//pdf 다운
function pop_op(url) {
	window.open("/M_insure/" + url, "pop_op", "left=20, top=20, toolbar=no, location=no, directories=no, status=no, scrollbars=yes, resizable=yes,width=716,height=560");
}

/*
// cyber 링크처리
function goPCyber(RET_URL, SCREEN_ID, command){ //v2.0
    var pageURL ="";
    var args=goPCyber.arguments;

    if(RET_URL == null || RET_URL == 'undefined'){
		RET_URL = "";
	}

    if(SCREEN_ID == null || SCREEN_ID == 'undefined'){
		SCREEN_ID = "";
	}

    if(command == null || command == 'undefined'){
		command = "";
	}

    if(args.length == 3){
        pageURL ="command=" + command + "&SCREEN_ID=" + SCREEN_ID;
    }

    if(pageURL != "" && pageURL == "/"){
		pageURL  +=  "RET_URL=" + RET_URL;
	}

	top.location.href = "http://cyber.metlife.co.k/ML09_HOME/include/redirect_Cyber.jsp?"+pageURL;
	//top.location.href = "http://cyber.metlife.co.kr/ML09_HOME/include/redirect_Cyber.jsp?SCREEN_ID=IN_01_01_011&command=101&RET_URL=/insurance/IN_01_01_011.jsp";
	
	
 
	return "TRUE";
}
*/

/**
 * 사이버 창구 전용 이동 함수
 */
function goPCyber(RET_URL, SCREEN_ID, command) {
 //parent.location.href= "http://192.168.152.201:83/";
 window.top.location.href= "http://cyber.metlife.co.kr/";
 return "TRUE";
}
