﻿/* **************************************************************
	Wiz Javascript - AJAX Utility Library Modal Window
	Version : 1.0
	Developer : wiz (wizys@yahoo.co.kr / http://wiz.pe.kr/)
	Last Updated : 2007.04.11 - First Version By wiz
	* 소스의 무단 사용을 금지 합니다.
************************************************************** */





/** START:BROWSER DETECTION ********************/
_nv_common=navigator.appVersion.toLowerCase(); 
ie4_common = false;
ie5_common = false;
ie55_common = false;
ie6_common = false;
ie7_common =(_nv_common.indexOf('msie 7.0')!=-1)?true:false;
if(!ie7_common){ 
ie4_common =(!document.getElementById&&document.all)?true:false;
ie5_common =(_nv_common.indexOf('msie 5.0')!=-1)?true:false;
ie55_common=(_nv_common.indexOf('msie 5.5')!=-1)?true:false;
ie6_common =(_nv_common.indexOf('msie 6.0')!=-1)?true:false;
}

isIE_common=(ie5_common || ie55_common || ie6_common || ie7_common) ?true:false;
/** END:BROWSER DETECTION ********************/


var checkboxUtils = {
	isChecked : function(obj){
		if(obj.length == undefined) {
            if(obj.checked == true)
                return true;
            else
                return false;
        }

        for(var i = 0; i < obj.length; i++) {
            if(obj[i].checked == true)
                return true;
        }
        return false;
	}
	,
	allCheck : function(obj){
		if(obj.length == undefined) {
		   if(obj.checked)
           		obj.checked = false;
           else
           		obj.checked = true;
        }
		for(var i = 0; i < obj.length; i++) {
			if(obj[i].checked)
            	obj[i].checked = false;
            else
            	obj[i].checked = true;
        }
	}
	
}

var radioUtils = {

    /**
    * Radio Button의 선택된 값을 가져온다
    */
    checkedVal : function (obj) {

        if(obj.length == undefined) {

            if(obj.checked == true)
                return obj.value;
            else
                return null;
        }

        for(var i = 0; i < obj.length; i++) {
            if(obj[i].checked == true)
                return obj[i].value;
        }
        return null;
    },

    /**
    * Radio Button의 선택된 값을 가져온다
    */
    checkedObj : function (obj) {

        if(obj.length == undefined) {

            if(obj.checked == true)
                return obj;
            else
                return null;
        }

        for(var i = 0; i < obj.length; i++) {
            if(obj[i].checked == true)
                return obj[i];
        }
        return null;
    },

    disabledRadio : function (obj, isDisabled) {

        if(obj.length == undefined) {

            obj.disabled = isDisabled;
        }

        for(var i = 0; i < obj.length; i++) {
            obj[i].disabled = isDisabled;
        }
    }

}


var StringUtils = {

    /****************************************************************
    * 주어진 길이보다 길이가 작은 문자열을 앞에 0을 붙여 패딩한다 <BR>
    * param str 문자열
    # param len 길이
    * return 뒤에 '0'으로 패딩된 문자열을 리턴한다. 단, 주어진 길이보다 크거나 같으면 원본문자열을 그대로 리턴한다
    ****************************************************************/

    paddingTailZero : function (str, len) {
        var strLen = str.length;
        var cab = 0;
        var tmp = "";
        if (strLen >= len)
            return str;
        else
            cab = len - strLen;

        for (var ii = 0; ii < cab; ii++) {
            tmp = tmp + "0";
        }

        return str + tmp;
    },

    paddingBeforeZero : function (str, len) {
        var strLen = str.length;
        var cab = 0;
        var tmp = "";
        if (strLen >= len)
            return str;
        else
            cab = len - strLen;

        for (var ii = 0; ii < cab; ii++) {
            tmp = tmp + "0";
        }

        //return str + tmp;

        return tmp + str;
    },


    // 한/영 포함해서 Byte 단위로 자를때 한글이 깨지지 않는 범위에서 최소로 잘려진 글자를 리턴한다.
    // return : 자른 문자열
    getLimitChar : function ( value, limitBtye) {
        var strValue = "";

        for( var i=0; i<value.length; i++ ) {
            if( this.getByteLength(strValue) + this.getByteLength(value.charAt(i)) > limitBtye ) {
                break;
            }
            else {
                strValue += value.charAt(i);
            }
        }

        return strValue;
    },

    getByteLength : function (src) {
        var byteLength = 0;
        for (var inx = 0; inx < src.length; inx++) {
            var oneChar = escape(src.charAt(inx));
            if ( oneChar.length == 1 ) {
                byteLength ++;
            }
            else if (oneChar.indexOf("%u") != -1) {
                byteLength += 2;
            }
            else if (oneChar.indexOf("%") != -1) {
                byteLength += oneChar.length/3;
            }
        }
        return byteLength;

    },

    /**
    * 숫자나 문자열을 통화(Money) 형식으로 만든다.( 쉼표(,) 찍는다는 소리.. )
    * @param	amount	"1234567"
    * @return	currencyString "1,234,567"
    */
    formatCurrency : function (amount) {
        amount = new String(amount);
        var amountLength = amount.length;
        var modulus = amountLength % 3;
        var currencyString = amount.substr(0,modulus);
        for(i=modulus; i<amountLength; i=i+3) {
            if(currencyString != "")
                currencyString += ",";
            currencyString += amount.substr(i, 3);
        }
        return currencyString;
    }

}

var DateUtils = {

    getYoundal : function (year,month){      // 인자로 들어온 월이 몇일까지 있는지를 반환
        var monarr = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
        if (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0)) monarr[1] = "29";

        return monarr[month-1];
    }
}



