/* 브라우저 정보 */
var useragent = navigator.userAgent;
var bName = (useragent.indexOf('Opera') > -1) ? 'Opera' : navigator.appName;
var pos = useragent.indexOf('MSIE');
if (pos > -1) {
	bVer = useragent.substring(pos + 5);
	var pos = bVer.indexOf(';');
	var bVer = bVer.substring(0,pos);
}
var pos = useragent.indexOf('Opera');
if (pos > -1)    {
	bVer = useragent.substring(pos + 6);
	var pos = bVer.indexOf(' ');
	var bVer = bVer.substring(0, pos);
}
if (bName == "Netscape") {
	var bVer = useragent.substring(8);
	var pos = bVer.indexOf(' ');
	var bVer = bVer.substring(0, pos);
}
if (bName == "Netscape" && parseInt(navigator.appVersion) >= 5) {
	var pos = useragent.lastIndexOf('/');
	var bVer = useragent.substring(pos + 1);
}	


//-- 페이지 이동
function goto_page( v_page ){
	var fm = document.borfm;

	if(typeof fm != 'undefined')
	{
		if(typeof fm.act_url != 'undefined') fm.action=fm.act_url.value;
		if(typeof fm.act_target != 'undefined') fm.target=fm.act_target.value;
		if(typeof fm.act_method != 'undefined') fm.method=fm.act_method.value;
	}
	else
	{
		fm = document.pagefm;
	}

	//alert( fm.name );
	fm.page.value = v_page;
	fm.submit();
}

//-- 페이지 이동
function goto_page_( v_page ){
	var fm = document.borfm;

	if(1==2)
	{
		if(typeof fm.act_url != 'undefined') fm.action=fm.act_url.value;
		if(typeof fm.act_target != 'undefined') fm.target=fm.act_target.value;
		if(typeof fm.act_method != 'undefined') fm.method=fm.act_method.value;
	}
	else
	{
		fm = document.pagefm;
	}

	//alert( fm.name );
	fm.page.value = v_page;
	fm.submit();
}


// TR 바탕색 변경
function bg_ListOver(ele, color) { 
		if (!color) color='#f9f9f9'
		ele.style.backgroundColor = color; 
}
function bg_ListOut(ele) { ele.style.backgroundColor = ''; }

function MM_preloadImages() { //v3.0
	var d=document;
	if(d.images){
		if(!d.MM_p)
			d.MM_p=new Array();
		
		var i,j=d.MM_p.length,a=MM_preloadImages.arguments;
		for(i=0; i<a.length; i++)
			if(a[i].indexOf("#")!=0){
				d.MM_p[j]=new Image;
				d.MM_p[j++].src=a[i];
			}
	}
}

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_nbGroup(event, grpName) { //v6.0
  var i,img,nbArr,args=MM_nbGroup.arguments;
  if (event == "init" && args.length > 2) {
	if ((img = MM_findObj(args[2])) != null && !img.MM_init) {
	  img.MM_init = true; img.MM_up = args[3]; img.MM_dn = img.src;
	  if ((nbArr = document[grpName]) == null) nbArr = document[grpName] = new Array();
	  nbArr[nbArr.length] = img;
	  for (i=4; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
		if (!img.MM_up) img.MM_up = img.src;
		img.src = img.MM_dn = args[i+1];
		nbArr[nbArr.length] = img;
	} }
  } else if (event == "over") {
	document.MM_nbOver = nbArr = new Array();
	for (i=1; i < args.length-1; i+=3) if ((img = MM_findObj(args[i])) != null) {
	  if (!img.MM_up) img.MM_up = img.src;
	  img.src = (img.MM_dn && args[i+2]) ? args[i+2] : ((args[i+1])? args[i+1] : img.MM_up);
	  nbArr[nbArr.length] = img;
	}
  } else if (event == "out" ) {
	for (i=0; i < document.MM_nbOver.length; i++) {
	  img = document.MM_nbOver[i]; img.src = (img.MM_dn) ? img.MM_dn : img.MM_up; }
  } else if (event == "down") {
	nbArr = document[grpName];
	if (nbArr)
	  for (i=0; i < nbArr.length; i++) { img=nbArr[i]; img.src = img.MM_up; img.MM_dn = 0; }
	document[grpName] = nbArr = new Array();
	for (i=2; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
	  if (!img.MM_up) img.MM_up = img.src;
	  img.src = img.MM_dn = (args[i+1])? args[i+1] : img.MM_up;
	  nbArr[nbArr.length] = img;
  } }
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
	document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);


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_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 MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function flashLogin() //플래시에서 로그인 호출
{
	MM_openBrWindow('/member/login.asp','loginpop','width=600,height=500')
}
function flashFind() //플래시에서 아이디찾기 호출
{
	MM_openBrWindow('/member/find_id01.asp','find_id01','width=600,height=500')
}
function flashJoin() //플래시에서 회원가입 호출
{
	MM_openBrWindow('/member/join01.asp','join01','width=600,height=500')
}
function flashLoginHttps() //플래시에서 로그인 호출
{
	MM_openBrWindow('/member/login2.asp','loginpop','width=600,height=500')
}
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; }
}

