// LAYER FUNCTION #################################################################################
function MM_findObj(n, d) { //v4.0
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 && document.getElementById) x=document.getElementById(n); return x;
}
function MM_showHideLayers() { //v3.0
var i,p,v,obj,args=MM_showHideLayers.arguments;
for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
obj.visibility=v; }
}

// LINK IMAGE OUTLINE HIDE ########################################################################
function allblur()
{
	for (i = 0; i < document.links.length; i++) document.links[i].onfocus = document.links[i].blur;
}

// OPEN WINDOWS ###################################################################################
function PopUp(url,winname,wWidth,wHeight,sc,rs,st,conWidth,conHeight)
{
	if(conWidth == null && conHeight == null)
	{
		var conWidth = wWidth; conHeight = wHeight;
		conWidth = (screen.Width - conWidth) / 2;
		conHeight = (screen.Height - conHeight) / 2;
	}else{
		if(conWidth == null) conWidth = 50;
		if(conHeight == null) conHeight = 50;
	}
	if(sc == null) sc = 'No';
	if(rs == null) rs = 'Yes';
	if(st == null) st = 'No';

	window.open(url,winname,'left=' + conWidth + ',top=' + conHeight + ',width=' + wWidth + ',height=' + wHeight + ',scrollbars= ' + sc + ',resizable=' + rs + ',status=' + st);
}

function WinResize(width, height)
{
	var conWidth = width; conHeight = height;
	conWidth = (screen.Width - conWidth) / 2;
	conHeight = (screen.Height - conHeight) / 2;
	window.resizeTo(width, height);
	window.moveTo(conWidth, conHeight);
}

// MODALDIALOG WINDOWS ###################################################################################
function OpenModalDialog( HtmlFile, vOptions, nWidth, nHeight )
{
	var qResult = window.showModalDialog( HtmlFile, vOptions, "dialogwidth:"+nWidth+"px; dialogheight:"+nHeight+"px;toolbar:no; location:no; help:no; directories:no; status:no; menubar:no; scrollbars=no; resizable:no");
	return qResult;
}

function Modal(url, name, wWidth, wHeight)
{
    var szReturnValue = OpenModalDialog(url, name, wWidth, wHeight);
}


// SELECTION SCRIPT ###############################################################################
chg_temp = 1;
function ChangeTrColor(num,color1,color2)
{
	document.all.heytable.firstChild.childNodes[chg_temp].style.backgroundColor = color1;
	document.all.heytable.firstChild.childNodes[num].style.backgroundColor = color2;
	chg_temp = num;
}

// SELECTION SET COLOR ############################################################################
function SetColor(obj)
{
	var oldcolor = obj.value;
	obj.value = showModalDialog("colorset.php", oldcolor, "resizable: no; help: no; status: no; scroll: no; ");
	if(obj.value == 'undefined') obj.value = "FFFFFF";
	obj.style.background = obj.value;
}

// IMAGE POPUP ####################################################################################
function pop_image(img)
{
	img_conf1= new Image();
	img_conf1.src=(img);
	view_conf(img);
}

// Flash Patch ####################################################################################
function MakeFlash(Url,Width,Height){                 
  document.writeln("<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0\" width=\"" + Width + "\" height=\"" + Height + "\">"); 
  document.writeln("<param name=\"movie\" value=\"" + Url + "\">"); 
  document.writeln("<param name=\"quality\" value=\"high\" />");     
  document.writeln("<param name=\"wmode\" value=\"transparent\">"); 
  document.writeln("<embed src=\"" + Url + "\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width=\"" + Width + "\"  height=\"" + Height + "\">"); 
  document.writeln("</object>");     
}

function MakeJoy(){
	document.writeln("<object classid=\"CLSID:7236F083-1DC0-45A8-A3CC-A0CB8DAFB1BC\" width=\"100%\" height=\"150\" id=\"JoyUpLoad\" name=\"JoyUpLoad\" onError=\"bUploadControl = false;\" style=\"border:0px\">");
	document.writeln("<param name=\"uploadSize\" value=\"0\">"); 
	document.writeln("<param name=\"uploadCount\" value=\"20\">");
	document.writeln("<param name=\"formround\" value=\"10\">");
	document.writeln("<param name=\"uploadFilter\" value=\"ÀÌ¹ÌÁöÆÄÀÏ(*.jpg,*.gif)|*.jpg;*.gif;||\">"); 
	document.writeln("<param name=\"formUploadSize\" value=\"0\">");
	document.writeln("<param name=\"formUploadFilter\" value=\"ÀÌ¹ÌÁöÆÄÀÏ(*.jpg,*.gif)|*.jpg;*.gif;||\">"); 
	document.writeln("</object>"); 
}

function view_conf(img)
{
	if((img_conf1.width!=0)&&(img_conf1.height!=0))
	{
	    view_img(img);
	}else{
		funzione="view_conf('"+img+"')";
		intervallo=setTimeout(funzione,20);
	}
}