// Key Event 발생시 Validation 항목들
var keyEventValidator = {

    number : function () {

        var key = String.fromCharCode(event.keyCode);

        if(checkValidator.number(key) == false) {
            event.returnValue = false;
        }
    },

    numberRange : function (min, max) {

        var key = String.fromCharCode(event.keyCode);

        var selectVal = document.selection.createRange().text;

        var beforeValue = event.srcElement.value;

        beforeValue = beforeValue.replace(selectVal, "");

        beforeValue = beforeValue + '' + key;

        if(beforeValue == "0")  return;

        if(checkValidator.numberRange(beforeValue, min, max) == false){

            event.returnValue = false;
        }
    },

    year : function () {

        var key = String.fromCharCode(event.keyCode);

        var beforeValue = event.srcElement.value;

        beforeValue = beforeValue + '' + key;

        beforeValue = StringUtils.paddingTailZero(beforeValue, 4);

        if(checkValidator.year(beforeValue) == false){

            event.returnValue = false;
        }
    },


    month : function () {
        if(event.ctrlKey == true)// Ctrl 키
        {
            if(event.keyCode == 86)// v 키
            {
                return;
            }
        }

        var key = String.fromCharCode(event.keyCode);

        var selectVal = document.selection.createRange().text;

        var beforeValue = event.srcElement.value;

        beforeValue = beforeValue.replace(selectVal, "");

        beforeValue = beforeValue + '' + key;

        if(beforeValue == "0")  return;

        beforeValue = StringUtils.paddingBeforeZero(beforeValue, 2);

        if(checkValidator.month(beforeValue, 1, 12) == false){

            event.returnValue = false;
        }
    },

    day : function (objYear, objmonth) {

        if(event.ctrlKey == true)// Ctrl 키
        {
            if(event.keyCode == 86)// v 키
            {
                return;
            }
        }

        var valYear = objYear.value;
        var valMonth = objmonth.value;

        var key = String.fromCharCode(event.keyCode);

        var selectVal = document.selection.createRange().text;

        var beforeValue = event.srcElement.value;

        beforeValue = beforeValue.replace(selectVal, "");

        beforeValue = beforeValue + '' + key;

        if(beforeValue == "0")  return;

        beforeValue = StringUtils.paddingBeforeZero(beforeValue, 2);

        if(checkValidator.day(valYear, valMonth, beforeValue) == false){

            event.returnValue = false;

            return;
        }

        return;
    },

    hour : function () {
        if(event.ctrlKey == true)// Ctrl 키
        {
            if(event.keyCode == 86)// v 키
            {
                return;
            }
        }

        var key = String.fromCharCode(event.keyCode);

        var selectVal = document.selection.createRange().text;

        var beforeValue = event.srcElement.value;

        beforeValue = beforeValue.replace(selectVal, "");

        beforeValue = beforeValue + '' + key;

        if(beforeValue == "0")  return;

        beforeValue = StringUtils.paddingBeforeZero(beforeValue, 2);


        if(checkValidator.hour(beforeValue) == false){

            event.returnValue = false;
        }
    },

    minute : function () {
        if(event.ctrlKey == true)// Ctrl 키
        {
            if(event.keyCode == 86)// v 키
            {
                return;
            }
        }

        var key = String.fromCharCode(event.keyCode);

        var selectVal = document.selection.createRange().text;

        var beforeValue = event.srcElement.value;

        beforeValue = beforeValue.replace(selectVal, "");

        beforeValue = beforeValue + '' + key;

        if(beforeValue == "0")  return;

        beforeValue = StringUtils.paddingBeforeZero(beforeValue, 2);

        if(checkValidator.minute(beforeValue) == false){

            event.returnValue = false;
        }
    },

    seconds : function () {
        if(event.ctrlKey == true)// Ctrl 키
        {
            if(event.keyCode == 86)// v 키
            {
                return;
            }
        }

        var key = String.fromCharCode(event.keyCode);

        var selectVal = document.selection.createRange().text;

        var beforeValue = event.srcElement.value;

        beforeValue = beforeValue.replace(selectVal, "");

        beforeValue = beforeValue + '' + key;

        if(beforeValue == "0")  return;

        beforeValue = StringUtils.paddingBeforeZero(beforeValue, 2);

        if(checkValidator.seconds(beforeValue) == false){

            event.returnValue = false;
        }
    },

    illegal : function (filter) {

        var key = String.fromCharCode(event.keyCode);

        var beforeValue = event.srcElement.value;

        beforeValue = beforeValue.replace(selectVal, "");

        beforeValue = beforeValue + '' + key;

        if(checkValidator.illegal(beforeValue, filter) == false){

            event.returnValue = false;
        }
    },

    limit : function () {

        var beforeValue = event.srcElement.value;

        var limitCnt = event.srcElement.maxLength;

        if(StringUtils.getByteLength(beforeValue) > limitCnt) {
            alert("최대글자수를 초과했습니다. 초과된 글자는 자동으로 삭제됩니다.");
            event.srcElement.value = StringUtils.getLimitChar(beforeValue, limitCnt);

            return false;
        }

        return true;
    }

}

var checkValidator = {

    fromYyyy : 1000,
    toYyyy : 2200,

    zero : function (val) {
        var iVal = Number(val);

        if(isNaN(iVal)) return false;

        if(iVal != 0) return false;

        return true;
    },

    minus : function (val) {
        var iVal = Number(val);

        if(isNaN(iVal)) return false;

        if(iVal >= 0) return false;

        return true;
    },

    zeroPlus : function (val) {
        var iVal = Number(val);

        if(isNaN(iVal)) return false;

        if(iVal < 0) return false;

        return true;
    },

    plus : function (val) {
        var iVal = Number(val);

        if(isNaN(iVal)) return false;

        if(iVal <= 0) return false;

        return true;
    },

    number : function (val) {
        var iVal = Number(val);

        if(isNaN(iVal)) return false;

        return true;
    },

    numberRange : function (val, min, max) {

        if(this.zeroPlus(val) == false) return false;

        if(this.zeroPlus(min) == false) return false;

        if(this.zeroPlus(max) == false) return false;

        var iVal = Number(val);
        var iMin = Number(min);
        var iMax = Number(max);

        if(iMin <= iVal && iVal <= iMax){
            return true;
        }
        else{
            return false;
        }
    },

    year : function (val) {


        var re = new RegExp('^[1-9][0-9][0-9][0-9]$');

        if(re.test(val) == false)
            return false;
        else
            return this.numberRange(val, this.fromYyyy, this.toYyyy);
    },

    month : function (val) {

        var re = new RegExp('^[0-9]$|^[0-9][0-9]$');

        if(re.test(val) == false) {
            return false;
        }
        else {

            return this.numberRange(val, 1, 12);

        }
    },

    day : function (valYear, valMonth, varDay) {

        if(this.year(valYear) == false){

            event.returnValue = false;

            alert("올바른 년도(입력예:2007)를 입력한 후에 일자를 입력하시기 바랍니다.");

            return false;
        }

        if(this.month(valMonth) == false){

            event.returnValue = false;

            alert("올바른 월(입력예:09)를 입력한 후에 일자를 입력하시기 바랍니다.");

            return false;
        }

        var re = new RegExp('^[0-9]$|^[0-9][0-9]$');

        if(re.test(varDay) == false) return false;


        var validLastDay = DateUtils.getYoundal(valYear, valMonth);


        if(this.numberRange(varDay, 1, validLastDay) == false){

            return false;
        }

        return true;
    },

    // 년, 월 에 대한 Validation 을 체크한 후에 수행해야한다.
    day2 : function (valYear, valMonth, varDay) {

        var re = new RegExp('^[0-9]$|^[0-9][0-9]$');

        if(re.test(varDay) == false) return false;


        var validLastDay = DateUtils.getYoundal(valYear, valMonth);


        if(this.numberRange(varDay, 1, validLastDay) == false){

            return false;
        }

        return true;
    },

    hour : function (val) {

        var re = new RegExp('^[0-9][0-9]$');

        if(re.test(val) == false)
            return false;
        else
            return this.numberRange(val, 0, 23);
    },

    minute : function (val) {

        var re = new RegExp('^[0-9][0-9]$');

        if(re.test(val) == false)
            return false;
        else
            return this.numberRange(val, 0, 59);
    },

    seconds : function (val) {

        var re = new RegExp('^[0-9][0-9]$');

        if(re.test(val) == false)
            return false;
        else
            return this.numberRange(val, 0, 59);
    },

    find : function (val, filter) {

        var re = new RegExp(filter);

        if(re.test(val) == true)  return false;

            return true;
        },

    illegal : function (val, filter) {

        if(this.find(val, filter) == false) return false;

        return true;
    },

    limit : function (val, limitCnt) {

        if(StringUtils.getByteLength(val) > limitCnt) return false;

        return true;
    }
}



