function nph_change_img_src(name, nsdoc, rpath)
{
     var img = eval((navigator.appName.indexOf('Netscape', 0) != -1) ? nsdoc+'.'+name : 'document.all.'+name);
     if (name == '')    return;
     if (img) {  img.altsrc = img.src;  img.src = rpath; }
}

function form_submit(){
	document.getElementById("form_btn_1").style.display = "none";
	document.getElementById("form_btn_2").style.display = "";
}

function img_erro(obj,img){
	obj.src = img;
}

function n_format(rightchar){
	var moneychar="";
	var rightchar=String(rightchar);
	for(index=rightchar.length-1;index>=0;index--){
		splitchar=rightchar.charAt(index);
		moneychar=splitchar+moneychar;
		if(index%3==rightchar.length%3&&index!=0){ moneychar=','+moneychar; }
	}
	return moneychar;
}

function show_table(obj,chk){
	var obj=document.getElementById(obj);
	(chk) ? obj.style.display="" : obj.style.display="none"
}

//¾ÆÀÌÇÁ·¹ÀÓ ÀÚµ¿ Å©±â Á¶Àý ¼³Á¤
function reSize() {
    try {
        var objBody = auto_iframe.document.body;
        var objFrame = document.all["auto_iframe"];
        ifrmHeight = objBody.scrollHeight + (objBody.offsetHeight - objBody.clientHeight);
        objFrame.style.height = ifrmHeight;
    }
        catch(e) {}
}
function init_iframe() {
    reSize();
    setTimeout('init_iframe()',1)
}

//¼ýÀÚ¸¸ ÀÔ·Â
function SetNum(obj){
	val=obj.value;
	re=/[^0-9]/gi;
	obj.value=val.replace(re,"");
}

//¼ýÀÚ°Ë»ö
function numcheck(check_num) {
	var inText = check_num.value;
	var ret;
	for (var i=0; i<inText.length; i++) {
		ret = inText.charCodeAt(i);
		if ((ret<48) || (ret>57))	return true;
	}
	return false;
}

function viewFlash(URL,mode,wid,hei) 
{
	document.write("<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='"+wid+"' height='"+hei+"'>");
	document.write("<param name='movie' value='"+URL+"'>");
	document.write("<param name='quality' value='high'>");
	document.write("<param name='WMODE' value='"+mode+"'>");
	document.write("<embed src='"+URL+"' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='"+wid+"' height='"+hei+"'></embed>");
	document.write("</object>");
}

function pre_viewFlash(URL,mode,wid,hei) 
{
	data="<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='"+wid+"' height='"+hei+"'>";
	data+="<param name='movie' value='"+URL+"'>";
	data+="<param name='quality' value='high'>";
	data+="<param name='WMODE' value='"+mode+"'>";
	data+="<embed src='"+URL+"' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='"+wid+"' height='"+hei+"'></embed>";
	data+="</object>";
	return data;
}

function media(file,w,h,auto,cont,state){
	document.write ('<OBJECT classid="clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95" width="'+w+'" height="'+h+'" id="movie">');
	document.write ('<PARAM NAME="Filename" VALUE="'+file+'">');
	document.write ('<param name="ClickToPlay" value="false">');
	document.write ('<param name="AutoSize" value="true">');
	document.write ('<param name="AutoStart" value="'+auto+'">');
	document.write ('<param name="ShowControls" value="'+cont+'">');
	document.write ('<param name="ShowAudioControls" value="false">');
	document.write ('<param name="ShowDisplay" value="0">');
	document.write ('<param name="ShowTracker" value="1">');
	document.write ('<param name="ShowStatusBar" value="'+state+'">');
	document.write ('<param name="EnableContextMenu" value="false">');
	document.write ('<param name="ShowPositionControls" value="false">');
	document.write ('<param name="ShowCaptioning" value="false">');
	document.write ('<param name="AutoRewind" value="true">');
	document.write ('<param name="Enabled" value="true">');
	document.write ('<param name="EnablePositionControls" value="true">');
	document.write ('<param name="EnableTracker" value="true">');
	document.write ('<param name="PlayCount" value="1">');
	document.write ('<param name="SendWarningEvents" value="true">');
	document.write ('<param name="SendErrorEvents" value="true">');
	document.write ('<param name="SendKeyboardEvents" value="false">');
	document.write ('<param name="SendMouseClickEvents" value="false">');
	document.write ('<param name="SendMouseMoveEvents" value="false">');
	document.write ('<param name="ShowGotoBar" value="false">');
	document.write ('<param name="TransparentAtStart" value="false">');
	document.write ('<param name="Volume" value="1000">');
	document.write ('</OBJECT>');
}

