﻿function CheckAll(){
 
	if(document.getElementById("checkid") == undefined || document.getElementById("checkid") == null) return;
	var cnt = document.getElementsByName("checkid").length;

 	 
	 
			if (document.getElementById("checkall").checked == false){
				for(i=0; i<cnt; i ++)
				{
					document.getElementsByName("checkid")[i].checked = false;
				}
				
			}
			else
			{
				for(i=0; i<cnt; i ++)
				{
					document.getElementsByName("checkid")[i].checked = true;
				}
			}
	
}


function runCommandEach(cmd,seq){
	
	if (cmd == "delete")
		if (!confirm("정말 삭제하시겠습니까?")) return;
	document.getElementById("oneCommand")["command"].value	= cmd;
	document.getElementById("oneCommand")["checkid"].value	= seq;
	document.getElementById("oneCommand").submit();
}

function MemberDelete(){
	if (!confirm("정말 탈퇴 하시겠습니까?")) return;
	document.getElementById("DeleteFrom").submit();
}


function CheckValid(){
	var cnt = document.getElementsByName("checkid").length;
	for(i=0; i<cnt; i ++)
	{
		if (document.getElementsByName("checkid")[i].checked)
		return true;
	}
		return false;
}

function runCommand(cmd){
	
	if (!CheckValid()) {
		alert("선택된 포스트가 없습니다.");
		return;
	}
	if (cmd=="" || !cmd) {
		alert("행동을 지정하세요.");
		return;
	}
	
	document.getElementById("chkCommand")["command"].value	= cmd;
	
	switch(cmd){
		case "disable":
			document.getElementById("chkCommand").submit();
		break;

		case "enable":
			document.getElementById("chkCommand").submit();
		break;
		case "delete":
			if (confirm("정말 삭제하시겠습니까?")){
				
				document.getElementById("chkCommand").submit();
			}
		break;
		case "deleteupdate":
			if (confirm("정말 삭제하시겠습니까?")){
				document.getElementById("chkCommand").submit();
			}
		break;
		
		case "state_1":
			if (confirm("대기상태로 변경하시겠습니까?")){
				
				document.getElementById("chkCommand").submit();
			}
		break;
		case "state_2":
			if (confirm("승인상태로 변경하시겠습니까?")){
				document.getElementById("chkCommand").submit();
			}
		break;
		
		case "state_3":
			if (confirm("미승인상태로 변경하시겠습니까?")){
				
				document.getElementById("chkCommand").submit();
			}
		break;
		case "tobest":
			if (confirm("베스트로 변경하시겠습니까?")){
				document.getElementById("chkCommand").submit();
			}
		break;
		case "tonormal":
			if (confirm("일반으로 변경하시겠습니까?")){
				document.getElementById("chkCommand").submit();
			}
		break;
		
		
 		
	}



	
}



function checkEmail(val) {			  	
		var re = new RegExp("(^[_0-9a-zA-Z-]+(\.[_0-9a-zA-Z-]+)*@[0-9a-zA-Z-]+(\.[0-9a-zA-Z-]+)*$)", "g");
		var r = val.match(re);
		if(r != null) { 
			return true;	//유효한 이메일 주소인 경우	
		} else { 
			return false; 
		}
	}
function res_no_chk(s) {
if( s.charAt(6) == 1 || s.charAt(6) == 2 ){
	if( s.charAt(12) ==
		(( 11 - ((s.charAt(0)*2+s.charAt(1)*3+s.charAt(2)*4
					 +s.charAt(3)*5+s.charAt(4)*6+s.charAt(5)*7
					 +s.charAt(6)*8+s.charAt(7)*9+s.charAt(8)*2
					 +s.charAt(9)*3+s.charAt(10)*4+s.charAt(11)*5)
					% 11)))%10)
		return true;
}
return false;
}


function chkspace(str){
	
	
	var sp = /\s/
	
	if ( sp.exec(str) ){
		return false;
	}
	return true;
}
	
function trimstr(str){
var tmp = str;
tmp = tmp.replace(/\s/g,"");   
return tmp;

}
function strlen(str){
	var tmp = str;
	tmp = tmp.replace(/\s/g,""); 
	return tmp.length ;
}

function removeScript(str)
{
 var re = /\r\n/g
 var strBox1 = str;
 strBox1 = strBox1.replace(re, "@!-_-!@");
 re = /<\s*script.+?<\/\s*script\s*>/gi
 strBox1 = strBox1.replace(re, "");
 re = /@!-_-!@/g
 strBox1 = strBox1.replace(re, "\r\n");
 re = /^\r\n/g
 return  strBox1.replace(re, "");
}