/***************************************************
함수 checkData()
	-폼데이터를 서브밋하기 전에 데이터 적합성 체크
	-입력 패러미터
		ObjName		:컨트롤 이름(txtTitle...)
		DataType	:문자열/숫자 구분.문자열이면 "S",숫자면 "N"(String/Number)
					 문자열이면 최대길이체크,숫자면 숫자여부체크
		IsEssential	:필수여부.필수입력사항이면 "Y",아니면 "N"
					 "Y"면서 값을 입력하지 않으면 return false
		MaxLen		:문자열일경우 최대길이(100을 지정하면 한글50자,영문100자)
					 입력값이 최대길이를 초과하면 return false
		msg			:사용자에게 보여주는 메시지에서 사용할 항목 이름
	-사용예
		<script language="javascript">
		function Form(){
			if(!checkData('form1','TextBox1','S','Y','10','제목')) return false;
			if(!checkData('form1','TextBox2','S','N','20','비고')) return false;
			if(!checkData('form1','TextBox3','N','Y','','가격')) return false;
			return true;
		}
		</script>
					
***************************************************/
function setFocusObjValue(pObjName){
	var focusObj = document.getElementsByName("focusObj")[0];
	if(focusObj != null)
		focusObj.value = pObjName;
}

function checkData(FormName,ObjName,DataType,IsEssential,MaxLen,msg){
   	var obj;
   	if(FormName){
   		obj=document.forms[FormName].elements[ObjName];
   	}else{
   		obj=eval("document.all."+ObjName);
   	}
   
   	//var obj=document.getElementsByName(ObjName);
   	//alert(obj.length);
   	if(!obj){
   		alert(ObjName + " 잘못된 객체입니다");
   		return false;
   	}

   	var sVal="";
   	if(obj.length==null){
   		sVal=obj.value;		
	}else{
		for(var i=0;i<obj.length;i++){
			//alert(obj[i].checked+"-"+obj[i].value);
			if(obj[i].checked || obj[i].selected){
				sVal=obj[i].value;
				break;
			}
		}
	}
	//alert(obj.name+"//"+obj.type+"//"+obj.length+"//"+sVal);
	if(sVal.indexOf("|")>-1){sVal=sVal.substring(0,sVal.indexOf("|"));}	
   	
   	DataType=DataType.toUpperCase();
   	IsEssential=IsEssential.toUpperCase();   
   		
	//setFocusObjValue(ObjName);
	
   	if(IsEssential=="Y"){
   		if(!checkEssential(sVal,msg)){
   			//alertMessageAction("dv_modal","알림",msg+"은(는) 필수입력사항입니다!",300,110,setFocusObject);
   			setFocus(obj);   			
   			return false;
   		}
   	}
   	
   	if(DataType=="S"){
   		if(!checkMaxLen(sVal,MaxLen,msg)){
   			//alertMessageAction("dv_modal","알림","["+msg+"] 한글은 "+(MaxLen/2)+"자, 영문.숫자.공백은 "+MaxLen+"자를 초과할수 없습니다.",300,110,setFocusObject);
   			setFocus(obj);
   			return false;
   		}   		
   	}
   	
   	if(DataType=="N"){
   		if(!checkNumeric(sVal,msg)){
   			//alertMessageAction("dv_modal","알림",msg+"에는 숫자만 입력할 수 있습니다!",300,110,setFocusObject);
   			setFocus(obj);
   			return false;
   		}   		
   	}
   	//setFocusObjValue("");
   	return true;
}

//값입력여부 체크
//입력값있으면 true,없으면 false
function checkEssential(str,msg){
	if(!str){
		alert(msg+'은(는) 필수입력사항입니다!');
		//alertMessage("dv_modal","알림",msg+"은(는) 필수입력사항입니다!",300,105);		
		return false;
	}else{
		return true;	
	}
}

//숫자여부 체크
//숫자이면 true,아니면 false
function checkNumeric(str,msg){
	if(isNaN(str)){
		alert(msg+'에는 숫자만 입력할 수 있습니다!');
		return false;
	}else{
		return true;	
	}
}

//최대길이 체크
//입력값이 최대길이를 초과하면 false
function checkMaxLen(str,MaxLen,msg){
	if(parseInt(getLength(str))>parseInt(MaxLen)){
		alert("["+msg+"] 한글은 "+(MaxLen/2)+"자, 영문.숫자.공백은 "+MaxLen+"자를 초과할수 없습니다.");
		return false;
	}else{
		return true;	
	}
}

//문자열길이 구하기(한글은 2자리로 계산)
function getLength(str){
	if(str==""){return 0;}
	
	var len=0;	
	
   	for(var i=0;i<str.length;i++){
     	var chr=str.charCodeAt(i);
     	
		if(chr>0 && chr<255){
			len=len+1;
		}else{
			len=len+2;
		}
   }
   
   return len;
}

//컨트롤에 포커스주기
function setFocus(obj){
	if(!obj){return;}
	if(obj.disabled==true){return;}
	if(obj.type=="hidden"){return;}

	if(obj.length!=null){
		obj[0].focus();
	}else{
		obj.focus();
	}
	
}

//컨트롤에 포커스주기
function setFocusObject(){		
	var focusObjID = document.getElementsByName("focusObj")[0];   
	var focusObj = null;
	if(focusObjID != null){ 
		focusObj = document.getElementsByName(focusObjID.value)[0];
		if(focusObj != null){ 
			focusObj.focus();
		}
	}
		
	alerMessageActionDetach("dv_modal",setFocusObject);
	WizModalClose();		
}


/***************************************************
	함수명 : ltrim
	기능    : 왼쪽 공백 제거 
***************************************************/	
String.prototype.ltrim = function() {
    var re = /\s*((\S+\s*)*)/;
    return this.replace(re, "$1");
 }

/***************************************************
	함수명 : rtrim
	기능    : 오른쪽  공백 제거 
***************************************************/	
String.prototype.rtrim = function() {
 var re = /((\s*\S+)*)\s*/;
 return this.replace(re, "$1");
}

/***************************************************
	함수명 : trim
	기능    : 공백 제거 
***************************************************/
String.prototype.trim = function() {
 return this.ltrim().rtrim();
}

