/************************************    공통 관련 Link    **************************************************/

/**
 * GNB 링크
 *
 * made by mercurii. 2009.10.21
 */
 function fnGo(no, value) {
	switch(no) {
		case "login" : // 로그인
			showLogin(1);
			break;
		case "center" :	// 고객센터
			location.href = "/actions/FrontPage?cmd=list&url=/ckcifront/customer/notice_list.jsp";
			break;
		case "logout" :
			location.href = "/actions/LoginUserAction?cmd=logout";	// 로그아웃
			break;
		case "member" :
			location.href = "/actions/MemberShipAction?cmd=agreePage";// 회원가입
			break;
		case "event" :
			location.href = "/actions/FrontPage?cmd=list&url=/ckcifront/customer/event_list.jsp";//이벤트
			break;
		case "list_open" :
			//document.all.Layer.style.visibility = "visible";
			//layer_view_open();								//전체 제품 이름 메뉴 열기
			break;
		case "list_close" :
			//layer_view_close();									//전체 제품 이름 메뉴 닫기
			break;
		case "home" :
			location.href = "/actions/CategorySiteMainView?cmd=view";// 메인으로가기
			break;
		case "mycanon" :
			location.href = "/actions/MyCanonClubPointList?cmd=list";//마이캐논
			break;
		case "webzine" :
			location.href = "/actions/PlayCkciWebzineAction?cmd=view";//웹진
			break;

		case "0//" :
			location.href = "/actions/CategoryProductMainView?cmd=view"; //프로덕트 메인
			break;
		case "0/0" :
			location.href = "/actions/ProductMainEosList?cmd=list"; //EOS시리즈
			break;
		case "0/1" :
			location.href = "/actions/ProductMainIxusList?cmd=list"; //IXUS시리즈
			break;
		case "0/2" :
			location.href = "/actions/ProductMainPowershotList?cmd=list"; //파워샷시리즈
			break;
		case "0/3" :
			location.href = "/actions/ProductMainLensList?cmd=list"; //EF 렌즈
			break;
		case "0/4" :
			location.href = "/actions/ProductMainPrinterList?cmd=list"; //포토프린터
			break;
		case "0/5" :
			location.href = "/actions/ProductMainCamList?cmd=list"; //캠코더
			break;
		case "0/6" :
			location.href = "/actions/ProductMainProjectorList?cmd=list"; //프로젝터
			break;
		case "0/7" :
			location.href = "/actions/ProductMainAccList?cmd=list&menu_id=7001"; //악세서리
			break;
		case "0/8" :
			location.href = "/actions/ProductMainCatalogList?cmd=list"; //카탈로그
			break;
		case "0/9" :
			location.href = "/actions/ProductMainSterilizeDigitalList?cmd=list"; //단종제품
			break;

	    case "1//" :
			location.href = "/actions/CategoryPlexMainView?cmd=view";//클럽메인
			break;
	    case "1/0" :
			location.href = "/actions/CanonplexIntroAction?cmd=view";//캐논플렉스  // "/actions/GalleryCkciOpenList?cmd=list&is_first_load=Y"; //"/actions/GalleryCkciBestAction?cmd=view";//베스트 갤러리
			break;
	    case "1/1" :
			location.href = "/actions/CategoryEstoreMainView?cmd=view";//쇼핑  // "/actions/AcademyIntroduce?cmd=list";//아카데미
			break;
	    case "1/2" :
			location.href = "/actions/AcademyNewMainAction?cmd=view";//아카데미  // "/actions/ReviewCkciProList?cmd=list";//전문가 리뷰
			break;
	    case "1/3" :
			location.href =  "/actions/PlayCkciPeopleList?cmd=list";//캐논피플
			break;
	    case "1/4" :
			location.href =  "/actions/ReviewCkciProList?cmd=list";//제품리뷰
			break;
	    case "1/5" :
			location.href =  "/actions/PlayCkciWebzineAction?cmd=view";//웹진
			break;
	    case "1/6" :
			location.href =  "/actions/PlayCkciPointMallList?cmd=list";//포인트몰
			break;
		case "1/7" :
			pageTracker._trackPageview('/PritingService/GNB.html');
			jsMainFotoAction();//인화샵
			break;
		case "2//" :
			location.href =  "/actions/CategoryGalleryMainView?cmd=view";//갤러리
			break;
		case "2/0" :
			location.href =  "/actions/GalleryCkciBestAction?cmd=view";//베스트샷
			break;
		case "2/1" :
			location.href =  "/actions/GalleryCkciOpenList?cmd=list&is_first_load=Y";//포토오픈갤러리
			break;
		case "2/2" :
			location.href =  "/actions/PlayCkciPartyJoinList?cmd=list";//케논파티
			break;
		case "2/3" :
			location.href =  "/actions/PlayTripList?cmd=list";//이벤트 & 출사
			break;
		case "2/4" :
			location.href =  "/actions/PlayCkciPhotospotList?cmd=list";//추천촬영지
			break;

		case "3//" :
			location.href = "/actions/CategorySupportMainView?cmd=list";//support 메인
			break;
		case "3/0" :
			location.href = "/actions/FrontPage?cmd=list&url=/ckcifront/support/regist/regist_guide.jsp";//정품등록
			break;
		case "3/1" :
			jsPickup();//서비스신청
			break;
		case "3/2" :
			location.href = "/actions/FrontPage?cmd=list&url=/ckcifront/support/servicecenter/centermap.jsp";//A/S안내
			break;
		case "3/3" :
			location.href = "/actions/FrontPage?cmd=list&url=/ckcifront/support/canonshop/shop_plaza.jsp";//캐논 전문매장
			break;
		case "3/4" :
			location.href = "/actions/FrontPage?cmd=list&url=/ckcifront/support/download/firm_list.jsp";//다운로드
			break;
		case "3/5" :
			jsContact();
			break;
		case "3/6" :
			location.href = "/actions/FrontPage?cmd=list&url=/ckcifront/support/cps/cps_guide.jsp";//CPS
			break;
		case "3/7" :
			location.href = "/actions/FrontPage?cmd=list&url=/ckcifront/customer/service_policy.jsp";// CKCI A/S정책
			break;

		case "4//" :	// eStore 메인
			location.href = "/actions/CategoryEstoreMainView?cmd=view";
			break;
		case "4" :	// eStore 섹션
			location.href = "/actions/EstoreGoodsList?cmd=list&ctg_id="+value+"&level=L";
			break;

		case "favo" :	// 관심상품리스트
			fnGoWishList();
			break;

		case "5/1" :
			jsMylecture();//나의신청현황
			break;
	}
}

