//------------------
// 자바스크립트 함수 정리 v.1
//호출 : 모든 페이지
//2003.08.14 전용환
//------------------
//2007.09.12 전용환 - Upload_check(filename) - 이미지 업로드 가능 확장자 체크
//2008.01.24 전용환 //------------------
// 자바스크립트 함수 정리 v.1
//호출 : 모든 페이지
//2003.08.14 전용환
//------------------
//2007.09.12 전용환 - Upload_check(filename) - 이미지 업로드 가능 확장자 체크
//2008.01.24 전용환 //------------------
// 자바스크립트 함수 정리 v.1
//호출 : 모든 페이지
//2003.08.14 전용환
//------------------
//2007.09.12 전용환 - Upload_check(filename) - 이미지 업로드 가능 확장자 체크
//2008.01.24 전용환 - CopyLink(url) - 링크경로를 간단히 마우스 클릭으로 복사하기
//2008.02.21 전용환 - GotoUrl(utl, string, target) - 페이지 바로 이동
//2008.04.02 전용환 - MousePositionxy(name, evt) 추가 - 마우스 포인트로 레이어 위치 시키기
//2008.04.03 전용환 - centerPositionxy(name) 추가 - 화면 중앙에 레이어 위치 시키기
//2008.04.12 전용환 - goURL() 과 GotoUrl() 함수를 통합  -> GotoUrl() 함수로 변경함
//2008.06.10 전용환 - 관리자 모드에서 금일주문, 금일결제 클릭시 호출됨 -> Gopage(n)
//2008.06.13 전용환 - 관리자 좌측메뉴를 bold 시키는 함수 추가함 -> Menubold()
//2008.09.11 전용환 - 자바스크립트 쿠키 -> SetCookie(name, value, time), getCookie(name), deleteCookie( name )
//2008.10.13 전용환 - https를 사용해야 하는 페이지만 https->http 제외 시킨다. ssl_changelink(ssl_portyn, ssl_port, url)
//2008.11.19 전용환 - 상품리스트에서 퀵뷰 레이어를 호출하는 함수 추가함. Quickview(item_id, item_subidkey)
//2009.05.12 전용환 - ff 에서 clipboard 사용한지 확인하는 함수 추가.CopyClip(meintext)
//2010.01.22 전용환 - 기본 검색어 input box 클릭스 내용비우기 함수 추가 texthide()
//2010.02.16 전용환 - 상품 수량으로 판매가 변경 기능 추가 stepQuantityCal(group_price_yn, group_price, quantity) -> showitem.js 로 이동시킴
//2010.02.22 전용환 - 카테고리 경로를 레이어로 호출 추가 할때 사용 viewcateon(id), viewcateoff(id)
//2010.03.20 전용환 - ModalDialog 팝업창 scroll 옵션 추가 Popup_modal(url,string, name,width,height,scroll)
//2010.06.04 전용환 - 기본 0 을 제거하는 방식 추가 onkeydown="pricecheck_4(event)" , style="ime-mode:disabled" 으로 입력필드에 영문만적용되도록 함께 설정
//2010.08.26 전용환 - CopyLink(url) 링크경로 복사가 되었는지 알려주기 추가 (ie만)
//------------------

// 2007.12.04 자리수 절사
function NumberFloorCut(number, price_unit) {

		var currency = price_unit.split('|');

		if(currency[0] == 'USD'){					//US는 소수2자리 이하 절사
			length	= -2;
		}else if(currency[0] == 'WON'){			//원화는 원단위 절사
			length	= 1;
		}else if(currency[0] == 'JPY' || currency[0] == 'CNY'){		// 절사 하지 않음
			length	= 0;
		}

		// 절삭할 자리수
		var len = '1';

		var abslength = Math.abs(length);

		for(var i=1; i <= abslength; i++) {
			len = len+'0';
		}

		len = parseInt(len);						// 형 변환

		// 음수(us달라일경우), 양수 구분하여 처리 하기 위해
		if(length.indexOf('-') == -1) {
			var result = Math.floor(number*len)/len;
		}else{
			var result = Math.floor(number/len)*len;
		}

		return result;
}