/***************************************************
	함수명 : selectInit(obj,value)
	기능    : 콤보 박스를 해당 값으로 선택되도록 하는 기능
	파라미터 : obj - select Object
			, value  - 선택되어질 값
***************************************************/	
function selectInit(pObj, pValue){
	//var obj = document.getElementById(pObj);
	var obj = document.getElementsByName(pObj)[0];
	var objCol = obj.options

	for (idx = 0 ; idx < objCol.length ; idx++){
		if(objCol[idx].value == pValue){
			objCol[idx].selected = true;
			return true;
		}
	}
	return false;
}

/***************************************************
	함수명 : radionInit(obj,value)
	기능    : 라디오 버튼을 해당 값으로 선택되도록 하는 기능
	파라미터 : obj - select Object
			, value  - 선택되어질 값
***************************************************/	
function radioInit(pObj, pValue){
	var objCol = document.getElementsByName(pObj);
	for (idx = 0 ; idx < objCol.length ; idx++){
		if(objCol[idx].value==pValue)
			objCol[idx].checked=true;
	}
}

/***************************************************
	함수명 : radionInit(obj,value)
	기능    : 라디오 버튼을 해당 값으로 선택되도록 하는 기능
	파라미터 : obj - select Object
			, value  - 선택되어질 값
***************************************************/	
function radioValue(pObj){
	var objCol = document.getElementsByName(pObj);
	for (idx = 0 ; idx < objCol.length ; idx++){
		if(objCol[idx].checked){
			return objCol[idx].value;
		}
	}
	return "";
}


/***************************************************
	함수명 : fileUpload()
	기능    : 파일 업로드 
***************************************************/
/*function fileUpload(module,callback,limitsize, w, h){
	//var winsize = "width=300,height=200,status=yes,scrollbars=no";
	var reqUrl = "/bas/fileupload.do?_method=uploadForm";
	reqUrl +="&module="+module;
	reqUrl +="&limitSize="+limitsize;
	reqUrl +="&callback="+callback;
	
	popupWindow(reqUrl, w, h);
}
*/
/***************************************************
	함수명 : fileUpload()
	기능    : 파일 업로드 (이미지 업로드)
	params : module => 모듈명 (해당 폴더가 생김)
			 callback => 업로드 후 호출되는 함수
			 limitsize => 파일 용량 제한 (kb단위)
***************************************************/
function fileUpload(module,callback,limitsize){ 
	fileUpload(module,callback,limitsize,"kr");
}

/***************************************************
함수명 : fileUpload()
기능    : 파일 업로드 (이미지 업로드)
params : module => 모듈명 (해당 폴더가 생김)
		 callback => 업로드 후 호출되는 함수
		 limitsize => 파일 용량 제한 (kb단위)
		 locale => locale 정보 (kr,en,jp,ck,cb)
***************************************************/
function fileUpload(module,callback,limitsize,locale){
//var winsize = "width=300,height=200,status=yes,scrollbars=no";

	locale = locale !=""? locale : "kr";	
	
var reqUrl = "/"+locale+"/fileupload.do?_method=uploadForm";

reqUrl +="&module="+module;
reqUrl +="&limitSize="+limitsize;
reqUrl +="&callback="+callback;

var w = 489;
var h = 325;
popupWindow("upload",reqUrl, w, h);
}

/***************************************************
함수명 : fileUpload()
기능    : 파일 업로드 (이미지 업로드)
params : module => 모듈명 (해당 폴더가 생김)
		 callback => 업로드 후 호출되는 함수
		 limitsize => 파일 용량 제한 (kb단위)
		 index => 몇번째인지 index
		 locale => locale 정보 (kr,en,jp,ck,cb)
***************************************************/
function fileUpload_Index(module,callback,limitsize,index,locale){
//var winsize = "width=300,height=200,status=yes,scrollbars=no";

	locale = locale !=""? locale : "kr";	
	
var reqUrl = "/"+locale+"/fileupload.do?_method=uploadForm";

reqUrl +="&module="+module;
reqUrl +="&limitSize="+limitsize;
reqUrl +="&callback="+callback;
reqUrl +="&index="+index;

var w = 489;
var h = 325;
popupWindow("upload",reqUrl, w, h);
}

/***************************************************
	함수명 : fileUpload()
	기능    : 파일 업로드 (확장자 제한)
	params : module => 모듈명 (해당 폴더가 생김)
			 callback => 업로드 후 호출되는 함수
		 	 limitsize => 파일 용량 제한 (kb단위)
		 	 exts => 파일 확장자 제한 
***************************************************/
function fileUpload_Ext(module,callback,limitsize,exts){
	//var winsize = "width=300,height=200,status=yes,scrollbars=no";
	var reqUrl = "/util/fileupload.do?_method=uploadForm";
	reqUrl +="&module="+module;
	reqUrl +="&limitSize="+limitsize;
	reqUrl +="&callback="+callback;
	reqUrl +="&exts="+exts;
	
	var w = 380;
	var h = 200;
	popupWindow("upload",reqUrl, w, h);
}



/***************************************************
	함수명 : fileUpload_FullExt()
	기능    : 파일 업로드 (게시판 용 : 파일 업로드 가능 파일 확장자 지정 )
***************************************************/
function fileUpload_FullExt(module,callback,limitsize,locale){
	locale = locale !=""? locale : "kr";
	//var winsize = "width=300,height=200,status=yes,scrollbars=no";
	var reqUrl = "/"+locale+"/fileupload.do?_method=uploadForm";
	//var exts = "txt,doc,xls,ppt,docx,pptx,xlsx,hwp,gul,hpt,hst,pdf,jpg,gif,bmp,png,zip,alz";
	var exts = "doc,ppt,docx,pptx,hwp,pdf,zip,alz";
	reqUrl +="&module="+module;
	reqUrl +="&limitSize="+limitsize;
	reqUrl +="&callback="+callback;
	reqUrl +="&exts="+exts;
	
	var w = 489;
	var h = 325;
	popupWindow("upload",reqUrl, w, h);
}

/***************************************************
	기능     : Div 위치 설정 및 숨김 
****************************************************/
//Div 숨김 
function closeDivShow(objID){
	var iframeObj = document.getElementById("ifPopup");
	document.getElementById(objID).style.display = "none";	

	if(iframeObj != null && ie6_common){ 
		document.body.removeChild(iframeObj);
	}
	
}

//스크롤 설정과 DIV설정 
function setDivShow(iframe_name, div_name, popup_url, ctl_pos){
	if(iframe_name != '' && popup_url != '')
		document.getElementById(iframe_name).src = popup_url;	//주소이동
			
	var topMenuTerm = 150;	//탑메뉴 높이는 빼야함 
	var setScrollPos  = 0 ;
	if(iframe_name != '')
		 setScrollPos = ctl_pos.y - parseInt(document.getElementById(iframe_name).height);
	else
		setScrollPos = ctl_pos.y
		
	if(setScrollPos < 0)
		setScrollPos = ctl_pos.y - topMenuTerm;
		
	//alert(document.body.scrollTop + ":" + setScrollPos);
	document.body.scrollTop = setScrollPos;	//스크롤위치
	document.getElementById(div_name).style.top = ctl_pos.y +"px"; //위치설정
	document.getElementById(div_name).style.left = ctl_pos.x +"px";	//위치설정
	document.getElementById(div_name).style.display = "block"; //DIV 활성화

	if(ie6_common){		//ie 6.0 
		document.getElementById(div_name).style.zIndex = 100;
	}
}