// CD-Manual 구매
function fnGoOrderCD() {
	// 로그인 체크
	if(!fnChkLogin()) {
		return;
	}
	location.href = "/actions/FrontPage?cmd=list&url=/ckcifront/support/service/CDManual.jsp";
}

////////////////
// 우편번호/주소 찾기
function goSearchPost(div) {
	var surl = "/actions/MemberShipList?cmd=list&is_first_load=Y";
	var type = "400*430";
	var name = "SEARCH_POST_POPUP";
	openWindow(surl, type, name);
	SearchPost = div;
}

////////////////
// 우편번호/주소 찾기 후 우편번호/주소 받아오기
function setValuePost(sVal1, sVal2) {
	if(SearchPost == 1){
		SettleForm.zipcode1.value = sVal1.substring(0,3);	// 보내는 분 우편번호 앞자리
		SettleForm.zipcode2.value = sVal1.substring(3,6);	// 보내는 분 우편번호 뒷자리
		SettleForm.addr_basic.value = sVal2;				// 보내는 분 기본주소
	}else if(SearchPost == 2){
		SettleForm.receive_zipcode1.value = sVal1.substring(0,3);	// 받는 분 우편번호 앞자리
		SettleForm.receive_zipcode2.value = sVal1.substring(3,6);	// 받는 분 우편번호 뒷자리
		SettleForm.receive_addr_basic.value = sVal2;				// 받는 분 기본주소
	}
}


	// 공지사항 링크
	function goView(seq,gubun){
		location.href = "/actions/FrontPage?cmd=list&url=/ckcifront/customer/notice_view.jsp?seq="+seq+"&cpage=1&search_type=&search_str=&gubun="+gubun;
	}
	// 프로덕트공지사항 링크
	function goPrtView(seq) {
		location.href = "/actions/FrontPage?cmd=list&url=/ckcifront/customer/notice_view.jsp?seq="+seq+"&cpage=1&search_type=&search_str=&gubun=PT";
	}
	// 이벤트 링
	function goEvent(seq) {
		location.href= "/actions/FrontPage?cmd=list&url=/ckcifront/customer/event_view.jsp?seq="+seq+"&cpage=1";
	}


/************************************    장바구니 관련 Link    **************************************************/

/**
 * 장바구니 가기
 *
 * @author  김현정
 * @since   2009.09.29
 */
function fnGoStoreCart() {
	// 로그인 체크
	if(!fnChkLogin()) {
		return;
	}

	location.href = "/actions/EsettleStoreCartList?cmd=list";
}

/**
 * 장바구니 담기
 *
 * @param  cart_yn: 장바구니화면여부(장바구니화면-'Y', 그이외의회면-'N')
 * @param  fi_goods_code: 상품코드 (ex f.goods_code)
 * @param  fi_quantity: 수량  (ex f.quantity)
 *
 * @author  김현정
 * @since   2009.09.29
 */
function fnInsertBasket(cart_yn, fi_goods_code, fi_quantity, fi_stock_quantity){

	// 로그인 체크
	if(!fnChkLogin()) {
		return;
	}

	if ( typeof(document.tempForm) == "undefined" ) {
//		alert("로딩중입니다.");
		return;
	}

	with( document.tempForm ){

		var obj = document.getElementById("divTemp");
		obj.innerText = "";

		if( isArray(fi_goods_code) <= 0 ){			// 0건

			alert("선택된 상품이 없습니다.[SC01]");
			return;
		}else if( isArray(fi_goods_code) == 1 ){	// 1건

			if( fi_goods_code.value == ""){

				alert("상품ID가 잘못 전달되었습니다. 다시 시도해주세요.[SC02]");
				return;
			}

			if(typeof(fi_stock_quantity)!="undefined" && fi_stock_quantity.value<1) {
				alert("품절된 상품이 존재합니다. 다시 시도해주세요.");
				return;
			}

			putDomInput(obj, "cart_yn", cart_yn);	// 장바구니 화면여부

			putDomInput(obj, "goods_code", fi_goods_code.value);

			if( isArray(fi_quantity) < 1 || fi_quantity.value == "" ) {
				putDomInput(obj, "quantity", 1);
			}else {
				putDomInput(obj, "quantity", fi_quantity.value);
			}

		}else{									// 배열
			putDomInput(obj, "cart_yn", cart_yn);	// 장바구니 화면여부
			var selTf = false;
			for( var idx = 0; idx < isArray(fi_goods_code); idx++ ){

				if( fi_goods_code[idx].value == ""){

					alert("상품ID가 잘못 전달되었습니다. 다시 시도해주세요.[SC03]");
					return;
				}

				if( fi_goods_code[idx].checked == true ) {	// 선택된 상품처리

					if(fi_goods_code[idx].plan_goods_yn != "0")
					{
						alert("["+fi_goods_code[idx].goods_name+"]\n\n 상품은 바로구매만 가능한 상품인 관계로 장바구니에 담을 수 없습니다.");
						fi_goods_code[idx].checked = false;
						return;
					}//end if

					if(typeof(fi_stock_quantity)!="undefined" && fi_stock_quantity[idx].value<1)
					{
						alert(fi_goods_code[idx].goods_name+" 상품은  품절상품입니다. \n확인후 다시시도해 주십시오.");
						fi_goods_code[idx].checked = false;
						return;
					}//end if

					selTf = true;
					putDomInput(obj, "goods_code", fi_goods_code[idx].value);

					if( isArray(fi_quantity) <= 1 || fi_quantity[idx].value == "" ) {
						putDomInput(obj, "quantity", 1);
					} else {
						putDomInput(obj, "quantity", fi_quantity[idx].value);
					}
				}
			}
			if(!selTf) {
				alert("선택된 상품이 없습니다.");
				return;
			}
		}

		cmd.value = "insert";
		target = "action_frame";
		action = "EsettleStoreCartAction";
		submit();
	}
}


