var htmlSTR = ""
+"<table width=100% border=0 cellpadding=0 cellspacing=0 oncontextmenu='return false;'>"
+"<tr><td valign=top>"
+"<table width='306' height='86' border='0' bordercolor='#D1D0CA' cellpadding='0' cellspacing='0' class='divbox' bgcolor='#ffffff'>"
+"<tr><td colspan=3 height=5></td></tr>"
+"<tr>"
+"	<td width=8 nowrap></td>"
+"	<td width=100% valign=bottom><font class='infotitle1'>내용:</font><font class='infotitle1' id=djcp></font><font color=6c2c00></font>..</font></td>"
+"</tr>"
+"<tr>"
+"	<td colspan=2>"
+"	<form name=djf method=get action=>"
+"	<table width=100% border=0 cellpadding=0 cellspacing=0 >"
+"	<tr><td colspan=2 height=1></td></tr>"
+"	<tr>"
+"		<input type=hidden name=where value=dj>"
+"		<td width=8 nowrap></td>"
+"		<td width=100%>"
+"		<font class='infotitle1'>이름</font><input type=text name=nm size=5 maxlength=8 hideFocus=0> "
+"		<font class='infotitle1'>연락처</font><input type=text name=hp size=12 maxlength=13 hideFocus=0>"
+"		<a href='javascript:cPrint21();'><img src='img/com/btn_couponprint2.gif' border=0 align=absmiddle></a>"
+"		</td>"
+"		<input type=hidden name=skey id=djskey>"
+"	</form>"
+"	</tr>"
+"	<tr><td colspan=2 height=4></td></tr>"
+"	<tr>"
+"		<td width=8 nowrap></td>"
+"		<td width=100% style='padding-top:3pt;'><font class='infotitle1'>ㆍ수강등록시 위의 할인내용을 적용합니다.<br> &nbsp;ㆍ해당학원 담당자의 상담전화를 받으실 수 있습니다.</font></td>"
+"	</tr>"
+"	<tr><td colspan=3 height=2></td></tr>"
+"	</table>"
+"	</td>"
+"</tr>"
+"</table>"
+"</td></tr>"
+"</table>"

document.write("<DIV id=dj style='cursor:default; BACKGROUND-COLOR:fef8eb; BORDER-WIDTH:0PX; BORDER-STYLE:solid; BORDER-COLOR:e59f34; VISIBILITY: hidden; Z-INDEX: 2; LEFT: 0px; TOP: 0px; BOTTOM:0px; RIGHT:0px; WIDTH:288px; HEIGHT:72px; POSITION: absolute;'>");
document.write(htmlSTR + "</div>");

var method_type = document.attachEvent;

var lW;		// layer width
var lH;		// layer Height
var lL;		// layer left
var lT;		// layer top
var sL;		// body scroll left
var sT;		// body scroll top
var mX;		// mouse x position
var mY;		// mouse y position
var dj;	// dj div reference
var body;	// body reference
// body function

function cPrint21(){        
        if(djf.nm.value.replace(/\s/g,"")==""){
           alert("\n이름을 입력해 주십시오");
           djf.nm.focus();
           return;
        }
        if(djf.nm.value.indexOf(" ")!=-1){
           alert("\n이름은 공백 없이 연속된 한글만 사용할 수 있습니다.");
           djf.nm.focus();
           return;
        } 
        var regExp=/^[가-힣]{2,4}$/; 
	if(!regExp.test(djf.nm.value)){
           alert("\n이름은 2~4자의 한글만 사용할 수 있습니다.");
           djf.nm.focus();
           return;
        }
	if(djf.hp.value.replace(/\s/g,"")==""){
           alert("\n휴대폰번호 또는 전화번호를 입력해 주십시오");
           djf.hp.focus();
           return;
        }
        if(djf.hp.value.indexOf(" ")!=-1){
           alert("\n휴대폰번호 또는 전화번호는 공백 없이 연속된 숫자와 - 만 사용할 수 있습니다.");
           djf.hp.focus();
           return;
        }
        regExp=/^\d{2,4}\-?\d{3,4}\-?\d{4}$/;
        if(!regExp.test(djf.hp.value)){
           alert("\n유효한 휴대전화 또는 전화번호가 아닙니다.");
           djf.hp.focus();
           return;
        }
	skey=document.djf.skey.value;
	nm=document.djf.nm.value;
	hp=document.djf.hp.value;
	window.open("coupon_print.asp?skey="+skey+"&nm="+nm+"&hp="+hp, "coupon2","width=400,height=265,top=155,left=145,status=no,toolbar=no,menubar=no,scrollbars=no");
}

