//━━━━━━━━━━━━━━━━━━━━━━━
// 창닫기
//───────────────────────
   function selfClose(){
        if(navigator.appVersion.indexOf("MSiE 7.0") >= 0 ){
            window.open('about:blank','_self').close();
        }else{
            window.opener = self;
            self.close();
        }
    }

//━━━━━━━━━━━━━━━━━━━━━━━
// 폼생성
//───────────────────────
function createForm(str_Name,str_Method,str_Action,str_Target) {
	var form=document.createElement("form");
	form.name		=	str_Name;
	form.method	=	str_Method;
	form.action		=	str_Action;
	form.target		=	str_Target;
	return form;
}

//───────────────────────
// <Input type="hidden"> 태그
//───────────────────────
function addHidden(form,Name,value) {
  var input = document.createElement("input");
  input.type		="hidden";
  input.name	=Name;
  input.value	=value;
  form.insertBefore(input);
  return form;
}

//━━━━━━━━━━━━━━━━━━━━━━━
// getElementById 개체 얻기
//───────────────────────
function GID(ElementName) {
	try {
		var form = document.getElementById(ElementName);
	}catch(e){
		var form = "";
	}
	return form;
}
//━━━━━━━━━━━━━━━━━━━━━━━
// getElementById.value 값 얻기
//───────────────────────
function get_ID(ElementName) {
	try {
		var form = document.getElementById(ElementName).value;
	}catch(e){
		var form = "";
	}
	return form;
}
//━━━━━━━━━━━━━━━━━━━━━━━
// TageName.value 값 얻기
//───────────────────────
function TagValue(ObjDOM,TagName){
	try {
		Result =  ObjDOM.getElementsByTagName(TagName)[0].childNodes[0].nodeValue;
	}catch(e){
		//alert(TagName+"이 읍따");
		Result = "";
	}
	
	return Result;
}
//━━━━━━━━━━━━━━━━━━━━━━━
// TageName 갖고 상위 객체
//───────────────────────
function parentTagName(obj, tagName) {
	var isMatch = eval('/^' + tagName + '$/i').test(obj.tagName);
		if (isMatch) {
			return obj;
		} else {
			return parentElementByTagName(obj.parentElement, tagName);
		}
}
//━━━━━━━━━━━━━━━━━━━━━━━
// ID값에 innerHTML
//───────────────────────
function InnerHTML(ID,HTML){
	try {
		document.getElementById(ID).innerHTML = HTML;
	}catch(e){
		
	}
}
//━━━━━━━━━━━━━━━━━━━━━━━━━
// allCheck (헤드id/적용id)
//─────────────────────────
function Chk_all(obj_id,Target_id){

	var Obj		= GID(obj_id).checked;
	var Target	= eval("document.all."+Target_id+"");

	try{
		var Length = Target.length;
	}catch(e){
		var Length = 0;
	}

	//체크박스 여러개일경우
	if (GID(Target_id) == '[object]' && Length > 0){
		if (Obj == true){
			for (var i = 0; i < Length ; i++ ){
				if (Target[i].disabled != true){
					Target[i].checked = true;
				}
			}
		}else{
			for (var i = 0; i < Length ; i++ ){
				if (Target[i].disabled != true){
					Target[i].checked = false;
				}
			}
		}
	//단일체크박스경우 
	}else{

		if (Obj == true){
			Target.checked = true;
		}else{
			Target.checked = false;
		}
	}

}
//━━━━━━━━━━━━━━━━━━━━━━━
// Replace
//───────────────────────
function Replace(obj, Str_word, Str_Change){
	var Result = eval(" obj.replace( /"+Str_word+"/gi , \""+Str_Change+"\" );");
	return Result;
}


//━━━━━━━━━━━━━━━━━━━━━━━
// Instr
//───────────────────────
function Instr(obj, Str_Word){
	var Result = obj.indexOf(Str_Word);
	return Result;
}
//━━━━━━━━━━━━━━━━━━━━━━━
// 돈표시
//───────────────────────
function Money(val) {
	var num = val.trim();
	while((/(-?[0-9]+)([0-9]{3})/).test(num)) {
		num = num.replace((/(-?[0-9]+)([0-9]{3})/), "$1,$2");
	}
	return num;
}
//━━━━━━━━━━━━━━━━━━━━━━━
// 해당Obj 배경색 바꾸기
//───────────────────────
function OBJ_BGColor(Obj,Color) {
	eval("Obj.style.backgroundColor = \""+ Color + "\"");
}

