window.onload = function() {

	layPop.Start(
	'yoseip0010', 'http://www.zzonge.com/new_school/popup/20110207.jpg', '<area shape="rect" coords="0,0,660,454" href="http://www.zzonge.com/school/main.php?t=info&v=ticket"  alt="»õÇØ¸ÂÀÌ ÀÌº¥Æ®.">', '20110226'
);
//cookie Name
//ÀÌ¹ÌÁö
//ÀÌ¹ÌÁö ¸µÅ©ÁÖ¼Ò
//¸¶°¨ÀÏ
}

var winPop = {
	Img : null,
	winTop : "0px",
	winLeft : "0px",
	
	winPop : "",

	Start : function(Code, Adr, enDay, winTop, winLeft) {
		//³¯Â¥°¡ ¸¸·á, ¿À´Ã ÇÏ·ç ¾Èº¸±âÀÏ °æ¿ì ÆË¾÷ ÁßÁö
		if((enDay != null && this.nowYMD() > enDay)
			|| this.getCookie(Code) == "1") { return; }

		this.winTop = winTop;//À©µµ¿ìÃ¢ÀÇ À§Ä¡ ÁöÁ¤ top
		this.winLeft = winLeft;//À©µµ¿ìÃ¢ÀÇ À§Ä¡ ÁöÁ¤ left

		if(this.Img == null) {
			this.Img = new Image();

			this.Img.onload = function() {
				winPop.Open(Code);
			}

			this.Img.src = Adr;
		}
	},

	Open : function(Code) {
		this.winPop01 = open("","winPop01","top="+ this.winTop +", left="+ this.winLeft +", width="+ this.Img.width 
			+", height="+ (this.Img.height + 25) +", menubars=0, scrollbars=0");

		winPopHtml = ''
						+'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'
						+'<html xmlns="http://www.w3.org/1999/xhtml">'
						+'<head>'
						+'<meta http-equiv="Content-Type" content="text/html; charset=euc-kr" />'
						+'<meta http-equiv="Content-Script-Type" content="text/javascript" />'
						+'<meta http-equiv="Content-Style-Type" content="text/css" />'
						+'<meta http-equiv="X-UA-Compatible" content= "IE=edge" />'
						+'</head>'
						+'<body topmargin="0" leftmargin="0">'
						+'<div>'
						+'	<img src="'+ this.Img.src +'" border="0" galleryimg="false"><br>'
						+'		<div style="width:100%;  text-align:left; font-size:12px; background-color:#000000;">'
						+'			<span><input type="checkbox" onclick="opener.winPop.Close(\''+ Code +'\');" align="absmiddle">'
						+'			<font color="white">¿À´Ã ÇÏ·ç ¾Èº¸±â</font><i></i></span>'
						+'			<span onclick="window.close();" style="padding-left:10px; cursor:pointer;"><font color="white">[´Ý±â]</font></span>'
						+'		</div>';
						+'</div>'
						+'</body>'
						+'</html>'
		
		this.winPop01.document.write(winPopHtml);
	},

	Close : function(Str) {
		this.setCookie( Str, "1" , 1); //ÄíÅ°¿¡ ÀúÀå
		this.winPop01.close();
	},

	getCookie : function(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 ""; 
	},

	setCookie : function(name, value, expiredays) { 
		var todayDate = new Date(); 
		todayDate.setDate(todayDate.getDate() + expiredays); 
		document.cookie = name + "=" + escape(value) + "; path=/; expires=" + todayDate.toGMTString() + ";" 
	},

	nowYMD : function() {
		now = new Date();
		nowYear = now.getYear();
		nowMonth = now.getMonth()+1;
		nowMonth = (nowMonth < 10)? "0"+nowMonth : ""+nowMonth ;
		nowDay = now.getDate();
		nowDay = (nowDay < 10)? "0"+nowDay : ""+nowDay;

		nowY4MD = nowYear + nowMonth + nowDay;

		return nowY4MD;
	}
};



