﻿//document.title = "고고씽 도서 쇼핑몰";
 
function include_script (type, defer, src)
{
	var script = document.createElement("script") ;
	script.type = type, script.defer = defer ;
	document.getElementsByTagName('head')[0].appendChild(script) ;
	script.src = src ;
}

include_script("text/javascript", true, "/common/js/fixed.js");
include_script("text/javascript", true, "/common/js/DataCheck.js");
include_script("text/javascript", true, "/common/js/CommonScript.js");

include_script("text/javascript", true, "/common/js/miniCart.js");
include_script("text/javascript", true, "/common/js/book_main.js");

 // 웹로그 분석을 위한 JS -----------
include_script("text/javascript", true, "/common/js/makePCookie.js");
//----------------------------------------------

//------------------- SWF 제어함수 시작
/**
 *	version 1.5
 *	최종수정일 : 2008. 11. 10
 *
 *	-- 플래시로더 객체생성 기본사용방법 ---
 *	<script language="javascript" type="Text/JavaScript">
 *		var setFlash = new SWFLoader();
 *		setFlash.init( '넓이', '높이', '파일경로', 총 매개변수값);
 *		setFlash.parameter('파람이름','값'); //이미 기본옵션 사용중
 *		setFlash.wmode('window'); //이미 기본옵션('transparent') 사용중
 *		setFlash.id('아이디이름'); //예) ID_SWF파일이름
 *		setFlash.alt('값');	// 플래시 대체 텍스트 값 입력
 *		setFlash.layer('div 아이디 이름')  //예) <div id='SWF파일명Layer'></div> 
 *		setFlash.show( );
 *	</script>
 *
 *	SWF파일 아이디 표준화 사용방법 : ID_파일명(대소문자구분) 예제 : 파일명이 navi.swf 인경우 --> 'ID_navi'
 *
 *	-- setFlash.layer() 사용시 방법 - 기본사용방법을 showSWFLayer() 함수로
 *     객체를 감싸주고 메서드호출 시 인자로 Div 아이디 값을 넘겨준다.
 *	
 *	<script language="javascript" type="Text/JavaScript">
 *		function showSWFLayer( layername) {
 *			var setFlash = new SWFLoader();
 *			setFlash.init( '넓이', '높이', '파일경로', 총 매개변수값);
 *			setFlash.parameter('파람이름','값'); //이미 기본옵션 사용중
 *			setFlash.id('아이디이름'); //예) ID_SWF파일이름
 *			setFlash.layer(layername)  //예) <div id='SWF파일명Layer'></div>
 *			setFlash.show();
 *		}
 *  </script>
 *
 *	<a href="javascript:showSWFLayer('siteMapLayer')">열기</a>
 *
 *	-- 최종 추가수정 내용
 *	url 입력시 "&" 엠퍼센드 기호 --> "&amp;" 자동치환기능 추가 
 *
 */

function SWFLoader() {
	var obj = new String;
	var parameter = new String;
	var embed = new String;
	
	var classId = new String;
    var codeBase = new String;
	var pluginSpage = new String;
	var embedType = new String;	
	var allParameter = new String;	
	
	var src = new String;
	var width = new String;
	var height = new String;
	var id = new String;
	var layer = new String;
	var arg = new String;
	var altText = new String;
	var wmode = new String;

	this.init = function ( w, h, s, a ) {
		width = w; //넓이
		height = h; //높이
		src = s; //파일경로
		arg = String(a).replace(/\&/gi, '%26'); // 매개변수

		wmode = 'transparent'; //모드설정

		classId = 'clsid:d27cdb6e-ae6d-11cf-96b8-444553540000';
		codeBase = 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0';
		pluginSpage = 'http://www.macromedia.com/go/getflashplayer';
		embedType = 'application/x-shockwave-flash';

		parameter += "<param name='allowScriptAccess' value='always'>\n";
		parameter += "<param name='allowFullScreen' value='false'\n>";
		parameter += "<param name='movie' value='"+ s + "'>\n";
		parameter += "<param name='quality' value='high'>\n";
		parameter += "<param name='base' value='.'>\n";
		parameter += "<param name=FlashVars value='arg="+arg+"'>\n";
	}
	
	//플래시 오브젝트 옵션설정
	this.parameter = function ( param, value ) {
		 parameter += "<param name='"+param +"' value='"+ value + "'>\n";
	}

	// 플래시 wmode 설정 setFlash.wmode('window')
	this.wmode = function ( value ) {
		wmode = value;
	}

	// 플래시 아이디 설정
	this.id = function ( value ) {
		id = value;
	}
	
	// 플래시 대체텍스트 설정
	this.alt = function ( value ) {
		altText = value;
	}

	// 플래시 삽입 레이어 설정
	this.layer = function ( value ) {
		if(value == undefined) {
			layer = "";
		} else {
			layer = value;
		}
	}

	this.show = function () {
		obj = '<object id="'+id+'" width="'+width+'" height="'+height+'" classid="'+classId+'" codebase="'+codeBase+'">\n'+
			parameter +
			'<param name="wmode" value="'+wmode+'">\n'+
			'<!--[if !IE]>-->\n' +
			'<object type="application/x-shockwave-flash" data="' + src + '" width="' + width + '" height="' + height + '" name="' + id + '">\n' +
				parameter +
				'<param name="wmode" value="'+wmode+'">\n'+
			'<!--<![endif]-->\n' +
				'<div class="alt-content alt-' + id + '">' + altText + '</div>\n' +
			'<!--[if !IE]>-->\n' +
			'</object>\n' +
			'<!--<![endif]-->\n' +
		'</object>';

		if(layer == "") {
			document.write(obj);
		}else{
			var div = document.getElementById( layer);
			div.style.display = "";
			div.innerHTML = obj;
		}
	}

	this.view = function () {
		obj = '<object id="'+id+'" width="'+width+'" height="'+height+'" classid="'+classId+'" codebase="'+codeBase+'">\n'+
			parameter +
			'<param name="wmode" value="'+wmode+'">\n'+
			'<!--[if !IE]>-->\n' +
			'<object type="application/x-shockwave-flash" data="' + src + '" width="' + width + '" height="' + height + '" name="' + id + '">\n' +
				parameter +
				'<param name="wmode" value="'+wmode+'">\n'+
			'<!--<![endif]-->\n' +
				'<div class="alt-content alt-' + id + '">' + altText + '</div>\n' +
			'<!--[if !IE]>-->\n' +
			'</object>\n' +
			'<!--<![endif]-->\n' +
		'</object>';

		return obj;
	}
}