/**
 * 하나의 상품을 장바구니 담기
 *
 * @param  cart_yn: 장바구니화면여부(장바구니화면-'Y', 그이외의회면-'N')
 * @param  goods_code: 상품코드
 * @param  quantity: 수량
 * @param  stock_quantity: 실재고 수량
 *
 * @author  손성택
 * @since   2009.10.22
 */
function fnOneInsertBasket(cart_yn, goods_code, quantity, stock_quantity){
// 로그인 체크
	if(!fnChkLogin()) {
		return;
	}

	if ( typeof(document.tempForm) == "undefined" ) {
//		alert("로딩중입니다.");
		return;
	}

	with( document.tempForm ){

		var obj = document.getElementById("divTemp");
		obj.innerText = "";



		if( goods_code == ""){

			alert("상품ID가 잘못 전달되었습니다. 다시 시도해주세요.[SC02]");
			return;
		}

		if( stock_quantity<1){

			alert("일시품절된 상품은 장바구니에 담을 수 없습니다..[SC03]");
			return;
		}

		putDomInput(obj, "cart_yn", cart_yn);	// 장바구니 화면여부

		putDomInput(obj, "goods_code", goods_code);

		if( quantity.value == "" ) {
			putDomInput(obj, "quantity", 1);
		}else {
			putDomInput(obj, "quantity", quantity);
		}

		cmd.value = "insert";
		target = "action_frame";
		//action = "EsettleOrderInfoAction";
		action = "EsettleStoreCartAction";
		submit();

	}
}

/**
 * 장바구니 담기후 처리
 *
 * @author  김현정
 * @since   2009.12.04
 */
function fnStoreCartAddRst(vCartYn) {
	if(vCartYn == "Y") {	// 장바구니 페이지에서 처리시
		alert("해당 상품이 장바구니에 추가되었습니다.");
		parent.fnGoStoreCart();
	} else {	// 그 이외의 화면
		if(!confirm("해당 상품이 장바구니에 추가되었습니다.\n장바구니로 이동하시겠습니까?")) {
			location.replace("");
		} else {
			parent.fnGoStoreCart();
		}
	}
}

/************************************    주문 관련 Link    **************************************************/

/**
 * 주문하기
 *
 * @param  cart_yn: 장바구니화면여부(장바구니 주문-'Y', 상품상세 바로주문-'N')
 * @param  fi_goods_code: 상품코드 (ex f.goods_code)
 * @param  fi_quantity: 수량  (ex f.quantity)
 *
 * @author  김현정
 * @since   2009.10.15
 */
function fnOrder(cart_yn, fi_goods_code, fi_quantity, fi_stock_quantity, fi_goods_name, fi_order_limit_quantity){

	// 로그인 체크
	if(!fnChkLogin()) {
		return;
	}

	if ( typeof(document.tempForm) == "undefined" ) {
//		alert("로딩중입니다.");
		return;
	}

	with( document.tempForm ){

		var obj = document.getElementById("divTemp");
		obj.innerText = "";

		if( isArray(fi_goods_code) <= 0 ){			// 0건

			alert("선택된 상품이 없습니다.[SC01]");
			return;
		}else if( isArray(fi_goods_code) == 1 ){	// 1건

			if( fi_goods_code.value == ""){

				alert("상품ID가 잘못 전달되었습니다. 다시 시도해주세요.[SC02]");
				return;
			}

			if( fi_goods_code.checked == false ) {	// 선택된 상품처리
				alert("선택된 상품이 없습니다.");
				return;
			}

			if(typeof(fi_stock_quantity) != "undefined") {
				if(fi_stock_quantity.value < 1) {
					alert(fi_goods_name.value + "은(는) 품절된 상품입니다.\n다시 시도해주세요.");
					return;
				}
				if(parseInt(fi_quantity.value) > parseInt(fi_stock_quantity.value)) {
					alert(fi_goods_name.value + "\n제품의 재고 수량이 부족합니다. 다시 시도해주세요.\n");
					return;
				}
				if(parseInt(fi_order_limit_quantity.value) > 0	// 주문제한 수량이 있으며
					&& parseInt(fi_quantity.value) > parseInt(fi_order_limit_quantity.value)	// 주문제한수량 초과 주문시
					)
				{
					alert(fi_goods_name.value + "\n의 최대주문수량은 " + fi_order_limit_quantity.value + "개 입니다.");
					return;
				}
			}

			putDomInput(obj, "cart_yn", cart_yn);	// 장바구니 화면여부

			putDomInput(obj, "goods_code", fi_goods_code.value);

			if( isArray(fi_quantity) < 1 || fi_quantity.value == "" ) {
				putDomInput(obj, "quantity", 1);
			}else {
				putDomInput(obj, "quantity", fi_quantity.value);
			}

		}else{									// 배열
			putDomInput(obj, "cart_yn", cart_yn);	// 장바구니 화면여부

			var selTf = false;
			for( var idx = 0; idx < isArray(fi_goods_code); idx++ ){


				if( fi_goods_code[idx].value == ""){

					alert("상품ID가 잘못 전달되었습니다. 다시 시도해주세요.[SC03]");
					return;
				}

				if( fi_goods_code[idx].checked == true ) {	// 선택된 상품처리
					selTf = true;

					if(typeof(fi_stock_quantity[idx])!="undefined") {
						if(fi_stock_quantity[idx].value < 1) {
							alert(fi_goods_name[idx].value + "은(는) 품절된 상품입니다.\n다시 시도해주세요.");
							return;
						}

						if(parseInt(fi_quantity[idx].value) > parseInt(fi_stock_quantity[idx].value)) {
							alert(fi_goods_name[idx].value + "\n제품의 재고 수량이 부족합니다. 다시 시도해주세요.");
							return;
						}
						if(parseInt(fi_order_limit_quantity[idx].value) > 0	// 주문제한 수량이 있으며
							&& parseInt(fi_quantity[idx].value) > parseInt(fi_order_limit_quantity[idx].value)	// 주문제한수량 초과 주문시
							)
						{
							alert(fi_goods_name[idx].value + "\n의 최대주문수량은 " + fi_order_limit_quantity[idx].value + "개 입니다.");
							return;
						}
					}

					putDomInput(obj, "goods_code", fi_goods_code[idx].value);

					if( isArray(fi_quantity) <= 1 || fi_quantity[idx].value == "" ) {
						putDomInput(obj, "quantity", 1);
					} else {
						putDomInput(obj, "quantity", fi_quantity[idx].value);
					}
				}
			}
			if(!selTf) {
				alert("선택된 상품이 없습니다.");
				return;
			}
		}

		cmd.value = "insert";
		target = "action_frame";
		action = "EsettleOrderInfoAction";
		submit();
	}
}