function MM_popupMsg(msg) { //v1.0
  alert(msg);
}

/* 날짜 쿠키 생성 */
function setCookie_Day( name, value, expiredays )  { 
	var todayDate = new Date(); 
	todayDate.setDate( todayDate.getDate() + expiredays ); 
	document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + todayDate.toGMTString() + ";" 
} 

/* 쿠키 구하기  */
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) {
	var argv = setCookie.arguments;
	var argc = setCookie.arguments.length;
	var expires = (2 < argc)? argv[2] : null;
	var path = (3 < argc)	? argv[3] : null;
	var domain = (4 < argc)	? argv[4] : null;
	var secure = (5 < argc)	? argv[5] : false;
	document.cookie = name + "=" + escape (value) + ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + ((path == null) ? "" : ("; path=" + path)) + ((domain == null) ? "" : ("; domain=" + domain)) + ((secure == true) ? "; secure" : "");
}

// 윈도우 리사이즈 처리(ie 7.0처리)
function window_resize(v_width , v_height){
	if(chk_ie7())  v_height+=30;
	window.resizeTo(v_width , v_height);
}



/* IE7 여부 리턴 > return : true/false  */
function chk_ie7() {
	if(parseInt(bVer) == 7 ) {
		return true;
	} else {
		return false;
	}
}

/* IE6 여부 리턴 > return : true/false  */
function chk_ie6() {
	if(parseInt(bVer) == 6) {
		return true;
	} else {
		return false;
	}
}

/* 팝업 오픈 */
// var opt_str = "left=0, top=0,width=800, height=700,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no"
// url : 주소 , wname : 윈도우 이름 , w ; 가로크기 , h : 세로크기 , option : 속성 , posi_left : 오픈 위치(left) , posi_top : 오픈 위치(top)  값이 없으면 중앙 )
//var url = "/member/postsearch_pop.asp"
//var opt_str = "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no"
//popup_open(url, 'postsearch', 400, 480, opt_str , '', '')
function popup_open(url, wname, w, h, option , posi_left, posi_top){
	if (chk_ie7()) h+=30;

	if(posi_left == -1 || posi_top == -1){
		var winl = (screen.width - w)/2;
		var wint = (screen.height - h)/2;
	}else{
		var winl  = posi_left;
		var wint = posi_top;
	}
/*
	var winl  = posi_left;
	var wint = posi_top;
*/
	if (!option)  option = 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no'

	var objwin = window.open(url, wname, 'width='+w+',height='+h+',top='+wint+',left='+winl+',' + option) ;
	objwin.focus();
}

/* 질의없이 창 닫기 */
function selfClose(){
	if(navigator.appVersion.indexOf("MSIE 7") != -1){
		window.open('about:blank','_self').close();
	}else{		
		window.opener = self;
		self.close();
	}
}

