function setFontags(x){
var y={1:12,2:13,3:16,4:18,5:24,6:32,7:48};
return y[x]+'px';
}
function swapTopbar(opt,divID1,divID2) {
  switch (opt) {
    case "on" :
    if(document.getElementById(divID1)) {
      document.getElementById(divID1).id = divID2;
    }
    break;
    case "off" :
    if(document.getElementById(divID2)) {
      document.getElementById(divID2).id = divID1;
    }
    break;
 }
}
function addEvent(obj, evType, fn){
 if (obj.addEventListener){
   obj.addEventListener(evType, fn, false);
   return true;
 } else if (obj.attachEvent){
   var r = obj.attachEvent("on"+evType, fn);
   return r;
 } else {
   return false;
 }
}
//addEvent(window, 'load', foo); // How to use

function getContent(id) {
  location.href='index.php?mode=view_page&content_id='+id;
}

function imgError(obj) {
	obj.style.display='none';
}
function imgFix(obj) {
 var maxW = imgMaxWidth;
 var img = document.createElement("img");
 img.src = obj.src;
 if(img.width > maxW) {
 	obj.style.width = imgMaxWidth;
 	obj.style.height = img.height * (maxW/img.width);
 	obj.style.cursor = 'url(images/zoomin.cur),pointer';
 } else {
 	obj.style.width = img.width;
 	obj.style.height = img.height;
 }
}
function imgChkClick(obj) {
 var maxW = imgMaxWidth;
 var img = document.createElement("img");
 img.src = obj.src;
 if(img.width > maxW) {
 	picview(img.src,img.width,img.height);
 }
}

function getExt(val) {
  var tmp1 = val.split(".");
  var tmp2 = tmp1.length - 1;
  var ext = tmp1[tmp2];
  ext = ext.toLowerCase();
  return ext;

}
function confirmLink(theLink, theSqlQuery)
{
    // Confirmation is not required in the configuration file
    // or browser is Opera (crappy js implementation)
    if (confirmMsg == '' || typeof(window.opera) != 'undefined') {
        return true;
    }
    var is_confirmed = confirm(confirmMsg + ' :\n' + theSqlQuery);
    if (is_confirmed) {
        theLink.href += '';
    }
    return is_confirmed;
} // end of the 'confirmLink()' function
function trim(inputString) {
   // Removes leading and trailing spaces from the passed string. Also removes
   // consecutive spaces and replaces it with one space. If something besides
   // a string is passed in (null, custom object, etc.) then return the input.
   if (typeof inputString != "string") { return inputString; }
   var retValue = inputString;
   var ch = retValue.substring(0, 1);
   while (ch == " ") { // Check for spaces at the beginning of the string
      retValue = retValue.substring(1, retValue.length);
      ch = retValue.substring(0, 1);
   }
   ch = retValue.substring(retValue.length-1, retValue.length);
   while (ch == " ") { // Check for spaces at the end of the string
      retValue = retValue.substring(0, retValue.length-1);
      ch = retValue.substring(retValue.length-1, retValue.length);
   }
   while (retValue.indexOf("  ") != -1) { // Note that there are two spaces in the string - look for multiple spaces within the string
      retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length); // Again, there are two spaces in each of the strings
   }
   return retValue; // Return the trimmed string back to the user
} // Ends the "trim" function
function pop(rq,IdNo) {
 switch(rq) {
 	case "ipBlock" : w = 400; h = 320 ; s = 0; break;
 	case "send_pm" : w = 400; h = 320 ; s = 0; break;
 	case "send_pm_admin" : w = 400; h = 280 ; s = 0; break;
  case "rq_step1" : w = 400; h = 250 ; s = 0; break;
  case "checkID" : w = 400; h = 250 ; s = 0; break;
  case "checkJumin" : w = 400; h = 250 ; s = 0; break;
  case "weblink" : w = 400; h = 250; s = 0; break;
  case "smtp" : w = 400; h = 250; s = 0;break;
  case "search_user" : w = 400; h = 250; s = 0;break;
  case "prvmsg" : w = 400; h = 250; s = 0;break;
  case "scrap" : w = 740; h = 480; s = 0;
  default : w = 740; h = 480; s = 1;
 }
	var mypage = "pop.php?rq=" + rq + "&IdNo=" + IdNo + "&langFile="+langFile+"&theme="+theme+"&mid="+mid;
  newWindow(mypage, 'pop', w, h, s);
}
function newWindow(mypage, myname, w, h, scroll) {
var winl = (screen.width - w) / 2;
var wint = (screen.height - h) / 2;
var winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',status=1,scrollbars='+scroll+',resizable=no';
var win = window.open(mypage, myname, winprops);
if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}