function couponPrint(skey){
	window.open("coupon_print.asp?skey="+skey, "coupon2","width=400,height=265,top=155,left=145,status=no,toolbar=no,menubar=no,scrollbars=no");
}
function FindBodyScrollCoordinates (  )
{
	sL = body.scrollLeft;
	sT = body.scrollTop;
}
// layer function
function FindLayerCoordinates ( layer )
{
	lL = parseInt ( layer.style.left );
	lT = parseInt ( layer.style.top );
	lW = parseInt ( layer.style.width );
	lH = parseInt ( layer.style.height );
}
function MoveLayerTo ( layer, posx, posy )
{ 
	layer.style.left = posx;
	layer.style.top = posy;
}
function MoveLayerBy ( layer, incx, incy )
{ 
	layer.style.left = parseInt ( layer.style.left ) + incx;
	layer.style.top = parseInt ( layer.style.top ) + incy;
}
// mouse
function FindMouseCoordinates ( e )
{
	FindBodyScrollCoordinates (  );
	mX = e.clientX + sL;
	mY = e.clientY + sT;
}


function MouseMoveHandler ( e )
{
	beforeMX = mX;
	beforeMY = mY;
	FindMouseCoordinates ( e );
	MoveLayerBy ( dj, mX - beforeMX, mY - beforeMY );
	return false;
}
function MouseUpHandler ( e )
{
	if ( method_type ) {
		document.detachEvent ( 'onmousemove', MouseMoveHandler );
		document.detachEvent ( 'onmouseup', MouseUpHandler );
	}
	else {
		document.removeEventListener ( 'mousemove', MouseMoveHandler, false );
		document.removeEventListener ( 'mouseup', MouseUpHandler, false );
	}
	return false;
}
// when mouse is down
function MouseDownHandler( e )
{
	FindMouseCoordinates ( e ) ;
	FindLayerCoordinates ( dj );
	if ( dj.style.visibility == "visible" ) {
		if ( ! ( ( lL < mX && mX < lL + lW ) && ( lT < mY && mY < lT + lH ) ) ) { 
			if ( method_type )
				document.detachEvent( 'onmousedown', MouseDownHandler );
			else
				document.removeEventListener ( 'mousedown', MouseDownHandler, false );
			hidePopup(  );
		}
	}
	else
		return	false ;
}
function movePopup( e )
{
	FindLayerCoordinates ( dj );
	FindMouseCoordinates ( e );
	if ( method_type ) {
		document.attachEvent ( 'onmousemove', MouseMoveHandler );
		document.attachEvent ( 'onmouseup', MouseUpHandler );
	}
	else {
		document.addEventListener ( 'mousemove', MouseMoveHandler, false );
		document.addEventListener ( 'mouseup', MouseUpHandler, false );
	}
    return false;
}

function showPopup ( e, cp, skey )
{

	dj = document.getElementById ( "dj" );
	body = document.getElementsByTagName ( "body" ).item ( 0 );

	FindMouseCoordinates ( e );
	dj.style.visibility = "visible";
	MoveLayerTo ( dj, mX - 38, mY + 10 );

	document.getElementsByName("djf")[0].nm.focus();
	document.getElementsByName("djf")[0].nm.value = '';
	document.getElementsByName("djf")[0].djskey.value = skey;
	document.getElementById ( "djcp" ).innerHTML = cp.substring ( 0, 24 );

	if ( method_type ) {
		document.attachEvent ( 'onmousedown', MouseDownHandler );
		dj.attachEvent ( 'onmousedown', movePopup );
	}
	else {
		document.addEventListener ( 'mousedown', MouseDownHandler, false );
		dj.addEventListener ( 'mousedown', movePopup, false );
	}
	return false;

}
function hidePopup (  )
{   
	dj.style.visibility = "hidden";
	return false;
}