// 체크박스 전체선택/해제 (objMe : 선택 , objTarget : 대상)
function checkboxchg(objMe, objTarget) {
	var TargetLen = objTarget.length;
   if(TargetLen) {  // 여러 개일 경우
		for(var i = 0; i<TargetLen;i++) {
			objTarget[i].checked = objMe.checked;
		}
	} else { // 한 개일 경우
		objTarget.checked = objMe.checked;
	}
}

// 라디오/체크박스 선택여부 반환
function validChoice(obj) {
	if(obj.length == null) {
		if (obj.checked) {
			return true;
		} else {
			return false;
		}
	} else {
		var len = obj.length;
		for (var z = 0; z < len; z++) {
			if(obj[z].checked) {
				return true;
				break;
			}
		}
		return false;
	}
}

/* body 크기에 맞는 창으로 리사이즈 처리 */
function resizeWin() {        
	var Width = parseInt(document.body.scrollWidth);  
	var Height = parseInt(document.body.scrollHeight);  
	var popWin = document.createElement("div");  
	popWin.style.position = "absolute";  
	popWin.style.left = "0px";  
	popWin.style.top = "0px";  
	popWin.style.width = "100%";  
	popWin.style.height = "100%";  

	document.body.appendChild(popWin);  

	window.resizeBy(Width-popWin.offsetWidth, Height-popWin.offsetHeight);  
	document.body.removeChild(popWin);  
}


// 객체 이름 확인
function thisMovie(movieName) {
	var isIE = navigator.appName.indexOf("Microsoft") != -1;
	return (isIE) ? window[movieName] : document[movieName];
}


function replace(msrc,sstr,rstr) {
       var idx,sleft,sright;

       msrc+="";
       sstr+="";
       rstr+="";
       idx=msrc.indexOf(sstr);
       if (idx > -1) {
              sleft = msrc.substring(0,idx) + rstr;
              sright = msrc.substring(idx+sstr.length);
              return sleft + replace(sright,sstr,rstr);
       } else {
              return msrc;
       }
}


/*
####################################################
## 메뉴 링크 정보 #####################################
####################################################
*/
//- 로그인 페이지 이동
function goto_login(){
	location.href="/etc/login.asp";
}

//- 로그아웃 페이지 이동
function goto_logout(){
	location.href="/etc/logout_proc.asp";
}

//- 회원가입 페이지 이동
function goto_join(){
	location.href="/etc/join01.asp";
}

//- 아이디 , 비밀번호 찾기 페이지 이동
function goto_idpwd_search(){
	location.href="/etc/find.asp";
}

//- 아이디 , 비밀번호 찾기 페이지 이동
function goto_idpwd_search(){
	location.href="/etc/find.asp";
}

//- 나의 이벤트 정보
function goto_my_eventinfo(){
	location.href="/etc/mypage01.asp";
}

//- 회원정보 수정
function goto_mem_edit(){
	location.href="/etc/mypage02.asp";
}

//- cf vote 페이지 이동
function goto_cfvote(){
	alert("정의해야함")
	//location.href="/etc/find.asp";
}

//- 룰렛 이벤트 페이지 이동
function goto_roulette(){
	alert("정의해야함")
	//location.href="/etc/find.asp";
}

//- 원스토리 팝업
function goto_ownstory(){
	var url = "/etc/popup_ownstory.asp";
	var wname = "ownpopup"
	var w = 740;
	var h = 538;
	var option = "status=yes";
	var posi_left = -1;
	var posi_top = -1;
	popup_open(url, wname, w, h, option , posi_left, posi_top);
}

//- 우편번호검색
function goto_zipcode(){
	var url = "/include/zipcode.asp";
	var wname = "zippopup"
	var w = 384;
	var h = 400;
	var option = "status=yes,scrollbars=yes";
	var posi_left = -1;
	var posi_top = -1;
	popup_open(url, wname, w, h, option , posi_left, posi_top);
}