/**
 * 하나의 상품 주문하기
 *
 * @param  cart_yn: 장바구니화면여부(장바구니 주문-'Y', 상품상세 바로주문-'N')
 * @param  v_goods_code: 상품코드 (ex f.goods_code)
 * @param  fi_quantity: 수량  (ex f.quantity)
 *
 * @author  김현정
 * @since   2009.10.21
 */
function fnOrderOne(v_cart_yn, v_goods_code, v_quantity, v_stock_quantity, v_goods_name, v_order_limit_quantity){

	// 로그인 체크
	if(!fnChkLogin()) {
		return;
	}

	if ( typeof(document.tempForm) == "undefined" ) {
//		alert("로딩중입니다.");
		return;
	}

	with( document.tempForm ){

		var obj = document.getElementById("divTemp");
		obj.innerText = "";


		if( v_goods_code == ""){

			alert("상품ID가 잘못 전달되었습니다. 다시 시도해주세요.[SC02]");
			return;
		}

		if(typeof(v_stock_quantity) != "undefined") {
			if(v_stock_quantity < 1) {
				alert(v_goods_name + "은(는) 품절된 상품입니다.\n다시 시도해주세요.");
				return;
			}
			if(parseInt(v_quantity) > parseInt(v_stock_quantity)) {
				alert(v_goods_name + "\n제품의 재고 수량이 부족합니다. 다시 시도해주세요.");
				return;
			}
			if(parseInt(v_order_limit_quantity) > 0	// 주문제한 수량이 있으며
				&& parseInt(v_quantity) > parseInt(v_order_limit_quantity)	// 주문제한수량 초과 주문시
				)
			{
				alert(v_goods_name + "\n의 최대주문수량은 " + v_order_limit_quantity + "개 입니다.");
				return;
			}
		}

		putDomInput(obj, "cart_yn", v_cart_yn);	// 장바구니 화면여부

		putDomInput(obj, "goods_code", v_goods_code);

		if( isArray(v_quantity) < 1 || v_quantity == "" ) {
			putDomInput(obj, "quantity", 1);
		}else {
			putDomInput(obj, "quantity", v_quantity);
		}

		cmd.value = "insert";
		target = "action_frame";
		action = "EsettleOrderInfoAction";
		submit();
	}
}




/************************************    위시리스트 관련 Link    **************************************************/


/**
 * 위시리스트 가기
 */
function fnGoWishList() {
	// 로그인 체크
	if(!fnChkLogin()) {
		return;
	}
	location.href = "/actions/MyCanonInterestGoodsList?cmd=list";
}


/**
 * 위시리스트 담기
 *
 * @param  fi_goods_code: 상품코드 (ex f.goods_code)
 *
 * @author  sst
 * @since   2009.10.15
 */
function fnInsertAllWishlist(fi_goods_code){

	// 로그인 체크
	if(!fnChkLogin()) {
		return;
	}

	goods_code="";

	if ( typeof(document.tempForm) == "undefined" ) {
//		alert("로딩중입니다.");
		return;
	}

	with( document.tempForm ){

		var obj = document.getElementById("divTemp");
		obj.innerText = "";

		if( isArray(fi_goods_code) <= 0 ){			// 0건

			alert("선택된 상품이 없습니다.[SC01]");
			return;
		}else if( isArray(fi_goods_code) == 1 ){	// 1건

			if( fi_goods_code.value == ""){

				alert("상품ID가 잘못 전달되었습니다. 다시 시도해주세요.[SC02]");
				return;
			}

			goods_code=fi_goods_code.value;

			DWRSettle.insertWishList(goods_code, resultReturnWishList);

		}else{

			var selTf = false;
			for( var idx = 0; idx < isArray(fi_goods_code); idx++ ){

				if( fi_goods_code[idx].value == ""){

					alert("상품ID가 잘못 전달되었습니다. 다시 시도해주세요.[SC03]");
					return;
				}

				if( fi_goods_code[idx].checked == true ) {	// 선택된 상품처리
					selTf = true;
					goods_code += fi_goods_code[idx].value+"#";
				}
			}
			if(!selTf) {
				alert("선택된 상품이 없습니다.");
				return;
			}

			goods_code = goods_code.substring(0,goods_code.length-1);
			//alert(goods_code);

			DWRSettle.insertAllWishList(goods_code, resultReturnWishList);
		}
	}
}

	/**
	 * 위시리스트 한건추가하기
	 *
	 * @param  v_goods_code: 상품코드 value값 (ex f.goods_code.value)
	 */
	function fnInsertAllWishlistOne(v_goods_code) {
		// 로그인 체크
		if(!fnChkLogin()) {
			return;
		}

		DWRSettle.insertWishList(v_goods_code, resultReturnWishList);
	}

/************************************    마이캐논 관련 Link    **************************************************/

// 배송현황 확인
function goDeliveryStatus(arg) {
	var surl = "http://www.hlc.co.kr/hydex/jsp/tracking/trackingViewCus.jsp?InvNo=" + arg;
	//var surl = "http://www.hydex.net/ehydex/jsp/home/distribution/tracking/tracingNView.jsp?param1=222902&param2=" + f.order_code.value;
	var name = "DELIVERY_POPUP";
	var Top  = (window.screen.availHeight - 700) / 2;
	var Left = (window.screen.availWidth  - 900) / 2;
	var Feature = "fullscreen=no,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,left=" + Left + ",top=" + Top + ",width=650,height=800";
	window.open(surl, name, Feature);
}


