﻿var nowurl			= "http://www.picaplay.com";
var sslurl			= "https://secure.picaplay.com";
//var sslurl = "http://test.picaplay.com";
var imgurl          = "http://image.picaplay.com";

//window.name = "PicaMain";

try {
    if (top.location == location) {
        if (location.href.toLowerCase().indexOf("http://picaplay.com") == 0) {
            location.href = "http://www.picaplay.com" + location.href.substring(19, location.href.length);
        }
    }
}
catch (ex)
{ }

//location.href = "http://www.picaplay.com/html/ServerCheck.htm";

function ReLocate(sUrl, sType) {

    if (sUrl == "") {
        location.href = location.href;
    } else {
        if (sUrl.substr(0, 4) == 'http') {
            location.href = sUrl;
        } else {
            if (sType == "ssl") {
                location.href = sslurl + sUrl;
            } else {
                location.href = nowurl + sUrl;
            }
        }
    }
}

function topLocation(tget, func) {
    try {
        if (top.location.href) {
            top.hidSslFrame.location.href = sslurl+"/Etc/ExecFunc.aspx?target=" + tget + "&fname=" + escape(func);
        }
    }
    catch (ex) {
        top.hidSslFrame.location.href = nowurl+"/Etc/ExecFunc.aspx?target=" + tget + "&fname=" + escape(func);
    }
}


// ie버젼체크
function msieversion() {
    var ua = window.navigator.userAgent
    var msie = ua.indexOf("MSIE ")

    if (msie > 0)      // If Internet Explorer, return version number
        return parseInt(ua.substring(msie + 5, ua.indexOf(".", msie)))
    else                 // If another browser, return 0
        return 0
}


//##################################################  DESIGN  ####################################################

//===========================================================================
// 함수명: ViewFlash
// 설  명: 플래시파일
// 작업일: 2007.11.05
// 작업자: 김숙연
//=============================================================================
var TopcurMenu, LeftcurMenu;
function ViewFlash(URL,width,height,vars,bgColor,winmode,curmenu) { //(파일경로, 가로, 세로, 변수, 배경색, 윈도우모드)

	var id=URL.split("/")[URL.split("/").length-1].split(".")[0];
	if(vars==null) vars='';
	if(bgColor==null) bgColor='#FFFFFF';
	if(winmode==null) winmode='transparent';  //wmode속성=window,opaque,transparent

	document.write("	<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='https://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0' "); 
	document.write("		width='"+width+"' height='"+height+"' id='"+id+"' align='middle'> ");
	document.write("	<param name='allowScriptAccess' value='always' /> ");
	document.write("	<param name='movie' 						value='"+URL+"' /> ");
	document.write("	<param name='FlashVars' 				value='"+vars+"' /> ");
	document.write("	<param name='wmode' 						value='"+winmode+"' /> ");
	document.write("	<param name='menu' 							value='false' /> ");
	document.write("	<param name='quality'						value='high' /> ");
	document.write("	<param name='scale'							value='noscale' /> ");
	document.write("	<param name='salign'						value='lt' /> ");
	document.write("	<param name='bgcolor'						value='"+bgColor+"' /> ");
	document.write("	<embed src='"+URL+"' flashVars='"+vars+"' wmode='"+winmode+"' menu='false' quality='high' scale='noscale' salign='lt'");
	document.write("		bgcolor='"+bgColor+"' width='"+width+"' height='"+height+"' name='"+id+"' align='middle' ");
	document.write("		allowScriptAccess='always' type='application/x-shockwave-flash' pluginspage='https://www.macromedia.com/go/getflashplayer' /> ");
	document.write("	</object> ");
}
/* 페이지 사용 방법 (변수,배경색,윈도우모드 생략가능)
<script>ViewFlash('URL','Width','Height','VARS','BGC','WINMODE')</script>
*/

//=============================================================================
// 함수명: MM_preloadImages
// 설  명: Mouse Over에 의한 이미지 전환
// 작업일: 2007.11.05
// 작업자: 김숙연
//=============================================================================
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];}}
}


