function iePass(idx){
 document.write(document.getElementById(idx).value); 
}

function fileCheck(obj) {
	// 선택파일의 경로를 분리하여 확장자를 구합니다.
	pathpoint = obj.lastIndexOf('.');
	filepoint = obj.substring(pathpoint+1,obj.length);
	filetype = filepoint.toLowerCase();

	// 확장자가 이미지 파일이면 preview에 보여줍니다.
	if(filetype=='jpg' || filetype=='gif' || filetype=='png' || filetype=='jpeg' || filetype=='bmp') {
		regform.preview.src = obj;
//		obj_src = obj;
	} else {
	// 이미지 확장자가 아닐경우 경고를 주며, 원래의 임시 이미지 경로로 바꿔줍니다.
		alert('이미지 파일만 업로드 하실수 있습니다.');
		document.regform.preview.src = '/admin/images/tech/11.jpg';
		return false;
	}
			
	// 이미지 확장자이지만 BMP 확장자라면 일단 경고를 준다.
	// 이 부분은 꼭 필요한 부분은 아니지만 제가 운영자라면 bmp 파일은 용량이 크기때문에 웬지.. -_-;
	if(filetype=='bmp') {
		upload = confirm('BMP 파일은 웹상에서 사용하기엔 적절한 이미지 포맷이 아닙니다.\n그래도 계속 하시겠습니까?');
		if(!upload) return false;
	}
}

function filetypeCheck(obj) {
	// 선택파일의 경로를 분리하여 확장자를 구합니다.
	pathpoint = obj.lastIndexOf('.');
	filepoint = obj.substring(pathpoint+1,obj.length);
	filetype = filepoint.toLowerCase();

	// 확장자가 이미지 파일이면 preview에 보여줍니다.
	if(filetype=='jpg' || filetype=='gif' || filetype=='png' || filetype=='jpeg') {
		return true;
//		obj_src = obj;
	} else {
	// 이미지 확장자가 아닐경우 경고를 주며, 원래의 임시 이미지 경로로 바꿔줍니다.
		alert('허용되지 않는 파일 확장자입니다.');
		return false;
	}
	 var imgInfo        = new Image(); 			
	 imgInfo.onload = img_Load();
	// 이미지 확장자이지만 BMP 확장자라면 일단 경고를 준다.
	// 이 부분은 꼭 필요한 부분은 아니지만 제가 운영자라면 bmp 파일은 용량이 크기때문에 웬지.. -_-;
}

function img_Load(){ 
   var imgSrc, imgWidth, imgHeight, imgFileSize; 
   var maxFileSize; 
   maxFileSize    = 1024000; 
   imgSrc            = this.src; 
   imgWidth        = this.width; 
   imgHeight        = this.height; 
   imgFileSize    = this.fileSize; 

   if (imgWidth > 100 || imgHeight > 100){ 
      alert('가로 100px 또는 세로 100px을 초과하는 이미지파일을 가져올 수 없습니다.'); 
       return; 
    } 

     if (imgFileSize > maxFileSize){ 
           alert('선택하신 그림 파일은 허용 최대크기인 ' + maxFileSize/1024 + ' KB 를 초과하였습니다.'); 
            return; 
     } 
} 

var isNN = (navigator.appName.indexOf("Netscape")!=-1); 
function autoTab(input,len, e) { 
var keyCode = (isNN) ? e.which : e.keyCode; 
var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46]; 
if(input.value.length >= len && !containsElement(filter,keyCode)) { 
input.value = input.value.slice(0, len); 
input.form[(getIndex(input)+1) % input.form.length].focus(); 
} 
function containsElement(arr, ele) { 
var found = false, index = 0; 
while(!found && index < arr.length) 
if(arr[index] == ele) 
found = true; 
else 
index++; 
return found; 
} 
function getIndex(input) { 
var index = -1, i = 0, found = false; 
while (i < input.form.length && index == -1) 
if (input.form[i] == input)index = i; 
else i++; 
return index; 
} 
return true; 
} 

/*
function CheckAll(f) {
	var val = f.checkall.checked;
	var cbox = f.check;
	len = f["check[]"].length;
	var j=0;
	for(j = 0; j < len; j++) {
		var checkbox_obj = f["check[]"][j];
		if(val == false) {
			checkbox_obj.checked=false;
		} else {
			checkbox_obj.checked=true;
		}
	}	
}
*/
function CheckAjaxAll() {
	var f = document.all;
	var val = f.checkall.checked;
    for (var i=0; i<f.length; i++) {
        if (f.elements[i].name == "check[]") {
			if(val == true) {
	            f.elements[i].checked = true;
			} else {
				f.elements[i].checked = false;
			}
		}
    }
}