////////////////
// PG 매출전표 팝업 링크
function fnShowSaleSlipPop(s_cd, o_cd, div) {
	// 신용카드 결제:SC0010
	if(div == 'A'){
		popupWin =  window.open( "https://pgweb.dacom.net/MpFlowCtrl?eventDiv1=search&eventDiv2=getReceipt&TRANSACTIONID="+s_cd+"&SYSTEM=NEW", "popWinName","scrollbars=yes,width=440,height=700,resize=1,left=100,top=50" );
	// 실시간 계좌이체시:SC0030
	}else if(div == 'B'){
		popupWin =  window.open( "https://pg.dacom.net/transfer/cashreceipt.jsp?orderid="+o_cd+"&mid=canonkorea02&servicetype=SC0030", "popWinName","scrollbars=yes,width=420,height=600,resize=1,left=100,top=50" );
	// 무통장입금시:SC0040
	}else if(div == 'C'){
		popupWin =  window.open( "https://pg.dacom.net/transfer/cashreceipt.jsp?orderid="+o_cd+"&mid=canonkorea03&servicetype=SC0040&seqno=001", "popWinName","scrollbars=yes,width=420,height=600,resize=1,left=100,top=50" );
	}
}

/**
 * 결제 상세 페이지
 *
 * @author  김현정
 * @since   2008.11.05
 *
 * @param : v_order_code			주문코드
 **/
function fnGoSettleDtlView(v_order_code) {
	// 로그인 체크
	if(!fnChkLogin()) {
		return;
	}

	location.href = "/actions/EmyCanonFrontSettleAction?cmd=view&order_code=" + v_order_code;
}

/**
 * 주문내역 리스트
 *
 * @author  김현정
 * @since   2008.11.06
 **/
function fnGoSettleList() {
	// 로그인 체크
	if(!fnChkLogin()) {
		return;
	}

	location.href = "/actions/EmyCanonFrontSettleList?cmd=list&pageNum=1";
}


/**
 * 쿠폰 다운로드 팝업
 **/
 /*
function fnCpnDn(no) {
	// 로그인 체크
	if(!fnChkLogin()) {
		return;
	}

	var width = 400;
	var height = 500;
	var wid = (screen.width)/2 - width/2 ;
	var hei = (screen.height)/2 - height/2;
	var param =  "&coupon_seq="+no;
	var win = window.open("/actions/EstoreCouponDetailView?cmd=view" + param, "coupond", "menubar=no, scrollbars=no, resizable=no, width=" + width + ", height=" + height+ ",top=" + hei + ",left=" + wid + "");
	win.focus();
}
*/

// 쿠폰적용상품 팝업
function fnUsableGoods(seq) {
	if ( seq == "") {
		alert("올바른 링크가 아닙니다. 다시시도해 주십시오.");
		return;
	}
	var url="/actions/EstoreCouponGoodsList?cmd=list";
	var param = "&coupon_seq="+seq;
	window.open(url + param, 'test', "menubar=no, scrollbars=yes, resizable=no, width=" + 620 + ", height=" + 625);
}

/************************************    상품 전시관련 Link    **************************************************/

/**
 * 이스토어 메인
 *
 * @author  김현정
 * @since   2008.11.06
 **/
function fnGoEstoreMainView() {
	location.href = "/actions/CategoryEstoreMainView?cmd=view";
}

/**
 * @author  손성택
 **/
function fnListType(type){
	var obj = document.GoodsPageForm;
	obj.list_type.value=type
	obj.action="/actions/EstoreGoodsList";
	obj.submit();
}

/**
 * @author  손성택
 **/
function fnOrderbyType(type){
	var obj = document.GoodsPageForm;

	obj.orderby_type.value=type

	obj.action="/actions/EstoreGoodsList";
	obj.submit();
}

/**
 * 상품상세
 * @author  손성택
 */
function fnViewDetail(v_goods_code, v_ctg_id, v_accYN){

	if(v_accYN == true || v_accYN == "Y") {	// 악세사리
		location.href = "/actions/EstoreAccGoodsDetailView?cmd=view&goods_code=" + v_goods_code + "&ctg_id="+v_ctg_id;
	} else {
		location.href = "/actions/EstoreGoodsDetailView?cmd=view&goods_code=" + v_goods_code + "&ctg_id="+v_ctg_id;
	}
}

/**
 * 팝업에서 상품상세
 * @author  손성택
 */
function fnViewDetail_P(v_goods_code, v_ctg_id, v_accYN){
	if(v_accYN == true || v_accYN == "Y")
	{	// 악세사리
		opener.location.href = "/actions/EstoreAccGoodsDetailView?cmd=view&goods_code=" + v_goods_code + "&ctg_id="+v_ctg_id;
	}
	else
	{
		opener.location.href = "/actions/EstoreGoodsDetailView?cmd=view&goods_code=" + v_goods_code + "&ctg_id="+v_ctg_id;
	}//end if
	window.self.close();
}

/**
 * 상품상세
 * @author
 */
function fnViewDetailBlank(v_goods_code, v_ctg_id, v_accYN){

	if(v_accYN == true || v_accYN == "Y") {	// 악세사리
		window.open("/actions/EstoreAccGoodsDetailView?cmd=view&goods_code=" + v_goods_code + "&ctg_id="+v_ctg_id);
	} else {
		window.open("/actions/EstoreGoodsDetailView?cmd=view&goods_code=" + v_goods_code + "&ctg_id="+v_ctg_id);
	}
}

/**
 * @author  손성택
 **/
function goGoodsList(level,ctg_id){
	location.href="/actions/EstoreGoodsList?cmd=list&level="+level+"&ctg_id="+ctg_id+"";
}

function getCookieVal (offset) {
   var endstr = document.cookie.indexOf (";", offset);
   if (endstr == -1) endstr = document.cookie.length;
   return unescape(document.cookie.substring(offset, endstr));
}

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 setCookie(name,value,expiredays)
{
  var todayDate = new Date();
  todayDate.setDate(todayDate.getDate() + expiredays);
  document.cookie = name + "=" + escape(value) + "; path=/; expired="
  todayDate.toGMTString() + ";" // path= 는쿠키가 저장될 위치 , 위치지정안하면 웹문서가 있는폴더로 저장된다.
}

/**
	* 오늘본 상품 쿠키 설정
	*
	*/