//가격단위 설정 20070228
function js_price_unit_view(send_price, price_division, price_unit, milage_unit){
//값, 마일리지/일반가격, 일반가격단위(USD,$,1), 마일리지단위
	if(price_division == 'ML'){
		var return_price = send_price +""+ milage_unit;
	}else{
		var s_unit = price_unit.split("|");

		if(s_unit[2] == '1'){	//단위 표시가 앞
			var return_price = s_unit[1] +""+ send_price;

		}else{//단위 표시가 뒤
			var return_price = send_price+""+s_unit[1];
		}
	}

	return  return_price;
}

//가격round
function js_round_price(send_price, price_unit){
//값, 일반가격단위(USD,$,1)

	var s_unit = price_unit.split('|');
	if(s_unit[0] == 'USD'){	//단위 표시가 앞
		var return_price = (send_price);

	}else{//단위 표시가 뒤
		var return_price = Math.round(send_price);
	}

	return  return_price;
}

// 가격에 ',', 원 붙이기
function Pprice_string_2(form, obj, unit ) {
	var price_ln = eval("document."+form+"."+obj+".value").length;
	var val="";
	var n_val="";
	var r=0;
	for(var i=eval(price_ln); i >= 0; i--) {
		val = eval("document."+form+"."+obj+".value").charAt(i);

		if(r%3==1 && r !=1 ) {
			n_val =val+ "," +n_val;
		} else {
			n_val = val + n_val;
		}
		r++;
	}

	return n_val + unit;
}

// 가격에 ',', 원 붙이기 -- 단위 안붙음
function Pprice_string(form, obj) {
	var price_ln = eval("document."+form+"."+obj+".value").length;
	var val="";
	var n_val="";
	var r=0;

	var chg_str  = eval("document."+form+"."+obj+".value");
	if(chg_str > 0) {

		if(chg_str.indexOf('.') > -1){
			split_str = chg_str.split('.');
			price_ln = split_str[0].length;//실수 길이
			chg_str2 = split_str[0]; //실수만 빼기
		}else{
			price_ln = price_ln;
			chg_str2 = chg_str;
		}

		for(var i=eval(price_ln); i >= 0; i--) {
			val = chg_str2.charAt(i);
			if(r%3==1 && r !=1 ) {
				n_val =val+ "," +n_val;
			} else {
				n_val = val + n_val;
			}
			r++;
		}

		if(chg_str.indexOf('.') > -1){
			n_val = n_val+"."+split_str[1];
		}else{
			n_val = n_val;
		}

		return n_val;

	} else {
		return '0';
	}
}

// 숫자만 입력가능하게
// 호출 onkeyup="pricecheck('str')"
function pricecheck(str) {
	var val="", nval="";
	var fo = eval("document.form_1."+str);
	var price = fo.value;
	var priceln = fo.value.length;

	for(var i=0;i<priceln;i++) {
		val =price.charAt(i);
		if(!(val>=0 && val<=9)) {
			nval += val.replace(val,"");
		} else {
				// 2008.01.28 첫째짜리 0 을 제거한다
				if(price.charAt(0)==0) {
					nval += val.replace(0,"");
				}else{
					nval += val;
				}
		}
	}
	eval("document.form_1."+str).value = nval;
}

// 2007.08.31 달러 표시일 경우 소수점 2째자리 까지 출력이 되야 함
// 호출 onkeyup="pricecheck_us('str')"
function pricecheck_us(form, str) {
	var val="", nval="";
	var fo = eval("document."+form+"."+str);
	var price = fo.value;
	var priceln = fo.value.length;
	var dotcount = 0;

	for(var i=0;i<priceln;i++) {
		val =price.charAt(i);

		if(!(val>=0 && val<=9) && val !='.') {		// '.' 제외
			nval += val.replace(val,"");

		} else {
			if(val =='.') {									// 첫 '.' 이외의 '.'는 '' 로 치환
				if(dotcount < 1) {
					dotcount++;
				}else{
					continue;
				}
			}
			nval += val;
		}
	}

	var nstr = nval;
	var nstrln = nval.length;
	var nstrpos = nstr.indexOf('.');

	// 소숫점 2째 자리까지만 입력되도록
	if(nstrpos > -1){

			var first = nstr.substring(0, nstrpos);
			var last = nstr.substring(nstrpos+1, nstrln);

			var lastln = last.length;

			if(lastln > 2) last = nstr.substring(nstrpos+1, nstrpos+3);

			nval = first+'.'+last;
	}

	eval("document."+form+"."+str).value = nval;
	eval("document."+form+"."+str).focus();
}


