function roll(st,color) { 
	idx=eval(st);
	idx.style.backgroundColor=color;
}

///////// ÀÚµ¿¸µÅ© /////////////////////////////////////////////////////////////////////
function autolink( id )
{
	//alert(id);
	var container = document.getElementById(id);
	var doc = container.innerHTML;
	var regSRC = new RegExp("(src|href)=(\'|\")(http|https|ftp|telnet|news|irc)://([-/.a-zA-Z0-9_~#%$?&=:200-377();|°¡-ÆR]+)","gi");
	var regURL = new RegExp("(http|https|ftp|telnet|news|irc)://([-/.a-zA-Z0-9_~#%$?&=:200-377();|°¡-ÆR]+)","gi");
	var regEmail = new RegExp("([_a-z0-9]+[_a-z0-9+-]+@[a-z0-9+-]+\.[a-z0-9+-]+[\.a-z0-9+-]+)","gi");
	doc = doc.replace(regSRC,"$1=$2donelink://$4");
	doc = doc.replace(regURL,"<a href='$1://$2' target='_blank'>$1://$2</a>");
	doc = doc.replace(regEmail,"<a href='mailto:$1'>$1</a>");
	container.innerHTML = doc.replace( /donelink/gi, 'http' );
}
function Trim(string) { 
    for(;string.indexOf(" ")!= -1;){ 
        string=string.replace(" ","") 
    } 
    return string; 
}
function get_number(str) { 
    var val = str; 
    var temp = ""; 
    var num = ""; 

    for(i=0; i<val.length; i++) { 
        temp = val.charAt(i); 
        if(temp >= "0" && temp <= "9") num += temp; 
    } 
    return num; 
} 
function alertID()
{
	for(i = 0; i < document.all.length; i++)
	if( document.all[i].id != "" ) alert(document.all[i].id);
}
///////////////////////// ÀÚµ¿¸µÅ© //////////////////////////////////////////////////////////

// setCookie
function setCookie( name, value, expiredays ) 
{
var todayDate = new Date();
todayDate.setDate( todayDate.getDate() + expiredays );
document.cookie = name + "=" + escape( value ) + "; path=/;"
}

// getCookie
function t_getCookie(name){
        var arg = name + "=";
        var alen = arg.length;
        var clen=document.cookie.length;
        var i=0;
        
        while(i< clen){
                var j = i+alen;
                if(document.cookie.substring(i,j)==arg){
                        var end = document.cookie.indexOf(";",j);
                        if(end== -1)
                                end = document.cookie.length;
                        return unescape(document.cookie.substring(j,end));
                }
        i=document.cookie.indexOf(" ",i)+1;
        if (i==0) break;
        }
        return null;
}

function t_setCookie(name,value,expires){
        document.cookie=name + "=" + escape(value)+
        ((expires == null)? "" : (" ; expires=" + expires.toGMTString()));
}
function t_setcookieVariables(){
        var today = new Date();
        var expires=new Date();
        expires.setTime(today.getTime()+ 1000*60*60*24*365);
        
        setCookie("news_title","",expires)
        
}

function numberFormat(str) {
	var Re = /[^0-9.]/g; 
	var ReN = /(-?[0-9]+)([0-9]{3})([^.0-9]*)/; 
	str = str.replace(Re,''); 
	while (ReN.test(str)) { 
		str = str.replace(ReN, "$1,$2$3"); 
	} 
	return str; 
} 