//━━━━━━━━━━━━━━━━━━━━━━━
// 뷰창 및 하위 흰색바탕 닫기 
//───────────────────────
function Close_Layer(Layer_ID){
	document.getElementById(Layer_ID).style.display = "none";
	try{
	document.getElementById("whiteboard").style.display = "none";
	}catch(e){	}
}
//━━━━━━━━━━━━━━━━━━━━━━━
// 흰색바탕 열기
//───────────────────────
function OpenWhiteWall(){
	var Old_Layer = top.document.getElementById("Drag_Layer").value;
	var frm	=	top.document.getElementById("whiteboard");
	try{
		top.document.getElementById(Old_Layer).style.zIndex = 50;
	}catch(e){}
	frm.style.width= top.document.body.scrollWidth;
	frm.style.height = top.document.body.scrollHeight;
	frm.style.display="block";
	frm.style.zIndex = 75;
}
//━━━━━━━━━━━━━━━━━━━━━━━
// 라디오/체크박스 체크여부 (val = name)
//───────────────────────
function ReturnCheck(val){
	var frm = eval("document.all."+val);
	var check = false;
	for (var i = 0 ; i < frm.length ; i++ ){
		if (frm[i].checked == true){
			check = true;
		}
	}
	return check;
}
//━━━━━━━━━━━━━━━━━━━━━━━
// 레이어 닫기/열기
//───────────────────────
function None_Layer(Layer_ID){
	document.getElementById(Layer_ID).style.display = "none";
}
function Block_Layer(Layer_ID){
	document.getElementById(Layer_ID).style.display = "block";
}
//━━━━━━━━━━━━━━━━━━━━━━━
// 모든레이어 닫기
//───────────────────────
function Close_All_Layer(){
	var layers = document.getElementsByTagName("div");
	for(var i=0;i<layers.length;i++){
	  layers[i].style.display = "none";
	}
	try{
	document.getElementById("Drag_Layer").value = "";
	}catch(e){	}

}
//━━━━━━━━━━━━━━━━━━━━━━━
// 체크박스 체크 여부
//───────────────────────
function CheckboxCheck(frm){
	var check = false;
	if (frm.length >= 1){
		for(var i=0;i < frm.length ; i++){
			if (frm[i].type=='checkbox' && frm[i].checked){check = true;}
		}
	}else if(data.item_check.checked){
		check = true;
	}
	return check;
}


//━━━━━━━━━━━━━━━━━━━━━━━
//좌측 공백제거
//─────────────────────
function L_Trim(oStr){
	while (1) {
		if (oStr.substring(0,1) != " "){
break;
		}
		oStr = oStr.substring(1, oStr.length);
	}
	return oStr;
}

//─────────────────────
//우측 공백제거
//─────────────────────
function R_Trim(oStr){
	while (1) {
		if (oStr.substring(oStr.length - 1,oStr.length) != " "){
break;
		}
		oStr = oStr.substring(0, oStr.length - 1);
	}
	return oStr;
}

//─────────────────────
//양쪽 공백제거
//─────────────────────
function B_Trim(oStr){
	var Str;
	return R_Trim(L_Trim(oStr));
}

//━━━━━━━━━━━━━━━━━━━━━━━
// FSO 폴더생성
//───────────────────────
function CreatFolder(Folder_Name){
	var fso = new ActiveXObject("Scripting.FileSystemObject");
	if (fso.FolderExists(Folder_Name)) {    
//		var fldr = fso.CreateFolder(Folder_Name); 
	}else{
		var fldr = fso.CreateFolder(Folder_Name); 
	}
	fldr.close();
}

//───────────────────────
// FSO 파일생성
//───────────────────────
function CreatFile(File_Name,OverWrite,Contents){
	var fso = new ActiveXObject("Scripting.FileSystemObject");
	if (fso.FileExists(File_Name)) {    
		var ofile = fso.OpenTextFile(File_Name, 8, true);
	}else{
		var ofile = fso.CreateTextFile(File_Name, true);
	}
	ofile.Write(Contents);
	ofile.close();
}