// 호출 onkeyup="pricecheck('form','str')"
function pricecheck_2(form, str) {

	var val="", nval="";
	var fo 			= eval("document."+form+"."+str);
	var price 	= fo.value;
	var priceln = fo.value.length;

	for(var i=0;i<priceln;i++) {
		val =price.charAt(i);

		if(!(val>=0 && val<=9)) {
			nval += val.replace(val,"");
		} else {
				// 2008.01.28 첫째짜리 0 을 제거한다
				if(price.charAt(0)==0) {
					nval += val.replace(0,"");
				}else{
					nval += val;
				}
		}
	}

	eval("document."+form+"."+str).value = nval;
}

// 호출 onkeyup="pricecheck_3('form','str')"	- 2008.03.07 첫째짜리 0 을 제거하지 않는 방식 추가
function pricecheck_3(form, str) {

	var val="", nval="";
	var fo 			= eval("document."+form+"."+str);
	var price 	= fo.value;
	var priceln = fo.value.length;

	for(var i=0;i<priceln;i++) {
		val =price.charAt(i);

		if(!(val>=0 && val<=9)) {
			nval += val.replace(val,"");
		} else {
			nval += val;
		}
	}

	if(nval =='') nval=0;
	eval("document."+form+"."+str).value = nval;

}

// 호출 onkeydown="pricecheck_4(event)"	- 2010.06.04 기본 0 을 제거하는 방식 추가
function pricecheck_4(e) {

	var e = e ? e : window.event;

	var keycode = parseInt(e.keyCode);
	var keyval = parseInt(String.fromCharCode(keycode));

	var shift_r = e.shiftKey;
	var shift_l = e.shiftLeft;

	//if(keycode>=48 && keycode<=57)
	//if(keycode>=96 && keycode<=105) - 오른쪽 숫자키
	if( (shift_r != true && shift_l != true) && keyval>=0 && keyval<=9){
	}else{
		// keycode 탭-9, 스페이스-32, 백스페이지-8, 엔터-13 , del-46, 좌우화살표 -37,39

		if((keycode < 96 || keycode > 105) && keycode != 37 && keycode != 39 && keycode !=8 && keycode !=9 && keycode !=13 && keycode != 46) {

			if(navigator.appName.charAt(0) !='N') {
				e.returnValue=false;
				return false;
			}else{
				e.preventDefault();
				return false;
			}
		}
	}
}

// 2008.01.17
// 호출 onkeyup="pricecheck_us_2('form','str')"
function pricecheck_us_2(form, str) {
	var val="", nval="";
	var fo = eval("document."+form+"."+str);
	var price = fo.value;
	var priceln = fo.value.length;
	var dotcount = 0;

	for(var i=0;i<priceln;i++) {
		val =price.charAt(i);

		if(!(val>=0 && val<=9) && val !='.') {		// '.' 제외
			nval += val.replace(val,"");

		} else {
			if(val =='.') {									// 첫 '.' 이외의 '.'는 '' 로 치환
				if(dotcount < 1) {
					dotcount++;
				}else{
					continue;
				}
			}
			nval += val;
		}
	}

	var nstr = nval;
	var nstrln = nval.length;
	var nstrpos = nstr.indexOf('.');

	// 소숫점 2째 자리까지만 입력되도록
	if(nstrpos > -1){

			var first = nstr.substring(0, nstrpos);
			var last = nstr.substring(nstrpos+1, nstrln);

			var lastln = last.length;

			if(lastln > 2) last = nstr.substring(nstrpos+1, nstrpos+3);

			nval = first+'.'+last;
	}

	eval("document."+form+"."+str).value = nval;
	eval("document."+form+"."+str).focus();
}


// 공백 제거
function Trim(string) {
    for(;string.indexOf(" ")!= -1;){
        string=string.replace(" ","");
    }
    return string;
}