function todayGoods(goods_code){//오늘본상품

		//setCookie("todayGoods", "",0);

		var checkCnt = 0;
		var checkRealCnt=0;
		var checkGoodsCode = "";

		var todayGoods = getCookie("todayGoods");
		var arrTodayGoods = todayGoods.split(", ");

		inToday=true;
		todayGoods = goods_code;
		for(j=0;j<arrTodayGoods.length;j++){
			if(arrTodayGoods[j]==goods_code){
				inToday=false;
			}else{
				if(arrTodayGoods[j]!=""){
					todayGoods += ", " + arrTodayGoods[j];
				}
			}
		}

		setCookie("todayGoods", todayGoods,7);

}

/**
	* 비교함 담기
	* 목록에서 여러개를 한번에 비교함에 담을 때 사용하는 메소드
	* @author  손성택
	*/
function compareGoods(){//상품비교 페이지

		//setCookie("compareGoods", "");
		var obj = document.goodsListForm;

		var checkCnt = 0;
		var checkRealCnt=0;
		var checkGoodsCode = "";

		var compareGoods = ltrim(getCookie("compareGoods"));
		var flag = "";
		var arrCompareGoods = compareGoods.split(", ");

		if(compareGoods=="")
		{
			flag="false";
		}
		else
		{
			flag="true";
		}//end else

		if(obj.chkGoods == null)
		{
			alert("등록된 이스토어 상품이 없습니다.");
			return;
		}//end if

		for(i=0;i<obj.chkGoods.length;i++)
		{
			if(obj.chkGoods[i].checked)
			{

				inCompare=true;
				for(j=0;j<arrCompareGoods.length;j++)
				{
					if(arrCompareGoods[j]==obj.chkGoods[i].value)
					{
						inCompare=false;
					}//end if
				}//end for

				if(inCompare)
				{
					checkGoodsCode += obj.chkGoods[i].value +", "
					checkRealCnt++;
				}//end if
				checkCnt++;

			}//end if
		}//end for

		if(checkCnt>0){

			checkGoodsCode = checkGoodsCode.substring(0,checkGoodsCode.length-2);
			/**
			 * */
			if(arrCompareGoods.length == 3)
			{
				alert("최대 3개의 상품을 비교 할 수 있습니다. \n\n 이미  "+arrCompareGoods.length+"개의 상품이 등록되어 있어서 "+checkCnt+"개의 상품을 추가 할 수 없습니다.");
				return;
			}//end if

			if(flag=="false")
			{
				if((arrCompareGoods.length + checkCnt) >=5)
				{
					alert("최대 3개의 상품을 비교 할 수 있습니다. \n\n 이미  "+arrCompareGoods.length+"개의 상품이 등록되어 있어서 "+checkCnt+"개의 상품을 추가 할 수 없습니다.");
					return;
				}//end if
			}//end if

			//alert(checkGoodsCode);
		}else{
			alert("선택된 상품이 없습니다.");
			return;
		}//end else

		if(checkCnt>3){
			alert("상품비교는 3개까지 가능합니다.");
			return;
		}





		var arrCompareGoodsCnt = arrCompareGoods.length;
		if(arrCompareGoodsCnt+checkRealCnt>4)
		{
			alert("최대 3개의 상품을 비교 할 수 있습니다. \n\n 이미 "+arrCompareGoodsCnt+"개의 상품이 등록되어 있어서 "+checkRealCnt+"개의 상품을 추가 할 수 없습니다.");
			return;
		}

		if(compareGoods!=""){
			if(checkGoodsCode!=""){
				compareGoods =  compareGoods + ", " + checkGoodsCode;
			}
		}else{
			compareGoods = checkGoodsCode;
		}

		setCookie("compareGoods", compareGoods,0);


		var width=820; //안선아 주임님. 팝업사이즈 가로 변경 805로..
  		var height=600;


	  	var wid = (screen.width)/2 - width/2 ;
		var hei = (screen.height)/2 - height/2;

		theURL = "/actions/EstoreCompareGoods?cmd=list&compare_goods_code=" + compareGoods;

		var win = window.open(theURL , "compareGoods", "menubar=no, scrollbars=yes, resizable=no, width=" + width + ", height=" + height+ ",top=" + hei + ",left=" + wid + "");
		win.focus();
}


/**
	* 비교함 담기
	* 목록에서 여러개를 한번에 비교함에 담을 때 사용하는 메소드
	* @author  손성택
	*/
function viewCompareGoods(){//상품비교 페이지

		var compareGoods = ltrim(getCookie("compareGoods"));


		if(compareGoods!="")
		{
			var width=820;	// 2009-11-27 21시 수정. by mercurii
			var height=600;	// 2009-11-27 21시 수정. by mercurii


			var wid = (screen.width)/2 - width/2 ;
			var hei = (screen.height)/2 - height/2;

			theURL = "/actions/EstoreCompareGoods?cmd=list&compare_goods_code=" + compareGoods;

			var win = window.open(theURL , "compareGoods", "menubar=no, scrollbars=yes, resizable=yes, width=" + width + ", height=" + height+ ",top=" + hei + ",left=" + wid + "");
			win.focus();
		}
		else
		{
			alert("비교함에 담긴 상품이 없습니다.");
		}//end else

}


/**
	* 비교함 담기
	* 목록에서 여러개를 한번에 비교함에 담을 때 사용하는 메소드
	* @author  손성택
	*/
function compareOneGoods(goods_code){//상품비교 페이지

		//setCookie("compareGoods", "");
		var obj = document.goodsListForm;

		var checkCnt = 0;
		var checkRealCnt=0;
		var checkGoodsCode = "";

		var compareGoods = ltrim(getCookie("compareGoods"));
		var arrCompareGoods = compareGoods.split(", ");


		inCompare=true;
		for(j=0;j<arrCompareGoods.length;j++){
			if(arrCompareGoods[j]==goods_code){
				inCompare=false;
			}
		}


		if(inCompare){//없는 상품일경우

			if(arrCompareGoods.length>2){//이미 3개의 상품이 담겨 있을 경우
				alert("상품비교는 3개까지 가능합니다.");
			}else{//아직 3개가 안될경우

				if(compareGoods==""){//쿠키에 값이 없을때...
					compareGoods = goods_code;
				}else{
					compareGoods+= ", "+goods_code;
				}

			}
		}else{//이미 등록되어있는 상품일 경우
			alert("이미등록된 상품입니다..");
		}




		setCookie("compareGoods", compareGoods,0);


		var width=820;
  		var height=800;


	  	var wid = (screen.width)/2 - width/2 ;
		var hei = (screen.height)/2 - height/2;

		theURL = "/actions/EstoreCompareGoods?cmd=list&compare_goods_code=" + compareGoods;

		var win = window.open(theURL , "compareGoods", "menubar=no, scrollbars=yes, resizable=yes, width=" + width + ", height=" + height+ ",top=" + hei + ",left=" + wid + "");
		win.focus();
}