//모바일 용 Modal 스크롤 설정과 DIV설정 : 앞에 영역 top 지정 
function setModalDivShow(div_name){
	
	var w = 400;
	var h = 330;
	var ctl_pos = findNormalPos(w,h);
	
	var topMenuTerm = 150;	//탑메뉴 높이는 빼야함 
	var setScrollPos  = 0 ;
	
	setScrollPos = ctl_pos.y;
	
	if(setScrollPos < 0)
		setScrollPos = ctl_pos.y - topMenuTerm;
	
	document.body.scrollTop = setScrollPos;	//스크롤위치
	document.getElementById(div_name).style.top = ctl_pos.y +"px"; //위치설정
	if(ie6_common){		//ie 6.0 
	//	document.getElementById(div_name).style.zIndex = 100;
	}
}



//위치설정함수
function Point(iX, iY){
	this.x = iX;
	this.y = iY;
//	alert("Point x :"+this.x+ "    Point y :"+this.y);
	
}

//콘트롤위치 찾기
function findCtlPos(ctl_obj){
 	var pos = null;
 	var curleft = 0;
 	var curtop = 0;
 	var ctl_height = parseInt(ctl_obj.offsetHeight);
	
 	if(ctl_obj.offsetParent){
		while(ctl_obj.offsetParent){  	//부모노드가 있을때까지 돕니다(없다면 루트죠)
   		curleft += ctl_obj.offsetLeft;  //부모노드로 부터 X좌표를 구합니다.
   		curtop += ctl_obj.offsetTop;  	//부모노드로 부터 X좌표를 구합니다.
   		ctl_obj = ctl_obj.offsetParent;    	//현재노드값에 부모노드를  대입합니다.
 	 	}
 	}
 	else if(ctl_obj.x && ctl_obj.x){ 
 		curleft += ctl_obj.x;
 		curtop += ctl_obj.y;
 	}

 	
 	
 	curtop = parseInt(curtop)+ctl_height+1
 	pos = new Point(curleft, curtop);
 	
 	return pos;
}


//콘트롤위치 찾기
function findNormalPos(w,h){
 	
 	var pos = null; 	
 	var SH = screen.availHeight ;
 	var SW = screen.availWidth ;
 	
 	var curLeft = 0;
 	var curTop = 0; 	

	var BT = (document.documentElement.scrollTop == 0 ? document.body.scrollTop  : document.documentElement.scrollTop);
	var BL = (document.documentElement.scrollLeft == 0 ? document.body.scrollLeft : document.documentElement.scrollLeft);
	
	var BW = (document.documentElement.clientWidth == 0? document.body.clientWidth : document.documentElement.clientWidth);
	var BH = (document.documentElement.clientHeight == 0? document.body.clientHeight : document.documentElement.clientHeight);
	
 	curLeft = ((BW - w) / 2)  +  BL;
	curTop = ((BH - h) / 2)   + BT;
	
 	pos = new Point(curLeft, curTop); 	
 	return pos;
 	
 	
}

function center(){ 
    var x,y; 
    if (self.innerHeight) { // IE 외 모든 브라우저 
        x = (screen.availWidth - self.innerWidth) / 2; 
        y = (screen.availHeight - self.innerHeight) / 2; 
    }else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict 모드 
        x = (screen.availWidth - document.documentElement.clientWidth) / 2; 
        y = (screen.availHeight - document.documentElement.clientHeight) / 2; 
    }else if (document.body) { // 다른 IE 브라우저( IE < 6) 
        x = (screen.availWidth - document.body.clientWidth) / 2; 
        y = (screen.availHeight - document.body.clientHeight) / 2; 
    } 
    pos = new Point(x, y); 	
 	return pos;
} 

/***************************************************
	함수명 : is_valid_email()
	기능    : 이메일 유효성 체크 
***************************************************/
function is_valid_email(email)
{
	var pattern = /^[_a-zA-Z0-9-\.]+@[\.a-zA-Z0-9-]+\.[a-zA-Z]+$/;
	return (pattern.test(email)) ? true : false;
}

/***************************************************
	함수명 : popupWindow
	기능    : 팝업 
***************************************************/
function popupWindow(winname, reqUrl, w, h){
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2; 
	var winsize = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars=no,resizable'; 
	var newWin = window.open(reqUrl,winname,winsize);
	newWin.focus();
}

/***************************************************
	함수명 : popupWindowS
	기능    : 팝업 (스크롤 포함)
***************************************************/
function popupWindowS(winname, reqUrl, w, h, s){
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2; 
	var winsize = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+s+',resizable'; 
	
	var newWin = window.open(reqUrl,winname,winsize);
	newWin.focus();
}



/***************************************************
	함수명 : delCookie
	기능    : 쿠키 
***************************************************/
function delCookie(name,value,expires,path,domain,secure) {
  document.cookie = name + "=" + escape (value) +
	((expires) ? "; expires=" + expires : "") +
	((path) ? "; path=" + path : "") +
	((domain) ? "; domain=" + domain : "") +
	((secure) ? "; secure" : "");
}

/***************************************************
	함수명 : setCookie
	기능    : 쿠키 설정
***************************************************/
function setCookie (name,value,expires,path,domain,secure) {
  document.cookie = name + "=" + escape (value) +
	((expires) ? "; expires=" + expires.toGMTString() : "") +
	((path) ? "; path=" + path : "") +
	((domain) ? "; domain=" + domain : "") +
	((secure) ? "; secure" : "");
}

/***************************************************
	함수명 : getCookieVal
	기능    : 쿠키 값 순서에 의해 가져오기
***************************************************/
function getCookieVal (offset) {
  var endstr = document.cookie.indexOf (";", offset);
  if (endstr == -1)
	endstr = document.cookie.length;
  return unescape(document.cookie.substring(offset, endstr));
}

/***************************************************
	함수명 : getCookieName
	기능    : 쿠키 값 이름으로 가져오기
***************************************************/
function getCookieName (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)
			return getCookieVal (j);
		i = document.cookie.indexOf(" ", i) + 1;
		if (i == 0) break;
	}
	return null;
}
    
    
/***************************************************
	함수명 : isLogin
	기능    : 로그인 유무 확인 
***************************************************/
function isLogin() {
	var v_login = false;
	var userObj = document.getElementById("s_userid");

	if(userObj != null){
		if(userObj.value != "")
			v_login= true;		
	}
	return 	v_login;
}


/***************************************************
	함수명 : inputNumber()
	기능    : input box에 숫자만 입력할 수 있도록 하는 기능
***************************************************/
function inputNumber(){
	if((event.keyCode<48) || (event.keyCode>57)) 
		event.returnValue=false;
}