//=============================================================================
// 함수명: MM_swapImgRestore
// 설  명: Mouse Over에 의한 이미지 전환
// 작업일: 2007.11.05
// 작업자: 김숙연
//=============================================================================
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;
}


//=============================================================================
// 함수명: MM_findObj
// 설  명: Mouse Over에 의한 이미지 전환
// 작업일: 2007.11.05
// 작업자: 김숙연
//=============================================================================
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;
}

//=============================================================================
// 함수명: MM_swapImage
// 설  명: Mouse Over에 의한 이미지 전환
// 작업일: 2007.11.05
// 작업자: 김숙연
//=============================================================================
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];}
}


//=============================================================================
// 함수명: MM_showHideLayer
// 설  명: 레이어
// 작업일: 2007.12.26
// 작업자: 김숙연
//=============================================================================

/*
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_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 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 '';
}
//##################################################  DESIGN ####################################################



//##################################################  공통합수 시작  ####################################################


// 숫자체크
function KeyCheckNum(key)
{
	if (navigator.appName == 'Netscape')
	{
		keyValue = key.which;
	}
	else
	{
		keyValue = event.keyCode;
	}
	if (  ((keyValue >= 48) && (keyValue <= 57 )) ) //0-9
	{
		return true;
	}
	return false;
}

function win_open(url,uname,w,h) {
	 var position ="width="+w+",height="+h+",left=" + ((screen.width-w)/2) + ",top=" + ((screen.height-h)/2) + ",toolbar=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no";
	window.open(url, uname, position);
}

function imgViewOpen(url,maxsize)
{
	if (url)
	{
			var maximagesize = maxsize // 이미지 최대사이즈

		var tmpImage	= new Image();
		tmpImage.src	= url;
		var tmpwidth	= tmpImage.width;
		var tmpheight	= tmpImage.height;
		
		if ( tmpwidth==0) tmpwidth = maxsize;
		if ( tmpheight==0) tmpheight = maxsize;
		
		//if ( tmpwidth==0 || tmpheight==0)
		//{
		//	var tid = setInterval("imgViewOpen()",200);
		//}
		//else
		//{
		//	if (tid != null)
		//	{
		//		tid = clearInterval(tid);
		//		tid = null;
		//	}
			
			var longsize	= tmpwidth>tmpheight ? tmpwidth : tmpheight;
			
			if (longsize > maximagesize)
			{
				if (tmpwidth > tmpheight)
				{
					tmpwidth = maximagesize;
					tmpheight = Math.floor((tmpheight * maximagesize) / tmpwidth);
				}
				if (tmpwidth < tmpheight)
				{
					tmpwidth = Math.floor((tmpwidth * maximagesize) / tmpheight);
					tmpheight = maximagesize;
				}
			}
			
			imgWin=window.open('',tmpwidth,tmpheight);
			imgWin.document.write("<html><head><title>Picaclient</title></head><body background='"+url+"' onclick='self.close()' style='cursor:hand'></body></html>");
		//}
		
	}
}

function cal_textarea(formname,textname,cLength)
{
	var tmpStr, tcount;
	tmpStr = eval(formname+"."+textname).value;

	if (tmpStr=="로그인이 필요한 서비스입니다.")
	{
		return;
	}

	cal_byte(tmpStr,formname,textname,cLength);

	if(eval(formname+".cbyte").value > cLength)
	{
		reserve = tcount-cLength;
		alert(cLength+" byte를 초과하였습니다.\r\n초과된 부분은 자동으로 삭제됩니다.");
		cutText(formname,textname,cLength);
		return;
	}
}
function cal_byte(query,formname,textname,cLength)										// 공지사항,게시판 입력 바이트 수 
{
       var tmpStr;
       var temp=0;
       var onechar;
       var tcount;
       tcount = 0;

       tmpStr = new String(query);
       temp = tmpStr.length;

       for (k=0;k<temp;k++)
       {
            onechar = tmpStr.charAt(k);
            if (escape(onechar).length > 4) {
                 tcount += 2;
            }
            else if (onechar!='\r') {
                 tcount++;
            }
       }

       eval(formname+".cbyte").value = tcount;

       if(tcount>cLength) {
            reserve = tcount-cLength;
            alert(cLength+" byte를 초과하였습니다.\r\n초과된 부분은 자동으로 삭제됩니다.");
            cutText(formname,textname,cLength);
            return;
       }
}

function cutText(formname,textname,cLength)													
{
       cut_string(eval(formname+"."+textname).value, cLength,formname,textname);			
}
function cut_string(query,max,formname,textname)										//문자자르는 로직
{
       var tmpStr;
       var temp=0;
       var onechar;
       var tcount;
       tcount = 0;

       tmpStr = new String(query);
       temp = tmpStr.length;

       for(k=0;k<temp;k++)
       {
            onechar = tmpStr.charAt(k);

            if(escape(onechar).length > 4) {
                 tcount += 2;
            }
            else if(onechar!='\r') {
                 tcount++;
            }

            if(tcount>max) {
                 tmpStr = tmpStr.substring(0,k);
                 break;
            }
       }

       if (max == max) {
            eval(formname+"."+textname).value = tmpStr;
            cal_byte(tmpStr,formname,textname);
       }

       return tmpStr;
}



//숫자 세자리씩 컴마
function plusComma(num)
{
	if (num < 0) { num *= -1; var minus = true}
	else var minus = false

	var dotPos = (num+"").split(".")
	var dotU = dotPos[0]
	var dotD = dotPos[1]
	var commaFlag = dotU.length%3

	if(commaFlag) {
		var out = dotU.substring(0, commaFlag)
		if (dotU.length > 3) out += ","
	}
	else var out = ""

	for (var i=commaFlag; i < dotU.length; i+=3) {
		out += dotU.substring(i, i+3)
		if( i < dotU.length-3) out += ","
	}

	if(minus) out = "-" + out
	if(dotD) return out + "." + dotD
	else return out;
}

/*=============================================================================* 
 * 년월을 입력받아 마지막 일를 반환한다(년월)
 * 
 * param : sYM 입력스트링(YYYYMM)
 *
 * return : String 해당월의 마지막날
 *============================================================================*/