//ÀÌ¹ÌÁö »õÃ¢ 
function CaricaFoto(img)
{
	foto1= new Image();
	foto1.src=(img);
	Controlla(img);
}

function Controlla(img)
{
	if((foto1.width!=0)&&(foto1.height!=0))
	{
		viewFoto(img);
	}
	else
	{
		funzione="Controlla('"+img+"')";
		intervallo=setTimeout(funzione,20);
	}
}

function viewFoto(img)
{
	largh=foto1.width+20;
	altez=foto1.height;
	stringa="width="+largh+",height="+altez+",scrollbars=1,top=10,left=10";
	finestra=window.open("/board/include/img_pop.php?img="+img,"",stringa);
}


//ÆÄÀÏÀÇ È®ÀåÀÚ¸¦ °¡Á®¿Å
function getFileExtension(filePath)
{
    var lastIndex = -1;
    lastIndex = filePath.lastIndexOf('.');
    var extension = "";

if ( lastIndex != -1 )
{
    extension = filePath.substring( lastIndex+1, filePath.len );
} else {
    extension = "";
}
    return extension;
}


//·Ñ¿À¹ö ÀÌ¹ÌÁö º¯È¯
function ch_over(obj)
{
	var img = obj.src.split('.gif');
	obj.src = img[0] + '_ov.gif';
}
function ch_out(obj)
{
	var img = obj.src.split('_ov.gif');
	obj.src = img[0] + '.gif';
}

function isNull( s ) { 
	if( s == null ) return true; 

	var result = s.replace(/(^\s*)|(\s*$)/g, ""); 

	if( result ) return false; 
	else return true; 
}

function resizeImg(arg,w2,h2) {
    var w = eval(arg.width);
    var h = eval(arg.height);  
    if (w > eval(w2)) arg.width = w2;
    if (h > eval(h2)) arg.height = h2;
}

//ÁÖ¹Î¹øÈ£ Ã¼Å©
function JuminCheck(ResNo1, ResNo2){
	var chk = 0;
	var yy  = ResNo1.substring(0,2);
	var mm  = ResNo1.substring(2,4);
	var dd  = ResNo1.substring(4,6);
	var sex = ResNo2.substring(0,1);

	if(ResNo1.length != 6) return true;

	if((sex != 1 && sex != 2 && sex != 3 && sex != 4) || (ResNo2.length != 7)) return true;   

	if((ResNo1.length == 6) && (ResNo2.length == 7)) {
		var ich = parseInt(sex, 10); 
		switch(ich) {
			case 1: break;
			case 2: break;
			case 3: if(yy == 00) break;
			case 4: if(yy == 00) break;
			default:
			return true;
		}
	}

	for(var i = 0; i <=5; i++) { 
		chk = chk + (((i % 8) + 2) * parseInt(ResNo1.substring(i, i + 1)));
	}

	for(var i = 6; i <= 11; i++) {
	chk = chk + (((i % 8) + 2) * parseInt(ResNo2.substring(i - 6, i - 5)));
	}

	chk = 11 - (chk % 11);
	chk = chk % 10;

	if(chk != ResNo2.substring(6, 7)) return true;
	return false
}

function move_url(str){
	location.href=str;
}


function date_chk(ymd1,ymd2){
	//ymd Çü½Ä : y/m/d H:i;
	
	date1	= ymd1;
	date2	= ymd2;
	d1 = new Date(date1); 
	d2 = new Date(date2); 

	if (d1 >= d2) return true;
	else return false;
}