/**
 * @author  손성택
 **/
function deleteCompare(){

	//setCookie("compareGoods", "");
		var obj = document.goodsListForm;

		var checkCnt = 0;
		var checkRealCnt=0;
		var checkGoodsCode = "";

		var compareGoods = getCookie("compareGoods");
		var arrCompareGoods = compareGoods.split(", ");

		if(obj.chkGoods == null)
		{
			alert("삭제할 상품이 없습니다.");
			return;
		}//end if

		for(i=0;i<arrCompareGoods.length;i++){
			var inCompare=true;
			if(typeof(obj.chkGoods.length)=="undefined"){
				if(obj.chkGoods.checked){
					if(arrCompareGoods[i]==obj.chkGoods.value){
						inCompare=false;
					}
					checkCnt++;
				}
			}else{
				for(j=0;j<obj.chkGoods.length;j++){
					if(obj.chkGoods[j].checked){
						if(arrCompareGoods[i]==obj.chkGoods[j].value){
							inCompare=false;
						}
						checkCnt++;
					}
				}
			}


			if(inCompare){
				checkGoodsCode += arrCompareGoods[i] +", "
				checkRealCnt++;
			}


		}


		if(checkCnt>0){

			checkGoodsCode = checkGoodsCode.substring(0,checkGoodsCode.length-2);
			//alert(checkGoodsCode);
		}else{
			alert("선택된 상품이 없습니다.");
			return;
		}

		setCookie("compareGoods", checkGoodsCode,0);

		theURL = "/actions/EstoreCompareGoods?cmd=list&compare_goods_code=" + checkGoodsCode;

		location.href=theURL;
}

/**
 * @author  손성택
 **/
function go_planshopView(c_seqnum){
	location.href="/actions/EstorePlanshopView?cmd=list&c_seqnum=" + c_seqnum;
}

/**
 * @author  손성택
 **/
function viewDetailImg(goods_code){
	var width=732;
	var height=640;


	var wid = (screen.width)/2 - width/2 ;
	var hei = (screen.height)/2 - height/2;

	if(goods_code!=""){


	theURL = "/actions/EstoreGoodsDetailImgView?cmd=view&goods_code=" + goods_code;

	var win = window.open(theURL , "detailImg", "menubar=no, scrollbars=yes, resizable=no, width=" + width + ", height=" + height+ ",top=" + hei + ",left=" + wid + "");
	win.focus();
	}else{
		alert("상품코드가 정확하지 않습니다.")
	}
}

/**
 * 마이크로 사이트로 이동하기
 * @author  손성택
 **/
function goMicrosite(theURL){

	var width=1220;
	var height=850;


	var wid = (screen.width)/2 - width/2 ;
	var hei = (screen.height)/2 - height/2;






	var win = window.open(theURL , "microSite", "menubar=no, scrollbars=yes, resizable=yes, width=" + width + ", height=" + height+ ",top=" + hei + ",left=" + wid + "");
	win.focus();

}

/**
 * @author  손성택
 **/
function fnGoLcategory(ctg_id){
	location.href="/actions/EstoreGoodsList?cmd=list&ctg_id="+ctg_id+"&level=L";
}

/**
 * 공지사항 상세보기 페이지로 가기
 * @author  손성택
 **/
function goNoticeView(seq,gubun){
	location.href = "/actions/FrontPage?cmd=list&url=/ckcifront/customer/notice_view.jsp?seq="+seq+"&cpage=1&search_type=&search_str=&gubun="+gubun;
}

/**
 * @author  손성택
 **/
function goSupportView(seq){

	location.href = "/actions/FrontPage?cmd=list&url=/ckcifront/customer/notice_view.jsp?seq="+seq+"&cpage=1&search_type=&search_str=&gubun=SP";
}
/**
 * @author  손성택
 **/
function goCpsView(seq){

	location.href = "/actions/FrontPage?cmd=list&url=/ckcifront/customer/notice_view.jsp?seq="+seq+"&cpage=1&search_type=&search_str=&gubun=CP";
}

/**
 * @author  손성택
 **/
function goEventView(seq){

	location.href = "/actions/FrontPage?cmd=list&url=/ckcifront/customer/evemt_view.jsp?seq="+seq+"&cpage=1&search_type=&search_str=&gubun=";
}

/**
 * @author  손성택
 **/
function goBodoView(seq){

	window.open("/actions/CompanyUserInfoNewsAction?cmd=view&news_idx="+seq+"");
}

/**
 * 위시리스트 추가하기
 * @author  손성택
 **/
function fnAddWishlist(goods_code,chkLogin) {
	if(!fnChkLogin()) {
		return;
	}

	DWRSettle.insertWishList(goods_code, resultReturnWishList);
}

/**
 * 위시리스트 추가하기 에러메세지
 * @author  손성택
 **/
function errorHandlerWishList(){
	alert("관심상품 추가가 실패하였습니다.");
	consubmit=false;
}

/**
 * 위시리스트 추가하기 결과
 * @author  손성택
 **/
function resultReturnWishList(rnum){
	if(rnum >= 1 ){
		alert("상품이 관심상품에 추가되었습니다.");
	 	return;
	}else if(rnum == -1){
		errorHandlerWishList();
	}else if(rnum == -2){
		alert("이미 등록된 상품입니다.");
	}
}

/**
 * 파티 목록
 * @author  손성택
 **/
function fnGoPartyList(party_idx) {
	location.href="/actions/PlayCkciPartyJoinList?cmd=list&party_idx="+party_idx;
}

/**
 * 상세보기 페이지 이동(주간베스트샷)
 * @author  손성택
 **/