// 새창열기a
function Popup(url,string,width,height,scroll) {
	if(string !='') {
		url = url+"?"+string;
	}
	if(scroll) {
		var scrollyn = scroll;
	} else {
		var scrollyn = "no";
	}
	window.open(url,"", "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars="+scrollyn+",resizable=no,width="+width+",height="+height+"");
}
// 새창열기 -2
function Popup_name(url,string, name,width,height,scroll) {
	if(string !='') {
		url = url+"?"+string;
	}
	if(scroll) {
		var scrollyn = scroll;
	} else {
		var scrollyn = "no";
	}

	window.open(url,name, "toolbar=no,location=no,directories=no,status=off,menubar=no,scrollbars="+scrollyn+",resizable=yes,width="+width+",height="+height+"");
}
// 새창열기 ModalDialog
function Popup_modal(url,string, name,width,height,scroll) {
	if(string !='') {
		url = url+"?"+string;
	}
	window.showModalDialog(url,name,"dialogHeight:"+height+"px; dialogWidth:"+width+"px; scroll:"+scroll+"; edge:Raised; center:Yes; help: No; resizable: No; status: No;");
}
// 삭제 할때 경고 메세지 띄우고 삭제
function Deleteid(url,string) {
	if(confirm('정말로 삭제 하시겠습니까?')) {
		var del_url = url+"?"+string;
		document.location.href = del_url;
	}
}
// 삭제 할때 경고 메세지 띄우고 삭제-2
function Deleteid_cate(url,string) {
	if(confirm('주의!\n\n카테고리를 삭제할경우 카테고리에 포함된 모든 상품이 삭제 됩니다.\n\n정말로 삭제 하시겠습니까?')) {
		var del_url = url+"?"+string;
		document.location.href = del_url;
	}
}
// 삭제 할때 경고 메세지 띄우고 삭제-2
function Backup(url,string) {
	if(confirm('주의!\n\n초기값 복원을 하시면 세팅시 적용된 초기값으로 변경됩니다.\n\n초기값으로 복원 하시겠습니까?')) {
		var del_url = url+"?"+string;
		document.location.href = del_url;
	}
}

// 점프메뉴
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  if(selObj.options[selObj.selectedIndex].value !=''){
	eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  }
  if (restore) selObj.selectedIndex=0;
}

// 카테고리 접근권한이 없을 경우 2005.08.01
function Grade_check() {
	alert("죄송합니다. 회원등급이 낮아서 접근할 수 없습니다.");
}



// 상품배송비 및 기타내용 전체변경 2005.08.01
function All_change(id, page) {
	if( confirm("전체적용일 경우 전체상품이 모두 변경됩니다. 적용 하시겠습니까?") ) {
		document.location.href="item_comment_allchange.php?comid="+id+"&page="+page;
	}
}

// window 팝업창 위치 이동 시키기 2006.07.21
function Poup_pos(type, rex, rey) {

	if(document.all) {
		 var x = document.body.clientWidth;
		 var y = document.body.clientHeight;
	}else{
		 var x = window.innerWidth;
		 var y = window.innerHeight;
	}

	var sc_w = window.screen.width;
	var sc_h = window.screen.height;

	// 중앙으로 위치 시키는것
	if(type=='c') {
		var rex = parseInt((sc_w-x)/2);
		var rey = parseInt((sc_h-y)/2);
	}
	// type !='c' 는 rex, rey 강제로 위치시키는것

	window.moveTo(rex, rey);
	window.focus();
}

//에러메세지 띄우기
//input 포커스네임, 메세지, 보낼 문자열
function errmsg_alt(vale, msg, c_vale){
	var vale;
	var msg;
	var c_vale;
	var r_value;

	alert(msg);
	if(vale){
		vale.value = c_vale;
		vale.focus();
	}
	return false;
}