function CheckAll(f) {
	var val = f.checkall.checked;
    for (var i=0; i<f.length; i++) {
        if (f.elements[i].name == "check[]") {
			if(val == true) {
	            f.elements[i].checked = true;
			} else {
				f.elements[i].checked = false;
			}
		}
    }
}

function  checkUserSelect(f) {
	var check_nums = f.elements.length;
	for(var i = 0; i < check_nums; i++) {
	  var checkbox_obj = eval("f.elements[" + i + "]");
	  if(checkbox_obj.checked == true) {
	     break;
	  }
	}	

	if(i == check_nums) {
	  alert("먼저 리스트를 선택하여 주십시오");
	  return false;   
	} else {
	  ref = confirm("정말 삭제하시겠습니까?");
	  if(ref == true) {
	      f.submit();
	  } else {
		  return;
	  }
   }   
}

function  checkUserEdit(f) {
	var check_nums = f.elements.length;
	for(var i = 0; i < check_nums; i++) {
	  var checkbox_obj = eval("f.elements[" + i + "]");
	  if(checkbox_obj.checked == true) {
	     break;
	  }
	}	

	if(i == check_nums) {
	  alert("먼저 리스트를 선택하여 주십시오");
	  return false;   
	} else {
	  ref = confirm("정말 수정하시겠습니까?");
	  if(ref == true) {
	      f.submit();
	  } else {
		  return;
	  }
   }   
}


function checkUserDefault(f, str, action) {
	var check_nums = f.elements.length;
	for(var i = 0; i < check_nums; i++) {
	  var checkbox_obj = eval("f.elements[" + i + "]");
	  if(checkbox_obj.checked == true) {
	     break;
	  }
	}	

	if(i == check_nums) {
	  alert("먼저 리스트를 선택하여 주십시오");
	  return false;   
	} else {
	  ref = confirm(str);
	  if(ref == true) {
		  f.action = action;
	      f.submit();
	  } else {
		  return;
	  }
   }   
}

function checkUserForm(form, str, action) {
	var f = document.forms[form];
	var check_nums = f.elements.length;
	for(var i = 0; i < check_nums; i++) {
	  var checkbox_obj = eval("f.elements[" + i + "]");
	  if(checkbox_obj.checked == true) {
	     break;
	  }
	}	

	if(i == check_nums) {
	  alert("먼저 리스트를 선택하여 주십시오");
	  return false;   
	} else {
	  ref = confirm(str);
	  if(ref == true) {
		  f.action = action;
	      f.submit();
	  } else {
		  return;
	  }
   }   
}

function checkUserBase(form) {
	var f = document.forms[form];
	var check_nums = f.elements.length;
	for(var i = 0; i < check_nums; i++) {
	  var checkbox_obj = eval("f.elements[" + i + "]");
	  if(checkbox_obj.checked == true) {
	     break;
	  }
	}	

	if(i == check_nums) {
	  alert("먼저 리스트를 선택하여 주십시오");
	  return;   
	} else {
	  ref = confirm("정말 삭제하시겠습니까?");
	  if(ref == true) {
	      f.submit();
	  } else {
		  return;
	  }
   }   
}

function PopWindow(theURL,width,height,scroll) {
	if(scroll == "Y") {
		scrollbars = "yes";
	} else {
		scrollbars = "no";
	}

	features = "width=" + width + ", height=" + height + ", scrollbars=" + scrollbars + ", resizable=yes";
	winName = "";
	window.open(theURL,winName,features);
}

function PopUp(theURL,winName,features) {
	window.open(theURL,winName,features);
}
function page_move(url) {
	location.href=url;
}

var prev_tab="";
function expand_content(cur_tab)
{

	if (prev_tab != "") 
		document.getElementById(prev_tab).style.display="none";
		document.getElementById(cur_tab).style.display="block";

		prev_tab = cur_tab;
//		expand_reple(0);
}


function expand_content1(cur_tab,im)
{
	var ff = document.getElementById(im);

	if (prev_tab != "") 
		document.getElementById(prev_tab).style.display="none";
		document.getElementById(cur_tab).style.display="block";

		prev_tab = cur_tab;
	if (cur_tab != "")	{ ff.focus(); }
}


var nscp = (navigator.appName == "Netscape") 
var ismc = (navigator.appVersion.indexOf("Mac") != -1) 
var vers = parseFloat(navigator.appVersion.substring(22,25)) 

function getObj(obj) { 
  if (nscp) { 
     compLayr = document.layers[obj]
  }else{ 
     compLayr = eval("document.all." + obj + ".style")
  } 
  return compLayr
} 

function showHide(name){ 
	obj = getObj(name) ;
	if(obj.display == "none") {
		obj.display = "block";
		
	} else {
		obj.display = "none";
	}
}

