
//소스보기방지
function mouseClickRight() {
if((event.button == 2) || (event.button == 3)){
document.body.oncontextmenu = function () { return false; };
document.body.ondragstart = function () { return false; };
document.body.onselectstart = function () { return false; };
return;
}
} 
document.onmousedown = mouseClickRight;

document.oncontextmenu = function () { return false; };

function noKey() { 
//if((event.ctrlKey) || (event.shiftKey)) { 
if((event.ctrlKey)) { 
alert('키를 사용할 수 없습니다.'); 
} 
} 
document.onmousedown=noKey; 
document.onkeydown=noKey; 

// 회원관련팝업창
var win = null;
function popupCenter(mypage,myname,w,h,scroll){
	//화면가운데띄우기
	//LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	//TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
	
	//부모창 왼쪾상단에 띄우기
	LeftPosition = window.screenLeft
	TopPosition = window.screenTop
	//alert(window.screenLeft+":"+window.screenTop);
	//alert(screen.width);
	//alert(LeftPosition);
	//alert(TopPosition);
	settings = 'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars=yes,resizable'
	win = window.open(mypage,myname,settings)
}
//롤오버이미지
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  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_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

// 공백제거 스크립트
function SpaceRemove(strText)
{
  var r, re;
  re = /\s/g;
  r = strText.replace(re, "");
  return(r);
}

// E-mail 수집 프로그램에 의한 E-mail수집을 최대한 방지하기 위한 스크립트
function SendMailTo(mailaddr)
{
	var WebmasterAddr = mailaddr
	var HrefAttrib = "mail"
	var HrefTo = "to"

	if (confirm('웹메일(한메일,Hotmail등)을 사용하십니까?\n\n ※ Outlook 사용시 [취소] 클릭')) {
		alert("관리자 메일 주소(" + WebmasterAddr.replace(/\［AT］/g,"@") + ")가 복사되었습니다.\n\n수신인 주소에 붙여넣기(Ctrl+V)하시기 바랍니다.");
		window.clipboardData.setData('Text', WebmasterAddr.replace(/\［AT］/g,"@"));
	}
	else {
		location.href=HrefAttrib + HrefTo + ":" + WebmasterAddr.replace(/\［AT］/g,"@")
		alert("메일프로그램을 실행중입니다.\n\n잠시만 기다려 주십시요.")
	}
	
}

// 이미지 사이즈를 줄여주는 스크립트
function changeImageSize(pWidth,pHeight) {
	testImg = new Image();
	for (var i=0;i<document.images.length;i++) {
		if (document.images[i].src != ""&&document.images[i].name.substr(0,8)=="tmpPhoto") {
			testImg.src = document.images[i].src;
			if (testImg.width > pWidth || testImg.height > pHeight) {
				if((testImg.width/pWidth) > (testImg.height/pHeight)) {
				    document.images[i].width = pWidth;
				    document.images[i].height = testImg.height * pWidth / testImg.width;
				}
				else {
				    document.images[i].width =testImg.width * pHeight / testImg.height;
				    document.images[i].height = pHeight;
				}
			}
		}
	}
}


function isNotValidPID(pid1, pid2) {

	if(isEmpty(pid1,"주민등록번호를 입력해 주세요!")) return true;
	if(isEmpty(pid2,"주민등록번호를 입력해 주세요!")) return true;
	if(!isNumber(pid1,"주민등록번호 앞자리는 숫자로만 기입해 주세요!")) return true;
	if(!isNumber(pid2,"주민등록번호 뒷자리는 숫자로만 기입해 주세요!")) return true;
	if(isNotExactLength(pid1, 6, "주민등록번호 앞자리는 6자리입니다!")) return true;
	if(isNotExactLength(pid2, 7, "주민등록번호 뒷자리는 7자리입니다!")) return true;
	strchr = form.pid1.value.concat(pid2.value);
	if (strchr.length == 13	) {
		nlength = strchr.length;

		num1 = strchr.charAt(0);
		num2 = strchr.charAt(1);
		num3 = strchr.charAt(2);
		num4 = strchr.charAt(3);
		num5= strchr.charAt(4);
		num6 = strchr.charAt(5);
		num7 = strchr.charAt(6);
		num8 = strchr.charAt(7);
		num9 = strchr.charAt(8);
		num10 = strchr.charAt(9);
		num11 = strchr.charAt(10);
		num12 = strchr.charAt(11);

		var total = (num1*2)+(num2*3)+(num3*4)+(num4*5)+(num5*6)+(num6*7)+(num7*8)+(num8*9)+(num9*2)+(num10*3)+(num11*4)+(num12*5);
		total = (11-(total%11)) % 10;

		if(total != strchr.charAt(12)) {
			alert("주민등록번호가 올바르지 않습니다. \n다시 입력해 주세요!");
			pid1.value="";
			pid2.value="";
			pid1.focus();
			return true;
		}
		return false;
	}	else
		alert("주민등록번호가 올바르지 않습니다. \n다시 입력해 주세요!");
		pid1.value="";
		pid2.value="";
		pid1.focus();
		return true;

}