//───────────────────────
// FSO 파일삭제
//───────────────────────
function DeleteFile(File_Name){
	var fso = new ActiveXObject("Scripting.FileSystemObject");
	if (fso.FileExists(File_Name)) {    
		fso.DeleteFile(File_Name);
	}
}

//───────────────────────
//이미지 리사이즈
//───────────────────────
Image_Object=new Array();

function View_Image(){ 

	IMG_Obj=event.srcElement;

	var Big_Img=new Image();
	Big_Img.src=IMG_Obj.original;
	Big_Img.id ="Big_I";

	var w = Big_Img.width;
	var h  = Big_Img.height;

//	var w=Image_Object[IMG_Obj.name].w; 
//	var h=Image_Object[IMG_Obj.name].h; 

	test=window.open('','tst','width='+w+',height='+h); 
	test.document.write("<body topmargin=0 leftmargin=0 background="+Big_Img.src+" onclick=self.close() onload=\"\">"); 
 }

function View_Full_Image(val){ 

	IMG_Obj="/UploadFiles/Goods/"+val;

	var w=Image_Object[IMG_Obj.name].w; 
	var h=Image_Object[IMG_Obj.name].h; 

	test=window.open('','tst','width='+w+',height='+h); 
	test.document.write("<body topmargin=0 leftmargin=0 background="+IMG_Obj+" onclick=self.close()>"); 

 }

function Resize_IMG(width_Size,Height_Size){
	IMG_Obj=event.srcElement; 

	var w		= IMG_Obj.width; 
	var h		= IMG_Obj.height;

	Image_Object[IMG_Obj.name]		=	new Object(); 
	Image_Object[IMG_Obj.name].w	=	IMG_Obj.width;
	Image_Object[IMG_Obj.name].h	=	IMG_Obj.height;

	if(w>width_Size){ //너비가 한계치보다 크면
		h/=w/width_Size; //높이 재설정
		w=width_Size; //너비 재설정
	}

	if(h>Height_Size){ //너비가 한계치보다 크면
		w/=h/Height_Size; //높이 재설정
		h=Height_Size; //너비 재설정
	}
	
	IMG_Obj.width=w; //너비 갱신
	IMG_Obj.height=h; //높이 갱신

}


//───────────────────────
// Null 값환훤
//───────────────────────
function nvl(value, replacer){
	if ( value == null){
		return replacer;
	}else{
		return value;
	}
}

function nvl2(value, replacer){
	if ( value == null || value == "" ){
		return replacer;
	}else{
		return value;
	}
}

function isnull(value){
	if ( value == null){
		return true;
	}else{
		return false;
	}
}
function isnull2(value){
	if ( value == null || value == "" ){
		return true;
	}else{
		return false;
	}
}



//━━━━━━━━━━━━━━━━━━━━━━━
// 이미지 롤오버
//━━━━━━━━━━━━━━━━━━━━━━━

function CHIMG(obj){
	var str = obj.src;               
	if(str.indexOf('_on.gif') < 0){         
		ss = str.substr(0, str.indexOf('.gif'))      
		obj.src = ss + "_on.gif";                         
	}else{                                      
		ss = str.substr(0, str.indexOf('_on.gif'))
		obj.src = ss + ".gif";
	}
}


//━━━━━━━━━━━━━━━━━━━━━━━
// 투명 PNG
//━━━━━━━━━━━━━━━━━━━━━━━
function setPng24(obj) { 
	obj.width=obj.height=1; 
	obj.className=obj.className.replace(/\bpng24\b/i,''); 
	obj.style.filter = 
	"progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+ obj.src +"',sizingMethod='image');" 
	obj.src='';  
	return ''; 
}
//━━━━━━━━━━━━━━━━━━━━━━━
// URL 인/디코딩
//───────────────────────
function encodeURL(str){

	var s0, i, s, u;
	s0 = "";           
	for (i = 0; i < str.length; i++){   
		s = str.charAt(i);
		u = str.charCodeAt(i);        

		if (s == " "){s0 += "+";}     
		else {
if ( u == 0x2a || u == 0x2d || u == 0x2e || u == 0x5f || ((u >= 0x30) && (u <= 0x39)) || ((u >= 0x41) && (u <= 0x5a)) || ((u >= 0x61) && (u <= 0x7a))){       // check for escape
	s0 = s0 + s;        
}else {                 

                if ((u >= 0x0) && (u <= 0x7f)){ 
                    s = "0"+u.toString(16);
                    s0 += "%"+ s.substr(s.length-2);
                }
                else if (u > 0x1fffff){   
                    s0 += "%" + (oxf0 + ((u & 0x1c0000) >> 18)).toString(16);
                    s0 += "%" + (0x80 + ((u & 0x3f000) >> 12)).toString(16);
                    s0 += "%" + (0x80 + ((u & 0xfc0) >> 6)).toString(16);
                    s0 += "%" + (0x80 + (u & 0x3f)).toString(16);
                }
                else if (u > 0x7ff){  
                    s0 += "%" + (0xe0 + ((u & 0xf000) >> 12)).toString(16);
                    s0 += "%" + (0x80 + ((u & 0xfc0) >> 6)).toString(16);
                    s0 += "%" + (0x80 + (u & 0x3f)).toString(16);
                }
                else { 
                    s0 += "%" + (0xc0 + ((u & 0x7c0) >> 6)).toString(16);
                    s0 += "%" + (0x80 + (u & 0x3f)).toString(16);
                }
            }
        }
	}
    return s0;
}