function showHide1(name,im){ 
	obj = getObj(name) ;
	var ff = document.getElementById(im);

	if(obj.display == "none") {
		obj.display = "block";
		ff.focus();
		
	} else {
		obj.display = "none";
	}
}


//AJAX 스크립트
var xmlhttp;

function xmlhttp_create()
{
	var a = null;
	if (window.ActiveXObject) {
		try
		{
			a = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e1)
		{
			try
			{
				a = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e2)
			{
				a=null
			}
		}
	}
	if (!a && typeof XMLHttpRequest != "undefined") {
	// if (window.XMLHttpRequest) {
		a = new XMLHttpRequest();
	}
	return a;
}

function xmlhttp_process() 
{
	if (xmlhttp.readyState == 4) {
		if (xmlhttp.status == 200) {
			if (xmlhttp.responseText.length>1) {
				alert(xmlhttp.responseText);
				// xmlhttp = null;
			}
		} else {
			alert("Error:" + xmlhttp.statusText);
		}
	}
}



function xmlhttp_load(url) {
	xmlhttp = xmlhttp_create();
	if (xmlhttp) {
		xmlhttp.onreadystatechange = xmlhttp_process;
		xmlhttp.open("GET", url, true);
		xmlhttp.send(null);
	}
}


function BoardDel(url) {
	var ref = confirm("정말 삭제하시겠습니까?");
	if(ref == true) {
		location.href=url;
	} else {
		return false;
	}
}



function iframe_move(iframe_name, url) {
	eval(iframe_name + ".document.location.href='" + url + "';");
}

function BoardDelFrame(frame_name,url, str) {
	var ref = confirm(str + "\n\n정말 삭제하시겠습니까?");
	if(ref == true) {
		eval(frame_name + ".location.href='" + url + "';");
	} else {
		return false;
	}
}

function showImage(img,e,width,height)
{
	var x = e.pageX ? e.pageX : document.body.scrollLeft+event.clientX;
	var y = e.pageY ? e.pageY : document.body.scrollTop+event.clientY;
	var l = document.getElementById('img_layer');

	l.style.top = y - 10;
	l.style.left = x + 10;
	l.style.display = 'block';
	l.innerHTML = "<img src='"+img+"' width='" + width + "' height='" + height + "'>";
}

function closeImage() {
	var l = document.getElementById('img_layer');
	l.style.display = 'none';
}


function ZipSearch(zip, addr, f) {	
	theURL = "/mem_refer/zipsearch.php?zip_field=" + zip + "&addr_field=" + addr + "&form=" + f;
	winName = "";
	features = "width=500, height=300, scrollbars=no";
	window.open(theURL,winName,features);
}

function TakbaeZipSearch(zip1,zip2,addr,f) {
	theURL = "/mem_auth/takbae_zipsearch.php?zip_field_1=" + zip1 + "&zip_field_2=" + zip2 + "&addr_field=" + addr + "&form=" + f;
	winName = "";
	features = "width=500, height=300, scrollbars=no";
	window.open(theURL,winName,features);
}

function LookVod(url) {
	theURL = url;
	winName = "select_vod";
	features = "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no, width=300,   height=400, resizable=no,left=100,top=100";
	window.open(theURL,winName,features);
}


//로그인 체크 부분	
function verify(f)
{
        var error = '';
        if ( !f.login_id.value ) {
                alert("아이디를 입력해 주십시오.");
                f.login_id.focus();
                return false;
        }else if ( !f.login_pw.value ) {
                alert("비밀번호를 입력해 주십시오.");
                f.login_pw.focus();
                return false;
        }else{
                if(f.ssl_check.checked){
                        f.action = 'https://ssl.daehangosi.net/lib/login.php';
                }
                //아이디 저장이 있으면
                if(f.id_check != undefined){
				var id_value = f.login_id.value;
                		if(f.id_check.checked){
                			document.cookie = "id_check=ok ; path=/ ; ";
                			document.cookie = "id_value=" + id_value + " ; path=/ ; ";
                		}else{
                			document.cookie = "id_check=no ; path=/ ; " ;
                		}
                }
					return true;
        }
}

function parent_move(url) {
	parent.document.location.href=url;
}