function timeview(sTday,eNday){ 
    var sTyear=sTday.substr(0,4);var sTmonth=sTday.substr(5,2);var sTday=sTday.substr(8,2); 
    var eNyear=eNday.substr(0,4);var eNmonth=eNday.substr(5,2);var eNday=eNday.substr(8,2); 
    var sTall=new Date(sTyear, sTmonth-1, sTday); 
    var eNall=new Date(eNyear, eNmonth-1, eNday); 
    return (eNall.getTime()-sTall.getTime())/(24*60*60*1000); 
} 

//ÄíÅ°°ª ÃßÃâ
//@param cookieName ÄíÅ°¸í

function getCookie( cookieName ){
	var search = cookieName + "=";
	var cookie = document.cookie;

	// ÇöÀç ÄíÅ°°¡ Á¸ÀçÇÒ °æ¿ì
	if( cookie.length > 0 )	{
		// ÇØ´ç ÄíÅ°¸íÀÌ Á¸ÀçÇÏ´ÂÁö °Ë»öÇÑ ÈÄ Á¸ÀçÇÏ¸é À§Ä¡¸¦ ¸®ÅÏ.
		startIndex = cookie.indexOf( cookieName );
		// ¸¸¾à Á¸ÀçÇÑ´Ù¸é
		if( startIndex != -1 ){
			// °ªÀ» ¾ò¾î³»±â À§ÇØ ½ÃÀÛ ÀÎµ¦½º Á¶Àý
			startIndex += cookieName.length;
			// °ªÀ» ¾ò¾î³»±â À§ÇØ Á¾·á ÀÎµ¦½º ÃßÃâ
			endIndex = cookie.indexOf( ";", startIndex );
			// ¸¸¾à Á¾·á ÀÎµ¦½º¸¦ ¸øÃ£°Ô µÇ¸é ÄíÅ° ÀüÃ¼±æÀÌ·Î ¼³Á¤
			if( endIndex == -1) endIndex = cookie.length;
				// ÄíÅ°°ªÀ» ÃßÃâÇÏ¿© ¸®ÅÏ
			return unescape( cookie.substring( startIndex + 1, endIndex ) );
		}else{
			// ÄíÅ° ³»¿¡ ÇØ´ç ÄíÅ°°¡ Á¸ÀçÇÏÁö ¾ÊÀ» °æ¿ì
			return false;
		}
	}else{
		// ÄíÅ° ÀÚÃ¼°¡ ¾øÀ» °æ¿ì
		return false;
	}
}


//ÄíÅ° ¼³Á¤
//@param cookieName ÄíÅ°¸í
//@param cookieValue ÄíÅ°°ª
//@param expireDay ÄíÅ° À¯È¿³¯Â¥

function setCookie( cookieName, cookieValue, expireDate ){
	var today = new Date();
	today.setDate( today.getDate() + parseInt( expireDate ) );
	document.cookie = cookieName + "=" + escape( cookieValue ) + "; path=/; expires=" + today.toGMTString() + ";"
}

//ÄíÅ° »èÁ¦
//@param cookieName »èÁ¦ÇÒ ÄíÅ°¸í

function deleteCookie( cookieName ){
	var expireDate = new Date();
	//¾îÁ¦ ³¯Â¥¸¦ ÄíÅ° ¼Ò¸ê ³¯Â¥·Î ¼³Á¤ÇÑ´Ù.
	expireDate.setDate( expireDate.getDate() - 1 );
	document.cookie = cookieName + "= " + "; expires=" + expireDate.toGMTString() + "; path=/";
}

//È­¸éÁß¾Ó ÆË¾÷Ã¢ À§Ä¡
function center_popup(w,h,url,scroll,name){
	if(scroll=="undefined")	scroll	= "no";
	if(name=="undefined")	name	= "normal";

	if (screen.width < 1025){
		LeftPosition=0;
		TopPosition=0;
	} else {
		LeftPosition=(screen.width)?(screen.width-w)/2:100;
		TopPosition=(screen.height)?(screen.height-h)/2:100;
	}
	window.open(url,name,"width="+w+",height="+h+",top="+TopPosition+",left="+LeftPosition+", scrollbars="+scroll).focus();
}