function decodeURL(str){
    var s0, i, j, s, ss, u, n, f;
    s0 = "";     
    for (i = 0; i < str.length; i++){
        s = str.charAt(i);
        if (s == "+"){s0 += " ";}
        else {
            if (s != "%"){s0 += s;}
            else{
                u = 0;
                f = 1;
                while (true) {
                    ss = "";
                        for (j = 0; j < 2; j++ ) {
                            sss = str.charAt(++i);
                            if (((sss >= "0") && (sss <= "9")) || ((sss >= "a") && (sss <= "f"))  || ((sss >= "A") && (sss <= "F"))) {
                                ss += sss;
                            } else {--i; break;}
                        }
                   n = parseInt(ss, 16);
                    if (n <= 0x7f){u = n; f = 1;}
                    if ((n >= 0xc0) && (n <= 0xdf)){u = n & 0x1f; f = 2;}
                    if ((n >= 0xe0) && (n <= 0xef)){u = n & 0x0f; f = 3;}
                    if ((n >= 0xf0) && (n <= 0xf7)){u = n & 0x07; f = 4;}
                    if ((n >= 0x80) && (n <= 0xbf)){u = (u << 6) + (n & 0x3f); --f;}
                    if (f <= 1){break;}
                    if (str.charAt(i + 1) == "%"){ i++ ;}
                    else {break;}
                }
            s0 += String.fromCharCode(u); 
            }
        }
    }
    return s0;
}


/*━━━━━━━━━━━━━━━━━━━━━━━
 Base64 encode / decode
 사용법
────────────────────────
	Base64.encode(strValue);
	Base64.decode(strValue);
	Base64._utf8_encode(strValue);
	Base64._utf8_decode(strValue);
	Base64.URLEncode(strValue);
	Base64.URLDecode(strValue);
━━━━━━━━━━━━━━━━━━━━━━━*/