/***************************************************
	함수명 : gotoFileLink()
	기능    : Upload 파일 링크 (한글 파일명일 경우 필수 사용)
***************************************************/
function gotoFileLink(pObj, pLink){
	var v_filePath= pLink;
	var v_idx = 0 ;
	var v_fileName = null;
	if(pLink != null && pLink !=""){
		v_idx = v_filePath.lastIndexOf("/");
		v_fileName = pLink.substring(v_idx+1);	//파일명 
		v_filePath = pLink.substring(0,v_idx+1); //파일경로 
	}
	pObj.target = "_blank";
	pObj.href = v_filePath + encodeURIComponent(v_fileName);
}


/***************************************************
	함수명 : showForm
	기능    : form 띄우기 
***************************************************/
function showForm(objID){
	var obj = document.getElementById(objID);
	var w = 380;
	var h = 200;
	var pos = findNormalPos(w,h);
	setDivShow('', objID, '', pos);	
}


/***************************************************
	함수명 : loginForm()
	기능    : 로그인 창 띄우기 
***************************************************/
function loginForm(){
	var v_login = isLogin();
	if(!v_login){
		showForm("dv_login");
		return false;
	}
	return true;
}


/***************************************************
	함수명 : createIframe
	기능   : select element 에 div 띄우기 위하여 iframe 생성 
	파라미터 : pos - point 객체
			   w   - 너비
			   h   - 높이 
***************************************************/
function createIframe(pos, w, h){ 
	if(ie6_common){
		var iframeObj = document.getElementById("ifPopup");
		if(iframeObj != null && ie6_common){ 
			document.body.removeChild(iframeObj);
		}
		
		iframeObj = document.createElement("iframe");
		iframeObj.src = "/blank.html";	//ssl 보안  경고 문구 없애기 위해 
		iframeObj.id = "ifPopup";
		iframeObj.style.top = pos.y + 8;
		iframeObj.style.left = pos.x + 8;
		iframeObj.style.width = w;
		iframeObj.style.height = h;
		iframeObj.style.position = "absolute";
		iframeObj.frameBorder = 0;
		iframeObj.style.zIndex = 2;
		document.body.appendChild(iframeObj);
	}
}

/***************************************************
	함수명 : resizeIframe
	기능   :  select element 에 div 띄우기 위하여 iframe 생성한
			iframe 크기 재조정 
	파라미터 :   w   - 너비
			   h   - 높이 
***************************************************/
function resizeIframe(w,h){
	if(ie6_common){ 
		var iframeObj = document.getElementById("ifPopup");
		iframeObj.style.height = h;
		iframeObj.style.width = w;
	}	
}


function getCookie( name ) 
{ 
        var nameOfCookie = name + "="; 
        var x = 0; 
        while ( x <= document.cookie.length ) 
        { 
                var y = (x+nameOfCookie.length); 
                if ( document.cookie.substring( x, y ) == nameOfCookie ) { 
                        if ( (endOfCookie=document.cookie.indexOf( ";", y )) == -1 ) 
                                endOfCookie = document.cookie.length; 
                        return unescape( document.cookie.substring( y, endOfCookie ) ); 
                } 
                x = document.cookie.indexOf( " ", x ) + 1; 
                if ( x == 0 ) 
                        break; 
        } 
        return ""; 
} 

function open_main_popup(url,window_name,param){
	if ( getCookie(window_name) != "done" ) 
	{ 
			noticeWindow  =  window.open(url,window_name,param); 
	} 
}

/***************************************************
	함수명 : checkByteInput
	기능    : 입력 내용 바이트 수 체크 
	param : objID - input object 아이디
			displayID - byte 표기 할 object ID
			maxByte	- 최대 바이트 수 
***************************************************/
function checkByte(objID,displayID, maxByte){
	var inputObj = document.getElementsByName(objID)[0];
	var byteObj = document.getElementById(displayID);	
	var v_byte = maxByte;
	if(inputObj !=null){
		v_byte = StringUtils.getByteLength(inputObj.value);
		if(v_byte > maxByte){			
			alert(maxByte+"byte를 초과하였습니다.");			
			inputObj.value = StringUtils.getLimitChar(inputObj.value, maxByte);
			v_byte = StringUtils.getByteLength(inputObj.value);
		}		
		byteObj.innerHTML = v_byte;		
	}	
}   

/***************************************************
	함수명 : checkAll
	기능    : check box 전체 선택 
***************************************************/
function checkAll(objName){
	var ctObj = document.getElementsByName(objName);
	if(ctObj != null){
		checkboxUtils.allCheck(ctObj);
	}
}



function isLoginPop(locale){
	window.open("/"+locale+"/member/member.do?_method=login_pop","win","left=0,top=0,width=489,height=373");
}

//스크롤 설정과 DIV설정 
function setDivShowExtend(iframe_name, div_name, popup_url, ctl_pos){
	if(iframe_name != '' && popup_url != '')
		document.getElementById(iframe_name).src = popup_url;	//주소이동
			
	var topMenuTerm = 150;	//탑메뉴 높이는 빼야함 
	var setScrollPos  = 0 ;
	if(iframe_name != '')
		 setScrollPos = ctl_pos.y - parseInt(document.getElementById(iframe_name).height);
	else
		setScrollPos = ctl_pos.y
		
	if(setScrollPos < 0)
		setScrollPos = ctl_pos.y - topMenuTerm;
		
	//alert(document.body.scrollTop + ":" + setScrollPos);
	document.body.scrollTop = setScrollPos;	//스크롤위치
	document.getElementById(div_name).style.top = ctl_pos.y +"px"; //위치설정
	document.getElementById(div_name).style.left = ctl_pos.x +"px";	//위치설정
	document.getElementById(div_name).style.display = "inline"; //DIV 활성화
}

//스크롤 설정과 DIV설정 
function setDivShowExtend(iframe_name, div_name, popup_url, ctl_pos){
	if(iframe_name != '' && popup_url != '')
		document.getElementById(iframe_name).src = popup_url;	//주소이동
			
	var topMenuTerm = 150;	//탑메뉴 높이는 빼야함 
	var setScrollPos  = 0 ;
	if(iframe_name != '')
		 setScrollPos = ctl_pos.y - parseInt(document.getElementById(iframe_name).height);
	else
		setScrollPos = ctl_pos.y
		
	if(setScrollPos < 0)
		setScrollPos = ctl_pos.y - topMenuTerm;
		
	//alert(document.body.scrollTop + ":" + setScrollPos);
	document.body.scrollTop = setScrollPos;	//스크롤위치
	document.getElementById(div_name).style.top = ctl_pos.y +"px"; //위치설정
	document.getElementById(div_name).style.left = ctl_pos.x +"px";	//위치설정
	document.getElementById(div_name).style.display = "inline"; //DIV 활성화
}


