/**
 * global function
 * author : 김대현
 * date : 2007-04-24
 */

// 에스크로 결제 안내 페이지(makeb2b 전용)
function onPopKBAuthMark()          
{           
    window.open('','KB_AUTHMARK','height=750, width=650, status=yes, toolbar=no, menubar=no, location=no');         
    document.KB_AUTHMARK_FORM.action='http://ibn1.kbstar.com/quics';            
    document.KB_AUTHMARK_FORM.target='KB_AUTHMARK';         
    document.KB_AUTHMARK_FORM.submit();         
}           

// 폼 validate 할때 걸렸을때 보여 주는 메세지 (show_result.tpl.html)
function showValidateMessage(errors, prefix) { // void
    mess = '다음항목을 확인해 주세요.\n\n';
    for (var i = 0; i < errors.length; i++) {
        mess += '* ' + errors[i].message + '\n';
        $(prefix + errors[i].field).update(errors[i].message);
    }
    alert(mess);
}

/**
 * 플래시 테두리 없이 보이기 위한...
 *
 * http://hyeonseok.com/pmwiki/index.php/Markup/Object 참고
 * param 변수 - index 상단 메뉴의 id값이 존재해야 함으로 추가
 */
function flashMovie(fid, src, wid, hei, fvs, wmd, param) {
    this.fPrint     = '';
    this.Id         = document.getElementById(fid);
    this.Src        = src;
    this.Width      = wid;
    this.Height     = hei;
    this.FlashVars  = (typeof fvs != 'undefined')? fvs :'';
    this.Wmod       = (typeof wmd != 'undefined')? wmd :'';
    this.Param      = (typeof param != 'undefined')? param :'';

    if(isObject(Id)) {
        fPrint  = '<object type="application/x-shockwave-flash" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="https://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0"';
        fPrint += ' width="'+Width+'"';
        fPrint += ' height="'+Height+'" '+Param+'>';
        fPrint += '<param name="movie" value="'+Src+'">';
        fPrint += '<param name="quality" value="high">';
        fPrint += '<param name="AllowScriptAccess" value="always" />';
        fPrint += (FlashVars != null) ? '<param name="FlashVars" value="'+FlashVars+'">' : '';
        fPrint += (Wmod != null) ? '<param name="wmode" value="'+Wmod+'">' : '';
        fPrint += '<embed';
        fPrint += fPrint + ' src="'+Src+'"';
        fPrint += (FlashVars != null) ? ' FlashVars="'+FlashVars+'"' : '';
        fPrint += (Wmod != null) ? ' wmode="'+Wmod+'"' : '';
        fPrint += ' quality="high"';
        fPrint += ' pluginspage="https://www.macromedia.com/go/getflashplayer"';
        fPrint += ' type="application/x-shockwave-flash"';
        fPrint += ' width="'+Width+'"';
        fPrint += ' height="'+Height+'"';
        fPrint += ' AllowScriptAccess="always"></embed>';
        fPrint += '</object>';
        Id.innerHTML = fPrint;
    }
}
function isObject(a) {
    return (a && typeof a == 'object');
}

//최근본상품 닫기 -sj (footer.tpl.html)
function latest_view(type) {
    setCookie('latest_view',type);
    if (type === "close") {
        $('latest_display').style.display = "none";
    } else {
        $('latest_display').style.display = "";
    }
}

// 공급사 제휴 메일 보내기 - cheong(footer.tpl.html, goods_detail.tpl.html, mypage_data.tpl.html)
function mail_pvd_Popup(addr) {
    window.open(WEBROOT + '/mail/mail_pvdregister/','mail', 'width=560, height=850, scrollbars=no');
}
// 통합배송 제휴 메일 보내기
function mail_unify_Popup(addr) {
    window.open(WEBROOT + '/mail/mail_unifyregister/','mail', 'width=560, height=850, scrollbars=yes');
}

//쿠키심기 -sj  (member_authentication.php)
function setCookie(cookieName,cookieVal) {
    document.cookie = cookieName + '='+ escape(cookieVal) +'; path=/;';
}

//쿠키꺼내기
function getCookie(name) {
	var dcookie = document.cookie;
		var cname = name + "=";
		var clen = dcookie.length;
		var cbegin = 0;
		while (cbegin < clen) {
			var vbegin = cbegin + cname.length;
				if (dcookie.substring(cbegin, vbegin) == cname) {
					var vend = dcookie.indexOf (";", vbegin);
					if (vend == -1) {
						vend = clen;
					}
					return unescape(dcookie.substring(vbegin, vend));
				}
			cbegin = dcookie.indexOf(" ", cbegin) + 1;

			if (cbegin == 0) break;
		}
		return "";
}
//상단 장바구니 (header.tpl.html) 
function basket_alert() {
    alert("장바구니는 로그인후 이용하실 수 있습니다!");
}

//장바구니 메뉴 노출/숨김 - cheong 08.08.21 (header.tpl.html)
function showBasketMenu() {
    $('basket_menu').style.display = "";
}
function hideBasketMenu() {
    $('basket_menu').style.display = "none";
}

// 스타일샵 정렬기능 관련 스크립트 -cheong204 08.08.22 (goods_list.tpl.html)
function styOrderBy(order, orderby) {
    $('sty_form').order.value   = order;
    $('sty_form').orderby.value = orderby;
    $('sty_form').submit();
}
// 스타일샵 정렬기능 관련 스크립트 -cheong204 08.08.22 (styleshop_detail_list.tpl.html)
function styOrder(order, orderby) {
    $('sty_form').order.value   = order;
    $('sty_form').submit();
}

//팩토리 메뉴 노출/숨김 - cheong 08.10.22 (header.tpl.html)
function showFacMenu() {
    $('fac_menu').style.display = "";
}
function hideFacMenu() {
    $('fac_menu').style.display = "none";
}

// 옵션 카테고리 레이어 show / hidden (header.tpl.html)
function openerCategoryOption() {
	if ($('category_option_layer').style.display == 'none') {
		$('category_option_layer').style.display = 'block';
		$('category_layer_opener').src = WEBROOT + "/images/btn_show_category_layer.gif";
		$('category_layer_opener').alt = '카테고리 옵션 숨기기';
		setCookie('USE_CATEGORY_OPTION_LAYER', 'YES');
	} else {
		$('category_option_layer').style.display = 'none';
		$('category_layer_opener').src = WEBROOT + "/images/btn_hidden_category_layer.gif";
		$('category_layer_opener').alt = '카테고리 옵션 보기';
		setCookie('USE_CATEGORY_OPTION_LAYER', 'NO');
	}
	return;
}

// 헤더 상단 대분류 카테고리 링크 [플래쉬] (header.tpl.html)
function goMenu(category_link) {
	window.location.href = category_link;
}

// css 핵 png 파일 백그라운드 없앰
function setPng24(obj) {
    obj.width = obj.height = 1;
    obj.className = obj.className.replace(/\bpng24\b/i,'');
    obj.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+ obj.src + "',sizingMethod='image');"
    obj.src = ''; 
    return '';
}



// 공지사항 말머리 선택시 링크
function notice_list(value) {
    location.href = WEBROOT + "/notice/list/notice_write_type/" + value;
}