/*
//2006.07.12
//orders_progress_memo.html 에서 사용 함
//string 길이 체크 및 제한 두기 checklen_vb(객체명, 허용byte, 표시해줄 byte 객체명)
*/
function checkbyte(frm, objname, maxlength, dispbyte) {

	var msgtext;
//	var eng = maxlength;
//	var kor = maxlength/2;

	var form = "document."+frm;
	msgtext = eval(form+"."+objname+".value");

	var i=0,l=0;
	var temp,lastl;
	while(i < msgtext.length)
	{
		temp = msgtext.charAt(i);

		if (escape(temp).length > 4)
			l+=2;
		else if (temp!='\r')
			l++;
		// OverFlow
		if(l>maxlength)
		{
			alert("허용 길이를 초과하셨습니다.\n "+maxlength+"byte 까지만 쓰실 수 있습니다.");
			temp = msgtext.substr(0,i);

			eval(form+"."+objname).value = temp;

			l = lastl;

			break;
		}
		lastl = l;
		i++;
	}

	// byte 표시 객체가 있을 경우 0 인경우 제외

//	if( dispbyte !='' && dispbyte !=0)
		eval(form+"."+dispbyte).value = l;

		return;
}

	//이미지 로드 관련--카테고리 사용
	function roll_menu_one(id,img) {

		var menu = new Image();
		menu.src = img; // 이미지 경로
		document.getElementById(id).src = menu.src;
	}
	function roll_menu_two(id,imgover) {
		var menu_over = new Image(); // 선언
		menu_over.src = imgover; // 이미지 경로

		document.getElementById(id).src= menu_over.src;
	}

 function callColorDlg(setcolor) {

 	if(navigator.appName.charAt(0)=='N') {
 		var path_name = self.location.pathname;
		//파이어폭스에서는 웹색상선택창이 뜨게 한다.. 페이지 경우의 수
 		if(path_name.indexOf("board_main.html") > -1 || path_name.indexOf("/Admin") > -1){
 			Popup('../../Include/color.html','Name='+setcolor,200,345,'no');
 		}else if(path_name.indexOf("Ncboard/admin/") > -1 ){
 			Popup('../../../Include/color.html','Name='+setcolor,200,345,'no');
		}else{ //기타
			Popup('../Include/color.html','Name='+setcolor,200,345,'no');
		}

	}else{
		var setcolor_val = eval("form_1."+setcolor+".value");

		if (setcolor_val == null){
		//display color dialog box
			var sColor = dlgHelper.ChooseColorDlg();
		}else{
			var sColor = dlgHelper.ChooseColorDlg(setcolor_val);
		//change decimal to hex
		}

		sColor = sColor.toString(16);
		//add extra zeroes if hex number is less than 6 digits

		if (sColor.length < 6){
		var sTempString = "000000".substring(0,6-sColor.length);
		sColor = sTempString.concat(sColor);
		}

		//change color of the text in the inputbox
		sColor = "#"+sColor;
		eval("document.form_1."+setcolor).value = sColor.toUpperCase();
		eval("document.form_1."+setcolor+".style").background =  sColor;
	}
 }

function loginCheck() {
	alert("로그인을 하신후에 이용해 주세요!     ");
	return;
}
 function callColorDlg_frm(frm, setcolor) {

 	if(navigator.appName.charAt(0)=='N') {
 		var path_name = self.location.pathname;
//alert(path_name.indexOf("Ncboard"));
 		if(path_name.indexOf("Ncboard") == -1 ){
 			Popup('board_inc/color.html','Name='+setcolor,200,345,'no');
		}else{
			Popup('../../Include/color.html','Name='+setcolor,200,345,'no');
		}

	}else{
		var setcolor_val = eval(frm+"."+setcolor+".value");

	  if (setcolor_val == null){
	   //display color dialog box
	   var sColor = dlgHelper.ChooseColorDlg();
	  }else{
	   var sColor = dlgHelper.ChooseColorDlg(setcolor_val);
	   //change decimal to hex
		}

	  sColor = sColor.toString(16);
	  //add extra zeroes if hex number is less than 6 digits

	  if (sColor.length < 6){
	   var sTempString = "000000".substring(0,6-sColor.length);
	   sColor = sTempString.concat(sColor);
	  }

	  //change color of the text in the inputbox
	  sColor = "#"+sColor;
	  eval(frm+"."+setcolor).value = sColor.toUpperCase();
	  eval(frm+"."+setcolor+".style").background =  sColor;
	}
 }

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf('?'))>0&&parent.frames.length) {
	d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
	if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
	obj.visibility=v; }
}


