try { 
	document.execCommand('BackgroundImageCache', false, true); 
} catch(me) {}

//check browser
var isie=(/msie/i).test(navigator.userAgent); //ie
var isie6=(/msie 6/i).test(navigator.userAgent); //ie 6
var isie7=(/msie 7/i).test(navigator.userAgent); //ie 7
var isie8=(/msie 8/i).test(navigator.userAgent); //ie 8
var isfirefox=(/firefox/i).test(navigator.userAgent); //firefox
var isapple=(/applewebkit/i).test(navigator.userAgent); //safari,chrome
var isopera=(/opera/i).test(navigator.userAgent); //opera
if(isie7 || isie8) isie6=false;


// ¿À¸¥ÂÊ ¸¶¿ì½º±ÝÁö ½ºÅ©¸³Æ®
//function f_Left(e) {
//    if (navigator.appName == 'Netscape' && ( e.which == 2))
//        return false;
//    else if (navigator.appName == 'Microsoft Internet Explorer' && (event.button == 2)) {
//        alert("¸¶¿ì½º ¿À¸¥ÂÊ ¹öÆ°Àº »ç¿ëÇÒ ¼ö ¾ø½À´Ï´Ù.");
//        return false;
//    }
//    return true;
//}
//
//document.onmousedown=f_Left;
//
//if (document.layers) {
//    window.captureEvents(Event.MOUSEDOWN);
//    window.onmousedown=f_Left;
//}



// global image root
var imageroot='/images';

// util
var util={

	// create element
	create : function(opts){
		var rv=(isie)? '' : document.createElement(opts.tagname);
		for(var i in opts){
			if(i!='tagname'){
				if(isie) rv+=' '+((i=='classname')? 'class' : i)+'="'+opts[i]+'"';
				else rv.setAttribute((i=='classname')? 'class' : i,opts[i]);
			}
		}
		return (isie)? document.createElement('<'+opts.tagname+rv+'>') : rv;
	},

	// add event
	addevent : function(tg,name,func){
		if(tg.attachEvent) tg.attachEvent('on'+name,func);
		else tg.addEventListener(name,func,false);
	},

	add : function(tgt, typ, call) {
		if(tgt.addEventListener) {
			tgt.addEventListener(typ, call, false);
		} else if(tgt.attachEvent) {
			tgt["e"+typ+call] = call;
			tgt[typ+call] = function() { tgt["e"+typ+call]( window.event ); }
			tgt.attachEvent("on"+typ, tgt[typ+call]);
		} else {
			tgt["on"+typ] = tgt["e"+typ+call];
		}
	},

	//set scroll
	getscroll : function(){
		if(isapple) return [document.body.scrollLeft,document.body.scrollTop];
		else return [document.documentElement.scrollLeft,document.documentElement.scrollTop];
	},

	// write flash
	writeflash : function(containerid,swfid,src,w,h,flashvars,winmode,bgcolor){
		if(!winmode) var winmode='transparent';
		if(!bgcolor) var bgcolor='none';
		var html='';
		if(isie){
			html+='<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="'+w+'" height="'+h+'" id="'+swfid+'">';
			html+='<param name="allowScriptAccess" value="always" />';
			html+='<param name="allowFullScreen" value="true" />';
			html+='<param name="quality" value="high" />';
			html+='<param name="movie" value="'+src+'" />';
			html+='<param name="wmode" value="'+winmode+'" />';
			html+='<param name="bgcolor" value="'+bgcolor+'" />';
			html+='<param name="flashvars" value="'+flashvars+'"/>';
			html+='</object>';
		}else{
			html+='<embed src="'+src+'" quality="high" wmode="'+winmode+'" bgcolor="'+bgcolor+'" width="'+w+'" height="'+h+'" id="'+ swfid+'" flashvars="'+flashvars+'" allowScriptAccess="always" allowFullScreen="true" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>';
		}
		document.getElementById(containerid).innerHTML=html;
	},

	// set opacity
	setopacity : function(tg,v){
		if(isie) tg.style.filter='alpha(opacity='+(v*100)+')';
		else tg.style.opacity=v;
	}

}