/***************************************************
	함수명 : DivFormExtendCtrl()
	기능    : 특정위치에 DIV 창 띄우기 (특정 element 위치 지정)
***************************************************/
function DivFormExtendCtrl(element,divID){
	var obj = document.getElementById(element);
	var pos = findCtlPos(obj);
	setDivShowExtend('', divID, '', pos);
	return;
}
                                                               

//도보관광
var _page = null;
function  fc_ifr_resize(){	 
		document.domain="visitseoul.net";
		var  lo_iframe2    =  document.getElementById("ifrmCp");  //  Iframe  객체를  지정함
		 	minHeight = 300;
			try {
				var getHeightByElement = function(body) {
					var last = body.lastChild;
					try {
						while (last && last.nodeType != 1 || !last.offsetTop) last = last.previousSibling;
						return last.offsetTop+last.offsetHeight;
					} catch(e) {
						return 0;
					}
				}
		    
				var doc = lo_iframe2.contentDocument || lo_iframe2.contentWindow.document;
				if (doc.location.href == 'about:blank') {
					lo_iframe2.style.height = minHeight+'px';
					return;
				}
				if (_page != doc.location.href) {
					window.scroll(0,0);
					_page = doc.location.href;
				}
				//window.scroll(0,0);
		 
				if (/MSIE/.test(navigator.userAgent)) {
					var h = doc.body.scrollHeight;
				} else {
					var s = doc.body.appendChild(document.createElement('DIV'))
					s.style.clear = 'both';
		 
					var h = s.offsetTop+10;
					s.parentNode.removeChild(s);
				}
		  
				if (h < minHeight) h = minHeight;
		 
				lo_iframe2.style.height = h + 'px';
				if (typeof resizeIfr.check == 'undefined') resizeIfr.check = 0;
				if (typeof lo_iframe2._check == 'undefined') lo_iframe2._check = 0;
		
			} catch (e) { 
			//  alert(e);	
			}
			setTimeout(function(){resizeIFrame("ifrmCp", minHeight);} ,100);
}

function resizeIFrame(obj, minHeight) {
	minHeight = minHeight || 10;
	try {
		var getHeightByElement = function(body) {
			var last = body.lastChild;
			try {
				while (last && last.nodeType != 1 || !last.offsetTop) last = last.previousSibling;
				return last.offsetTop+last.offsetHeight;
			} catch(e) {
				return 0;
			}
		}
    
		var doc = obj.contentDocument || obj.contentWindow.document;
		if (doc.location.href == 'about:blank') {
			obj.style.height = minHeight+'px';
			return;
		}
		if (_page != doc.location.href) {
			window.scroll(0,0);
			_page = doc.location.href;
		}
		//window.scroll(0,0);
 
		if (/MSIE/.test(navigator.userAgent)) {
			var h = doc.body.scrollHeight;
		} else {
			var s = doc.body.appendChild(document.createElement('DIV'))
			s.style.clear = 'both';
 
			var h = s.offsetTop+10;
			s.parentNode.removeChild(s);
		}
  
		if (h < minHeight) h = minHeight;
 
		obj.style.height = h + 'px';
		if (typeof resizeIfr.check == 'undefined') resizeIfr.check = 0;
		if (typeof obj._check == 'undefined') obj._check = 0;

	} catch (e) { 
	//  alert(e);	
	}
 
	setTimeout(function(){resizeIFrame(obj, minHeight);} ,100);
}


	
function menu_check(val1){
	if(val1 == 1)
		v_url= "http://www.visitseoul.net/jp/statics.do?_method=includePage&m=0003001004004&p=04&url=http://dobo.visitseoul.net/walktour/japanese_2009/course_index.jsp";
	else if(val1 == 2)
		v_url = "http://www.visitseoul.net/jp/statics.do?_method=includePage&m=0003001004004&p=04&url=http://dobo.visitseoul.net/walktour/japanese_2009/apply02.jsp";
	else if(val1 == 3)
		v_url = "http://www.visitseoul.net/jp/statics.do?_method=includePage&m=0003001004004&p=04&url=http://dobo.visitseoul.net/walktour/japanese_2009/myreserv_login.jsp";	
	else if(val1 == 4)
		v_url= "http://www.visitseoul.net/jp/statics.do?_method=includePage&m=0003001004004&p=04&url=http://dobo.visitseoul.net/walktour/japanese_2009/faq_list.jsp";
	
	location.href = v_url;
}

/***************************************************
함수명 : goSearchTotal(lang,category,query);
기능 : 통합검색 페이지 이동

category
- 통합검색 : total
- 기사 : totalNews
- 공연 영화예매 : totalIp
- 사진 : photo
- 동영상 : mov
- 태그 : tag
***************************************************/

function goSearchTotal(lang,category,query){
	
	var form = document.getElementById("frmSearch");

	form.query.value = query;
	form.category.value = category;
	form.action = "/search/search_"+lang+".jsp";

	form.submit();
}

function fitImageSize(obj, href, maxWidth, maxHeight) {
	   var image = new Image();
	 
	    image.onload = function(){
	     
	      var width = image.width;
	        var height = image.height;
	         
	        var scalex = maxWidth / width;
	        var scaley = maxHeight / height;
	         
	        var scale = (scalex < scaley) ? scalex : scaley;
	        if (scale > 1)
	            scale = 1;
	         
	        obj.width = scale * width;
	        obj.height = scale * height;
	         
	        obj.style.display = "block";
	    }
	    image.src = href;
}

function fitImageSizeView(obj, href,maxWidth) {
	   var image = new Image();
	 
	    image.onload = function(){
	     
	    	var width = image.width;
	        var height = image.height;
	         
	        if(width>maxWidth){
	        	obj.width = maxWidth;
	        }
	         
	        obj.style.display = "block";
	    }
	    image.src = href;
}



function TextOnly(){
	OnlyTextBottom();
}

function addCaption(obj){
	
}

function ImageResize(obj){
	 var maxWidth = 324;
	 var maxHeight = 243;             
	 var imgOriginal = new Image();
	 var imgObj = obj
	 imgOriginal.src = imgObj.src;
	 
	
	 if(imgOriginal.width >= maxWidth && imgOriginal.height >= maxHeight){
	  var vaseAxis;
	  if((imgOriginal.width/maxWidth) > (imgOriginal.height/maxHeight)){
	   baseAxis = "width";
	  }else{
	   baseAxis = "height";
	  }
	
	  if(baseAxis == "width"){
	   imgObj.height = Math.round(imgOriginal.height * (maxWidth/imgOriginal.width));
	   imgObj.width = Math.round(imgOriginal.width * (imgObj.height/imgOriginal.height));
	  }else{
	   imgObj.width = Math.round(imgOriginal.width * (maxHeight/imgOriginal.height));
	   imgObj.height = Math.round(imgOriginal.height * (imgObj.width/imgOriginal.width));
	  }
	 }else if(imgOriginal.width >= maxWidth && imgOriginal.height < maxHeight){
	  imgObj.width = maxWidth;
	  imgObj.height = Math.round(imgOriginal.height * (maxWidth/imgOriginal.width));
	 }else if(imgOriginal.width < maxWidth && imgOriginal.height >= maxHeight){
	  imgObj.width = Math.round(imgOriginal.width * (maxHeight/imgOriginal.height));
	  imgObj.height = maxHeight;
	 }else{
	  imgObj.height = imgOriginal.height;
	  imgObj.width = imgOriginal.width;
	 }
	 
	 if(imgObj.height < maxHeight){
	 	obj.parentNode.style.paddingTop = maxHeight / 2 - imgObj.height / 2+"px";
   		obj.parentNode.style.height = imgObj.height + maxHeight -  ( maxHeight/2)- (imgObj.height / 2)+"px";
	 }
	     
}