function hideSWFLayer(div) {
	var div = document.getElementById( div);
	div.style.display = "none";
	div.innerHTML = "";
}

function thisMovie(movieName) {
	if (navigator.appName.indexOf("Microsoft") != -1) {
		return window[movieName];
	}
	else {
		return document[movieName] != null ? document[movieName] : document.getElementById(movieName);
	}
 }

 function callExternalInterface(movieId) {
    thisMovie(movieId).moveMc();	
}
//------------------- SWF 제어함수 끝

// 상단 메인 플래시 장바구니 수치 변경 ------------------//
// (송성민 08/09/03) ------------------------------------//

function setTopCartCnt(modi_cnt)
{
    //thisMovie("naviFlash").changeBasCnt(modi_cnt);
    document.getElementById("naviFlash").changeBasCnt(modi_cnt);
}

//-------------------------------------------------------//



// 하단 리아 플래시 오늘상품, 찜리스트 수치 변경 --------//
// (송성민 08/09/03) ------------------------------------//

function setRiaTodayCnt(modi_cnt)
{
    thisMovie("flashWidget").changeTodayCount(modi_cnt);
}

function setRiaWishCnt(modi_cnt)
{
    thisMovie("flashWidget").changeFavoriteCount(modi_cnt);
}

//-------------------------------------------------------//


// 상단 메인 플래시 장바구니 수치 가져오기 --------------//
// (송성민 08/09/08) ------------------------------------//

function getTopCartCnt()
{
    //return thisMovie("naviFlash").getTopCartCnt();
    return document.getElementById("naviFlash").getTopCartCnt();
}

//-------------------------------------------------------//


// 하단 리아 플래시 오늘상품, 찜리스트 수치 가져오기 ----//
// (송성민 08/09/03) ------------------------------------//

function getRiaTodayCnt()
{
    // Safari 브라우저에서 플래시 내부 스크립트를 호출하는 경우 오류남.. (2010.12.02 송성민)
    if(navigator.appVersion.indexOf("Safari") == -1) {
        return thisMovie("flashWidget").getRiaTodayCnt();
    }
    return 0;
}
 
function getRiaWishCnt()
{
    // Safari 브라우저에서 플래시 내부 스크립트를 호출하는 경우 오류남.. (2010.12.02 송성민)
    if(navigator.appVersion.indexOf("Safari") == -1) {
        return thisMovie("flashWidget").getRiaWishCnt();
    }
    return 0;
}

//-------------------------------------------------------//


// 하단 리아 플래시 오늘상품, 찜리스트 플래시 열기 ------//
// (송성민 08/09/09) ------------------------------------//

function showWidgetToday()
{
    changeFooterRia("flash");
    thisMovie("flashWidget").showWidgetToday();
}

function showWidgetWish()
{
    changeFooterRia("flash");
    thisMovie("flashWidget").showWidgetWish();
}

//-------------------------------------------------------//

// 하단 리아 플래시 오늘상품, 찜리스트 버튼 이벤트 ------//
// (송성민 08/09/09) ------------------------------------//

///////////장바구니 버튼 이벤트
function pushCartBtn(ret)
{
    if(parseInt(ret) > 0) {
        ajaxAdd("Cart", "", "");
    }
}

///////////찜리스트 버튼 이벤트
function pushWishBtn(ret)
{
    if(parseInt(ret) > 0) {
        ajaxAdd("Wish", "", "");
    }
}

//-------------------------------------------------------//

//-------------------------------------------------------//

function changeFooterRia(mode)
{    
    if(mode == "image") {
        thisMovie("divTodayCnt").innerText = getRiaTodayCnt() + "건";
        thisMovie("divWishCnt").innerText = getRiaWishCnt() + "건";
        
        thisMovie("foot_ria").style.top = "0px";
        
        thisMovie("foot_ria_img").style.display = "block";
        thisMovie("foot_ria_link").style.display = "block";
    }
    else if(mode == "flash") {
        thisMovie("foot_ria").style.top = "100%";
        
        thisMovie("foot_ria_img").style.display = "none";
        thisMovie("foot_ria_link").style.display = "none";
    }
}

// 하단 리아 플래시 닫기 ------//
// (송성민 08/09/22) ------------------------------------//

function closeRiaWidget()
{
    thisMovie("flashWidget").closeRiaWidget();
    setTimeout("changeFooterRia('image')", 500);
}

//-------------------------------------------------------//