var dom = {
	$ : function(emt) {
		emt = document.getElementById(emt);
		return emt;
	},
	$$ : function(par, tag, cnm) {
		var emt = par.getElementsByTagName(tag);
		if(arguments.length == 3) {
			var arr = new Array();
				for(var i = 0; i < emt.length; i++) {
					if(emt[i].className == cnm) {
						arr.push(emt[i]);
					}
				}
			return arr;
		}
		else if(arguments.length == 2) {
			return emt;
		}
	},
	rule : new Array("of", "on"),
	toggle : function(emt) {
		var src = emt.getAttribute("src");
		var typ = (src.indexOf("gif") != -1) ? ".gif" : ".jpg";
		var of = "", on = "";

		if(src.indexOf(this.rule[0]+typ) != -1) {
			of = this.rule[0]+typ;
			on = this.rule[1]+typ;
		} else {
			of = this.rule[1]+typ;
			on = this.rule[0]+typ;
		}
		emt.src = src.replace(of, on);
	},
	x : function(cmt, obj_id) {
		var emt = this.$(cmt);
		if(navigator.appName == "Microsoft Internet Explorer") {
			document.write(emt.text);
			emt.id = "";
		}
		if(obj_id)
			window[obj_id] = this.$(obj_id);
	},
	checkin : function(k1, k2) {
		var c = (k1.indexOf(k2) != -1) ? true : false;
		return c;
	},
	flashfunction : function(emt_id ,funcname) {
		var ie = navigator.appName.indexOf("Microsoft") != -1; 
		var emt = null;
		emt = (ie) ? dom.$(emt_id) : window.document.emt_id;
		emt[funcname]();
	}
};

// Attach Photo Resize
dom.autoresize = function() {
	this.limit = 420;
	this.list = dom.$$(dom.$("board_contents_area"), "img");
	
	this.contents = "";
	this.contents += "<html><head><title>Å« ÀÌ¹ÌÁö º¸±â</title></head>"
	for(var i = 0; i < this.list.length; i++) {
		var w = this.list[i].width, h = this.list[i].height;
		if(parseInt(w)>this.limit) {
			with(this.list[i].style) {
				width = this.limit;
				height = parseInt(h/100) * parseInt(this.limit/w*100) + "px";
				cursor = "pointer";
				visibility = "visible";
			}
		} else {
			with(this.list[i].style) {
				width = w;
				height = h + "px";
				cursor = "pointer";
				visibility = "visible";
			}
		}
		this.list[i].ow = w;
		this.list[i].oh = h;
		this.list[i].call = this;
		util.add(this.list[i], "click", function(){ this.call.popup(this) });
	}
};
dom.autoresize.prototype = {
	create : function(w, h, path) {
		var contents = this.contents, win;
			contents += "<body style=\"margin: 0;\"><a href=\"#close\" onclick=\"window.close();\"><img src=\""+path+"\" border=\"0\" width=\""+w+"\" height=\""+h+"\" alt=\"ÀÌ¹ÌÁö¸¦ Å¬¸¯ÇÏ¸é Ã¢ÀÌ ´ÝÈü´Ï´Ù.\" />";
			contents += "</a></body></html>";
		win = window.open("","bigimage","width="+w+",height="+h);
		win.document.open();
		win.document.write(contents);
		win.document.close();
	},
	popup : function(emt) {
		this.create(emt.ow, emt.oh, emt.getAttribute("src"));
	}
};