var Base64 = {

	// private property
	_keyStr : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",

	// public method for encoding
	encode : function (input) {
		var output = "";
		var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
		var i = 0;

		input = Base64._utf8_encode(input);

		while (i < input.length) {

			chr1 = input.charCodeAt(i++);
			chr2 = input.charCodeAt(i++);
			chr3 = input.charCodeAt(i++);

			enc1 = chr1 >> 2;
			enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
			enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
			enc4 = chr3 & 63;

			if (isNaN(chr2)) {
				enc3 = enc4 = 64;
			} else if (isNaN(chr3)) {
				enc4 = 64;
			}

			output = output +
			this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) +
			this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4);

		}

		return output;
	},

	// public method for decoding
	decode : function (input) {
		var output = "";
		var chr1, chr2, chr3;
		var enc1, enc2, enc3, enc4;
		var i = 0;

		input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");

		while (i < input.length) {

			enc1 = this._keyStr.indexOf(input.charAt(i++));
			enc2 = this._keyStr.indexOf(input.charAt(i++));
			enc3 = this._keyStr.indexOf(input.charAt(i++));
			enc4 = this._keyStr.indexOf(input.charAt(i++));

			chr1 = (enc1 << 2) | (enc2 >> 4);
			chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
			chr3 = ((enc3 & 3) << 6) | enc4;

			output = output + String.fromCharCode(chr1);

			if (enc3 != 64) {
				output = output + String.fromCharCode(chr2);
			}
			if (enc4 != 64) {
				output = output + String.fromCharCode(chr3);
			}

		}

		output = Base64._utf8_decode(output);
		return output;

	},

	// private method for UTF-8 encoding
	_utf8_encode : function (string) {
		string = string.replace(/\r\n/g,"\n");
		var utftext = "";

		for (var n = 0; n < string.length; n++) {

			var c = string.charCodeAt(n);

			if (c < 128) {
				utftext += String.fromCharCode(c);
			}
			else if((c > 127) && (c < 2048)) {
				utftext += String.fromCharCode((c >> 6) | 192);
				utftext += String.fromCharCode((c & 63) | 128);
			}
			else {
				utftext += String.fromCharCode((c >> 12) | 224);
				utftext += String.fromCharCode(((c >> 6) & 63) | 128);
				utftext += String.fromCharCode((c & 63) | 128);
			}

		}

		return utftext;
	},

	// private method for UTF-8 decoding
	_utf8_decode : function (utftext) {
		var string = "";
		var i = 0;
		var c = c1 = c2 = 0;

		while ( i < utftext.length ) {

			c = utftext.charCodeAt(i);

			if (c < 128) {
				string += String.fromCharCode(c);
				i++;
			}
			else if((c > 191) && (c < 224)) {
				c2 = utftext.charCodeAt(i+1);
				string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
				i += 2;
			}
			else {
				c2 = utftext.charCodeAt(i+1);
				c3 = utftext.charCodeAt(i+2);
				string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
				i += 3;
			}

		}

		return string;
	},
	
	URLEncode : function (string) {   
        return escape(this._utf8_encode(string));   
    },   
  
    // public method for url decoding   
    URLDecode : function (string) {   
        return this._utf8_decode(unescape(string));   
    }
}

//━━━━━━━━━━━━━━━━━━━━━━━
// Trim
//───────────────────────
String.prototype.trim = function() {
	return this.replace(/(^\\s*)|(\\s*$)/g, "");
}

//━━━━━━━━━━━━━━━━━━━━━━━
// LTrim
//───────────────────────
String.prototype.lrim = function() {
	return this.replace(/(^\\s*)/, "");
}

//━━━━━━━━━━━━━━━━━━━━━━━
// RTrim
//───────────────────────
String.prototype.rtrim = function() {
	return this.replace(/(\\s*$)/, "");
}

//━━━━━━━━━━━━━━━━━━━━━━━
// replaceAll
//───────────────────────
String.prototype.replaceAll = function(str1, str2)
    {
      var temp_str = "";

      if (this.trim() != "" && str1 != str2)
      {
        temp_str = this.trim();

        while (temp_str.indexOf(str1) > -1){
          temp_str = temp_str.replace(str1, str2);
        }
      }

      return temp_str;
    }

//━━━━━━━━━━━━━━━━━━━━━━━
// 문자열길이 반환 Byte
//───────────────────────
String.prototype.byte = function() {
	var cnt = 0;
	for (var i = 0; i < this.length; i++) {
		if (this.charCodeAt(i) > 127){
			cnt += 2;
		}else{
			cnt++;
		}
	}
	return cnt;
}
//━━━━━━━━━━━━━━━━━━━━━━━
// 정수형으로 반환 (@return : String)
//───────────────────────
String.prototype.int = function() {
	if(!isNaN(this)) {
		return parseInt(this);
	}else {
		return null;    
	}
}

//━━━━━━━━━━━━━━━━━━━━━━━
// 숫자만 가져오기 (@return : String)
//───────────────────────
String.prototype.num = function() {
	return (this.trim().replace(/[^0-9]/g, ""));
}

//━━━━━━━━━━━━━━━━━━━━━━━
// 3자리수 콤마 (돈표시) (@return : String)
//───────────────────────
String.prototype.money = function() {
	var num = this.trim();
	while((/(-?[0-9]+)([0-9]{3})/).test(num)) {
		num = num.replace((/(-?[0-9]+)([0-9]{3})/), "$1,$2");
	}
	return num;
}

//━━━━━━━━━━━━━━━━━━━━━━━
// 숫자의 자리수(cnt)에 맞도록 반환 (@return : String) - Ex: 01 001
//───────────────────────
String.prototype.digits = function(cnt) {
	var digit = "";
	if (this.length < cnt) {
		for(var i = 0; i < cnt - this.length; i++) {
			digit += "0";
		}
	}
	return digit + this;
}