function goto_zipcode02(v_cmd){
	var url = "/include/zipcode.asp?cmd="+v_cmd;
	var wname = "zippopup"
	var w = 384;
	var h = 400;
	var option = "status=yes,scrollbars=yes";
	var posi_left = -1;
	var posi_top = -1;
	popup_open(url, wname, w, h, option , posi_left, posi_top);
}


//- 바이럴이벤트 랭킹정보
function goto_rank(){
	var url = "/etc/popup_viral_rank.asp";
	var wname = "rankpopup"
	var w = 480;
	var h = 448;
	var option = "status=yes,scrollbars=yes";
	var posi_left = -1;
	var posi_top = -1;
	popup_open(url, wname, w, h, option , posi_left, posi_top);
}

//- 스크랩 리스트 팝업
function goto_scrap_popup(){
	var url = "/etc/popup_urllist.asp";
	var wname = "scrappopup"
	var w = 745;
	var h = 538;
	var option = "status=yes,scrollbars=no";
	var posi_left = -1;
	var posi_top = -1;
	popup_open(url, wname, w, h, option , posi_left, posi_top);
}

//-- 관리자 문의 메일
function help_mail(){
	location.href="mailto:hsk@bokwang.com";
}

//-- Nespresso 플레쉬 메뉴로 이동
function goto_flash_menu01(){
	location.href="/index.asp?pagenum=10";
}

//-- CF VOTE 플레쉬 메뉴로 이동
function goto_flash_menu02(){
	location.href="/index.asp?pagenum=20";
}

//-- 룰렛 플레쉬 메뉴로 이동
function goto_flash_menu03(){
	location.href="/index.asp?pagenum=30";
}

//-- 스크랩 메뉴로 이동
function goto_flash_menu04(){
	location.href="/index.asp?pagenum=40";
}

//-- 통계호출
function set_visit(v_vmidx){
	_proc.location.href="/proc/visit_proc.asp?vmidx="+ v_vmidx;
}

//-- 스크랩이미지 미리보기
function scrap_img_popup(){
	var url = "/popup/scrap_view.asp";
	var wname = "scrappop"
	var w = 615;
	var h = 700;
	var option = "status=yes,scrollbars=yes";
	var posi_left = -1;
	var posi_top = -1;
	popup_open(url, wname, w, h, option , posi_left, posi_top);
}

//-- 스크랩
function scrap_img(){
	copyclip(document.getElementById("html_img_source"));
}

//-- 클립보드에 저장
function copyclip(ele){
	var result = false;
	var copy_val = ele.value;

	var doc = document.body.createTextRange();
	doc.moveToElementText(ele);
	result = doc.execCommand("Copy");
	if(!result){
		alert("복사실패!\n\n다시 복사하기를 클릭해주세요.");
	}else{
		alert("복사되었습니다.\n\nCTRL+V 를 이용하여 붙여넣기 하세요.");
	}
}

/*
####################################################
## 플래시 관련    #####################################
####################################################
*/