function checkLoginForm(form,item,fieldName) {


}
function checkThis(form,item,radio,disable,fieldName) {
if(fieldName){
 var fn = true;
 var fieldName2 = fieldName.split(',');
}
if(item != '')
{
 var item2 = item.split(',');
 var ex = new Array();
  for(i=0;i<item2.length;i++)
  {
  ex[i] = item2[i];
  }
  for(i=0;i<ex.length;i++)
  {
      newName = trim(form[ex[i]].value);
       if(newName == "")
       {
       	if(fn) { errorMessage_ = errorMessage + " - " + fieldName2[i];}
        alert(errorMessage_);
        if(ex[i] != 'postbody') {
         form[ex[i]].focus();
         form[ex[i]].className = 'error';
        }
        return false;
       }
        else
        {
        	if(ex[i] != 'postbody') {
        	 form[ex[i]].className = 'text';
        	}
        }
  }
}
if(radio != '')
{
  var count = 0;
 for(i=0;i<form[radio].length;i++)
 {
  if(form[radio][i].checked == true) { count += 1; }
 }
  if(count == 0)
  {
 	alert(error2);
 	form[radio][0].focus();
 	return false;
 	}
}
if(disable != '') {
 var disable2 = disable.split(',');
 for(i=0; i<disable2.length; i++)
 {
 form[disable2[i]].disabled = true;
 }
}
}
function checkFormValue(form,item,radio) {
if(item != '')
{
 var item2 = item.split(',');
 var ex = new Array();
  for(i=0;i<item2.length;i++)
  {
  ex[i] = item2[i];
  }
  for(i=0;i<ex.length;i++)
  {
      newName = trim(form[ex[i]].value);
       if(newName == "")
       {
        alert(errorMessage); form.checksum.value = '1';
        form[ex[i]].focus();break;
       }
  }
}
if(radio != "")
 {
  var count = 0;
 for(i=0;i<form[radio].length;i++)
 {
  if(form[radio][i].checked == true) { count += 1; }
 }
  if(count == 0)
  {
 	alert(error2); form.checksum.value = '1';
  form[radio][0].focus();
 	}
 }
}
function noKeyDown() {
alert(error11);
}
function mkshadow(content,opt,table_align) {
 var string = "<table align=\"" + table_align + "\">";
     string += "<td style=\"padding-left:6px;padding-top:6px\">";
     string += "<div class=\"shadow_" + opt + "\"><nobr>" + content + "</nobr></div>";
     string += "</td>";
     string += "</table>";
 document.write(string);
}
function Doc_Title(txt) {
document.title = "["+txt +"]" + document.title;
}
function checkImageFile(form,item,allowed,message) {
 if (message == '3') {var errorMessage_ = errorImg3;}
 if (message == '1') {var errorMessage_ = errorImg1;}
 if (message == '2') {var errorMessage_ = "GIF / JPG / SWF only"; }
 var item2 = item.split(',');
 var ex_item = new Array();
 for(i=0;i<item2.length;i++)
 {
  ex_item[i] = item2[i];
 }
 var allowed2 = allowed.split(',');
 var ex_allowed = new Array();
  for(i=0;i<allowed2.length;i++)
  {
  ex_allowed[i] = allowed2[i];
  }
 for(i = 0;i < ex_item.length; i++)
 {
  if(form[ex_item[i]].value)
  {
   var string = form[ex_item[i]].value;
   var e = string.length;
   var s = e-4;
   var range = string.substring(s,e).toLowerCase();
    var count = 0;
    for(j = 0; j < ex_allowed.length; j++)
    {
     if(range.indexOf(ex_allowed[j]) >= 0) { count += 1;}
    }
    if(count == 0)
    {
    	alert(errorMessage_);
    	form.checksum.value = '1';
    }
  }
 }
}
function picview(src,w,h) {

 var iw = screen.width - 16;
 var ih = screen.height - 68;
 var s = 0;
 var scroll = '';
if(w > iw) { w = iw; s += 1; }
if(h > ih) {
 h = ih; s += 1;
 if(w < iw) w += 20;
}
if(s > 0 ) { scroll = ",scrollbars=1"; }
var opt_mo = "top=5,left=5,width="+w+",status=no,height="+h+",resizable=1"+scroll;
NFW = window.open("","newWin",opt_mo);
NFW.focus();
var string = "<html>" +
             "<head><title>Photo</title></head>" +
             "<body topmargin=0 leftmargin=0 marginwidth=0 marginheight=0>" +
             "<a href='javascript:window.close()' style='cursor:url(images/zoomout.cur),pointer'><img src='" + src + "' border=0></a>" +
             "</body></html>";
NFW.document.open();
NFW.document.write(string);
NFW.document.close();
}
function picview0(t_id,src,w,h) {
 var iw = screen.width - 16;
 var ih = screen.height - 68;
 var s = 0;
 var scroll = '';
if(w > iw) { w = iw; s += 1; }
if(h > ih) {
 h = ih; s += 1;
 if(w < iw) w += 20;
}
if(s > 0 ) { scroll = ",scrollbars=1"; }
var opt_mo = "top=0,left=0,width="+w+",status=no,height="+h+",resizable=1"+scroll;
NFW = window.open("zoom.php?t_id="+t_id+"&src="+src,"newWin",opt_mo);
NFW.focus();
}
function Check_Char(id_text){// ¿µ¼ýÀÚ Ã¼Å©
	var alpha = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
	var numeric = '1234567890';
	var special = '_-{}[]';
	var nonkorean = alpha+numeric+special;
	var i ;
	for ( i=0; i < id_text.length; i++ )  {
		if( nonkorean.indexOf(id_text.substring(i,i+1)) < 0) {
			break ;
		}
	}
	if ( i != id_text.length ) {
		return false ;
	}else{
		return true ;
	}
	return true;
}
function Check_Num(id_text){
	var numeric = '1234567890';
	var nonkorean = numeric;
	var i ;
	for ( i=0; i < id_text.length; i++ )  {
		if( nonkorean.indexOf(id_text.substring(i,i+1)) < 0) {
			break ;
		}
	}
	if ( i != id_text.length ) {
		return false ;
	}else{
		return true ;
	}
	return true;
}
function Check_nonChar(id_text){	// Æ¯¼ö¹®ÀÚ Ã¼Å©
	var nonchar = '~`!@#$%^&*()-_=+\|<>?,./;:"[]';
	var nonkorean = nonchar;
	var i ;
	for ( i=0; i < id_text.length; i++ )  {
		if( nonkorean.indexOf(id_text.substring(i,i+1)) > 0) {
			break ;
		}
	}
	if ( i != id_text.length ) {
		return true ;
	}
	else{
		return false ;
	}
	return true;
}
function sendMail(str1,str2) {
 location.href = 'mailto:'+str1+'@'+str2;
}
function in_array(stringToSearch, arrayToSearch) {
        for (s = 0; s < arrayToSearch.length; s++) {
                thisEntry = arrayToSearch[s].toString();
                if (thisEntry == stringToSearch) {
                        return true;
                }
        }
        return false;
}
function MakeFlashString(source,id,width,height,wmode)
{

	var str = "";

	str = "<object id=\""+id+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0\" width=\""+width+"\" height=\""+height+"\">";
	str = str + "<param name=movie value=\""+source+"\">";
        str = str + "<param name=quality value=high>";
        str = str + "<param name=wmode value=\"transparent\">";
        str = str + "<param name=scale value=exactfit>";
        str = str + "<param name=menu value=false>";
        str = str + "<embed src=\""+source+"\" menu=false quality=high scale=exactfit wmode=\"transparent\" quality=high pluginspage=\"http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash\" type=\"application/x-shockwave-flash\" width=\""+width+"\" height=\""+height+"\">";
        str = str + "</embed>";
        str = str + "</object>";

     	return str;
}
function MakeEmbedString(source,width,height)
{
	var str = "";
  var w = '';
  var h = '';
	      if(! isNaN(width)) w = "width=\""+width+"\"";
	      if(! isNaN(height)) h = "height=\""+height+"\"";
	      str = str + "<embed src=\""+source+"\" "+w+" "+h+" autostart=false menu=false EnableContextMenu=false showStatusBar=1></embed>";
        DocumentWrite(str);
}
function DocumentWrite(str) {
 document.write(str);
}
function MM_preloadImages() {
  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_showHideLayers() { //v6.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')?'inline':(v=='hide')?'none':v; }
    obj.display=v;
    }
}
function MM_setClass() { //v6.0
  var i,p,v,obj,args=MM_setClass.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    obj.className=v;
  }
}