function mail_send(subject) {
	browsing_window = window.open('index_pop.php?incf=customer/mail_send&subject='+subject, 'mailSend', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=500, height=400');
	browsing_window.focus();
	return;
}

function optionList(table,no,name,title,fld,vvs,type,where,txt) {
	//alert(table);
	if ( fld==null ) fld="";
	if ( vvs==null ) vvs="";
	if ( type==null ) type="";
	if ( where==null ) where="";
	if ( txt==null ) txt="";

	browsing_window = window.open('index_pop.php?incf=more/optionList&table='+table+'&no='+no+'&name='+name+'&title='+title+'&fld='+fld+'&vvs='+vvs+'&type='+type+'&where='+where+'&txt='+txt, '__optionList_'+table, 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=no,width=600, height=300');
	browsing_window.focus();
	return;
}

function onlyNumber(charName) {
	var nums="0123456789";
	var result="";
	for (i=0 ; i < charName.value.length ; i++ ) {
		if(nums.indexOf(charName.value.substring(i,i+1)) != -1) {
			result=result+charName.value.substring(i,i+1);
		}
	}
	//alert(result);
	charName.value= result;
}
function nextFild(fd1,fd2,size){
	if ( fd1.value.length==size ){
		fd2.focus();
		//fd2.select();
	}
	return;
}
function preFild(fd1,fd2,size) {
	if ( fd1.value.length != size ) {
		fd1.focus();
	}
	return;
}
function FindAddress(pop,form,zip1,zip2,addz,more,focus){
	var browzing=window.open(pop+'?inc=common_post&form='+form+'&zip1='+zip1+'&zip2='+zip2+'&addz='+addz+'&more='+more+'&focus='+focus, 'postFind', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=450,height=170');
	browzing.focus();
}

//-------------------------------------------------------------------
// ¹®ÀÚ¿­Ã¼Å© ÇÔ¼ö 
//===================================================================
// 1.charName:Æû³×ÀÓ, 2.showName : alert·Î º¸ÀÌ´Â ÀÌ¸§
// 3.min:ÃÖ¼ÒÇã¿ë¹®ÀÚ¼ö, 4.max:ÃÖ´ëÇã¿ë¹®ÀÚ¼ö
// 5.rightChar : Çã¿ë¹®ÀÚ¿­¸®½ºÆ®  6.leftChar : Çã¿ëÇÏÁö¾Ê´Â¹®ÀÚ¿­¸®½ºÆ®
// 7.email : min=null, max=null, rightChar=null, leftChar=null
// 8.¹®ÀÚ¼ö : min=null, max=Çã¿ëÇÒ¹®ÀÚ¼ö
// 9.max=null : ¹®ÀÚ¼ö¸¦ Ã¼Å©ÇÏÁö ¾ÊÀ½.
//-------------------------------------------------------------------

function isUserChar(charName,showName,min,max,rightChar,leftChar)
{
	if ( charName.value == '' ) {
		alert( showName+' ÀÔ·ÂÀº ÇÊ¼ö ÀÔ·Â »çÇ×ÀÔ´Ï´Ù.');
		charName.focus();
		return false;
	}
	if ( max!= null ) {
		if ( ( min == null ) && ( charName.value.length != max ) ) {
			alert( showName+'¿¡´Â '+max+'ÀÚ°¡ ÀÔ·ÂµÇ¾î¾ß ÇÕ´Ï´Ù.');
			charName.select();
			return false;
		} else if  ( charName.value.length < min || charName.value.length > max ) {
			alert( showName+'¿¡´Â '+min+'~'+max+'ÀÚ°¡ ÀÔ·ÂµÇ¾î¾ß ÇÕ´Ï´Ù.');
			charName.select();
			return false;
		}
	} else if ( ( min != null ) && ( charName.value.length < min ) ) {
			alert( showName+'¿¡´Â '+min+'ÀÚ ÀÌ»ó ÀÔ·ÂµÇ¾î¾ß ÇÕ´Ï´Ù.');
			charName.select();
			return false;
	}
	if ( rightChar!=null ) {
		for (i=0 ; i < charName.value.length ; i++ ) {
			if(rightChar.indexOf(charName.value.substring(i,i+1)) == -1) {
				alert(showName + '¿¡ Çã¿ëÇÒ ¼ö ¾ø´Â ¹®ÀÚ°¡ ÀÔ·ÂµÇ¾ú½À´Ï´Ù.(1)');
				charName.focus();
				charName.select()
				return false;
			}
		}
	}
	if ( leftChar!=null ) {
		for ( i=0 ; i<leftChar.length ; i++ ) {
			badChar=leftChar.charAt(i);
			if (charName.value.indexOf(badChar,0)>-1) {
				alert(showName + '¿¡ Çã¿ëÇÒ ¼ö ¾ø´Â ¹®ÀÚ°¡ ÀÔ·ÂµÇ¾ú½À´Ï´Ù.(2)');
				charName.select();
				return false;
			}
		}
	}
	if ( min==null && max==null && rightChar==null && leftChar==null ) {  // E-mailÀÏ°æ¿ì.
		/** ±ÝÁö»çÇ×
		 - @°¡ 2°³ÀÌ»ó
		 - .ÀÌ ºÙ¾î¼­ ³ª¿À´Â °æ¿ì
		 -  @.³ª  .@ÀÌ Á¸ÀçÇÏ´Â °æ¿ì
		 - ¸ÇÃ³À½ÀÌ.ÀÎ °æ¿ì **/
		var regDoNot = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/; 
		/** ÇÊ¼ö»çÇ×
		 - @ÀÌÀü¿¡ ÇÏ³ªÀÌ»óÀÇ ¹®ÀÚ°¡ ÀÖ¾î¾ß ÇÔ
		 - @°¡ ÇÏ³ªÀÖ¾î¾ß ÇÔ
		 - Domain¸í¿¡ .ÀÌ ÇÏ³ª ÀÌ»ó ÀÖ¾î¾ß ÇÔ
		 - Domain¸íÀÇ ¸¶Áö¸· ¹®ÀÚ´Â ¿µ¹®ÀÚ 2~3°³ÀÌ¾î¾ß ÇÔ **/
		var regMust = /^[a-zA-Z0-9\-\.\_]+\@[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3})$/;
		
		if ( regDoNot.test(charName.value) || !regMust.test(charName.value) ) {
			alert('Àß¸øµÈ ÀÌ¸ÞÀÏ ÁÖ¼ÒÀÔ´Ï´Ù. Á¤È®ÇÑ ÁÖ¼Ò¸¦ ´Ù½Ã ÀÔ·ÂÇØ ÁÖ¼¼¿ä.');
			charName.select();
			return false;
		}

	}
	return true;
}

function logout(usr){
	var cnf=confirm(usr+'´Ô ·Î±×¾Æ¿ôÇÏ½Ã°Ú½À´Ï±î?');
	if ( cnf )
	{
		swap.location.href=('member/member_q.php?qmode=logout');
	}
	return;
}

function popLogin(){
	browsing_window = window.open('index_pop.php?incf=member/login_pop', 'popUpLogin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=450, height=350');
	browsing_window.focus();
	return;
}

////////////////////
function chz_bg(idx,wth,src) {
	idx.style.cssText="background-image:url('"+src+"')";
	idx.style.width=wth;
	return;
}

var currentCateFrmList=null;
var overCateFrmList=null;

///////////Ä«Å×°í¸® ¼¿·ºÆ®Æû ¿ÀÇÂ..
function cateFrmList(layer,view){
	//alert(view);
	if ( view=='visible' )
	{
		var nleft=event.clientX - event.offsetX -2;
		var ntop =event.clientY - event.offsetY + document.body.scrollTop - 5;
		layer.style.left=nleft;
		layer.style.top=ntop+23;
		layer.style.visibility=view;
		LayerProtectVisible(layer.style.left,layer.style.top,layer.style.width,layer.style.height);
		currentCateFrmList=layer.id;
	} else {
		layer.style.visibility=view;
		LayerProtectHidden();
		currentCateFrmList=null;
	}

	return;
}
function cateFrmOver(id){
	overCateFrmList=id;
	return;
}

function MouseDown(){
  //str='event.srcElement.tagName='+event.srcElement.tagName+'<BR>';
  //str+='event.srcElement.id='+event.srcElement.id+'<BR>';
 // str+='event.srcElement.type='+event.srcElement.type+'<BR>';
  //str+='event.type='+event.type+'<BR>';
 // show.innerHTML=str;

  //if ( overCateFrmList )alert(overCateFrmList);

  if ( currentCateFrmList!=null && currentCateFrmList!=overCateFrmList ) {
	  layer=eval(currentCateFrmList);
	  cateFrmList(layer,'hidden');
  }

}

///////////Ä«Å×°í¸® ¼¿·ºÆ®Æû ¼±ÅÃ..
function cateFrmChk(layer,type,fld,chzFld,vv){
	switch ( type )	{
		case 'radio' :
			if ( fld.checked==true ) chzFld.value=vv;
			cateFrmList(layer,'hidden');
			break;
		case 'checkbox' :
			break;
	
	}

	return;
}




//////////·¹ÀÌ¾î ¼¿·ºÆ®¹Ú½º º¸È£
function LayerProtectVisible(x,y,fwidth,fheight){
	LayerProtect.style.left=x;
	LayerProtect.style.top=y;
	LayerProtect.style.width=fwidth;
	LayerProtect.style.height=fheight;
	LayerProtect.innerHTML="<iframe style='width:"+fwidth+";height:"+fheight+";' frameborder='0'>";
	//alert(LayerProtect.innerHTML);
	LayerProtect.style.visibility='visible';
	return;
}
function LayerProtectHidden(){
	LayerProtect.style.visibility='hidden';
	//alert('test');
	return;
}


function idxHtmls(idx,htmls) {
	//alert('test');
	idx=eval(idx);
	//alert(idx.innerHTML);
	idx.innerHTML=htmls;
	return;
}
function deliv_check(url) {
	browsing_window = window.open(url, '', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=no,width=800, height=500');
	browsing_window.focus();
	return;
}

function zboardREAD(zno,cate,not_public,get){
	if ( not_public ){
		var browzing=window.open('index_pops.php?inc=board_readpasswd&cate='+cate+'&sub=bdetail&zno='+zno+get, 'read_passwd', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=400,height=300');
		browzing.focus();
	} else location.href=('board/zread.php?cate='+cate+'&sub=bdetail&zno='+zno+get);
	return;
}