function alertWin(sURL,sMsg,sWidth,sHeight,sTop,sLeft,sResize)
{
	var sFeatures = new Array();
	sFeatures[0] = (sWidth > 0)? "dialogWidth:"+sWidth+"px":"dialgWidth:300px";
	sFeatures[1] = (sHeight > 0)? "dialogHeight:"+sHeight+"px":"dialogHeight:300px";
	sFeatures[2] = (sTop > 0)? "dialogTop:"+sTop+"px":"";
	sFeatures[3] = (sLeft > 0)? "dialogLeft:"+sLeft+"px":"";
	sFeatures[4] = (!sTop && !sLeft)? "center:Yes":"";
	sFeatures[5] = (sResize)? "resizeable:"+sResize:"resizeable:No";
	sFeatures[6] = "help:No";
	sFeatures[7] = "status:No";
	sFeatures = sFeatures.join(";");
	window.showModalDialog(sURL,sMsg,sFeatures);
}

var old_menu = '';
function menuclick(submenu) {
    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 check_busino(vencod) {
	var sum = 0;
	var getlist =new Array(10);
	var chkvalue =new Array("1","3","7","1","3","7","1","3","5");
	for(var i=0; i<10; i++) { getlist[i] = vencod.substring(i, i+1); }
	for(var i=0; i<9; i++) { sum += getlist[i]*chkvalue[i]; }
	sum = sum + parseInt((getlist[8]*5)/10);
	sidliy = sum % 10;
	sidchk = 0;
	if(sidliy != 0) { sidchk = 10 - sidliy; }
	else { sidchk = 0; }
	if(sidchk != getlist[9]) { return false; }
	return true;
}

function downLoad(bbs_id,b_id,cnt){
	location.href="/board/action/download.php?bbs_id="+bbs_id+"&b_id="+b_id+"&f="+cnt;
}

function delete_alert(ss,url,return_page)
{
	if(ss == "1") {
		var bool = confirm("»èÁ¦ ÇÏ½Ã°Ú½À´Ï±î!?");
		if (bool) 	location.href = "/board/action/board_delete_ok.php?"+url+"&return_page="+return_page;
	}
	else {
		menuLocBod = window.document.body;
		mouse_x = window.event.x;
		mouse_y = window.event.y;
		scroll_left = menuLocBod.scrollLeft;
		scroll_top  = menuLocBod.scrollTop;
		posX = mouse_x + scroll_left;
		posY = mouse_y + scroll_top;
		document.getElementById("delete_area").style.left = posX-150;
		document.getElementById("delete_area").style.top = posY-70;
		document.getElementById("delete_area").style.display="";
		document.del_form.passwd.focus();
	}
}

function cmtdel(ss,no,bbs_id)
{
	if(ss == "1") {
		var bool = confirm("»èÁ¦ ÇÏ½Ã°Ú½À´Ï±î!?");
		if (bool) 	hiddenframe.location.href = "/board/action/comment_action.php?no="+no+"&bbs_id="+bbs_id+"&mode=del";
	}else {
		menuLocBod = window.document.body;
		mouse_x = window.event.x;
		mouse_y = window.event.y;
		scroll_left = menuLocBod.scrollLeft;
		scroll_top  = menuLocBod.scrollTop;
		posX = mouse_x + scroll_left;
		posY = mouse_y + scroll_top;
		document.getElementById("delete_area2").style.left = posX-150;
		document.getElementById("delete_area2").style.top = posY-70;
		document.getElementById("delete_area2").style.display="";
		document.del_form2.no.value = no;
		document.del_form2.passwd.focus();
	}
}

function ico_view() {
	menuLocBod = window.document.body;
	mouse_x = window.event.x;
	mouse_y = window.event.y;
	scroll_left = menuLocBod.scrollLeft;
	scroll_top  = menuLocBod.scrollTop;
	posX = mouse_x + scroll_left;
	posY = mouse_y + scroll_top;
	document.getElementById("ico_area").style.left = posX;
	document.getElementById("ico_area").style.top = posY;
	document.getElementById("ico_area").style.display="";
}
function cEs(i) {
	document.getElementById("e_ico").src = "/board/editor/img/emotions/"+i;
	document.getElementById("ico_area").style.display="none";
	document.getElementById("ico_value").value = i;
}

function check_it(obj){
	chk_bt	= document.getElementsByName("no[]");
	for(i=0;i<chk_bt.length;i++){
		chk_bt[i].checked = (obj.checked == true) ? true : false;
	}
}
function rs_del(bbs_id){
	no_list	= "";
	chk_bt	= document.getElementsByName("no[]");
	for(i=0;i<chk_bt.length;i++){
		if(chk_bt[i].checked==true){
			no_list	+= chk_bt[i].value+",";
		}
	}

	if(no_list==""){
		alert("¼±ÅÃµÈ °Ô½Ã¹°ÀÌ ¾ø½À´Ï´Ù.");
	}else{
		var c = confirm("°Ô½Ã¹°À» »èÁ¦ÇÏ½Ã°Ú½À´Ï±î?");
		if(c) hiddenframe.location.href = "/board/action/board_delete_ok.php?no_list="+no_list+"&mode=all&bbs_id="+bbs_id;
	}
}

function logout(){
	dynamic.src = "/board/member/logout.php";
}

/*-------------- È¸¿ø °ü·Ã ½ºÅ©¸³Æ® --------------------------*/

//¾à°üµ¿ÀÇ Ã¼Å©
function form_agree(obj){
	if(validate(obj)=="chk_ok"){
		if(JuminCheck(obj.ssn1.value,obj.ssn2.value)){
			alert("ÁÖ¹Î¹øÈ£°¡ ¿Ã¹Ù¸£Áö ¾Ê½À´Ï´Ù.");
			obj.ssn2.value = "";
			obj.ssn1.focus();
		}
		return true;
	}else{
		return false;
	}
}

//¾ÆÀÌµð Áßº¹°Ë»ç
function id_chk(){
	var obj	= document.getElementById("userid");
	if(isNull(obj.value)){
		alert("¾ÆÀÌµð¸¦ ÀÔ·ÂÇØÁÖ¼¼¿ä");
		obj.focus();		
	}else{
		dynamic.src = "/board/member/id_chk.php?id="+obj.value;
	}
}

//¿ìÆí¹øÈ£ °Ë»ö
function post_search(){
	center_popup(400,500,"/board/member/post.php","no","post");
}

function member_chk(obj){
	if(validate(obj)=="chk_ok"){

		var regMail =/^[_a-zA-Z0-9-]+@[\._a-zA-Z0-9-]+\.[a-zA-Z]+$/;

/*º°µµ Ã³¸® ºÎºÐ ---------------------*/
		if(obj.password.value != obj.repassword.value){
			alert("ºñ¹Ð¹øÈ£°¡ ÀÏÄ¡ÇÏÁö ¾Ê½À´Ï´Ù.");
			obj.password.value		= "";
			obj.repassword.value	= "";
			obj.password.focus();
			return false;
		}

		if(!isNull(obj.phone1.value) && isNull(obj.phone2.value)){
			alert("¿¬¶ôÃ³¸¦ ÀÔ·ÂÇØÁÖ¼¼¿ä.");
			obj.phone2.focus();
			return false;
		}

		if(!isNull(obj.phone1.value) && isNull(obj.phone3.value)){
			alert("¿¬¶ôÃ³¸¦ ÀÔ·ÂÇØÁÖ¼¼¿ä.");
			obj.phone3.focus();
			return false;
		}

		if(!isNull(obj.email.value) && !regMail.test(obj.email.value)){
			alert("ÀÌ¸ÞÀÏ Çü½ÄÀÌ Àß¸øÀÔ·Â µÇ¾ú½À´Ï´Ù.");
			obj.email.focus();
			return false;
		}

		if(isNull(obj.home_post.value) || isNull(obj.home_addr1.value)){
			alert("ÁÖ¼Ò¸¦ ÀÔ·ÂÇØÁÖ¼¼¿ä.");
			post_search();
			return false;
		}

		if(isNull(obj.home_addr2.value)){
			alert("»ó¼¼ ÁÖ¼Ò¸¦ ÀÔ·ÂÇØÁÖ¼¼¿ä.");
			obj.home_addr2.focus();
			return false;
		}
/*-------------------------------------------*/

		return true;
	}else{
		return false;
	}
}

function member_del(idx){
	var c = confirm("»èÁ¦ÇÏ½Ã°Ú½À´Ï±î?","");
	if(c) dynamic.src = "/board/member/member_proc.php?type=admin_member_del&idx="+idx;
}