function callExternalInterface(movieId) {
	thisMovie(movieId).moveMc();	
}
/****************************************************************************************/

// 모든 페이지 호출 시  적용되는 초기화 함수
// 서석배
function pageLoad(){

    // 상세페이지 일 경우 상품 히트카운트 업데이트 수행
    if(location.href.indexOf("detail2.aspx") > -1) {
        ajaxHitCountUpdate();
    }
    
    // IE6 버전에서 일부 이미지 x박스 현상 처리를 위한 추가 - SSM. 2009.12.16
    ImageReload();
    
	try{
		document.getElementById("wrap").style.height = document.documentElement.clientHeight;
	} catch(e){}
	
	try {
		document.getElementById("sub_wrap").style.height = document.documentElement.clientHeight;
	} catch(e){}
	
	MoveBodyScrollVal();
	setTimeout("changeFooterRia('image')", 500);
}
	
// 검색영역 위치 찾기(서석배 추가)
function gnbSrchDivPosition(styleType){
	if ("A" == styleType) {
		document.getElementById("gnbSrch_"+styleType).style.left=document.getElementById("header_"+styleType).offsetLeft + 280;
	//	alert();
	}else if ("B" == styleType) {
		document.getElementById("gnbSrch_"+styleType).style.left=document.getElementById("header_"+styleType).offsetLeft + 522;
	}else if ("C" == styleType) {
		document.getElementById("gnbSrch_"+styleType).style.left=document.getElementById("header_"+styleType).offsetLeft + 95;
	}
}