//플래시 마우스 아웃 체크를 위한 함수 onMouseOut 이벤트 추가
function insertFlash(swf, width, height, bgcolor, id, flashvars, trans )
{
	var strFlashTag = new String();

	if (navigator.appName.indexOf("Microsoft") != -1)
	{
		strFlashTag += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ';
		strFlashTag += 'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" ';
		strFlashTag += 'id="' + id + '" width="' + width + '" height="' + height + '">';
		strFlashTag += '<param name="movie" value="' + swf + '"/>';

		if(flashvars != null) {strFlashTag += '<param name="flashvars" value="' + flashvars + '"/>'};
		strFlashTag += '<param name="quality" value="Best"/>';
		strFlashTag += '<param name="bgcolor" value="' + bgcolor + '"/>';
		strFlashTag += '<param name="menu" value="false"/>';
		strFlashTag += '<param name="salign" value="LT"/>';
		strFlashTag += '<param name="scale" value="noscale"/>';
		strFlashTag += '<param name="wmode" value="transparent"/>';
		strFlashTag += '<param name="allowScriptAccess" value="always"/>';
		strFlashTag += '</object>';
	}
	else
	{
		strFlashTag += '<embed src="' + swf + '" ';
		strFlashTag += 'quality="Best" ';
		strFlashTag += 'bgcolor="' + bgcolor + '" ';
		strFlashTag += 'width="' + width + '" ';
		strFlashTag += 'height="' + height + '" ';
		strFlashTag += 'menu="false" ';
		strFlashTag += 'scale="noscale" ';
		strFlashTag += 'id="' + id + '" ';
		strFlashTag += 'salign="LT" ';
		strFlashTag += 'wmode="transparent" ';
		strFlashTag += 'allowScriptAccess="always" ';
		if(flashvars != null) {strFlashTag += 'flashvars="' + flashvars + '" '};
		strFlashTag += 'type="application/x-shockwave-flash" ';
		strFlashTag += 'pluginspage="http://www.macromedia.com/go/getflashplayer">';
		strFlashTag += '</embed>';
	}
	document.write(strFlashTag);
		
}

function zoom_pop( str1 ){
	MM_openBrWindow('/ad/zoom_pop.asp?filename='+str1,'','width=737,height=500, status=yes,scrollbars=yes');
}
function screen_download( str1 ){
	location.href=str1
}
function poster_download( str1 ){
	location.href=str1
}


function flashEvalLink( str ){

	switch( str ){
		case "home": location.href="/" ; break;

		case "event_Link": window.open("/event/20091214_webtour/index.asp?rf=2") ; break;//메인 센터 이벤트 링크


		case "footer_01": location.href="/customer/info.asp" ; break;
		case "footer_02": location.href="/customer/agree.asp" ; break;
		case "footer_03": location.href="/sitemap.asp" ; break;

		
		case "login": javascript:MM_openBrWindow('../member/login.asp','loginpop','width=600,height=500') ; break;
		case "logout": location.href="/member/logout_proc.asp" ; break;


		case "Top_Menu_01": location.href="/story/story.asp" ; break;
		case "Top_Menu_02": location.href="/ad/tvcf.asp" ; break;
		case "Top_Menu_03": location.href="/cafe/nohow_list.asp" ; break;
		case "Top_Menu_04": location.href="/zone/paper.asp" ; break;
		case "Top_Menu_05": location.href="/event/event_ing_list.asp" ; break;

		
		case "Top_MenuSub_11": location.href="/story/brand.asp" ; break;
		case "Top_MenuSub_12": location.href="/story/introduce.asp" ; break;
		case "Top_MenuSub_13": location.href="/story/coffee.asp" ; break;
		case "Top_MenuSub_14": location.href="/story/mytop.asp" ; break;
		
		case "Top_MenuSub_21": location.href="/ad/tvcf.asp" ; break;
		case "Top_MenuSub_22": location.href="/ad/advertise.asp" ; break;


		case "Top_MenuSub_31": location.href="/cafe/nohow_list.asp" ; break;
		case "Top_MenuSub_32": location.href="/cafe/talk_list.asp" ; break;
		case "Top_MenuSub_33": location.href="/cafe/love_send.asp" ; break;

		
		case "Top_MenuSub_41": location.href="/zone/paper.asp" ; break;
		case "Top_MenuSub_42": location.href="/zone/screen.asp" ; break;
		case "Top_MenuSub_43": location.href="/event/20091214_webtour/event_0209.asp" ; break;
		//case "Top_MenuSub_43": location.href="/zone/edgecf.asp" ; break;

		
		case "Top_MenuSub_51": location.href="/event/event_ing_list.asp" ; break;
		case "Top_MenuSub_52": location.href="/event/event_prev_list.asp" ; break;
		case "Top_MenuSub_53": location.href="/event/event_winner_list.asp" ; break;

	}
}


// 로그인 팝업
function open_login() {
}

// 회원가입 팝업
function open_memberjoin() {
}