function lastDay(sYM)
{
	if(sYM.length != 6)
	{
		alert("정확한 년월을 입력하십시오.");
		return;
	}

	if(!isDateYM(sYM))
	{
		return;
	}

	daysArray = new makeArray(12);    // 배열을 생성한다.

	for (i=1; i<8; i++)
	{
		daysArray[i] = 30 + (i%2);
	}
	for (i=8; i<13; i++)
	{
		daysArray[i] = 31 - (i%2);
	}
	var sYear = sYM.substring(0, 4) * 1;
	var sMonth	= sYM.substring(4, 6) * 1;

	if (((sYear % 4 == 0) && (sYear % 100 != 0)) || (sYear % 400 == 0))
	{
		daysArray[2] = 29;
	}
	else
	{
		daysArray[2] = 28;
	}

	return daysArray[sMonth].toString(); 
}

function isDateYM(sYM)
{
	// 숫자 확인
	if(!isNumber(sYM))
	{
		alert('날짜는 숫자만 입력하십시오');
		return false;
	}

	// 길이 확인
	if(sYM.length != 6)
	{
		alert('일자를 모두 입력하십시오');
		return false;
	}

	var iYear = parseInt(sYM.substring(0,4),10); //년도값을 숫자로
	var iMonth = parseInt(sYM.substring(4,6),10);  //월을 숫자로

	if((iMonth < 1) ||(iMonth >12))
	{
		alert(iMonth+'월의 입력이 잘못 되었습니다.');
		return false;
	}
	return true;		
}