//━━━━━━━━━━━━━━━━━━━━━━━
//파일 확장자만 가져오기 (@return : String)
//───────────────────────
String.prototype.ext = function() {
	return (this.indexOf(".") < 0) ? "" : this.substring(this.lastIndexOf(".") + 1, this.length);    
}

//━━━━━━━━━━━━━━━━━━━━━━━
//URL에서 파라메터 제거한 순수한 url 얻기(@return : String)
//───────────────────────
String.prototype.URL = function() {
	var arr = this.split("?");
	arr = arr[0].split("#");
	return arr[0];    
}


//━━━━━━━━━━━━━━━━━━━━━━━
//최소 최대 길이인지 검증(@return : boolean) str.isLength(min [,max])
//입력폼에서 사용 STR.isLength(4,20) 4자이상 20자 이내이면 true
//───────────────────────
String.prototype.isLength = function() {
	var min = arguments[0];
	var max = arguments[1] ? arguments[1] : null;
	var success = true;
	if(this.length < min) {
		success = false;
	}
	if(max && this.length > max) {
		success = false;
	}
	return success;
}
//━━━━━━━━━━━━━━━━━━━━━━━
// 최소 최대 바이트인지 검증(@return : boolean) str.isByteLength(min [,max])
//입력폼에서 사용 STR.isLength(4,20) 4바이트이상 20바이트 이내이면 true
//───────────────────────
String.prototype.isByteLength = function() {
	var min = arguments[0];
	var max = arguments[1] ? arguments[1] : null;
	var success = true;
	if(this.byte() < min) {
		success = false;
	}
	if(max && this.byte() > max) {
		success = false;
	}
	return success;

 }

//━━━━━━━━━━━━━━━━━━━━━━━
// 공백이나 널인지 확인(@return : boolean) / Trim이 있어야함
//───────────────────────
String.prototype.isBlank = function() {
	var str = this.trim();
	for(var i = 0; i < str.length; i++) {
		if ((str.charAt(i) != "\\t") && (str.charAt(i) != "\\n") && (str.charAt(i)!="\\r")) {
			return false;
		}
	}
	return true;
}

//━━━━━━━━━━━━━━━━━━━━━━━
// 숫자로 구성되어 있는지 학인arguments[0] : 허용할 문자셋(@return : boolean)
//───────────────────────
String.prototype.isNum = function() {
	return (/^[0-9]+$/).test(this.remove(arguments[0])) ? true : false;
}

//━━━━━━━━━━━━━━━━━━━━━━━
// 영어만 허용 arguments[0] : 허용할 문자셋(@return : boolean)
//───────────────────────
String.prototype.isEng = function() {
	return (/^[a-zA-Z]+$/).test(this.remove(arguments[0])) ? true : false;
}

//━━━━━━━━━━━━━━━━━━━━━━━
// 숫자와 영어만 허용 arguments[0] : 허용할 문자셋(@return : boolean)
//───────────────────────
String.prototype.isEngNum = function() {
	return (/^[0-9a-zA-Z]+$/).test(this.remove(arguments[0])) ? true : false;
}

//━━━━━━━━━━━━━━━━━━━━━━━
// 숫자와 영어만 허용 arguments[0] : 허용할 문자셋(@return : boolean)
//───────────────────────
String.prototype.isNumEng = function() {
	return this.isEngNum(arguments[0]);
}

//━━━━━━━━━━━━━━━━━━━━━━━
// 아이디 체크 영어와 숫자만 체크 첫글자는 영어로 시작 arguments[0] : 허용할 문자셋(@return : boolean)
//───────────────────────
String.prototype.isUserid = function() {
	return (/^[a-zA-z]{1}[0-9a-zA-Z]+$/).test(this.remove(arguments[0])) ? true : false;
}

//━━━━━━━━━━━━━━━━━━━━━━━
// 한글 체크 arguments[0] : 허용할 문자셋(@return : boolean)
// 한글이 포함되어 있으면 true, 하나도 포함되어 있지 않으면 false
//───────────────────────
String.prototype.isKor = function() {
	if(this!=null){
		for(var i=0;i<this.length;i++){
			if(this.charCodeAt(i)>=0 && this.charCodeAt(i)<=127){	// ascii
			}else{													// 한글 혹은 특수문자
				return true;
			}
		}
	}

	return false;
	//return (/^[가-힣]+$/).test(this.remove(arguments[0])) ? true : false;
}