function image_auto_resize(this_s,width,height){ 
 var ta_image = new Image(); 
 ta_image.src = this_s.src; 
  if(!width){this_s.removeAttribute('width'); 
  this_s.style.width='auto';} 
  else if(width < ta_image.width){ 
  this_s.width = width; 
  }else{ 
  this_s.width = ta_image.width; 
  } 
  if(!height){this_s.removeAttribute('height'); 
  this_s.style.height='auto';} 
  else if(height < ta_image.height){ 
  this_s.height = height; 
  }else{ 
  this_s.height = ta_image.height; 
  } 
} 
function showPicture(src) {
  var imgObj = new Image();
  imgObj.src = src;
  var wopt = "scrollbars=no,status=no,resizable=no";
  wopt += ",width=" + imgObj.width;
  wopt += ",height=" + imgObj.height;
  var wbody = "<head><title>»çÁø º¸±â</title>";
  wbody += "<script language='javascript'>";
  wbody += "function finalResize(){";
  wbody += "  var oBody=document.body;";
  wbody += "  var oImg=document.images[0];";
  wbody += "  var xdiff=oImg.width-oBody.clientWidth;";
  wbody += "  var ydiff=oImg.height-oBody.clientHeight;";
  wbody += "  window.resizeBy(xdiff,ydiff);";
  wbody += "}";
  wbody += "</"+"script>";
  wbody += "</head>";
  wbody += "<body onLoad='finalResize()' style='margin:0'>";
  wbody += "<a href='javascript:window.close()'><img src='" + src + "' border=0></a>";
  wbody += "</body>";
  winResult = window.open("about:blank","",wopt);
  winResult.document.open("text/html", "replace");
  winResult.document.write(wbody);
  winResult.document.close();
  return;
}

function fnDown(strBoardid, intSeq, intFileseq)
{
	//alert("intSeq = " + intSeq + " intFileSeq = " + intFileseq);
	document.location.href="/_lib/download.asp?strBoardid=" + strBoardid + "&intSeq=" + intSeq + "&intFileseq=" + intFileseq;
}

function fnDownfile(strBoardid, intSeq)
{
	//alert("intSeq = " + intSeq + " intFileSeq = " + intFileseq);
	document.location.href="/_lib/downfile.asp?strBoardid=" + strBoardid + "&intSeq=" + intSeq;
}

function fnExpDownfile(strBoardid, intSeq, intOrder)
{
	//alert("intSeq = " + intSeq + " intFileSeq = " + intFileseq);
	document.location.href="/_lib/downExpfile.asp?strBoardid=" + strBoardid + "&intSeq=" + intSeq + "&intOrder=" + intOrder;
}

function fnDownthumb(strBoardid, intSeq)
{
	//alert("intSeq = " + intSeq + " intFileSeq = " + intFileseq);
	document.location.href="/_lib/downthumb.asp?strBoardid=" + strBoardid + "&intSeq=" + intSeq;
}

function fnDownExpthumb(strBoardid, intSeq)
{
	//alert("intSeq = " + intSeq + " intFileSeq = " + intFileseq);
	document.location.href="/_lib/downExpthumb.asp?strBoardid=" + strBoardid + "&intSeq=" + intSeq;
}

function fnDownMov(strBoardid, intSeq)
{
	//alert("intSeq = " + intSeq + " intFileSeq = " + intFileseq);
	document.location.href="/_lib/downMov.asp?strBoardid=" + strBoardid + "&intSeq=" + intSeq;
}
function fnDownExpMov(strBoardid, intSeq)
{
	//alert("intSeq = " + intSeq + " intFileSeq = " + intFileseq);
	document.location.href="/_lib/downExpMov.asp?strBoardid=" + strBoardid + "&intSeq=" + intSeq;
}

function setCookie( name, value, expiredays ) { 
	var todayDate = new Date(); 
	todayDate.setDate( todayDate.getDate() + expiredays ); 
	document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + todayDate.toGMTString() + ";" 
} 

function getCookie(Name) {
  var search = Name + "="
  if (document.cookie.length > 0) { // ÄíÅ°°¡ ¼³Á¤µÇ¾î ÀÖ´Ù¸é
    offset = document.cookie.indexOf(search)
    if (offset != -1) { // ÄíÅ°°¡ Á¸ÀçÇÏ¸é
      offset += search.length
      // set index of beginning of value
      end = document.cookie.indexOf(";", offset)
      // ÄíÅ° °ªÀÇ ¸¶Áö¸· À§Ä¡ ÀÎµ¦½º ¹øÈ£ ¼³Á¤
      if (end == -1)
        end = document.cookie.length
      return unescape(document.cookie.substring(offset, end))
    }
  }
  return "";
}
/**
* ÄíÅ° »èÁ¦
* @param cookieName »èÁ¦ÇÒ ÄíÅ°¸í
*/
function deleteCookie( cookieName )
{
	var expireDate = new Date();
	//¾îÁ¦ ³¯Â¥¸¦ ÄíÅ° ¼Ò¸ê ³¯Â¥·Î ¼³Á¤ÇÑ´Ù.
	expireDate.setDate( expireDate.getDate() - 1 );
	document.cookie = cookieName + "= " + "; expires=" + expireDate.toGMTString() + "; path=/";
}