function isNumber(sVal)
{    
	if(sVal.length < 1)
	{ 
		return false;
	}

	for(i=0; i<sVal.length; i++) 
	{
		iBit = parseInt(sVal.substring(i,i+1));     //문자(Char)를 숫자로 변경
		if(('0' < iBit) || ('9' > iBit)) 
		{
			//alert(i+':'+iBit+':'+'Mun');
		}
		else 
		{
			return false;
		} 
	}
	return true;
}

/*=============================================================================* 
 * 숫자 0으로 초기화 된 1차원 배열을 생성한다.
 * 
 * param : iSize 배열 크기
 *
 * return : this 배열
 *============================================================================*/
function makeArray(iSize)
{
	this.length = iSize;

	for (i = 1; i <= iSize; i++)
	{
		this[i] = 0;
	}
	return this;
}

function alertMsgLogin()
{
    if(confirm("로그인이 필요한 서비스입니다. 로그인 하시겠습니까?"))
    {
		location.href = sslurl + "/member/login.aspx?ReturnUrl="+escape(document.location.href);
    }
}


function omitBlockWord(str)
{
	var result = "";
	var cnt = 0;
	for(var i=0;i<blockWord.length;i++)
	{
		if (str.indexOf(blockWord[i])>=0)
		{
			cnt++;
			break;
		}
	}
	
	if (cnt > 0)
	{
		result = blockWord[i];
	}
	
	return result;
}

//################################################## 공통함수 끝 ####################################################



function hidestatus(){
	//window.status = 'Picaplay, 피카PC방만의 특별한 혜택';
	return true;
}
/*
if (document.layers)
document.captureEvents(Event.MOUSEOVER | Event.MOUSEOUT)
document.onmouseover=hidestatus
document.onmouseout=hidestatus
*/

//document.oncontextmenu = new Function("return false");

// trim
String.prototype.trim = function() {
	var retValue = this;

	var ch = retValue.substring(0, 1);
	while (ch == " ") {
		retValue = retValue.substring(1, retValue.length);
		ch = retValue.substring(0, 1);
	}

	ch = retValue.substring(retValue.length - 1, retValue.length);
	while (ch == " ") {
		retValue = retValue.substring(0, retValue.length - 1);
		ch = retValue.substring(retValue.length - 1, retValue.length);
	}

	return retValue;
}

/*
 * utility functions
 */
// trim
function trim(input) {
	if (typeof input != "string") return input;
	
	var retValue = input;

	var ch = retValue.substring(0, 1);
	while (ch == " ") {
		retValue = retValue.substring(1, retValue.length);
		ch = retValue.substring(0, 1);
	}
	
	ch = retValue.substring(retValue.length - 1, retValue.length);
	while (ch == " ") {
		retValue = retValue.substring(0, retValue.length - 1);
		ch = retValue.substring(retValue.length - 1, retValue.length);
	}
	
	return retValue;
}

//######################################## 웹서비스용 #####################################################/
//
//  winClose(param) : 팝업창 닫기
//
function winClose(param)
{
    window.returnValue = param;

    if (/MSIE/.test(navigator.userAgent))
    {
	    if(navigator.appVersion.indexOf("MSIE 7.0")>=0)
	    {
		    window.open('about:blank','_self').close();
	    }
	    else
	    {
		    window.opener = self;
		    self.close();
	    }
    }
}      

// get cookie
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 FUNC_COMMON_getCookie(cookieName) {
    var search = cookieName + "=";
    if( document.cookie.length > 0 ) {
        offset = document.cookie.indexOf(search);
        if( offset != -1 ) {
            offset += search.length;
            end = document.cookie.indexOf(";", offset);
            if( end == -1 ) {
                end = document.cookie.length;
            }
            return unescape(document.cookie.substring(offset, end));
        }
    }
    return "";
}

function MM_closeBrWindow(winName)
{
	document.getElementById(winName).style.display = "none";
}