// 이미지 업로드 가능 확장자 체크 - 2007.09.12
function Upload_check(filename) {

	var nstrpos = filename.lastIndexOf('.');		// 뒤에서부터 검색

	// 소숫점 2째 자리까지만 입력되도록

	if(nstrpos > -1){
		var last = filename.substring(nstrpos+1);

		last.toLowerCase();	// 소문자로 체크

		if(last !='jpg' && last !='gif' && last !='png' && last !='swf') {
			alert('업로드 가능한 이미지 파일은 jpg, gif, png, swf');
			return false;
		}
	}else{
		alert('업로드 가능한 이미지 파일은 jpg, gif, png, swf');
		return false;
	}
}

// 페이지 타겟으로 이동함수 - 2007.09.13
// goURL() 과 GotoUrl() 함수를 통합  -> GotoUrl() 함수로 변경함 - 2008.04.12
// GotoUrl(url, str, target, Y/N)
function GotoUrl(url, str, target, frm) {

		if(str !='') {
			var str_url = url + '?' + str;
		}else{
			var str_url = url;
		}
		// 프레임접근여부
		if(frm.toLowerCase() =='y') {
				document.frames["'"+target+"'"].location.href = str_url;
		}else{
				if(target.replace(' ', '') =='') {
					document.location.href = str_url;
				}else{
					if(target.toLowerCase() == 'blank' || target.toLowerCase() == '_blank') {
						window.open(str_url, '', '');	 // 새창으로 열기
					}else{
						var targeturl = eval(target+'.location');
						targeturl.href = str_url;

					}
				}
		}
}

// 링크경로를 간단히 마우스 클릭으로 복사하기 - 2008.01.24
function CopyLink(url) {

	if(document.all) {
		window.clipboardData.setData('Text', url);

		var imgurl = window.clipboardData.getData('Text');

		// 2010.08.26 - 링크경로 복사가 되었는지 알려주기 추가
		if(url == imgurl) {
			alert("주소가 복사 되었습니다.");
		}
	}else{
		return CopyClip(url);
	}
}

// 마우스 포인트로 레이어 위치 시키기 - 2008.04.02
function MousePositionxy(name, evt) {
	currentX = (parseInt(evt.clientX) + parseInt(document.body.scrollLeft));
	currentY = (parseInt(evt.clientY) + parseInt(document.body.scrollTop));

	document.getElementById(name).style.left = currentX+'px';
	document.getElementById(name).style.top = currentY+'px';
}

// 화면 중앙에 레이어 위치 시키기 - 2008.04.03
function centerPositionxy(name) {
	var win_width=0, win_height=0;
	var currentX=0, currentY=0;
	var de =0;
	var width = parseInt(document.getElementById(name).style.width);
	var height = parseInt(document.getElementById(name).style.height);

	// window 창크기
	if(document.all) {
		 win_width = parseInt(document.body.clientWidth);
		 win_height = parseInt(document.body.clientHeight);
	}else{
		 win_width = parseInt(window.innerWidth);
		 win_height = parseInt(window.innerHeight);
	}
	currentX = parseInt((win_width-width)/2);
	currentY = parseInt((win_height-height)/2);

	document.getElementById(name).style.left = currentX+de+'px';
	document.getElementById(name).style.top = currentY+de+'px';

}

// 2008.06.13 - 관리자 좌측메뉴를 bold 시키는 함수 추가함. Menubold()
function Menubold(m){

			for(var i=1; i<26; i++){
				var name = 'me'+i;
				if(parent.ncfrm_left.document.getElementById(name)){
					parent.ncfrm_left.document.getElementById(name).style.fontWeight='normal';
					parent.ncfrm_left.document.getElementById(name).style.color='#666666';
				}else{
					break;
				}
			}

			parent.ncfrm_left.document.getElementById(m).style.fontWeight='bold';
			parent.ncfrm_left.document.getElementById(m).style.color='#33CC33';
}

// 2008.06.10 관리자 메인에서 금일주문, 금일결제 클릭시 호출됨
function Gopage(n){

	var now = new Date();
	var year = now.getFullYear();
	var month = now.getMonth()+1;
	var day = now.getDate();

	if(month<10) month = '0'+month;
	if(day<10) day = '0'+day;

	var date = '&start_y='+year+'&start_m='+month+'&start_d='+day+'&end_y='+year+'&end_m='+month+'&end_d='+day;

	if(n=='1') {	// 오늘주문
		parent.ncfrm_center.location.href = '../Ordersview/order_list_all.html?extension_5=1&search_5=pay_date'+date;
		location.href = '../frame_set/ordersview_left.html';

	}else if(n=='2'){	// 오늘결제
		parent.ncfrm_center.location.href = '../Ordersview/order_list_all.html?extension_5=1&search_5=pay_date&progress_2=2-결제완료'+date;
		location.href = '../frame_set/ordersview_left.html';
	}
}