var topMenuLayer = '';
	function topMenuOut(id_)
	{
		topMenuMouseOut_ = setTimeout(topMenuMouseOut,100);
		topMenuLayer = id_;
	}
	function topMenuOn()
	{
		topMenuLayer = '';
		if(window.topMenuMouseOut_)
		{
			clearTimeout(topMenuMouseOut_);
		}
	}
	function topMenuMouseOut()
	{
		if(topMenuLayer)
		{
			MM_showHideLayers(topMenuLayer,'','hide');
		}
	}
function picview2(img,w1,w2) {
 var img = document.images[img];
 if(img.width == w1) { img.width = w2; img.title='Click to shrink';} else { img.width = w1;img.title='Click to enlarge';}
}
//byteÃ¼Å·
function updateChar(form,FieldName,text_length){
	var strCount = 0;
	var tempStr, tempStr2;
	for(i = 0;i < form[FieldName].value.length;i++)
	{
		tempStr = form[FieldName].value.charAt(i);
		if(escape(tempStr).length > 4) strCount += 2;
      		else strCount += 1 ;
    	}
	if (strCount > text_length){
		alert("Max " + text_length + "byte.");
		strCount = 0;
		tempStr2 = "";
		for(i = 0; i < form[FieldName].value.length; i++)
		{
			tempStr = form[FieldName].value.charAt(i);
			if(escape(tempStr).length > 4) strCount += 2;
	      	else strCount += 1 ;
	      	if (strCount > text_length)
	      	{
	      		if(escape(tempStr).length > 4) strCount -= 2;
	      		else strCount -= 1 ;
	      		break;
	      	}
	      	else tempStr2 += tempStr;
	    }
		form[FieldName].value = tempStr2;
	}
	form.textlimit.value = strCount;
}
function h_onn(divID) {
	var divs = document.getElementById(divID)
  divs.className = 't_checked';
}
function h_on(divID) {
  var divs = document.getElementById(divID)
  divs.style.backgroundColor = color_1;
}
function h_off(divID) {
 var divs = document.getElementById(divID)
  divs.className = 't_data';
}
function goAD(table,myID,target,redir) {
  var request = false;
   try {
     request = new XMLHttpRequest();
   } catch (trymicrosoft) {
     try {
       request = new ActiveXObject("Msxml2.XMLHTTP");
     } catch (othermicrosoft) {
       try {
         request = new ActiveXObject("Microsoft.XMLHTTP");
       } catch (failed) {
         request = false;
       }
     }
   }

   if (!request)
     alert("Error initializing XMLHttpRequest!");

  var url = 'pop.php?rq=goAD&IdNo='+myID+'&table='+table;
  request.open("GET", url, true);
  request.send(null);
  if(target == '_self') {
     window.location.href=redir;
  } else {
     window.open(redir,'_blank');
  }

}
function add2scrap(myID,f_id,t_id) {
	var iframeObj = document.createElement('IFRAME');
     iframeObj.setAttribute('name','hiddenFrame');
     iframeObj.setAttribute('src','pop.php?langFile='+langFile+'&theme='+theme+'&mid='+mid+'&rq=add2scrap&IdNo='+myID+'&f_id='+f_id+'&t_id='+t_id);
     iframeObj.setAttribute('width','0');
     iframeObj.setAttribute('height','0');
     iframeObj.setAttribute('style','visibility:hidden');
     document.body.appendChild(iframeObj);

	}
	function idCheck(myID) {
	  var iframeObj = document.createElement('IFRAME');
     iframeObj.setAttribute('name','hiddenFrame');
     iframeObj.setAttribute('src','pop.php?langFile='+langFile+'&theme='+theme+'&mid='+mid+'&rq=checkID&IdNo='+myID);
     iframeObj.setAttribute('width','0');
     iframeObj.setAttribute('height','0');
     iframeObj.setAttribute('style','visibility:hidden');
     document.body.appendChild(iframeObj);
	}