function MM_openBrWindow(theURL,winName,w,h,t,l) { //v2.0
  var divPopup;
  divPopup = "<div id='"+winName+"' style=\"width:"+w+"px;height:"+h+"px;BORDER-RIGHT:0px; PADDING-RIGHT:0px; BORDER-TOP:0px; DISPLAY:; PADDING-LEFT:0px; Z-INDEX:1; LEFT:"+l+"px; PADDING-BOTTOM:0px; OVERFLOW:hidden; BORDER-LEFT:0px; PADDING-TOP:0px; BORDER-BOTTOM:0px; POSITION:absolute; TOP:"+t+"px;\">";
  divPopup += "<iframe id=\"frame_"+winName+"\" style=\"width:"+w+"px;height:"+h+"px\" frameborder=\"0\" leftmargin=\"0\" topmargin=\"0\" src=\""+theURL+"\" scrolling=\"no\"></iframe>"
  divPopup += "</div>";

  document.write(divPopup)
}


function $(id) {
    return document.getElementById(id);
}

function PopCashChargeEx(isLogin) {
    if (isLogin) {
        //   win_open(sslurl+"/Shop/CashCharge.aspx", "cashcharge", 360, 420);
        //var retVal = window.showModalDialog(sslurl + "/Shop/CashCharge.aspx", window, "dialogWidth:537px;dialogHeight:364px;center=yes;status:no; scroll:no; help:no");
        if (ChkCert == "N") {
            location.href = sslurl + "/Member/ReJoin.aspx?relocUrl=" + encodeURIComponent(location.href);
        }
        else {
            win_open(sslurl + "/Shop/CashCharge.aspx", "cashcharge", 537, 364);
        }
    } else {
        if (confirm('로그인 후 이용하실 수 있습니다. 로그인하시겠습니까?')) {
            document.location.href = sslurl + '/Member/Login.aspx';
        }
    }
}

function PopCashCharge() {
    PopCashChargeEx(true);
}

function PopCashWithdraw() {
       win_open(sslurl+"/Shop/CashWithdraw.aspx", "cashwithdraw", 537, 438);
       //var retVal = window.showModalDialog(sslurl + "/Shop/CashWithdraw.aspx", window, "dialogWidth:400px;dialogHeight:420px;center=yes;status:no; scroll:no; help:no");
}

function FUNC_COMMON_onlyNum(e) {
    var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
    if (keyCode != 13) {
        if ((keyCode > 47 && keyCode < 58) || (keyCode > 95 && keyCode < 106) || keyCode == 8 || keyCode == 46 || keyCode == 37 || keyCode == 39) {
            event.returnValue = true;
        }
        else {
            event.returnValue = false;
        }
    }
}

/**
한 e1 의 값의 길이가 e1Len 이 되면 e2 로 자동 focus 
*/
function FUNC_COMMON_autoMove(e1, e1Len, e2) {
    var nKeyCode = window.event.keyCode;
    if ((nKeyCode >= 48 && nKeyCode <= 57) || (nKeyCode >= 96 && nKeyCode <= 105)) {
        if (e1.value.length == e1Len) {
            e2.focus();
            e2.select();
        }
    }
}

function Only_Korean(input_key) {
    if (input_key > 90 || input_key < 97 || input_key > 122) {
        alert('한글만 입력이 가능합니다.');
        event.returnValue = false;
    }
}

function FUNC_CheckJumin(val1, val2) {
    var IDtot = 0;
    var IDAdd = "234567892345";
    var jumin = val1 + val2;
    var bool = true;
	
	if((jumin.length != 13))
	{
		bool = false;
	}
	else 
	{
		for(i = 0; i < 12; i++) 
		{
			IDtot = IDtot + parseInt(jumin.charAt(i)) * parseInt(IDAdd.charAt(i));
		}

		IDtot = 11 - (IDtot % 11);

		if (parseInt(jumin.charAt(12)) != (IDtot % 10)) 
		{
			bool = false;
		}
    }
    return bool;
}