function addCaption2(obj){
	 var maxWidth = 324;
	 var maxHeight = 243;             
	 var imgOriginal = new Image();
	 var imgObj = obj
	 imgOriginal.src = imgObj.src;
	 
	
	 if(imgOriginal.width >= maxWidth && imgOriginal.height >= maxHeight){
	  var vaseAxis;
	  if((imgOriginal.width/maxWidth) > (imgOriginal.height/maxHeight)){
	   baseAxis = "width";
	  }else{
	   baseAxis = "height";
	  }
	
	  if(baseAxis == "width"){
	   imgObj.height = Math.round(imgOriginal.height * (maxWidth/imgOriginal.width));
	   imgObj.width = Math.round(imgOriginal.width * (imgObj.height/imgOriginal.height));
	  }else{
	   imgObj.width = Math.round(imgOriginal.width * (maxHeight/imgOriginal.height));
	   imgObj.height = Math.round(imgOriginal.height * (imgObj.width/imgOriginal.width));
	  }
	 }else if(imgOriginal.width >= maxWidth && imgOriginal.height < maxHeight){
	  imgObj.width = maxWidth;
	  imgObj.height = Math.round(imgOriginal.height * (maxWidth/imgOriginal.width));
	 }else if(imgOriginal.width < maxWidth && imgOriginal.height >= maxHeight){
	  imgObj.width = Math.round(imgOriginal.width * (maxHeight/imgOriginal.height));
	  imgObj.height = maxHeight;
	 }else{
	  imgObj.height = imgOriginal.height;
	  imgObj.width = imgOriginal.width;
	 }
	 
	 if(imgObj.height < maxHeight){
	 	obj.parentNode.style.paddingTop = maxHeight / 2 - imgObj.height / 2+"px";
   		obj.parentNode.style.height = imgObj.height + maxHeight -  ( maxHeight/2)- (imgObj.height / 2)+"px";
	 }
	     
}
	function fNewWin(name, width, height)  {
	 cw=screen.availWidth; // 화면 너비
	 ch=screen.availHeight; // 화면 높이

	 sw=width;// 띄울 창의 너비
	 sh=height;// 띄울 창의 높이

	 ml=(cw-sw)/2;// 가운데 띄우기위한 창의 x위치
	 mt=(ch-sh)/2;// 가운데 띄우기위한 창의 y위치

	 NewWindow=window.open(name,'newWin','width='+sw+',height='+sh+',top='+mt+',left='+ml+',toobar=no,scrollbars=no,menubar=no,status=no ,directories=no,'); 
	}

	function field_chk(lang){
		
		var fName = document.promotion;
		fName.user_code.value = fName.user_code_f.value;
		fName.user_id.value = fName.user_id_f.value;
		if(fName.user_id.value == "") {
			if(lang == 'kr'){
				alert("ID INSERT!!");
			}else if(lang == 'jp'){
				alert("IDを入力してください。");
			}else if(lang == 'cb'){
				alert("請輸入ID。 ");
			}
            fName.user_id_f.focus();
            return false;
        }
		if(fName.user_code.value == "") {
			if(lang == 'kr'){
				alert("ID INSERT!!");
			}else if(lang == 'jp'){
				alert("当選コードを入力してください。");
			}else if(lang == 'cb'){
				alert("請輸入中獎驗證碼。");
			}
            fName.user_code_f.focus();
            return false;
        }
        return true;
	}
	function code_chk_kr(){
		var fName = document.promotion;
		if(field_chk('kr')){

			fNewWin('', 670,500);
			fName.target = "newWin"; 
			fName.action = "/kr/promotionTicket/promotionTicket.do?_method=promotionTicket_resultChk";
			fName.user_code_f.value = "";
			fName.user_id_f.value = "";
			fName.submit();
		}
		return;
        
	}
	
	function user_chk_kr(){
		var fName = document.promotion;
		if(field_chk('kr')){
			fNewWin('', 670,600);
			fName.target = "newWin"; 
			fName.action = "/kr/promotionTicket/promotionTicket.do?_method=promotionTicket_userCodeChk";
			fName.user_code_f.value = "";
			fName.user_id_f.value = "";
			fName.submit();
		}
		return;
	}
	
	
	function code_chk_jp(){
		var fName = document.promotion;
		if(field_chk('jp')){

			fNewWin('', 670,500);
			fName.target = "newWin"; 
			fName.action = "/jp/promotionTicket/promotionTicket.do?_method=promotionTicket_resultChk";
			fName.user_code_f.value = "";
			fName.user_id_f.value = "";
			fName.submit();
		}
		return;
        
	}
	
	function user_chk_jp(){
		var fName = document.promotion;
		if(field_chk('jp')){
			alert("お申し込みの受付は7月22日14時にて終了いたしました。\n申し込み内容の確認は8月5日まで可能です。");
		}
		return;
	}
	
	function user_chk_cb(){
		var fName = document.promotion;
		if(field_chk('cb')){
			alert("本公社網站已經於7月15日在公告事項中張貼了以下公告。\n「招待券申請網頁將於7月22日下午2時(韓國時間)關閉!」\n為您帶來不便, 敬請原諒! \n");
		}
		return;
	}
	
	function code_chk_cb(){
		var fName = document.promotion;
		if(field_chk('cb')){

			fNewWin('', 670,500);
			fName.target = "newWin"; 
			fName.action = "/cb/promotionTicket/promotionTicket.do?_method=promotionTicket_resultChk";
			fName.user_code_f.value = "";
			fName.user_id_f.value = "";
			fName.submit();
		}
		return;
        
	}
	
/*
function eventUdali(lang) {
	if(lang == 'kr') {
		alert("이벤트에 참여 해 주셔서 감사합니다.\n이벤트 당첨자 발표일은 7월 9일 입니다.");
	}else if(lang == 'en') {
		alert("Thank you! You are now entered to win prizes!\nThe winners will be announced July 9th.");
	}else if(lang == 'jp') {
		alert("イベントにご参加いただきありがとうございます。\n当選者の発表日は7月9日となります。");
	}else if(lang == 'ck') {
		alert("非常感谢您参与本次活动\n7月9日将公布获奖者名单");
	}else if(lang == 'cb') {
		alert("感謝您參與本次活動\n得獎者將於7月9日公佈");
	}	
}
*/