function next_step(form,value,len,nextfld) {
  if(value.length == len) form[nextfld].focus();

}


function sm(cat_id,sub_id) {
var divID = "SUBMENU_"+cat_id+"_"+sub_id;
var divs = document.getElementById(divID)
 divs.style.display = 'inline';
}
function ssm(cat_id,sub_id,subsubid ) {
  var divID = "SUBMENU_"+cat_id+"_"+sub_id+"_"+subsubid;
  var divs = document.getElementById(divID)
  if(divs.style.display == 'none') {
    divs.style.display = 'inline';
  } else {
    divs.style.display = 'none';
  }
}

function setPos(targetObj,curObj,newPos)
{

	this.targetObj = targetObj;
	this.curObj = curObj;
	var oSideViewLayer = document.getElementById(this.targetObj);
	var oBody = document.body;

	  if(subYpos) {
	   oSideViewLayer.style.top = subYpos;
	  } else {
	   oSideViewLayer.style.top = getAbsoluteTop(this.curObj) + this.curObj.offsetHeight;
	  }
    if(newPos) {
     oSideViewLayer.style.left = getAbsoluteLeft(this.curObj) - this.curObj.offsetWidth + parseInt(newPos);
    } else {
     oSideViewLayer.style.left = getAbsoluteLeft(this.curObj) - this.curObj.offsetWidth;
    }
}
var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";