function isNotValidBID(bid1, bid2, bid3) {

	if(isEmpty(bid1,"사업자등록번호를 입력해 주세요!")) return true;
	if(isEmpty(bid2,"사업자등록번호를 입력해 주세요!")) return true;
	if(isEmpty(bid3,"사업자등록번호를 입력해 주세요!")) return true;
	if(!isNumber(bid1,"사업자등록번호 앞자리는 숫자로만 기입해 주세요!")) return true;
	if(!isNumber(bid2,"사업자등록번호 가운데자리는 숫자로만 기입해 주세요!")) return true;
	if(!isNumber(bid3,"사업자등록번호 뒷자리는 숫자로만 기입해 주세요!")) return true;
	if(isNotExactLength(bid1, 3, "사업자등록번호 앞자리는 3자리입니다!")) return true;
	if(isNotExactLength(bid2, 2, "사업자등록번호 뒷자리는 2자리입니다!")) return true;
	if(isNotExactLength(bid3, 5, "사업자등록번호 뒷자리는 5자리입니다!")) return true;
	strchr = bid1.value.concat(bid2.value.concat(bid3.value));

	num1 = strchr.charAt(0);
	num2 = strchr.charAt(1);
	num3 = strchr.charAt(2);
	num4 = strchr.charAt(3);
	num5= strchr.charAt(4);
	num6 = strchr.charAt(5);
	num7 = strchr.charAt(6);
	num8 = strchr.charAt(7);
	num9 = strchr.charAt(8);
	num10 = strchr.charAt(9);

	var total = (num1*1)+(num2*3)+(num3*7)+(num4*1)+(num5*3)+(num6*7)+(num7*1)+(num8*3)+(num9*5);
	total = total + parseInt((num9 * 5) / 10);
	var tmp = total % 10;
	if(tmp == 0) {
		var num_chk = 0;
	} else {
		var num_chk = 10 - tmp;
	}

	if(num_chk != num10) {
		alert("사업자등록번호가 올바르지 않습니다. \n다시 입력해 주세요!");
		bid1.value="";
		bid2.value="";
		bid3.value="";
		bid1.focus();
		return true;
	}
	return false;
}

function isNotValidEmail(field)
{
   var checkflag = true;
   var retvalue;

   if(field.value == "") {
	   retvalue = true;
   } else {

	   if (window.RegExp) {
		  var tempstring = "a";
		  var exam = new RegExp(tempstring);
		  if (tempstring.match(exam)) {
			 var ret1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
			 var ret2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
			 retvalue = (!ret1.test(field.value) && ret2.test(field.value));
		  } else {
			 checkflag = false;
		  }
	   } else {
		  checkflag = false;
	   }

	   if (!checkflag) {
		  retvalue = ( (field.value != "") && (field.value.indexOf("@")) > 0 && (field.value.index.Of(".") > 0) );
	   }

   }
   if(retvalue) { return false;
   } else {
		alert("이메일 주소가 정확하지 않습니다. \n다시 입력해 주세요!");
		field.focus();
		field.select();
		return true;
   }
}

function isNotValidTel(field) {

   var Count;
   var PermitChar =
         "0123456789-";

   for (var i = 0; i < field.value.length; i++) {
      Count = 0;
      for (var j = 0; j < PermitChar.length; j++) {
         if(field.value.charAt(i) == PermitChar.charAt(j)) {
            Count++;
            break;
         }
      }

      if (Count == 0) {
         alert("전화번호가 정확하지 않습니다. \n다시 입력해 주세요!")
		 field.focus();
		 field.select();
		 return true;
         break;
      }
   }
   return false;
}

