
//////////////////////////////// common ////////////////////////////////
function getCookie( name ){
	var nameOfCookie = name + "=";
	var x = 0;
	while ( x <= document.cookie.length )
	{
		var y = (x+nameOfCookie.length);
		if ( document.cookie.substring( x, y ) == nameOfCookie ) {
			if ( (endOfCookie=document.cookie.indexOf( ";", y )) == -1 )
				endOfCookie = document.cookie.length;
			return unescape( document.cookie.substring( y, endOfCookie ) );
		}
		x = document.cookie.indexOf( " ", x ) + 1;
		if ( x == 0 )
			break;
	}
	return "";
}


function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

//MM_showHideLayers
function MM_showHideLayers() { //v9.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) 
  with (document) if (getElementById && ((obj=getElementById(args[i]))!=null)) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}



function NewWindowCenter(theURL,win_name,w,h,opt)
{	
	var x = (window.screen.availWidth-w)/2;
	var y = (window.screen.availHeight-h)/2-30;
	var option = "width="+w+",height="+h+",left="+x+",top="+y;
	if(opt != "")
		option += ","+opt;
	window.open(theURL,win_name,option);
}

/**** onload event func ********/
function addLoadEvent(func){
	var oldonload = window.onload;
	if (typeof window.onload != 'function'){
		window.onload = func;
	}else{
		window.onload = function() {
			oldonload();
			func();
		}
	}
}


///////////////////////////////// board function /////////////////////////////

function popView(imgObj)
{
	var url = "";
	if(typeof imgObj == 'string')
	{
		url = imgObj; 
	}
	else if(typeof imgObj == 'object' && imgObj.parentNode != "undefined" && imgObj.src != "undefined")
	{
		if(imgObj.parentNode.tagName == 'A')
		{
    		return; 
		}
		else
		{
			url = imgObj.src;
		}
	}
	
	window.open("/lib/common/imageZoom.asp?url=" + url,"imgZoom","scrollbars=yes,width=100,height=100,left=0,top=0");
}


///////////////////////////////// menu function /////////////////////////////

function GNB_Swap()
{	
	var gnb = new Array(5);
	var links =  new Array(5);
	gnb[0]=document.getElementById("gnb_sw_1");
	gnb[1]=document.getElementById("gnb_sw_2");
	gnb[2]=document.getElementById("gnb_sw_3");
	gnb[3]=document.getElementById("gnb_sw_4");
	gnb[4]=document.getElementById("gnb_sw_5");
	
	for(var i=0;i<5;i++)
	{
		links[i] = gnb[i].getElementsByTagName("img");
	}
	for(var i=0;i<gnb.length;i++)
	{
		for(var j=0;j<links[i].length;j++)
		{
			//alert(links[i][j]);
			links[i][j].onmouseover = links[i][j].onfocus = function(){
				this.src = this.src.substring(0,this.src.length-4) + "_r.gif";
			};
			
			links[i][j].onmouseout = links[i][j].onblur = function(){
				this.src = this.src.substring(0,this.src.length-6) + ".gif";
			};
		}
	}
}

function ViewSubLayer(LayerID, ImageID)
{
	if(LayerID != "")
	{
		if(document.getElementById(LayerID).style.display == "none")
		{
			document.getElementById(LayerID).style.display = "block";
			document.getElementById(ImageID).src = document.getElementById(ImageID).src.substring(0,document.getElementById(ImageID).src.length-4) + "_r.gif";
			//alert(document.getElementById(ImageID).src.substring(0,document.getElementById(ImageID).src.length-4)+"_r.gif");
		}
		else
		{
			document.getElementById(LayerID).style.display = "none";
			document.getElementById(ImageID).src = document.getElementById(ImageID).src.substring(0,document.getElementById(ImageID).src.length-6) + ".gif";
		}
	}
	else
	{
		document.getElementById(ImageID).src = document.getElementById(ImageID).src.substring(0,document.getElementById(ImageID).src.length-4) + "_r.gif";
	}	
}

function HideSubLayer()
{
	var nav = document.getElementById("snb");
	var all_dl = nav.getElementsByTagName("dl");
	for(var k = 0; k < all_dl.length; k++) {
		all_dl.item(k).style.display = "none";			
	}	
}


function toggleView(target){
    var sTarget = target.href.split("#");
    var aTarget = document.getElementById(sTarget[sTarget.length-1]);
    if(aTarget.style.display == "none") aTarget.style.display = "block";
    else aTarget.style.display = "none";
}


 function CH(num){
  for(i=1;i<8;i++){
   document.getElementById('mainmenu' + i).src = "/resource/images/common/button/plus" + i + ".gif";
  }
  document.getElementById('mainmenu' + num).src = "/resource/images/common/button/minus.gif";
 }


var CurDiv = "";
function ViewDiv(id, cn){
	
	if(CurDiv == id)
	{
		document.getElementById("health_btn" + id + "").className=cn+"_off";			
		document.getElementById("show_health" + id + "").style.display="none";
		document.getElementById("health_a" + id + "").focus();
		CurDiv = "";
	}
	else
	{
		if(CurDiv != "")
		{
			document.getElementById("health_btn" + CurDiv + "").className=cn+"_off";			
			document.getElementById("show_health" + CurDiv + "").style.display="none";
		}
		document.getElementById("health_btn" + id + "").className=cn+"_on";		
		document.getElementById("show_health" + id + "").style.display="block";	
		CurDiv = id;
	}
	
}

function HideDiv(cnt)
{	
	for(var i=1;i<=cnt;i++)
	{	
		var temp;
		if(i<10) {
			temp = "0"+i;
		}else{
			temp = i;
		}
		document.getElementById("show_health"+temp).style.display = "none";
	}
}

var CurDiv1= "";
function ViewDiv1(id, cn){

	if(CurDiv1 == id)
	{
		document.getElementById("health_2_btn" + id + "").className=cn+"_off";
		document.getElementById("show_2_health" + id + "").style.display="none";
		document.getElementById("health_2_a" + id + "").focus();
		CurDiv1 = "";
	}
	else
	{
		if(CurDiv1 != "")
		{
			document.getElementById("health_2_btn" + CurDiv1 + "").className=cn+"_off";			
			document.getElementById("show_2_health" + CurDiv1 + "").style.display="none";
		}
		document.getElementById("health_2_btn" + id + "").className=cn+"_on";		
		document.getElementById("show_2_health" + id + "").style.display="block";	
		CurDiv1 = id;
	}
	
}

function HideDiv1(cnt)
{	
	for(var i=1;i<=cnt;i++)
	{	
		var temp;
		if(i<10) {
			temp = "0"+i;
		}else{
			temp = i;
		}
		document.getElementById("show_2_health"+temp).style.display = "none";
	}
}

//°í°´¹®ÀÇ ÆÄÀÏÀÔ·ÂÆû Á¶Àý
function HideFileTr(cnt)
{	
	for(var i=1;i<=cnt;i++)
	{												
		document.getElementById("FileTr_"+i).style.display = "none";
	}
}

var CurFileForm = "";
function FileFormAdd()
{
	var idx;
	if(CurFileForm == "")
	{
		idx = 1;
	}
	else
	{
		idx = CurFileForm + 1;
	}
	
	if(idx <= 3)
	{
		document.getElementById("FileTr_"+idx).style.display = "";
		CurFileForm = idx;
	}
	else
	{
		alert("ÆÄÀÏÀÔ·ÂÆûÀº ÃÑ 4°³±îÁö °¡´ÉÇÕ´Ï´Ù.");
	}
}

function viewObj(txt){

	document.write(txt);

}