function fnGoGalleryDetailView(openg_idx){

	//location.href = "/actions/GalleryCkciBestAction?cmd=view&best_year="+year+"&best_month="+month+"&go_check=1";
	location.href = "/actions/GalleryCkciOpenAction?cmd=view&openg_idx="+openg_idx;
}

/**
 * 상세보기 페이지 이동(월간베스트샷)
 * @author  손성택
 **/
function fnGoGalleryDetailViewMonth(year,month){

	location.href = "/actions/GalleryCkciBestAction?cmd=view&best_year="+year+"&best_month="+month+"&go_check=1";
	//location.href = "/actions/GalleryCkciOpenAction?cmd=view&openg_idx="+openg_idx;
}

/**
 * 삭제
 * @author  손성택
 **/
function fnDeleteWishlist(deleteidx) {

	// 삭제 대상이 존재하는 경우
	if(deleteidx != "") {
		if(confirm("삭제 하시겠습니까?")) {
			DWRSettle.deleteWishList(deleteidx, resultDeleteReturnWishList);
		}
	} else {
		alert("삭제 대상이 선택되지 않았습니다.");
	}
}

/**
 * 위시리스트 추가하기 에러메세지
 * @author  손성택
 **/
function errorDeleteHandlerWishList(){
	alert("관심상품 추가가 실패하였습니다.");
	consubmit=false;
}

/**
 * 위시리스트 추가하기 결과
 * @author  손성택
 **/
function resultDeleteReturnWishList(rnum){
	if(rnum >= 1 ){
		alert("해당 상품이 관심상품에서 삭제되었습니다.");
		location.reload();
	 	return;
	}else if(rnum == -1){
		errorDeleteHandlerWishList();
	}else if(rnum == -2){
		alert("삭제할 상품이 없습니다. 다시 확인 바랍니다.");
	}
}

/**
 * @author  손성택
 **/
function createWeeklyGallery(){

	DWREstore.createWeeklyGallery(resultCreateXMLList);
}

/**
 * @author  손성택
 **/
function createMonthGallery(){

	DWREstore.createMonthGallery(resultCreateXMLList);
}

/**
 * @author  손성택
 **/
function createCategoryEstore()
{
	DWREstore.createCategoryEstore(resultCreateXMLList);
}//end createCategoryEstore

/**
 *
 * @author  mercurii
 **/
function createGNBProductList()
{
	DWREstore.createGNBProductList(resultCreateXMLList);
}//end createCategoryEstore

/**
 * XML 생성 결과
 * @author  손성택
 **/
function resultCreateXMLList(rnum){
//	alert(rnum);
	if(rnum >= 0 ){
		alert("XML이 생성되었습니다.");
		//location.reload();
	 	return;
	}else if(rnum == -1){
		alert("XML이 생성실패했습니다.");
	}else if(rnum == -2){
		//alert("삭제할 상품이 없습니다. 다시 확인 바랍니다.");
	}
}

/**************************************************************************************
 My캐논관련
 **************************************************************************************/

	function goMenu(szValue) {
		// 로그인 체크
		if(!fnChkLogin()) {
			return;
		}
		// URL
		if(szValue == "A") {
			location.href = "/actions/MyCanonServicePointList?cmd=list";
		} else if(szValue == "B") {
			location.href = "/actions/MyCanonMemberInfoAction?cmd=write";
		} else if(szValue == "C") {
			location.href = "/actions/MyCanonPhotoGalleryList?cmd=list";
		} else if(szValue == "D") {
			location.href = "/actions/FrontPage?cmd=list&url=/ckcifront/support/contact/Q_list.jsp";
		} else if(szValue == "E") {
			location.href = "/actions/MyCanonSerialList?cmd=list";
		} else if(szValue == "F") {
			location.href = "/actions/FrontPage?cmd=list&url=/ckcifront/customer/service_policy.jsp";
		} else if(szValue == "G") {
			fnGoSettleList();
		} else if(szValue == "H") {
			fnGoRefundList("01");	// 취소반품조회
		} else if(szValue == "I") {
			fnGoRefundList("02");	// 교환신청조회
		} else if(szValue == "CPN") {
			fnGoMyCoupon();	// 쿠폰현황
		} else if(szValue == "FAV") {
			fnGoWishList();
		}else if(szValue == "ME") {
			fnGoMyEvent();
		}
	}

/**
 * 취소/반품 신청
 *
 * @author  김현정
 * @since   2009.11.15
 */
function fnGoRefundList(refund_gb) {
	// 로그인 체크
	if(!fnChkLogin()) {
		return;
	}
	location.href = "/actions/EmyCanonFrontRefundList?cmd=list&search_refund_type=" + refund_gb;
}

/**
 * 쿠폰현황 가기
 *
 * @author  김현정
 * @since   2009.11.15
 */
function fnGoMyCoupon() {
	// 로그인 체크
	if(!fnChkLogin()) {
		return;
	}
	location.href = "/actions/EmyCanonMyCouponList?cmd=list";
}

/**
 * 이벤트참여내역 가기
 *
 * @author  이관규
 * @since   2010.07.07
 */
function fnGoMyEvent() {
	// 로그인 체크
	if(!fnChkLogin()) {
		return;
	}
	location.href = "/actions/EmyCanonMyEventList?cmd=list";
}

// 플래쉬에서 사용하는 window open 스크립트.
function openWinSP(oURL, name, wwidth, wheight, top, left, isscroll, isresize )
{
	var aw, ah;
	if( wwidth == 0 && wheight == 0 )
	{
		if (screen.availHeight < 960) {
			aw = screen.availWidth;
			ah = screen.availHeight;
		}else{
			aw = screen.availWidth;
			ah = 960;
		}
	}
	else
	{
		aw = wwidth;
		ah = wheight;
	}
	window.open(oURL, name, "width="+aw+",height="+ah+", top="+top+", left="+left+", scrollbars="+isscroll+", resizable="+isresize+", menubar=no, status=no, toolbar=no");
}


// QuickRepair 메인 페이지 이동
function jsQuickRepair() {
	// 로그인 체크
	if(!fnChkLogin()) {
		return;
	}
	location.href = "/actions/QuickRepairIndexAction?cmd=view";
}