function checkdate(v_year,v_month,v_day ){

	var err=0
	if ( v_year.length != 4) err=1
	if ( v_month.length != 1 &&  v_month.length !=  2 ) err=1
	if ( v_day.length != 1  &&  v_day.length !=  2) err=1


	r_year = eval(v_year) ; 
	r_month = eval(v_month); 
	r_day = eval(v_day)  ; 

	if (r_month<1 || r_month>12) err = 1
	if (r_day<1 || r_day>31) err = 1
	if (r_year<0 ) err = 1


	if (r_month==4 || r_month==6 || r_month==9 || r_month==11){
		if (r_day==31) err=1
	}

	// 2,윤년체크
	if (r_month==2){
		var g=parseInt(r_year/4)

		if (isNaN(g)) {
			err=1
		}
		if (r_day>29) err=1
		if (r_day==29 && ((r_year/4)!=parseInt(r_year/4))) err=1
	}

	if (err==1){
		return false
	}else{
	               return true;

	}
}


function checkdatediff(sdate, edate){
	
var diff_date = edate.getTime() - sdate.getTime();
var count = Math.floor(diff_date/(24*60*60*1000));
if (count < 0){
	return false;
}

	return true;
}


function timecheck(h,m,s){
	if (parseInt(h,10) < 0  || parseInt(h,10) > 23)
	return false;
	
	if (parseInt(m,10) < 0  || parseInt(m,10) > 59)
	return false;
	
	if (parseInt(s,10) < 0  || parseInt(s,10) > 59)
	return false;
	
	
 
	
	return true;
}



function ViewCal(s,y,z){

x_1 = event.screenX
y_1 = event.screenY

window.open('/lib/js_cal.asp?year='+s+'&month='+y+'&day='+z,'cal_win','width=220, height=220, top='+y_1+', left='+x_1).focus();

}

function ViewCal2(s){

x_1 = event.screenX
y_1 = event.screenY

window.open('/lib/js_cal2.asp?date='+s,'cal_win','width=220, height=220, top='+y_1+', left='+x_1).focus();

}
 

function ValidNumChk(p_SelectEle)
{
     var i_KeyValue = event.keyCode;		
    if ((i_KeyValue < 48 || i_KeyValue > 57) && (i_KeyValue != 45))// && (i_KeyValue != 46))
    {
         alert ("- , 0 ~ 9 만 입력가능합니다.확인바랍니다.");
		 event.returnValue=false;
    }
	
}
function ValidNumChk2(p_SelectEle)
{
	 
     var i_KeyValue = event.keyCode;		
    if ( (i_KeyValue >= 48 && i_KeyValue <= 57) || (i_KeyValue >= 96 && i_KeyValue <= 105) || (i_KeyValue == 9) || (i_KeyValue == 8)  || (i_KeyValue == 46) || (i_KeyValue == 37)  || (i_KeyValue == 39) )
	{
		
	}
	else
    {
         alert ("숫자만 입력가능합니다.확인바랍니다.");
		 event.returnValue=false;
    }
	
}




function findzipcode(){
var winid = window.open("/zipcode/pop_post.asp","zipcode","width=410, height=300, scrollbars=1")
winid.focus();
}


function fileupload( s, t, r, x){
	
 window.open("upload_file.asp?dir="+s+"&thumb="+t+"&thumbsize="+r+"&coupon="+x,"image","width=600,height=420,status=1, resizable=1, scrollbars=1").focus();
	
}

function inputCss(){
jQuery("input.inputoneline").unbind("focus");
jQuery("input.inputoneline").unbind("blur");

jQuery("input.inputoneline").focus(function(){
											 
 											 this.className = "inputonelinefocus";
											 });
jQuery("input.inputoneline").blur(function(){
											  
											 this.className = "inputoneline";
											 });	
}



function inputCss2(){
jQuery("textarea").unbind("focus");
jQuery("textarea").unbind("blur");

jQuery("textarea").focus(function(){
											 
 											 this.className = "inputonelinefocus  width100p";
											 });
jQuery("textarea").blur(function(){
											  
											 this.className = "inputoneline width100p";
											 });	
}


function getUrl(url){

location.href=url;
}



function CopyClipBoard(val) {

   meintext = val;//eval(inputPath + ".value");

   if (window.clipboardData) { 

       // the IE-manier 
       window.clipboardData.setData("Text", meintext); 

       // waarschijnlijk niet de beste manier om Moz/NS te detecteren; 
       // het is mij echter onbekend vanaf welke versie dit precies werkt: 
   }else if (window.netscape){ 

      // dit is belangrijk maar staat nergens duidelijk vermeld: 
      // you have to sign the code to enable this, or see notes below 
      netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect'); 

      // maak een interface naar het clipboard 
      var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard); 
      if (!clip) return; 

      // maak een transferable 
      var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable); 
      if (!trans) return; 

      // specificeer wat voor soort data we op willen halen; text in dit geval 
      trans.addDataFlavor('text/unicode'); 

      // om de data uit de transferable te halen hebben we 2 nieuwe objecten nodig om het in op te slaan 
      var str = new Object(); 
      var len = new Object(); 

      var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString); 

      var copytext=meintext; 

      str.data=copytext; 

      trans.setTransferData("text/unicode",str,copytext.length*2); 

      var clipid=Components.interfaces.nsIClipboard; 

      if (!clip) return false; 

      clip.setData(trans,null,clipid.kGlobalClipboard); 

  } 


  alert("복사하였습니다. 블로그 등 게시판에 ctrl+v로 붙혀넣기 하십시오.");

}