function PopupOpen(strUrl,strWindowName,strWidth,strHeight) {
	var winl = (screen.width-strWidth)/2;
	var wint = (screen.height-strHeight)/2;
    var strWindowFeatures = "width="+strWidth+",height="+strHeight+",top="+wint+",left="+winl;
    var strWindowPopup = window.open(strUrl,strWindowName,strWindowFeatures);
  }

function cursorMove(arg,nextname,len) {
	if (arg.value.length==len) {
		nextname.focus() ;
		return;
	}
}

function onlyNumber()
{
  if(event.keyCode!=13 && ((event.keyCode<48) || (event.keyCode>57)))
  { 
    alert('¼ýÀÚ¸¸ ÀÔ·ÂÇÏ¼¼¿ä.'); 
    this.focus(); 
    event.returnValue=false; 
  }
}

String.prototype.trim = function(){
                    return this.replace(/(^[ \\f\\n\\r\\t]*)|([ \\f\\n\\r\\t]*$)/g,"");
                }

function fnRmspace(obj)
{
	obj.value=obj.value.replace(/ /gi, "");
}
function checkEng(str) { 
  for(var i=0;i<str.length;i++){ 
    achar = str.charCodeAt(i);  
    if( achar > 128 ){  
      return false; 
    }  
  } 
  return true;  
}

function checklength(strval, stnum, ednum)
{
	if((strval.length < parseInt(stnum)) || (strval.length > parseInt(ednum)))
	{
		return false;
	}
	else 
	{
		return true;
	}
}

function checkEngNum(field)
{
	var valid1 = "abcdefghijklmnopqrstuvwxyzABCDEFZHIJKLMNOPQRSTUVWXYZ";
	var valid2 = "0123456789";
	var int1 = 0;
	var int2 = 0;
	var temp;
	for (var i=0; i<field.length; i++)
	{
		temp = "" + field.substring(i, i+1);
		if (valid1.indexOf(temp) != "-1")
			int1 = int1 + 1;
		if (valid2.indexOf(temp) != "-1")
			int2 = int2 + 1;
	}
	if ((int1 == 0) || (int2 == 0))
		return false;
	else
		return true;
}

function chkemail(strVal)
{
	//alert(strVal);
	var mailexp = /[a-z0-9]{2,}(\S+)@[a-z0-9-]{2,}\.[a-z0-9]{2,}/i; 
	if(!mailexp.test(strVal))
	{
		return false;
	}
	return true;
}


function juminCheck(juminno) 
{
 var boolCheck = true;
 var pattern = /(^[0-9]{13}$)/; 
 if (!pattern.test(juminno)) boolCheck = false;
 else 
 {
  var sum_1 = 0;
  var sum_2 = 0;
  var at=0;

  sum_1 = (juminno.charAt(0)*2)+
  (juminno.charAt(1)*3)+
  (juminno.charAt(2)*4)+
  (juminno.charAt(3)*5)+
  (juminno.charAt(4)*6)+
  (juminno.charAt(5)*7)+
  (juminno.charAt(6)*8)+
  (juminno.charAt(7)*9)+
  (juminno.charAt(8)*2)+
  (juminno.charAt(9)*3)+
  (juminno.charAt(10)*4)+
  (juminno.charAt(11)*5);

  sum_2 = sum_1 % 11;

  if (sum_2 == 0) at = 10;
  else 
  {
   if (sum_2 == 1) at = 11;
   else at = sum_2;
  }

  att = 11 - at;
  // 1800 ³â´ë¿¡ ÅÂ¾î³ª½Å ºÐµéÀº ³²ÀÚ, ¿©ÀÚÀÇ ±¸ºÐÀÌ 9, 0 ÀÌ¶ó´Â 
  // ¾ê±â¸¦ µéÀºÀûÀÌ ÀÖ´Âµ¥ ±×·¸´Ù¸é ¾Æ·¡ÀÇ ±¸¹®Àº ¿À·ùÀÌ´Ù.
  // ÇÏÁö¸¸... 100»ì³ÑÀº ºÐµéÀÌ ÁÖ¹Îµî·Ï¹øÈ£¸¦ °ú¿¬ ÀÔ·ÂÇØº¼±î?

  if (juminno.charAt(12) != att || juminno.substr(2,2) < '01' || juminno.substr(2,2) > '12' || juminno.substr(4,2) < '01' || juminno.substr(4,2) > '31' || juminno.charAt(6) > 4) boolCheck = false;
 }

 return boolCheck;
}