var img_view = null;
function view_img(img)
{
if(img_view != null) {
  if(!img_view.closed) { 
  img_view.close(); 
  }
}
  width=img_conf1.width;
  height=img_conf1.height;

	var conWidth = 0; conHeight = 0;
	conWidth = (screen.Width - width) / 2;
	conHeight = (screen.Height - height) / 2;
  str_img="left=" + conWidth + ",top=" + conHeight + ",width="+width+",height="+height;
   img_view=window.open("about:blank","",str_img);
   img_view.document.open();   // document.open() 
   img_view.document.writeln("<html>");
   img_view.document.writeln("<head>");
   img_view.document.writeln("<title>È®´ëº¸±â</title>");
   img_view.document.writeln("<meta http-equiv='content-type' content='text/html; charset=euc-kr'>");
   img_view.document.writeln("<meta http-equiv='imagetoolbar' content='no'>");
   var start="<";
   img_view.document.writeln("<script language='javascript'>");
   img_view.document.writeln("function click() {");
   img_view.document.writeln("if ((event.button==1) || (event.button==2))  {");
   img_view.document.writeln("top.close();");
   img_view.document.writeln("      }");
   img_view.document.writeln("}");
   img_view.document.writeln("document.onmousedown=click");
   img_view.document.writeln(start+"/script>");
   img_view.document.writeln("</head>");
   img_view.document.writeln("<body topmargin=0 bottommargin=0 leftmargin=0 rightmargin=0>");
   img_view.document.writeln("<img src="+ img +" border=0 style='cursor:hand'>") // ¼Ò½º Å×½ºÆ® ºÎºÐ
   img_view.document.writeln("</body></html>");
   img_view.document.close();  // ¹Ýµå½Ã document.close() ´Ý¾ÆÁÖ¾î¾ß ÇÔ
   img_view.focus();
  return;
}

// COMMA PROCESS
function Comma(x)
{
	var txtNumber = '' + x;
	if (isNaN(txtNumber))
	{
		alert("¼ýÀÚ¸¸ ÀÔ·Â ÇÏ¼¼¿ä");
		fieldName.select();
		fieldName.focus();
	}else{
		var rxSplit = new RegExp('([0-9])([0-9][0-9][0-9][,.])');
		var arrNumber = txtNumber.split('.');
		arrNumber[0] += '.';
		do
		{
			arrNumber[0] = arrNumber[0].replace(rxSplit, '$1,$2');
		}
		while (rxSplit.test(arrNumber[0]));
		if (arrNumber.length > 1) 
		{
			return arrNumber.join('');
		}else{
			return arrNumber[0].split('.')[0];
		}
	}
}

// RATIO PROCESS
function ratio(frm, val1, val2)
{
	var x = val1+val2;
	var vi = (val2 / val1)*100;
	vi = Math.round(vi * 100)/100;
	document.all.ratio_index.innerHTML = vi+' %';
	if(isNaN(vi) || vi == "Infinity")
	{
		document.all.ratio_index.innerHTML = '';
	}
}

// UNIT OF AREA PROCESS
function unit(frm, val)
{
	var vi = val * 0.3025;
	vi = Math.round(vi * 100)/100;
	frm.gunit.value = vi;
	if(isNaN(vi) || vi == "Infinity")
	{
		frm.gunit.value = '';
	}
}

function getCookie(name)
{
	var cname	= name + "=";
	var dc		= document.cookie;
	
	if(dc.length > 0)
	{
		begin = dc.indexOf(cname);
		
		if(begin != -1)
		{
			begin += cname.length;
			end = dc.indexOf(";", begin);
			if(end == -1) end = dc.length;
			return unescape(dc.substring(begin, end));
		}
	}
	return null;
}

function getCookieNormal(name)
{
	var from_idx = document.cookie.indexOf(name+'=');
	if (from_idx != -1)
	{ 
		from_idx += name.length + 1
		to_idx = document.cookie.indexOf(';', from_idx)
		if (to_idx == -1)
		{
			to_idx = document.cookie.length
		}
		return unescape(document.cookie.substring(from_idx, to_idx))
	}
}

function setCookie(name, value) {
	var argv		= setCookie.arguments;
	var argc		= setCookie.arguments.length;
	var expires = (2 < argc) ? argv[2] : null;
	var path		= (3 < argc) ? argv[3] : null;
	var domain	= (4 < argc) ? argv[4] : null;
	var secure	= (5 < argc) ? argv[5] : false;
	
	document.cookie = name + "=" + value + ((expires == null) ? "" : ("; expires="+expires.toGMTString())) + 
		((path == null) ? "" : ("; path=" + path)) + ((domain == null) ? "" : ("; domain=" + domain)) + 
		((secure == true) ? "; secure" : "");
}

function setCookieNormal( name, value, expiredays )
{
	var todayDate = new Date();
	var days = "0";
	if(expiredays != 0)
	{
		todayDate.setDate( todayDate.getDate() + expiredays );
		days = todayDate.toGMTString();
	}
	document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + days + ";"
}

function fullwin(url){
maxwidth=screen.availWidth-10;
maxheight=screen.availheight-10;
var pop=window.open(url,'_new','toolbar=yes,location=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width='+maxwidth+',height='+maxheight+',top=0,left=0')
pop.window.focus();
}