function openChgPoint(isLogin) {
    if (isLogin) {
        if (ChkCert == "N") {
            location.href = sslurl + "/Member/ReJoin.aspx?relocUrl=" + encodeURIComponent(location.href);
        }
        else {
            var w, h;
            w = 537;
            h = 430;
            var position = "width=" + w + ",height=" + h + ",left=" + ((screen.width - w) / 2) + ",top=" + ((screen.height - h) / 2) + ",toolbar=0,directories=0,status=0,menubar=0,scrollbars=no,resizable=0";
            window.open(sslurl + '/MyPage/exchangePoint.aspx', 'chgPoint', position);
        }
    } else {
        if (confirm('로그인 후 이용하실 수 있습니다. 로그인하시겠습니까?')) {
            document.location.href = sslurl + '/Member/Login.aspx';
        }
    }    
}

function openChgSaleCoupon(isLogin) {
    if (isLogin) {
        if (ChkCert == "N") {
            location.href = sslurl + "/Member/ReJoin.aspx?relocUrl=" + encodeURIComponent(location.href);
        }
        else {
            var w, h;
            w = 537;
            h = 430;
            var position = "width=" + w + ",height=" + h + ",left=" + ((screen.width - w) / 2) + ",top=" + ((screen.height - h) / 2) + ",toolbar=0,directories=0,status=0,menubar=0,scrollbars=no,resizable=0";
            window.open(sslurl + '/MyPage/ExchangeSaleCoupon.aspx', 'ChgSaleCoupon', position);
        }
    } else {
        if (confirm('로그인 후 이용하실 수 있습니다. 로그인하시겠습니까?')) {
            document.location.href = sslurl + '/Member/Login.aspx';
        }
    }
}

function fn_ChargeAuction(ref, uno) {
    if (uno == 0) {
        if (confirm('로그인 후 이용하실 수 있습니다. 로그인하시겠습니까?')) {
            document.location.href = sslurl + '/Member/Login.aspx';
        }
    }
    else {

        if (ChkCert == "N") {
            location.href = sslurl + "/Member/ReJoin.aspx?relocUrl=" + encodeURIComponent(location.href);
        }
        else {
            /*
            var obj = new Object();
            obj.ref = ref;
    		
		    var retVal = window.showModalDialog(nowurl+"/Event/ChargeLucky.aspx",obj,"dialogWidth:548px;dialogHeight:540px;center=yes;status:no; scroll:no; help:no");
    		
		    if (retVal != null)
            {
            alert(retVal)
            //form.userCouponAmt.value = plusComma(retVal[0]);
            }
            */

            var w, h;
            w = 537;
            h = 498;

            var position = "width=" + w + ",height=" + h + ",left=" + ((screen.width - w) / 2) + ",top=" + ((screen.height - h) / 2) + ",toolbar=0,directories=0,status=0,menubar=0,scrollbars=no,resizable=0,location=0";
            //var position ="width="+w+",height="+h+",left=" + ((screen.width-w)/2) + ",top=" + ((screen.height-h)/2) + ",toolbar=0,directories=0,status=0,menubar=0,scrollbars=no,resizable=1";
            window.open(sslurl + '/Event/ChargeLucky.aspx?ref=' + ref, 'chargelucky', position);
        }
    }
}

function fn_ShopLogin() {
    location.href = sslurl + "/Member/Login.aspx?ReturnUrl=" + escape(nowurl + "/Shop/");
}

function fn_goEvent() {
    location.href = nowurl + "/Event";
}

var currSubMenuObj = null;
var currSubMenuDirection = 0;
var nextSubMenuObj = null;
var currSubmenuTimerId = 0;
var subMenuWidth = {
    submenu_shop: 95,
    submenu_event: 400,
    submenu_support: 500,
    submenu_mypage: 650
}

function showSubMenuQuickly(name) {
    currSubMenuDirection = 2;
    currSubMenuObj = $(name);
    currSubMenuObj.style.width = subMenuWidth[name] + 'px';
}