function createHttpRequest(){
    if ( window.ActiveXObject ) {
       try {
          return new ActiveXObject("Msxml2.XMLHTTP");
       } catch(e) {
          try {
             return new ActiveXObject("Microsoft.XMLHTTP");
          } catch(e2) {
             return null;
          }
       }
    } else if ( window.XMLHttpRequest ) {
       return new XMLHttpRequest();
    } else {
       return null;
    }
}


function HR_getXml(url){
   var request = createHttpRequest();
   request.open("GET", url, false);
   request.send("");
   return request.responseText; // ÅØ½ºÆ® Çü½ÄÀ¸·Î ¹Þ´Â °æ¿ì
 //return request.responseXML;   xmlÇü½ÄÀ¸·Î ¹Þ´Â °æ¿ì
}

function trim(str){
   str = str.replace(/^\s*/,'').replace(/\s*$/,'');
   return str;
}

function input_cal_byte(input_name, max_byte){
    var input_name_str, byte_count=0, input_name_length=0, one_str, ext_byte;
    input_name_str = new String(input_name.value);
    input_name_length = input_name_str.length;

    for (i=0;i<input_name_length;i++){
        one_str=input_name_str.charAt(i);
        if (escape(one_str).length > 4){
            byte_count+=2;
        }
        else if (one_str != '\r'){
            byte_count++;
        }
    }

    if (byte_count > max_byte){
        ext_byte = byte_count - max_byte;
        alert('\n³»¿ëÀ» '+max_byte+'Byte ÀÌ»ó ÀÔ·ÂÇÏ½Ç¼ö ¾ø½À´Ï´Ù.\n\nÀÔ·ÂÇÏ½Å ³»¿ë Áß ÃÊ°ú '+ext_byte+'Byte´Â ÀÚµ¿ »èÁ¦ µË´Ï´Ù.\n');
        input_cut_text(input_name,max_byte);
    }
}

//ÀÔ·ÂÃ¢ byte´ë·Î ÀÚ¸£±â

function input_cut_text(input_name, max_byte){
   var input_name_str, byte_count=0, input_name_length=0, one_str;
    input_name_str = new String(input_name.value);
    input_name_length = input_name_str.length;
    for (i=0;i<input_name_length;i++){
        if (byte_count < max_byte){
            one_str=input_name_str.charAt(i);
            if (escape(one_str).length > 4){
                byte_count+=2;
            }
            else if (one_str != '\r'){
                byte_count++;
            }
        }               
        else{
            input_name_str = input_name_str.substring(0,i);
            break;
        }
    }
    if ((max_byte%2) ==1){
        input_name_length = (input_name_str.length-1);
        if (escape(input_name_str.charAt(input_name_length)).length > 4){
            input_name_str = input_name_str.substring(0,input_name_length);
        }
    }
    input_name.value = input_name_str;
    return input_name_str;
}


function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		do {
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
		} 
		while 
			(obj = obj.offsetParent);
		}
	return [curleft,curtop];
}


// get offset position
function getoffsetpos(tg){
	var pos=[0,0];
	function addpos(left,top){
		pos[0]+=left;
		pos[1]+=top;
	}
	for(var i=0,cobj=tg; !cobj.tagName.toLowerCase().match(/body|html/); cobj=cobj.offsetParent,i++){
		addpos(cobj.offsetLeft,cobj.offsetTop);
		if(!isopera && i>0){
			if(isie) addpos(cobj.clientLeft,cobj.clientTop);
			else if(cobj.tagName.toLowerCase().match(/table|thead|tbody|tfoot|th|td/)){
				if(isapple) addpos(cobj.clientLeft,cobj.clientTop);
				else addpos(cobj.offsetWidth-cobj.clientWidth,cobj.offsetHeight-cobj.clientHeight);
			}
		}
	}
	return pos;
}


