/* image »çÀÌÁîÁ¶Àý =========================================================================*/
function imgSize(which, max_width){
	var obj;
		
	if (document.getElementById(which) == undefined || document.getElementById(which) == null ) return;
	obj = document.getElementById(which);
	var width = obj.width;
	var height = obj.height;
	var temp = 0;

//alert(width) ;

   //var max_width= 510;   // ÀÌ¹ÌÁöÀÇ ÃÖ´ë Å©±â

    if ( width > max_width ) {  // ÀÌ¹ÌÁö°¡ 600º¸´Ù Å©´Ù¸é ³Êºñ¸¦ 600À¸·Î ¸Â¿ì°í ºñÀ²¿¡ ¸ÂÃç ¼¼·Î°ªÀ» º¯°æÇÑ´Ù.
       height = height/(width / max_width);
       obj.width = max_width;
       obj.height = height;
    }
}


/* ·¹ÀÌ¾î SHOW/HIDE **********************************************************************/
function showdiv(targetEl, uniqid) {
	if(document.getElementById(targetEl)) document.getElementById(targetEl).style.display="block";
}
function hidediv(targetEl) {
	if(document.getElementById(targetEl)) document.getElementById(targetEl).style.display="none";
}


/* 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='opaque';


	// ÇÃ·¡½Ã ÄÚµå Á¤ÀÇ
	var flashStr= "	<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000'";
		flashStr+="			codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,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 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)
}


/* ÅÜ½ºÅ¸ÀÏ ******************************************************************/
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;
//		}
//	}
}


/* ·Ñ¸µ¹è³Ê ******************************************************************/
//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();
	}
};


/* ÇÃ·¡½Ã ¸®»çÀÌÁî ******************************************************************/
function reSizeFlash(a){
//	alert(a);
	document.topMenu.height = a;
	document.getElementById("headHeight").style.height = a + "px";
	document.getElementById("slidingMenu").initTop = a;
}

function searReSize(w,h){
//	alert(w);
//	alert(h);
	document.left_bar.width = w;
	document.left_bar.height = h;
	document.getElementById("searchLayer").style.width=w+"px";
	document.getElementById("searchLayer").style.height=h+"px";
}


/*
function foldEvent(flag){ //»óÀ§ ¿ÍÀÎ °Ë»ö ¿­°í ´ÝÈú¶§ divµµ °°ÀÌ ¸®»çÀÌÂ¡ ÇØÁØ´Ù.
	if(flag) {
		document.getElementById("mainSearch_div").style.height="425px";
	}else {
		document.getElementById("mainSearch_div").style.height="33px";  
	}
}
*/


function quickReSize(w,h){
//	alert(w);
//	alert(h);
	document.right_bar.width = w;
	document.right_bar.height = h;
}


function loungeReSize(w,h){
	document.getElementById("lounge").style.width=w+"px";
	document.getElementById("lounge").style.height=h+"px";
}


/* iframeÀÚµ¿¸®»çÀÌÁî **********************************************************************/
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){}
}

function fixedPositionForIE6(type,length){ //type:fixedSide or fixedBottom,  length:fixedSide=topCss or  fixedBottom:objHeight 
	var viewportScroll = (document.documentElement) ? document.documentElement.scrollTop : document.body.scrollTop;	
	var viewportHeight = (document.documentElement) ? document.documentElement.clientHeight : document.body.clientHeight;

	if(type == "fixedSide"){		
		var objTop = length;
		return objTop + viewportScroll + "px";
	} else if( type == "fixedBottom"){				
		var objHeight = length;
		var objTop = viewportHeight - objHeight;		
		return objTop + viewportScroll + "px"
	}
}


 // #### FF, IE °ø¿ë ¾ÆÀÌÇÁ·¹ÀÓ 	
var iframeids=["autoIFrame"] 
var iframehide="yes" 

var getFFVersion=navigator.userAgent.substring(navigator.userAgent.indexOf("Firefox")).split("/")[1] 
var FFextraHeight=parseFloat(getFFVersion)>=0.1? 16 : 0 

function resizeCaller() { 
var dyniframe=new Array() 

for (i=0; i<iframeids.length; i++) { 
if (document.getElementById) 
resizeIframe(iframeids[i]) 

if ((document.all || document.getElementById) && iframehide=="no") { 
var tempobj=document.all? document.all[iframeids[i]] : document.getElementById(iframeids[i]) 
tempobj.style.display="block" 
} 
} 
} 

function resizeIframe(frameid) { 
var currentfr=document.getElementById(frameid) 

if (currentfr && !window.opera){ 
currentfr.style.display="block" 

if (currentfr.contentDocument && currentfr.contentDocument.body.offsetHeight) 
currentfr.height = currentfr.contentDocument.body.offsetHeight+FFextraHeight; 
else if (currentfr.Document && currentfr.Document.body.scrollHeight) 
currentfr.height = currentfr.Document.body.scrollHeight; 

if (currentfr.addEventListener) 
currentfr.addEventListener("load", readjustIframe, false) 
else if (currentfr.attachEvent){ 
currentfr.detachEvent("onload", readjustIframe) 
currentfr.attachEvent("onload", readjustIframe) 
} 
} 
} 

function readjustIframe(loadevt) { 
var crossevt=(window.event)? event : loadevt 
var iframeroot=(crossevt.currentTarget)? crossevt.currentTarget : crossevt.srcElement 

if (iframeroot) 
resizeIframe(iframeroot.id); 
} 

function loadintoIframe(iframeid, url) { 
if (document.getElementById) 
document.getElementById(iframeid).src=url 
} 

if (window.addEventListener) 
window.addEventListener("load", resizeCaller, false) 
else if (window.attachEvent) 
window.attachEvent("onload", resizeCaller) 
else 
window.onload=resizeCaller 
// FF, IE °ø¿ë ¾ÆÀÌÇÁ·¹ÀÓ 