function showSubMenu(name) {
    var menuObj = $(name);

    switch (currSubMenuDirection) {
        case 0: // 초기
            currSubMenuDirection = 1;
            currSubMenuObj = menuObj;
            nextSubMenuObj = null;
            runSubMenuTimer();
            break;

        case 1: // 펼쳐지는 중
            if (currSubMenuObj != menuObj) {
                pauseSubMenuTimer();
                currSubMenuDirection = -1;
                nextSubMenuObj = menuObj;
                runSubMenuTimer();
            }
            break;

        case 2: // 펼쳐진 상태
            if (currSubMenuObj != menuObj) {
                currSubMenuDirection = -1;
                nextSubMenuObj = menuObj;
                runSubMenuTimer();
            }
            break;

        case -1: // 사라지는 중
            if (currSubMenuObj == menuObj) {
                pauseSubMenuTimer();
                currSubMenuDirection = 1;
                nextSubMenuObj = null;
                runSubMenuTimer();
            } else {
                nextSubMenuObj = menuObj;
            }
            break;
    }
}

function hideSubMenu() {
    if (currSubMenuDirection == 2) {
        currSubMenuDirection = -1;
        nextSubMenuObj = null;
        runSubMenuTimer();
    }
}

function pauseSubMenuTimer() {
    if (currSubmenuTimerId != 0) {
        clearTimeout(currSubmenuTimerId);
        currSubmenuTimerId = 0;
    }
}

function runSubMenuTimer() {
    if (currSubMenuDirection == -1) {
        var w = 30;
        var t = 20;
        var width = parseInt(currSubMenuObj.style.width, 10);
        width = (width - w < 0) ? 0 : width - w;
        currSubMenuObj.style.width = width + 'px';

        if (width == 0) {
            if (nextSubMenuObj == null) {
                currSubMenuObj = null;
                currSubMenuDirection = 0;
            } else {
                currSubMenuObj = nextSubMenuObj;
                nextSubMenuObj = null;
                currSubMenuDirection = 1;

                // 기존 서브 메뉴가 사라졌기 때문에 새로운 서브 메뉴를 나타나게 한다.
                currSubmenuTimerId = setTimeout("runSubMenuTimer()", t);
            }
        } else {
            // 서브 메뉴를 사라지게 한다.            
            currSubmenuTimerId = setTimeout("runSubMenuTimer()", t);
        }
    } else if (currSubMenuDirection == 1) {
        var w = 20;
        var t = 20;
        var width = parseInt(currSubMenuObj.style.width, 10);
        width = (width + w > subMenuWidth[currSubMenuObj.id]) ? subMenuWidth[currSubMenuObj.id] : width + w;
        currSubMenuObj.style.width = width + 'px';

        if (width == subMenuWidth[currSubMenuObj.id]) {
            currSubMenuDirection = 2;
        } else {
            currSubmenuTimerId = setTimeout("runSubMenuTimer()", t);
        }
    }
}

function FnShopLayerHeight(h) {
    $("FrmPayLayer").style.height = h;
    $("CommonLayer").style.height = h;
}

function swf_include(swfUrl, swfName, swfWidth, swfHeight, flashVars) {
    var flashStr =
		"<object style='z-index:100' classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,0,0' width='" + swfWidth + "' height='" + swfHeight + "' id='" + swfName + "' />" +
		"<param name='movie' value='" + swfUrl + "' />" +
		"<param name='FlashVars' value='" + flashVars + "' />" +
		"<param name='allowScriptAccess' value='always' />" +
		"<param name='allowFullScreen' value='true' />" +
		"<param name='wmode' value='opaque' />" +
		"<param name='loop' value='false' />" +
		"<param name='quality' value='high' />" +
		"<param name='scale' value='noscale' />" +
		"<embed src='" + swfUrl + "' id='" + swfName + "' width='" + swfWidth + "' height='" + swfHeight + "' FlashVars='" + flashVars + "' quality='high' wmode='window' allowScriptAccess='always' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />" +
		"</object>";

    document.write(flashStr);
}