//탭 롤오버 이미지 변경 --------------------------------------------------------------//
function MM_swapImgRestore() { //v3.0
	var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

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_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


// 레이어 팝업 (어두워지지 않음) --------------------------------------------------------------//
function show(object, type) { 
	if (document.layers && document.layers[object] != null) {
		if(document.layers[object].display == 'block') { hide(object); return; }
		document.layers[object].display = 'block';
	}
	else if (document.all) {
		if(document.all[object].style.display == 'block') { hide(object); return; }
		document.all[object].style.display = 'block';
	}
	
	if(arguments.length > 1) {
		document.getElementById(object).className = type;
	}
}   
//function show(object) {   
//if (document.layers && document.layers[object] != null) document.layers[object].visibility = 'visible';
//else if (document.all) document.all[object].style.visibility = 'visible';   

//}   
function hide(object) {   
	if (document.layers && document.layers[object] != null) document.layers[object].display = 'none';   
	else if (document.all) document.all[object].style.display = 'none';   
} 

/* =================================
    단말기/전자책 이용안내 탭 이동 함수
    made by. ssm
    =================================  */
function tabMove(strId)
{
    hide("imgDigitalGuide");
    hide("imgEbookGuide");
    show(strId);
}

//////// 주변 어두워지는 효과 설정
function openDark()
{
    var movieDiv = document.getElementById("movieDiv");
    movieDiv.style.display = "block";
	try {
		movieDiv.style.height = document.getElementById("wrap_BS").scrollHeight;
	} catch(e){}
	
	try {
		movieDiv.style.height = document.getElementById("wrap").scrollHeight;
	} catch(e){}
	
	try {
		movieDiv.style.height = document.getElementById("sub_wrap").scrollHeight;
	} catch(e){}
	
	setOpacity(movieDiv, 30);  //알파값 변경 (숫자로 변경)  
}

///////// 주변 어두워지는 효과 해제
function closeDark()
{
    var movieDiv = document.getElementById("movieDiv");
    movieDiv.style.display = "none";
}


// 레이어 팝업 (주변 어두워짐) ------------------------------------------//
function openMovie(name, type) {  
	if(arguments.length > 1) {
		document.getElementById(name).className = type;
	}

	var movie = document.getElementById(name);   
	var movieDiv = document.getElementById("movieDiv");   
	movie.style.display = "block";   
	movieDiv.style.display = "block";
	try {
		document.getElementById("movieDiv").style.height = document.getElementById("wrap_BS").scrollHeight;
	} catch(e){}
	
	try {
		document.getElementById("movieDiv").style.height = document.getElementById("wrap").scrollHeight;
	} catch(e){}
	
	try {
		document.getElementById("movieDiv").style.height = document.getElementById("sub_wrap").scrollHeight;
	} catch(e){}
	
	//setOpacity(movieDiv, 30);  //알파값 변경 (숫자로 변경)   
}   
function setOpacity(o,alpha) {
	//if(o.filters)o.filters.alpha.opacity = alpha;   
	//else o.style.opacity = alpha;   
}   
function closeMovie(movieFlash) {   
	var movie = document.getElementById(movieFlash);   
	var movieDiv = document.getElementById("movieDiv");   
	movieDiv.style.display = "none";   
	movie.style.display = "none";   
} 


// 미니카트 닫고 새로운 레이어 열기  --------------------------------------//
function miniCartClose(name) {
	var check_yn = false;
	var checkbox = document.getElementsByName("checkbox");
	for(var i=0; i<checkbox.length; i++) {
	    if(checkbox[i].checked) {
	        check_yn = true;
	        break;
	    }
	}
	
	//체크된 상품이 하나라도 존재할 경우 주문결제 수행
	if(check_yn) {
		alert("모비북 서비스의 종료로 판매가 중단되었습니다.\n\n메키아 서비스를 이용해 주세요.\n\n\n이야기속 깊은지혜 mekia - www.mekia.net");
//	    var movie = document.getElementById(name);
//	    movie.style.display = "";
//	    clearCookie("MINI_VIEW", "/", "");
//	    orderPopup(null, null, null, "pc");
	} else {
	    alert("선택된 상품이 없습니다.");
	}
}

// FAQ 토글 ---------------------------------------------------------//
var currentToggle;   
function toogleFaq(e) {   
	oldTd = document.getElementById("faq"+currentToggle);   
	newTd = document.getElementById("faq"+e);   
	if(currentToggle && currentToggle != e) oldTd.style.display = "none";   
	if(newTd.style.display == "") newTd.style.display = "none";   
	else newTd.style.display = "";   
	currentToggle = e;   
}   

var currentToggle2;   
function toogleFaqB(e) {   
	oldTd = document.getElementById("faqB"+currentToggle2);   
	newTd = document.getElementById("faqB"+e);   
	if(currentToggle2 && currentToggle2 != e) oldTd.style.display = "none";   
	if(newTd.style.display == "") newTd.style.display = "none";   
	else newTd.style.display = "";   
	currentToggle2 = e; 
  
	var HTML = document.getElementById("refresh").innerHTML;   
	document.getElementById("refresh").innerHTML = "";   
	document.getElementById("refresh").innerHTML = HTML;  
}   


// 기본 div 조절 ---------------------------------------------------------//
function divChange(name, type) {
	if(type=="on") {
	document.getElementById(name).className = "on";
	}
	else {
	document.getElementById(name).className = "off";
	}
}

// 베스트셀러 div 조절 ---------------------------------------------------------//
function flexSlide() {		
	if(document.getElementById("slide").className == ""
	|| document.getElementById("slide").className == "off") {   
	document.getElementById("slide").className = "on";  
	document.getElementById("best_chart").className = "bg2"; // bg2로 변경
}   
	else {   
	document.getElementById("slide").className = "off";   
	document.getElementById("best_chart").className = ""; // 원래 bg로 돌아감
	}   
}

//===================== 이메일주소 무단수집거부 팝업 ====================//
function popupStipulation()
{
	var email_no = document.getElementById("email_no");
	var email_content = document.getElementById("email_content");
	if(email_no.style.display == "block") {
		closeMovie(email_no.id);
		return;
	}
	
	var xmlHttp = Ajax.getTransport();
	xmlHttp.open("GET", "/popupStipulation.aspx", true);
	//xmlHttp.open("GET", "MyDxml.aspx?seq="+seq, false);
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttp.onreadystatechange = xmlCommitCallback;
	xmlHttp.send(null);
	
	function xmlCommitCallback()
	{
		if(xmlHttp.readyState == 4) {
			if(xmlHttp.status == 200) {
				var xmlDoc = xmlHttp.responseXML;
				var contents = xmlDoc.childNodes.item(1).text;
				//var contents = xmlDoc.childNodes[1].getElementsByTagName("contents")[0].firstChild.nodeValue;
				var btnOk = "<p style=\"position:absolute; top:204px; left:181px;\"><a href=\"javascript://\" onclick=\"javascript:popupStipulation();\"><img src=\"/images/common/btn/btn_ok2.gif\"></a></p>"
				email_content.innerHTML = contents + btnOk;
				
				var curWidth = parseInt(email_content.currentStyle.width);
				var curHeight = parseInt(email_content.currentStyle.height);
				with(email_no.style) {
				    var obj = getMainObj();
					left = (document.body.clientWidth/2)-(curWidth/2)+obj.scrollLeft;
					top = (document.body.clientHeight/2)-curHeight+obj.scrollTop;
				}
				openMovie(email_no.id);
			} else {
				var errmsg = "에러코드 : "+xmlHttp.status+"\n\n";
				errmsg = errmsg + "204 : 전달된 데이터가 없습니다.\n";
				errmsg = errmsg + "404 : URL을 확인하세요.\n";
				errmsg = errmsg + "500 : 내부 에러!\n";
				alert("에러코드 : "+xmlHttp.status+"\n\n 204 : 전달된 데이터가 없습니다.");
			}
		}
	}
}
//=======================================================================//


// 플렉스 회원가입 사이즈변경 ---------------------------------------------------------//
// 서석배
function joinHeight(height) {
	//alert(height);
	document.getElementById("joinSWF").height = height+"px";
}

// 플렉스 공통 사이즈변경 ---------------------------------------------------------//
// 서석배
function flashHeightChange(obj, height) {
//	alert("obj"+","+height);
	document.getElementById(obj).height = height+"px";
}

//상품 상세의 상단 플렉스 열고 닫기 제어 
// 서석배
function productDetailHeaderOpenClose(){
	var ExpDate = new Date();
	ExpDate.setTime(ExpDate.getTime() + 1000*60*60*24*360);
	if (document.getElementById("productDetailHeaderDiv").style.display == "block" || document.getElementById("productDetailHeaderDiv").style.display == ""){
		document.getElementById("productDetailHeaderDiv").style.display = "none";
		document.getElementById("productDetailHeadLine").style.display = "block";
		document.getElementById("btn_listOpenClose").src="/images/common/btn/btn_listOpen.gif";
		SetCookie("_ProductDetailOpenClose_", "CLOSE", ExpDate);
	} else {
		document.getElementById("productDetailHeaderDiv").style.display = "block";
		document.getElementById("productDetailHeadLine").style.display = "none";
		document.getElementById("btn_listOpenClose").src="/images/common/btn/btn_listClose.gif";
		SetCookie("_ProductDetailOpenClose_", "OPEN", ExpDate);
	}
}
//상품 상세의 목록 이미지가 가운데 들어 왔을때 플렉스에서 호출 하는 함수
// 서석배
function productDetailContent(prdtCD){
	document.getElementById("product_detail_basic_info").src = "/product/iframe_detail.aspx?plt_prdt_cd="+prdtCD;
	document.getElementById("productDetailFooterSWF").flexProductDetailContent(prdtCD);
}
function productDetailContentFlash(prdtCD){
	document.getElementById("product_detail_basic_info").src = "/product/iframe_detail_flash.aspx?plt_prdt_cd="+prdtCD;
}


function productDetailReviewOpen(){
	//document.getElementById("productDetailFooterSWF").frontReviewOpenClick();
	//document.getElementById('sub_wrap').scrollTop='1000';
	
	document.getElementById("sub_wrap").scrollTop = document.getElementById("sub_wrap").scrollHeight - 800;
}
	
// 상단 GNB 플래쉬에서 제어하는 함수 시작---------------------------------------------//
// 작성자 : 서석배
// 장바구니 클릭
function flashBasketClick() {
    var cnt = getTopCartCnt();
    if(cnt > 0) {
        ajaxMiniCart("VIEW", null);   //미니카트 내용 가져오기
    } else {
        if(loginCheckFunc() == "0") {
            if(confirm("장바구니는 로그인이 필요한 기능입니다.\n\n로그인 하시겠습니까?")) {
                SetCookie("CART_FLAG", "true", null, "/");
                //로그인
                goLogin();
            }
        }
        else {
            alert("장바구니가 비었습니다.");
        }
    }
}

// 카테고리 버튼 클릭 --------
// 서석배
function flashCategoryClick() {
//	show("top_category_"+type);
	show("top_category");
}

// 카테고리 버튼 마우스 오버/아웃 --------
// 서석배
var flashCategorytimeId;
function flashCategoryOver() {
	clearTimeout(flashCategorytimeId);
	if (document.getElementById("body")){
		document.getElementById("top_category_"+gnb_type).style.left = "33px";
	}
	document.getElementById("top_category_"+gnb_type).style.visibility="visible";
	document.getElementById("top_category_"+gnb_type).style.left = "45px";
	//document.getElementById("top_category_"+gnb_type).style.width="10px";
	document.getElementById("top_category_"+gnb_type).style.top="144px";
	document.getElementById("categoryBtn").style.visibility="hidden";
}
function flashCategoryOut() {
	flashCategorytimeId=setTimeout("flashCategoryOutEnd('"+gnb_type+"')",700);
}
function flashCategoryOutEnd() {
	document.getElementById("top_category_"+gnb_type).style.visibility="hidden";
	document.getElementById("categoryBtn").style.visibility="visible";
}
function flashCategoryClose() {
	document.getElementById("top_category_"+gnb_type).style.visibility="hidden";
	document.getElementById("categoryBtn").style.visibility="visible";
}
//----------------------------------------------

// 인기검색어 버튼 클릭 시
// 서석배
function flashSearchClick(keyword) {
	parent.document.location.href="/search/html/Search.aspx?srchType=all&researchFlg=false&detailsearchFlg=false&pageNum=1&sortName=&srchWord="+encodeURIComponent(keyword);
}

// GNB플래시 로드
// 서석배
function flashTopNavi(width, height, src, fixedgnb, top_gnb, popularkwd, loginCheck) {
	var html = "";
	html += "<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0' width='"+width+"' height='"+height+"'>";
	html += "<param name='allowScriptAccess' value='always'>";
	html += "<param name='allowFullScreen' value='false'>";
	html += "<param name='movie' value='"+src+"'>";
	html += "<param name='quality' value='high'>";
	html += "<param name='wmode' value='transparent'>";
	html += "<param name='base' value='.'>";
	html += "<param name=FlashVars value='fixedgnb="+fixedgnb+"&top_gnb="+top_gnb+"&popularkwd="+popularkwd+"&loginCheck="+loginCheck+"' />";
	html += "<embed base='.' src='"+src+"' name='wmode' value='transparent' FlashVars='fixedgnb="+fixedgnb+"&top_gnb="+top_gnb+"&popularkwd="+popularkwd+"&loginCheck="+loginCheck+"' quality='high' width='"+width+"' height='"+height+"' align='middle' allowScriptAccess='sameDomain' allowFullScreen='false' name='wmode' value='transparent' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer'>";
	html += "</object>";
	document.write(html);
}
// 상단 GNB 플래쉬에서 제어하는 함수 끝---------------------------------------------//

// 하단 리아 플래쉬 제어하는 함수 시작 -----------------------------------------------//
// 열고 닫기
// 서석배
function flashFooterRiaOpenClose(flag){ // 1이면 오픈, 0이면 클로즈
	if (flag == "1"){
		document.getElementById("foot_ria").style.height = "276px";
	} else {
		document.getElementById("foot_ria").style.height = "0"; //"38px";
	}
}
// 하단 리아 플래쉬 제어하는 함수 끝 -----------------------------------------------//

// 상품 상세에서 상품 퍼가기 복사
// 서석배
function copyText()
{
	var doc = document.body.createTextRange();
	doc.moveToElementText(document.getElementById("productScrapCopy"));
	doc.execCommand("Copy");
//	doc.select();
	text = window.clipboardData.getData("Text");
	alert("내용이 복사되었습니다.");
	hide('productScrap');
}

// 위젯, 미리보기 바로가기 팝업
// 서석배
function popupWidget(TYPE,EAN_CD) {
//	alert(TYPE+","+EAN_CD);
	var url = "http://widget.gogothink.com/InSide/Widget.asp?orderUrl=http://"+String(document.domain)+"/product/detail.aspx&MODE=single&TYPE="+TYPE+"&EAN_CD="+EAN_CD;
	window.showModalDialog(url,''," dialogWidth : 600px; dialogHeight : 700px; resizable : no; help : No; status : No; scroll : No;");
}

//////////asp.net의 String.Format 메소드 구현
function StringFormat()
{
    var expression = arguments[0];
    for(var i=1; i<arguments.length; i++) {
        var pattern = "{" + (i - 1) + "}";
        expression = expression.replace(pattern, arguments[i]);
    }
    return expression;
}

///////////////제품수량 변경(UI) - 상품상세페이지
function calculater2(mode, strID)
{

    var textfield = null;
    
    if(strID == null)   textfield = document.getElementById("txtAmount");
    else                textfield = document.getElementById("txtAmount_" + strID);
    
    var cnt = parseInt(textfield.value);
    
    if(mode == "UP") {              //수량 더하기
        if((cnt+1) > 99)    return;
        textfield.value = cnt + 1;
    } else if(mode == "DOWN") {     //수량 빼기
        if((cnt-1) < 1)     return;
        textfield.value = cnt - 1;
    }
}

//찜리스트 담기중 비회원일 경우 현재 체크된 상품 목록 쿠키 저장 후 로그인페이지로 유도
function SaveWithLogin(plt_prdt_cd)
{
    //여러개 상품일 경우
    if(plt_prdt_cd == null) {
        var chk = document.getElementsByName("chkbox");
        var iCnt =0;
        
        plt_prdt_cd = "";
        for(i=0; i < chk.length; i++) {
            if(chk[i].checked) {
                if(i == 0) {
                    plt_prdt_cd = chk[i].value;
                } else {
                    plt_prdt_cd += "," + chk[i].value;
                }
                iCnt += 1;
            }
        }
    }
    
    SetCookie("WISH_ARR_PRDT", plt_prdt_cd, null, "/");
    SetCookie("WISH_FLAG", "true", null, "/");
    goLogin();
}

/////////////로그인 페이지로 이동
function goLogin()
{
    var returl = String(document.location).toLowerCase();
	var domain = String(document.domain).toLowerCase();
//	var reg = new RegExp("/" +domain+ "\//");
//   	returl = returl.replace(reg, "");
	returl = returl.replace("http://"+domain, "");
	//if (returl != "/" && returl != "/login/login.aspx") {
	if (returl != "/login/login.aspx") {
	
	    //장바구니 담기 중 로그인 유도 시
	    if(GetCookie("CART_FLAG") == "true") {
	        SetCookie("CART_FLAG", "false", null, "/");
		    document.location.href = "/login/login.aspx?returl=" + escape("cart/cart_detail.aspx?arr_prdt=1");
	    }
	    //찜리스트 담기 중 로그인 유도 시
	    else if(GetCookie("WISH_FLAG") == "true") {
	        SetCookie("WISH_FLAG", "false", null, "/");
	        document.location.href = "/login/login.aspx?returl=" + escape("mypage/wishlist/wishlist.aspx?arr_prdt=1");
	    }
	    //구매 중 로그인 유도 시
	    else if(GetCookie("BUY_FLAG") == "true") {
	        SetCookie("BUY_FLAG", "false", null, "/");
	        document.location.href = "/login/login.aspx?returl=" + escape("product/detail.aspx?plt_prdt_cd=" + GetCookie("BUY_ARR_PRDT"));
	    }
	    //그 외
	    else {
	        var strRet = location.pathname + location.search;
	        document.location.href = "/login/login.aspx?returl=" + escape(strRet.substr(1));
	    }
	} else {
		document.location.href = "/login/login.aspx";
	}
}

/*
function imgRsize(img, rW, rH){
        var iW = img.width;
        var iH = img.height;

        var g = new Array;
        if(iW < rW && iH < rH) { // 가로세로가 축소할 값보다 작을 경우
                g[0] =  iW;
                g[1] =  iH;
        } else {
                if(img.width > img.height) { // 원크기 가로가 세로보다 크면

                        g[0] = rW;
                        g[1] = Math.ceil(img.height * rW / img.width);
                } else if(img.width <= img.height) { //원크기의 세로가 가로보다 크면
                        g[0] = Math.ceil(img.width * rH / img.height);
                        g[1] = rH;
                } else {
                        g[0] = rW;
                        g[1] = rH;
                }
                if(g[0] > rW) { // 구해진 가로값이 축소 가로보다 크면

                        g[0] = rW;
                        g[1] = Math.ceil(img.height * rW / img.width);
                }
                if(g[1] > rH) { // 구해진 세로값이 축소 세로값가로보다 크면
                        g[0] = Math.ceil(img.width * rH / img.height);
                        g[1] = rH;
                }
        }
        g[2] = img.width; // 원사이즈 가로
        g[3] = img.height; // 원사이즈 세로
        return g;
}
*/
function imgRsize(img,changeW,changeh){	
	var iW = changeW;
	var iH = changeh;
	if(iW == null || iW == "") {
		img.width = "91";
	} else {
		img.width = iW;
	}
	if(iH == null || iH == "") {
		img.height = "131";
	} else {
		img.height = iH;
	}
}

function imageLoadFail(img){
  // img.src="/images/common/img_nobook_s.jpg";
}


			
function 	gg(img, ww, hh, aL){
        var tt = imgRsize(img, ww, hh);
        if(img.width == 0 || img.height == 0){
        	imgRsize(img, 200, 151)
        }
        if(img.width > ww || img.height > hh || img.width == 0 || img.height == 0){ // 가로나 세로크기가 제한크기보다 크면
        	
            img.width = tt[0]; // 크기조정
            img.height = tt[1];
            img.alt = '클릭하시면 원본이미지를 보실수있습니다.';
            if(aL){ // 자동링크 on
                    img.onclick = function(){
                        wT = Math.ceil((screen.width - tt[2])/2.6); // 클라이언트 중앙에 이미지위치.
                        wL = Math.ceil((screen.height - tt[3])/2.6);
                        mm = window.open("", 'viewOrig', 'scrollbars=yes,width='+tt[2]+',height='+tt[3]+',top='+wT+',left='+wL);
						mm.document.open()
						mm.document.write("<body style='margin:0px;cursor:hand'><img src="+img.src+" alt='클릭하시면 창이 닫힙니다.' border='0' onclick='self.close();'></body>")
                        //mm.document.body.onmousedown = function(){ mm.close();}
                        mm.document.title = 'SoobakC.com';
						mm.document.close()
					/*
                   	    var doc = mm.document.open();
                        doc.body.style.margin = 0; // 마진제거
                        doc.body.style.cursor = "hand";
                        var previewimg = doc.createElement("img");
                        previewimg.src = img.src;                  
                        doc.body.appendChild(previewimg);
                        doc.body.onmousedown = function(){ mm.close();}
                        doc.title = 'Visang';
					*/
                    }
                    img.style.cursor = "hand";
            }
            
        } else {
        	
            img.onclick = function(){}
        }
}

function gg2(img, ww, hh, aL){
        var tt = imgRsize(img, ww, hh);
        if(img.width > ww || img.height > hh){ // 가로나 세로크기가 제한크기보다 크면
            img.width = tt[0]; // 크기조정
            img.height = tt[1];
            img.alt = '클릭하시면 원본이미지를 보실수있습니다.';
            if(aL){ // 자동링크 on
                    img.onclick = function(){
                        wT = Math.ceil((screen.width - tt[2])/2.6); // 클라이언트 중앙에 이미지위치.
                        wL = Math.ceil((screen.height - tt[3])/2.6);
                        mm = window.open("", 'viewOrig', 'scrollbars=yes,width='+tt[2]+',height='+tt[3]+',top='+wT+',left='+wL);
						mm.document.open()
						mm.document.write("<body style='margin:0px;cursor:hand'><img src="+img.src+" alt='클릭하시면 창이 닫힙니다.' border='0' onclick='self.close();'></body>")
                        //mm.document.body.onmousedown = function(){ mm.close();}
                        mm.document.title = '';
						mm.document.close()

                    }
                    img.style.cursor = "hand";
            }
        } else {
            img.onclick = function(){}
        }
}

function fncom_chk_strlength_cut(vn_maxlength, vn_str)
{
    var vn_sumlength=0;
    var vn_restr='';

    for(var i= 0;i < vn_str.length; i++) {
        if( escape(vn_str.charAt(i)).length > 3 ) { vn_length = 2; }
        else if (vn_str.charAt(i) == '<' || vn_str.charAt(i) == '>') { vn_length = 4; }
        else { vn_length = 1 ; }

        //if ( vn_maxlength < (vn_sumlength + vn_length) ) { break; }
        vn_sumlength += vn_length;
        if ( !(vn_maxlength < (vn_sumlength + vn_length)) ) {
            vn_restr += vn_str.charAt(i);
        }
    }
    
    if(vn_sumlength > vn_maxlength) {
        vn_restr += "...";
    }
    
    return (vn_restr);
}

//왼쪽상단 빠른탐색 위젯버튼 시작
function goCategory(type, e) {
	if (type == "flash"){
		location.href="/category/product_flash_list.aspx?cat_seq="+e;
	} else {
		location.href="/category/book_main.aspx?cat_seq="+e;
	}
}
function openSearchFlash()
{
    var noCasheXml = noCasheNow.getTime();
	var setFlash = new SWFLoader();
	//var category = "/images/flash/xml/category.xml";
	var category = "/xmlgroup/category/CategoryXmlList.aspx?nocache="+noCasheXml;
	//var info = "/images/flash/xml/info.xml?seq=";
	var info = "/xmlgroup/category/info_xml.aspx?nocache="+noCasheXml;
	var arg = [category, info];
	setFlash.init( '898', '447', '/images/flash/flashSearch.swf', arg);
	setFlash.id('quickSearch');
	document.getElementById("quickSearch").innerHTML = setFlash.view();
	document.getElementById("quickSearch").style.display = "block";
}
function closeSearchFlash()
{
	document.getElementById("quickSearch").innerText = "";
	document.getElementById("quickSearch").style.display = "none";
}
//왼쪽상단 빠른탐색 위젯버튼 끝

// 로그인 여부 체크 ajax
function loginCheckFunc(){
	var xmlHttp = Ajax.getTransport();
	xmlHttp.open("GET", "/login/loginStatus.aspx", false);
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttp.send(null);
	return xmlHttp.responseText;
}

//주문 배송 조회
function ship_trace(order_no){
    var popOpt = ""
        + "menubar=no,status=no,"
        + "toolbar=no,"
        + "titlebar=no,"
        + "scrollbars=no,"
        + "resizable=no,"
        + "width=305,"
        + "height=370,"
        + "top=100,"
        + "left=100";
        
	window.open("/mypage/orderlist/order_follow.aspx?order_no=" + order_no, "ship_popup", popOpt);
}

///////////////////// 금액 콤마 추가
function addComma(REC_AMT)
{
    var src;
    var i;
    var factor;
    var su;
    var Spacesize = 0;
    
    factor = REC_AMT.length % 3;
    su = (REC_AMT.length - factor) /3;
    src = REC_AMT.substring(0,factor);

    for(i=0; i<su; i++) {
        if((factor==0)&&(i==0)) {// " XXX "인 경우
            src += REC_AMT.substring(factor+(3*i), factor+3+(3*i));
        } else {
            src +=",";
            src += REC_AMT.substring(factor+(3*i), factor+3+(3*i));
        }
    }
    
    return src;
}

///////////////////// 금액 콤마 삭제
function delComma(account_number)
{
    var x, ch;
    var i=0;
    var newVal="";
    
    for(x=0; x <account_number.length ; x++) {
        ch=account_number.substring(x,x+1);
        if(ch != ",") {
            newVal += ch;
        }
    }
    return newVal;
}

//////////////////////숫자체크
function SetNum(obj)
{
    val=obj.value;
    re=/[^0-9]/gi;
    obj.value = val.replace(re,"");
    obj.focus();
}

///////////////////숫자체크2
function isNumber()
{
    var key = parseInt(event.keyCode);
    event.returnValue = false;
    // 숫자키 입력 허용 설정
    if(key >= 48 && key <= 57)  event.returnValue = true;
    if(key >= 96 && key <= 105) event.returnValue = true;   // 키패드 숫자
    // 그 외 허용키 설정
    switch(key) {
    case 8 :        // Backspace key
    case 9 :        // Tab key
    case 13 :       // Enter key
    case 16 :       // Shift key
    case 17 :       // Delete key
    case 35 :       // End key
    case 36 :       // Home key
    case 46 :       // Ctrl key
    case 67 :       // 'C' key
    case 86 :       // 'V' key
    case 88 :       // 'X' key
        event.returnValue = true; break;
    default :
        if(key >= 37 && key <= 40)      event.returnValue = true;   // Move key
    }
}

/////////////일자별 조회 날짜 체크
function dateComp(fromId, toId)
{
    var fromDate = document.getElementById(fromId).value;
    var toDate = document.getElementById(toId).value;
    
    fromDate = parseInt(fromDate.replace(/\-/g, ""));
    toDate = parseInt(toDate.replace(/\-/g, ""));
    
    if(fromDate > toDate) {
        alert("날짜 입력이 잘못되었습니다.\n\n상위 날짜가 하위 날짜보다 크거나 같아야 합니다.\n\n(ex)2012-12-20 ~ 2012-12-01");
        return false;
    }
    return true;
}

function receiptView(cash_no)
{
	receiptWin = "https://admin.kcp.co.kr/Modules/Service/Cash/Cash_Bill_Common_View.jsp?cash_no="+cash_no;
	window.open(receiptWin , "" , "width=360, height=640");
}

function cardreceiptView(tno)
{
	cardreceiptWin = "https://admin.kcp.co.kr/Modules/Sale/Card/ADSA_CARD_BILL_Receipt.jsp?c_trade_no="+tno;
	window.open(cardreceiptWin , "" , "width=420, height=670");
}

// body 레이어 이전 스크롤 y축으로 이동 함수
// SSM. 2009.12.01
function MoveBodyScrollVal()
{
    if(document.URL == GetCookie("COOKIE_REFERRE")) {
        setScrollVal(GetCookie("COOKIE_SCROLL_VAL"));
    }
}

// 링크 이동 함수 - 뒤로가기 버튼 클릭시 쓰일 이전 스크롤 위치 값 저장
// SSM. 2009.12.01
function LinkFunction(method, linkUrl)
{
    if(linkUrl == "/cart/cart_detail.aspx"
     && loginCheckFunc() == "0") {
        if(confirm("장바구니는 로그인이 필요한 기능입니다.\n\n로그인 하시겠습니까?")) {
            SetCookie("CART_FLAG", "true", null, "/");
            //로그인
            goLogin();
        }
        return;
    }
    
    SetCookie("COOKIE_REFERRE", document.URL, null, "/");
    SetCookie("COOKIE_SCROLL_VAL", getScrollVal(), null, "/");
    
    if(linkUrl == "goLogin") {
        //로그인
        goLogin();
    }
    else if(linkUrl == "indexsearchOpen") {
        //색인검색
        indexsearchOpen();
    }
    else {
        if(method == "GET")
        {
            location.href = encodeURI(linkUrl);
        }
        else if(method == "POST")
        {
            document.forms[0].action = linkUrl;
            document.forms[0].submit();
        }
    }
}

// IE6 버전에서 일부 이미지 x박스 현상 처리를 위한 추가
// SSM. 2009.12.16
function ImageReload()
{
    var images = document.all.tags("img");
    for(var i=0; i<images.length; i++) {
        images[i].src = images[i].src;
    }
    
    var inputs = document.all.tags("input");
    for(var i=0; i<inputs.length; i++) {
        inputs[i].src = inputs[i].src;
    }
}


// 팝업창 닫아주기
function ClosepopUpA(){

    self.close();

}