//━━━━━━━━━━━━━━━━━━━━━━━
//  주민번호 체크 - arguments[0] : 주민번호 구분자 (@return : boolean)
//───────────────────────
String.prototype.isJumin = function() {
	var arg = arguments[0] ? arguments[0] : "";
	var jumin = eval("this.match(/[0-9]{2}[01]{1}[0-9]{1}[0123]{1}[0-9]{1}" + arg + "[1234]{1}[0-9]{6}$/)");

	if(jumin == null) {
		return false;
	}else {
		jumin = jumin.toString().num().toString();
	}

	 // 생년월일 체크
	var birthYY = (parseInt(jumin.charAt(6)) == (1 ||2)) ? "19" : "20";
	birthYY += jumin.substr(0, 2);
	var birthMM = jumin.substr(2, 2) - 1;
	var birthDD = jumin.substr(4, 2);
	var birthDay = new Date(birthYY, birthMM, birthDD);

	if(birthDay.getYear() % 100 != jumin.substr(0,2) || birthDay.getMonth() != birthMM || birthDay.getDate() != birthDD) {
		return false;
	}        

	var sum = 0;
	var num = [2, 3, 4, 5, 6, 7, 8, 9, 2, 3, 4, 5]
	var last = parseInt(jumin.charAt(12));
	for(var i = 0; i < 12; i++) {
		sum += parseInt(jumin.charAt(i)) * num[i];
	}

	return ((11 - sum % 11) % 10 == last) ? true : false;

}

//━━━━━━━━━━━━━━━━━━━━━━━
//사업자번호 체크 - arguments[0] : 등록번호 구분자 (@return : boolean)
//───────────────────────
String.prototype.isBiznum = function() {
	var arg = arguments[0] ? arguments[0] : "";
	var biznum = eval("this.match(/[0-9]{3}" + arg + "[0-9]{2}" + arg + "[0-9]{5}$/)");

	if(biznum == null) {
		return false;
	}else {
		biznum = biznum.toString().num().toString();
	}

	var sum = parseInt(biznum.charAt(0));
	var num = [0, 3, 7, 1, 3, 7, 1, 3];

	for(var i = 1; i < 8; i++) sum += (parseInt(biznum.charAt(i)) * num[i]) % 10;
	sum += Math.floor(parseInt(parseInt(biznum.charAt(8))) * 5 / 10);
	sum += (parseInt(biznum.charAt(8)) * 5) % 10 + parseInt(biznum.charAt(9));

	return (sum % 10 == 0) ? true : false;
}

//━━━━━━━━━━━━━━━━━━━━━━━
//법인 등록번호 체크 - arguments[0] : 등록번호 구분자 (@return : boolean)
//───────────────────────
String.prototype.isCorpnum = function() {
	var arg = arguments[0] ? arguments[0] : "";
	var corpnum = eval("this.match(/[0-9]{6}" + arg + "[0-9]{7}$/)");
	if(corpnum == null) {
		return false;
	}else {
		corpnum = corpnum.toString().num().toString();
	}

	var sum = 0;
	var num = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]
	var last = parseInt(corpnum.charAt(12));

	for(var i = 0; i < 12; i++) {
		sum += parseInt(corpnum.charAt(i)) * num[i];
	}
	return ((10 - sum % 10) % 10 == last) ? true : false;
}

//━━━━━━━━━━━━━━━━━━━━━━━
// 이메일의 유효성을 체크 (@return : boolean)
//───────────────────────
String.prototype.isEmail = function() {
	return (/\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.[a-zA-Z]{2,4}$/).test(this.trim());
}


//━━━━━━━━━━━━━━━━━━━━━━━
// 전화번호 체크 arguments[0] : 전화번호 구분자 (@return : boolean)
//───────────────────────
String.prototype.isPhone = function() {
	var arg = arguments[0] ? arguments[0] : "";
	return eval("(/(02|0[3-9]{1}[0-9]{1})" + arg + "[1-9]{1}[0-9]{2,3}" + arg + "[0-9]{4}$/).test(this)");
}