function fnMyScrap(logged)
{
	if(logged=="False")
		alert("·Î±×ÀÎ ÇÏ¼Å¾ß ÇÕ´Ï´Ù.");
	else
		location.href='../mypage/my_scrap.asp';
}

function fnMyInfo(logged)
{
	if(logged=="False")
		alert("·Î±×ÀÎ ÇÏ¼Å¾ß ÇÕ´Ï´Ù.");
	else
		location.href='../mypage/modify_info.asp';
}

function fnSecede(logged)
{
	if(logged=="False")
		alert("·Î±×ÀÎ ÇÏ¼Å¾ß ÇÕ´Ï´Ù.");
	else
		location.href='../mypage/secede.asp';
}

function fnLoadMovie(vPath,w,h){
var movie = '';

if(navigator.appName == "Microsoft Internet Explorer") {
	clsid = "CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95";
	hei = 360;
}
else {
	clsid = "clsid:8E27C92B-1264-101C-8A2F-040224009C02";
	hei = 400;
}

	movie += '<object align=center id=MediaPlayer1 codebase=http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701 type=application/x-oleobject standby="Microsoft Windows Media Player ±¸¼º ¿ä¼Ò¸¦ ÀÐ¾îµéÀÌ´Â Áß..." width='+w+' height='+h+' classid='
					+ clsid
					+ '>'
					+ '<param name="Filename" value="' + vPath + '">'
					+ '<PARAM NAME="ShowControls" VALUE="1">'
					+ '<param name="ShowStatusBar" value="-1">'
					+ '<PARAM NAME="SendMouseClickEvents" VALUE="1">'
					+ '<param name="EnableContextMenu" value="false">'
					+ '<param name="TransparentAtStart" value="-1">'
					+ '<param name="AnimationAtStart" value="0">'
					+ '<param name="ShowGotoBar" value="0">'
					+ '<param name="showpositioncontrols" value="1">';
movie +=  '<param name="AutoStart" value="true">';


movie += '<embed type="application/x-mplayer2" pluginspage="http://www.microsoft.com/Windows/Downloads/Contents/Products/MediaPlayer/" filename="' + vPath + '" src="' + vPath + '" name="NSPlay"  width="'+w+'" height="'+h+'"></embed>'
				+ '</object>';

document.write(movie);
}

function sitemap(strUrl)
{
	//opener.location.href="/experience/star_list.asp";
	sitemap_close();
}

function fngetZero(val,len)
{
	for(var i=val.toString().length; i<len; i++)
	{
		val = "0" + val;	
	}
	return val;
}


/**
*
*  AJAX IFRAME METHOD (AIM)
*  http://www.webtoolkit.info/
*
**/

AIM = {

    frame : function(c) {

        var n = 'f' + Math.floor(Math.random() * 99999);
        var d = document.createElement('DIV');
        d.innerHTML = '<iframe style="display:none" src="about:blank" id="'+n+'" name="'+n+'" onload="AIM.loaded(\''+n+'\')"></iframe>';
        document.body.appendChild(d);

        var i = document.getElementById(n);
        if (c && typeof(c.onComplete) == 'function') {
            i.onComplete = c.onComplete;
        }

        return n;
    },

    form : function(f, name) {
        f.setAttribute('target', name);
    },

    submit : function(f, c) {
        AIM.form(f, AIM.frame(c));
        if (c && typeof(c.onStart) == 'function') {
            return c.onStart();
        } else {
            return true;
        }
    },

    loaded : function(id) {
        var i = document.getElementById(id);
        if (i.contentDocument) {
            var d = i.contentDocument;
        } else if (i.contentWindow) {
            var d = i.contentWindow.document;
        } else {
            var d = window.frames[id].document;
        }
        if (d.location.href == "about:blank") {
            return;
        }

        if (typeof(i.onComplete) == 'function') {
            i.onComplete(d.body.innerHTML);
        }
    }

}