// 2008.08.13 관리자 상단TOP에서 금일주문, 금일결제 클릭시 호출됨
function GopageTop(n){

	var now = new Date();
	var year = now.getFullYear();
	var month = now.getMonth()+1;
	var day = now.getDate();

	if(month<10) month = '0'+month;
	if(day<10) day = '0'+day;

	var date = '&start_y='+year+'&start_m='+month+'&start_d='+day+'&end_y='+year+'&end_m='+month+'&end_d='+day;

	var prm = window.parent.parent.main_center;

	if(n=='1') {	// 오늘주문
		prm.ncfrm_center.location.href = '../Ordersview/order_list_all.html?extension_5=1&search_5=pay_date'+date;
		prm.ncfrm_left.location.href = '../frame_set/ordersview_left.html';

	}else if(n=='2'){	// 오늘결제
		prm.ncfrm_center.location.href = '../Ordersview/order_list_all.html?extension_5=1&search_5=pay_date&progress_2=2-결제완료'+date;
		prm.ncfrm_left.location.href = '../frame_set/ordersview_left.html';
	}
}

// 디자인관리 - 스킨부분에서 사용됨
function Skinpopup(url, name) {
	var width = screen.availWidth-20;
	var height = screen.availHeight-90;

	var left = 0;
	var top = 0;
	var scrollyn = 'yes';

	window.open(url, name, "toolbar=no,location=no,directories=no,status=off,menubar=no,scrollbars="+scrollyn+",resizable=yes,width="+width+",height="+height+",left="+left+",top="+top);
}


// 쿠키 굽기
function SetCookie(name, value, time) {
	var ExpDate2 = new Date();
	ExpDate2.setTime(ExpDate2.getTime()+1000*60*60*time);	// 쿠키 지속시간
	document.cookie = name+"="+escape(value)+"; expires="+ExpDate2.toGMTString()+"; path=/;";
}

// 쿠키 찾기
function getCookie(name) {

	var i=0;
	var Found = false;
	var start, end;
	while(i <= document.cookie.length) {
		start =i;
		end = start+name.length;
		if(document.cookie.substring(start, end) == name) {
			Found = true;
			break;
		}
		i++;
	}
	if(Found == true) {
		start = end+1;
		end = document.cookie.indexOf(';',start);
		if(end < start)
			end = document.cookie.length;
			return document.cookie.substring(start, end);

	}
	return '';
}

// 쿠키 삭제
 function deleteCookie( name ){
  document.cookie = name+"=; expires=-1; path=/;";
 }


//2008.10.13 https를 사용해야 하는 페이지만 https->http 제외 시킨다. ssl_changelink(ssl_portyn, ssl_port, url)
//호출은 Function_group.php 의 SSL_changelink() 에서 호출한다.
function ssl_changelink(ssl_portyn, ssl_port, url) {

	//이미 php 페이지 내에서 http -> https 로 변경하는 작업이 되어있는데 안전장치 차원의 재검사를 또 하다보니
	//페이지 로딩이 느려져서 주석 처리함 2011-04-01 11:37:23 (금)
	/*
	var port = '';
	if(ssl_portyn=='Y'){
			port = ssl_port;
	}

	// https 로 링크변경할 페이지의 파라메터
	var pageArray = new Array('?Cpn=member_modify', '?Cpn=myreceipt_view', '?Cpn=mysearch_orderview', '?Cpn=myreceipt_form', '?ncmode=bmodify');
	var arraylen = pageArray.length;

 	var len=document.links.length;

	for(i=0; i< len; i++){

		var host = document.links[i].host;

		if(host.indexOf(url) > -1 ) {

				if(document.links[i].host !=''){
						document.links[i].protocol = 'http';
						document.links[i].port = '80';
						document.links[i].host = document.location.hostname;
				}

			// 보안서버 사용할 경우 https 로 링크걸 사이트
				for(r=0; r<arraylen; r++){
					if(document.links[i].search !='') {
						var stringval = document.links[i].search;
						if( stringval.indexOf(pageArray[r]) >-1 ){
							document.links[i].protocol = 'https';
							document.links[i].port = port;
							document.links[i].host = document.location.hostname;
						}
					}

				}	// for(r=0; r<arraylen; r++) end

		}	// if(host.indexOf('url') > -1 ) { end

	} // for(i=0; i< len; i++) end
	*/
}