function  checkSelect(shape, branch) {
	var f = document.pkg_form;

	var check_nums = f.elements.length;
	for(var i = 0; i < check_nums; i++) {
	  var checkbox_obj = eval("f.elements[" + i + "]");
	  if(checkbox_obj.checked == true) {
	     break;
	  }
	}	


	if(i == check_nums) {
	  alert("먼저 리스트를 선택하여 주십시오");
	  return false;   
	} else {
		switch(shape) {
			case "basket" :
			case "m_basket" :
				var str = "정말 장바구니에 등록하시겠습니까?";
				var act_url = "/mall/common/act_process.php?mode=" + shape + "&branch=" + branch;
				break;
/*			case "buy" :				
				var str = "정말 바로구입 하시겠습니까?";		
				f.target = "_top";
				var act_url = "./?mall=settle&pg=order_form&mode=" + shape + "&branch=" + branch;
				break;
*/
			case "buy" :
				var str = "정말 바로구입 하시겠습니까?";
				var act_url = "/mall/settle/order_exist.php?mode=" + shape + "&branch=" + branch;
				break;
			case "m_buy" :
				var str = "정말 바로구입 하시겠습니까?";		
				f.target = "_top";
				var act_url = "/mall/common/act_process.php?mode=" + shape + "&branch=" + branch;
				break;
			case "wish" :
			case "m_wish" :
				var str = "찜하시겠습니까?";
				var act_url = "/mall/common/act_process.php?mode=" + shape + "&branch=" + branch;
				break;
		}
				
		ref = confirm(str);
		if(ref == true) {
			f.action = act_url;
		    f.submit();
		} else {
			return;
		}
   }   
}

function checkSubmit(shape, branch) {
	var f = document.pkg_form;
	switch(shape) {
		case "buy" :					
			f.target = "_top";
			var act_url = "./?mall=settle&pg=order_form&mode=" + shape + "&branch=" + branch;
			break;
	}

	f.action = act_url;
	f.submit();
}


function LogOut() {
	common_iframe.document.location.href="/mall/common/login_process.php?mode=logout";
}

	function PopView(type) {
		var pkg_pk = document.all.m_select_pkg.value;
		switch(type) {
			case "P" :
				theURL = "/inc/pkg_view.php?pkg_pk=" + pkg_pk;
				break;
			case "B" :
				theURL = "/inc/book_view.php?pkg_pk=" + pkg_pk;
				break;
		}
		
		winName = "";
		features = "width=520, height=600, scrollbars=yes, resizable=yes";
		window.open(theURL,winName,features);
	}

function ImgFileView(tbl, col, pk, field, width, height) {
	theURL = "./inc/imgfile_view.php?tbl=" + tbl + "&col=" + col + "&pk=" + pk + "&field=" + field;
	winName = "";
	features = "width=" + width + ", height=" + height + ", scrollbars=no";

	window.open(theURL, winName, features);
}


function id_check(name){ 
	if(isNaN(name) == false) {
		alert("영문소문자 또는 영문+숫자 혼합형으로 입력하십시요.");
		return false;
	}

	if(!strLengthCheck(name.length)) {
		return false;
	}

	for (i = 0 ; i < name.length ; i++) { 
		sko = name.charAt(i); 
		if(i == 0) {
			if(isNaN(sko) == false) {
				alert("첫문자는 무조건 영문이어야 합니다.");
				return false;
			} 
		}
		if ((sko < '0' || sko > '9') && (sko < 'a' || sko > 'z')) { 
			alert("영문 소문자와 숫자만 입력하세요!"); 
      //숫자 혹은 영소문자가 아닌 글자가 하나라도 있으면 
      //false를 반환하고 이하는 수행안함. 
			return false; 
		} 
	}
	return true;
  } 


	function strLengthCheck(number) {
		if(number < 3 || number > 20) {
			alert("3자 이상 20자 이하로 입력하십시요");
			return false;
		} else {
			return true;
		}
	}

	function get_move(url) {
		document.location.href=url;
	}

	function get_pop_move(url) {
		window.open(url, 'popWin', '');
	}
	
	var focus_popup = null;
    var bdown = false;
    var x, y;
 
    function changeInt(num){
       var temp = parseInt(num);
            if(isNaN(temp)){
            temp = 0;
        }
        return temp;
    }
 
    function popup_set(p){
         focus_popup     = eval("document.all."+p);
    }
 
     function popup_move(){
          if(bdown) {
                var distX = event.clientX - x;
                var distY = event.clientY - y;
                focus_popup.style.left =changeInt(focus_popup.style.left) + distX;
                focus_popup.style.top  = changeInt(focus_popup.style.top) + distY;
                x = event.clientX;
                y = event.clientY;
                return false;
		    }
        }
 
        function popup_down(){
			if(event.srcElement.className == "drag") {
                bdown = true;
			    x = event.clientX;
                y = event.clientY;
			}
        }
 
        function popup_up(){
                 focus_popup = null;
                bdown =false;
        }
 
       function popup_close(p){
                focus_popup = null;
                bdown =false;
                eval("document.all." + p + ".style.display='none';");
                eval("f = document.all." +p + "_chk;");
                if(f.checked){
                        setCookie(f.value, 'done' , 1);
                }
        }

       function pop_resv_close(p){
                focus_popup = null;
                bdown =false;
                eval("document.all." + p + ".style.display='none';");
        }

     document.onmousedown = popup_down;
    document.onmouseup = popup_up;
    document.onmousemove =popup_move;


