﻿
function cmdIsNull(Obj, name) { 
 	if (Obj.value == '') { 
  		alert(name + '란을 입력해 주세요.'); 
  		Obj.focus(); 
  		return false; 
 	} 
 	return true; 
}

function cmdIsDigit(Obj){
	var digit = /[^0-9]/;
 	if(Obj.value.search(digit) != -1) {
  		alert('숫자로만 입력해주세요.');
  		Obj.value = '';
  		Obj.focus();
  		return false;
 	}
	 return true;
}

function onlyEng(objtext1) {
var inText = objtext1.value;
var ret;

	for (var i = 0; i < inText.length; i++) {
		ret = inText.charCodeAt(i);
			if ((ret > 57 && ret < 65) || (ret > 90 && ret < 97)) {
				alert("영문자와 숫자만을 입력하세요");
				objtext1.value = "";
				objtext1.focus();
				return false;
		}
	}
	return true;
} 




function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = window.innerWidth + window.scrollMaxX;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	
//	console.log(self.innerWidth);
//	console.log(document.documentElement.clientWidth);

	if (self.innerHeight) {	// all except Explorer
		if(document.documentElement.clientWidth){
			windowWidth = document.documentElement.clientWidth; 
		} else {
			windowWidth = self.innerWidth;
		}
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

//	console.log("xScroll " + xScroll)
//	console.log("windowWidth " + windowWidth)

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = xScroll;		
	} else {
		pageWidth = windowWidth;
	}
//	console.log("pageWidth " + pageWidth)

	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}

function MM_showHideLayers() { //v9.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) 
  with (document) if (getElementById && ((obj=getElementById(args[i]))!=null)) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

//iframe Resize 함수
//사용법 onload="resizeFrame(this)"
function resizeFrame(iframeObj){
        var innerBody = iframeObj.contentWindow.document.body;
        oldEvent = innerBody.onclick;
        innerBody.onclick = function(){ resizeFrame(iframeObj, 1);oldEvent; };

        var innerHeight = innerBody.scrollHeight + (innerBody.offsetHeight - innerBody.clientHeight);
        iframeObj.style.height = innerHeight;

        if( !arguments[1] )        /* 특정 이벤트로 인한 호출시 스크롤을 그냥 둔다. */
                this.scrollTo(1,1);
}

function onlyEng(objtext1) {
var inText = objtext1.value;
var ret;

	for (var i = 0; i < inText.length; i++) {
		ret = inText.charCodeAt(i);
			if ((ret > 57 && ret < 65) || (ret > 90 && ret < 97)) {
				alert("영문자와 숫자만을 입력하세요");
				objtext1.value = "";
				objtext1.focus();
				return false;
		}
	}
	return true;
} 

/*
function chkchar(0bj){	
	var chrTmp;
	var strTmp = obj.value;
	var strLen = strTmp.length;
	var chkAlpha = false;
	var resString = '';

	if(strLen > 0){
			for(var i=0; i<strTmp.length; i++){
				chrTmp = strTmp.charCodeAt(i);
				if(!((chrTmp > 47 && chrTmp <58 || (chrTmp >64 && chrTmp < 91) || (chrTmp >  96 && chrTmp <123) || (chrTmp > 44031 && chrTmp <55203 || chrTmp > 12592 && chrTmp < 12644))){
					chkAlpha == true;
				}
				else{
					resString = resString + String.fromCharCode(chrTmp);
				}
			}
	}
	if(chkAlpha == true){
		alert("한글,영문,숫자로만 작성해주세요.");
		obj.value = resString;
		obj.focus();
		return false;
	}
}
*/

//=================================
	// 이메일 유효성 검사 
	//=================================
	function chkMail(obj) { 
      var strMail = /\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/; 

		if(document.getElementById(obj).value != ""){
			  if(!document.getElementById(obj).value.match(strMail )) 
			{ 
				  alert("정확한 메일주소를 입력하세요.");
				document.getElementById(obj).value="";
				document.getElementById(obj).focus();
				return; 
			} 
		}
	}

	function changeImageSize(pWidth,pHeight) {
		var r, re;
		re = "#imgID#";

		 testImg = new Image();
		 
		 for (var i=0; i<document.images.length;i++) {
			r = (document.images[i].name).search(re);
			if (r > -1 && document.images[i].src != "") {
				testImg.src = document.images[i].src;
				if (testImg.width > pWidth) {
					document.images[i].width = pWidth;
					document.images[i].height = testImg.height * pWidth / testImg.width;
					document.images[i].style.width = pWidth;
					document.images[i].style.height = testImg.height * pWidth / testImg.width;
				}
			}
		}
	}		