//2008.11.19 상품리스트에서 퀵뷰 레이어를 호출하는 함수 추가함. Quickview(item_id, item_subidkey)
function Quickview(item_id, item_subidkey) {

		// view레이어가 열려 있다면 닫아준다
		if(document.getElementById('Quickview_Layer').style.display == '') {
				document.getElementById('Quickview_Layer').style.display = 'none';
				if(navigator.appName.charAt(0)=='N') window.parent.document.getElementById('Quickview_Layer').style.visibility="hidden";
		}

		document.getElementById('Quickview_Layer').style.display = '';


		// 레이어 중앙에 위치시킴
		var width = parseInt(document.getElementById('Quickview_Layer').style.width);
		var height = parseInt(document.getElementById('Quickview_Layer').style.height);

		// window 창크기
		if(document.all) {
			 win_width = parseInt(document.body.clientWidth);
		}else{
			 win_width = parseInt(window.innerWidth);
		}

		var currentX = parseInt((win_width-width)/2);
		var currentY = parseInt(document.body.scrollTop) + parseInt(height/5);

		document.getElementById('Quickview_Layer').style.left = currentX+'px';
		document.getElementById('Quickview_Layer').style.top = currentY+'px';
		//

		document.getElementById('quickview_frame').src = '../Cart/showitem_quickview.html?itemID='+item_id+'&item_subidkey='+item_subidkey;
}
//2008.11.19 상품리스트에서 퀵뷰 레이어를 닫기 함수 추가함. QuickClose()
function QuickClose() {
	if(document.getElementById('Quickview_Layer')){
		document.getElementById('Quickview_Layer').style.display = 'none';
		if(navigator.appName.charAt(0)=='N') document.getElementById('Quickview_Layer').style.visibility="hidden";
	}
	document.getElementById('quickview_frame').src = '';
}
function QuickopenerClose() {
	if(window.parent.document.getElementById('Quickview_Layer')){
		window.parent.document.getElementById('Quickview_Layer').style.display = 'none';
		if(navigator.appName.charAt(0)=='N') window.parent.document.getElementById('Quickview_Layer').style.visibility="hidden";
	}
}

// ff 에서 clipboard 사용한지 확인하는 함수 추가.CopyClip(meintext)
function CopyClip(meintext){
	if(window.netscape){
		try{
			  netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
		} catch (err) {
			// alert('브라우져는 자동소스 복사를 사용할 수 없습니다. Ctrl + C 를 이용하세요');
			 return false;
		}

      var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);
      if (!clip) return;
      var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);
      if (!trans) return;
      trans.addDataFlavor('text/unicode');
      var str = new Object();
      var len = new Object();
      var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);
      var copytext=meintext;
      str.data=copytext;
      trans.setTransferData("text/unicode",str,copytext.length*2);
      var clipid=Components.interfaces.nsIClipboard;
      if (!clip) return false;
      clip.setData(trans,null,clipid.kGlobalClipboard);

	  alert('소스가 복사 되었습니다.');
   }
    return false;
}


//2010.02.22 - 카테고리 경로를 레이어로 호출 추가 할때 사용
function viewcateon(id) {
	if(document.getElementById(id)) document.getElementById(id).style.display = 'block';
}
function viewcateoff(id) {
	if(document.getElementById(id)) document.getElementById(id).style.display = 'none';
}

function viewauto(id){

	if(document.getElementById(id)){
		if(document.getElementById(id).style.display == 'none'){
			document.getElementById(id).style.display = 'block';
		}else if(document.getElementById(id).style.display == 'block'){
			document.getElementById(id).style.display = 'none';
		}
	}
}



//2010.05.06 카테고리 접근권한이 없을 경우
function Grade_checklogin() {
	//alert('로그인후 이용해 주세요');
	document.location.href='../Member/main.html?Cpn=page_login';
}