function encode64(input) {
   var output = "";
   var chr1, chr2, chr3;
   var enc1, enc2, enc3, enc4;
   var i = 0;

   do {
      chr1 = input.charCodeAt(i++);
      chr2 = input.charCodeAt(i++);
      chr3 = input.charCodeAt(i++);

      enc1 = chr1 >> 2;
      enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
      enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
      enc4 = chr3 & 63;

      if (isNaN(chr2)) {
         enc3 = enc4 = 64;
      } else if (isNaN(chr3)) {
         enc4 = 64;
      }

      output = output + keyStr.charAt(enc1) + keyStr.charAt(enc2) +
         keyStr.charAt(enc3) + keyStr.charAt(enc4);
   } while (i < input.length);

   return output;
}

function decode64(input) {
   var output = "";
   var chr1, chr2, chr3;
   var enc1, enc2, enc3, enc4;
   var i = 0;

   // remove all characters that are not A-Z, a-z, 0-9, +, /, or =
   input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");

   do {
      enc1 = keyStr.indexOf(input.charAt(i++));
      enc2 = keyStr.indexOf(input.charAt(i++));
      enc3 = keyStr.indexOf(input.charAt(i++));
      enc4 = keyStr.indexOf(input.charAt(i++));

      chr1 = (enc1 << 2) | (enc2 >> 4);
      chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
      chr3 = ((enc3 & 3) << 6) | enc4;

      output = output + String.fromCharCode(chr1);

      if (enc3 != 64) {
         output = output + String.fromCharCode(chr2);
      }
      if (enc4 != 64) {
         output = output + String.fromCharCode(chr3);
      }
   } while (i < input.length);

   return output;
}

function pagePrint(Obj) {
	  Obj = document.getElementById(Obj);
	  var str = Obj.innerHTML;
    var W = Obj.offsetWidth;        //screen.availWidth;
    var H = Obj.offsetHeight + 64;        //screen.availHeight;
    var features = "menubar=no,toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=yes,width=" + W + ",height=" + H + ",left=0,top=0";
    var PrintPage = window.open("","print",features);
    var string = "<html>" +
                 "<head>" +
                 "<title>Print</title>" +
                 "<style type='text/css'>" +
                 " * { " +
                 " color:#000000 !important; " +
                 " background-color:#ffffff !important; " +
                 " font-size:9pt !important; " +
                 " } "+
                 "</style>" +
                 "</head>" +
                 "<body bgcolor=#ffffff>" + str + "</body></html>";
    PrintPage.document.open();
    PrintPage.document.write(string);
    PrintPage.document.close();
    PrintPage.print();
}

function calcHeight(i)
{
    var iframeHeight=
    (i).contentWindow.document.body.scrollHeight;
    (i).height=iframeHeight+20;
}