//━━━━━━━━━━━━━━━━━━━━━━━
// 핸드폰번호 체크 - arguments[0] : 핸드폰 구분자 (@return : boolean)
//───────────────────────
String.prototype.isMobile = function() {
	var arg = arguments[0] ? arguments[0] : "";
	return eval("(/01[016789]" + arg + "[1-9]{1}[0-9]{2,3}" + arg + "[0-9]{4}$/).test(this)");
}

//━━━━━━━━━━━━━━━━━━━━━━━
// Iframe 자동확장
//━━━━━━━━━━━━━━━━━━━━━━━
function getReSize(o)
{
       try {
              var objFrame = GID(o);
              var objBody = eval(o+".document.body");

              ifrmHeight = objBody.scrollHeight + (objBody.offsetHeight - objBody.clientHeight);

              if (ifrmHeight > 0) {
                     objFrame.style.height = ifrmHeight;
              } else {
                     objFrame.style.height = 0;
              }
              objFrame.style.width = '100%'
       } catch(e) {
       };
}

function OptionSelect(selObj,selVal) {
	if (selObj) {
		for(var i=0;i<selObj.options.length;i++) {
			if (selObj.options[i].value==selVal) {
				selObj.options[i].selected=true;
				return;
			}
		}
	}
}

function RdoSelect(selObj,selVal) {
	if (selObj) {
	if (selObj.length) {
		for(var i=0;i<selObj.length;i++) {
			if (selObj[i].value==selVal) {
				selObj[i].checked=true;
				return;
			}
		}
	}}
}

String.prototype.zform=function(pformat){
	var arg = this ? this : "";

	if(pformat.length<=arg.length){
		return arg;
	}else{
		return pformat.substr(0,pformat.length-arg.length) + arg;
	}
}

function dateToString(pDate,pDateDiv){
	var result="";

	if(!pDateDiv) pDateDiv="-";

	if(pDate){
		result+=pDate.getYear();
		result+=pDateDiv;
		result+=String(pDate.getMonth()+1).zform("00");
		result+=pDateDiv;
		result+=String(pDate.getDate()).zform("00");
	}

	return result;
}
String.prototype.isNum=function(){
   var str=this;
   
   if(str.length <= 0)
     return false;


   for(i=0; i<str.length; i++)
   {
     var cv = str.charCodeAt(i);
     if(!( 0x30 <=cv && cv<= 0x39))
     {
         return false;

     }
   }   
   return true;

}

function openPopupWindow(url,win_name,vwidth,vheight,vscrollbar,vleft,vtop,vresizable,props){
	if(props==null){
		props="toolbar=no,location=no,status=no,menubar=no";
	}

	if(vleft==null) vleft=parseInt(screen.width/2)-parseInt(vwidth/2);
	if(vtop==null) vtop=parseInt(screen.height/2)-parseInt(vheight/2)-50;
	if(vscrollbar==null) vscrollbar="no";
	if(vresizable==null) vresizable="no";

	vtop=(vtop<0)?0:vtop;

	props+=",width="+vwidth;
	props+=",height="+vheight;
	props+=",left="+vleft;
	props+=",top="+vtop;
	props+=",scrollbars="+vscrollbar;
	props+=",resizable="+vresizable;

	var hwin=null;
	hwin=window.open(url,win_name,props);
	hwin.focus();
}

// onkeyup="javascript:return moveFocus(this,nextFocusObj,sizeNumber);"
function moveFocus(srcObj,nextObj,txtSize){
	if(!srcObj.value.isNum()){
		srcObj.value=srcObj.value.substr(0,srcObj.value.length-1);
	}

	if(srcObj.value=="02" || srcObj.value.length>=txtSize){
		nextObj.focus();
	}

	return true;
}

// 파일명 얻기
function getFileName(filepath){
	if(filepath==null) filepath="";
	if(filepath.trim()=="") return "";

	// 파일명 반환
	var partPos=filepath.lastIndexOf("\\");

	if(partPos>-1){
		return filepath.substr(partPos+1);
	}

	return "";
}

//─────────────────────────────────────────────────────────────────
// 상품이미지 없을때 대체하는 이미지 96*68 (2007.11.3 신범섭 추가)
//─────────────────────────────────────────────────────────────────
function ShopListViewImg_Error(o){ 
o.src="/Korean/Club2008/images/temp/temp_96x68.gif";
} 