var layPop = {
	Img : null,
	Div : document.createElement('<div id="Popup01" onMouseOver="dragObj=Popup01; drag=1; move= 0" onMouseOut="drag= 0" style="position:absolute; border:3px solid #333333;'
			+' border-right:3px solid #333333; border-bottom:3px solid #333333;" title="µå·¡±× ÇÏ¸é ¿òÁ÷ÀÔ´Ï´Ù.">'),

	Start : function(Code, Adr, Map, enDay) {
		//³¯Â¥°¡ ¸¸·á, ¿À´Ã ÇÏ·ç ¾Èº¸±âÀÏ °æ¿ì ÆË¾÷ ÁßÁö
		if((enDay != null && this.nowYMD() > enDay)
			|| this.getCookie(Code) == "1") { return; }

		if(this.Img == null) {
			this.Img = new Image();

			this.Img.onload = function() {
				layPop.Edit(Code, Map);
			}

			this.Img.src = Adr;
		}
	},

	Edit : function(Code, Map) {
		document.body.appendChild(this.Div);

		this.Div.innerHTML = ''
			+'<img src="'+ this.Img.src +'" border="1" usemap="#laymap01"><br>'
			+'<div style="width:100%; text-align:right; font-size:12px; background-color:#ffffff;">'
			+'<span><input type="checkbox" onclick="layPop.Close(\''+ Code +'\');">'
			+'¿À´Ã ÇÏ·ç ¾Èº¸±â<i></i></span>'
			+'<span onclick="layPop.Close();" style="padding-left:10px; cursor:pointer;">[´Ý±â]</span>'
			+'</div><map name="laymap01">'
			+ Map +'</map>';

		IMG = this.Div.getElementsByTagName('img')[0];
		this.Div.style.width = IMG.width;

		layTop = (document.body.clientHeight - IMG.height) / 2;
		layLeft = (document.body.clientWidth - IMG.width) / 2;

		this.Div.style.top = layTop < 0 ? 0 : layTop ;
		this.Div.style.left = layLeft < 0 ? 0 : layLeft ;
	},

	Close : function(Str) {
		this.setCookie( Str, "1" , 1); //ÄíÅ°¿¡ ÀúÀå
		document.body.removeChild(this.Div);
	},

	getCookie : function(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 ""; 
	},

	setCookie : function(name, value, expiredays) { 
		var todayDate = new Date(); 
		todayDate.setDate(todayDate.getDate() + expiredays); 
		document.cookie = name + "=" + escape(value) + "; path=/; expires=" + todayDate.toGMTString() + ";" 
	},

	nowYMD : function() {
		now = new Date();
		nowYear = now.getYear();
		nowMonth = now.getMonth()+1;
		nowMonth = (nowMonth < 10)? "0"+nowMonth : ""+nowMonth ;
		nowDay = now.getDate();
		nowDay = (nowDay < 10)? "0"+nowDay : ""+nowDay;

		nowY4MD = nowYear + nowMonth + nowDay;

		return nowY4MD;
	}
};


var x=y=drag=move=0; 
window.document.onmousemove = mouseMove;
window.document.onmousedown = mouseDown; 
window.document.onmouseup = mouseUp; 
window.document.ondragstart = mouseStop; 

function mouseUp() { 
	move = 0;
} 

function mouseDown() {
	if (drag) { 
		clickleft = window.event.x - parseInt(dragObj.style.left); 
		clicktop = window.event.y - parseInt(dragObj.style.top); 
		dragObj.style.zIndex += 1; 
		move = 1;
	} 
} 

function mouseMove() { 
	if (move) { 
		dragObj.style.left = window.event.x - clickleft; 
		dragObj.style.top = window.event.y - clicktop; 
	} 
} 
function mouseStop() { 
	window.event.returnValue = false; 
}
 
