imageDir = "http://www.blueb.co.kr/SRC/javascript/image5/";

function getPoPCookie(name)
{
	var Found = false;
	var start , end;
	var i = 0;
	var megawin;

	while ( i <= document.cookie.length )
		{
		 start = i;
		 end = start + name.length;
		 if ( document.cookie.substring(start,end) == name )
		 {
				Found = true;
				break;
		 }
	 i++;
	}
	if ( Found == false )
	{
			
	}
	return false;
}

window.attachEvent('onload', function(){});
				
function createPopupWindow(title, width, popupColor, windowID, minimizeIcon, x, y)
{
	if (document.getElementById('popupWindow' + windowID)) {
	
	}else {
		new JSWindow("&nbsp;" + title, document.getElementById("popupDiv" + windowID), x, y, windowID, width, popupColor, minimizeIcon); 		
	}
}


function JSWindow(title, oContent, x, y, id, width, cookieName, minimizeIcon)
{
    
	// define variables
	this.title = title;
	this.oContent = oContent;
	this.width = width;
	this.x = x+100;
	this.y = y;
	this.id = id;
	this.cookieName = cookieName;    	
    
    //ÄíÅ° Ã¼Å© ÈÄ ÆË¾÷À» »ý¼ºÇÑ´Ù.
    if(!this.checkCookie(this.cookieName)){
     
	    //create div window
	    this.oDiv = document.createElement('DIV');
	    this.oDiv.id = "popupWindow" + this.id;
	    this.oDiv.style.width = (parseInt(this.width) + 10) + 'px';
	    this.oDiv.className = 'p_001';
	    this.oDiv.style.position = "absolute";
		this.oDiv.style.left = this.x + "px";
		this.oDiv.style.top = this.y + "px";
	    
	    // link from the div to the JSWindow object
	    this.oDiv.jsWindow = this;
	    
	    // if the div is clicked anywhere, show the div in front of other open windows
	    //ÇÑ¹ø ¼±ÅÃÇØ¾ß ÇÏ´Â ºÎºÐ Á¦°Å 2007.03.07 yhchoi
		//this.oDiv.onmousedown = JSWindow.prototype.onBringToFront;
	    
	    // append to document body
	    document.body.appendChild(this.oDiv);	    	    
	    
		this.makeContentArea();
		
     }

}

JSWindow.prototype.makeContentArea = function(){
	//create content table
    this.oTable = document.createElement("table");
    this.oTable.width = '100%';
	this.oTable.cellSpacing = 0;
	this.oTable.cellPadding = 0;
	this.oTable.border = 0;
	this.oTable.jsWindow = this;
	
	// append to popup div 
	this.oDiv.appendChild(this.oTable);
	
	// add a row for the titlebar
	var oTR_title = this.oTable.insertRow(0);
	
	var oTd1_title = oTR_title.insertCell(0);
	oTd1_title.height = '29px';
	oTd1_title.colSpan = '2';
	oTd1_title.className = 'f_12DB f_let white';
	oTd1_title.style.padding = '0px 0px 0px 10px';
	oTd1_title.innerHTML = '<font color=white><b>ÇÑ±¹°ø°£È¯°æÇÐÈ¸</b></font>';
	oTd1_title.jsWindow = this;
	oTd1_title.onmousedown = JSWindow.prototype.tdOnMouseDown;
	
	var oTd2_title = oTR_title.insertCell(1);
	oTd2_title.width = '21%';
	oTd2_title.align = 'right';
	oTd2_title.style.paddingRight = '5px';
	//oTd2_title.innerHTML = "<a href='#' onclick='this.jsWindow.minimize();'><img src='http://image.neonet.co.kr/service/newbank/images/common/popup_c1.gif' hspace='2' align='absmiddle'></a><a href='#' onclick='alert(3333);'><img src='http://image.neonet.co.kr/service/newbank/images/common/popup_c2.gif' align='absmiddle'></a>";
	
	// create and append minimize button 
//	var imgMinimize = document.createElement('IMG');
//	imgMinimize.src = 'http://image.neonet.co.kr/service/newbank/images/common/popup_c1.gif';
//	imgMinimize.hspace = '2';
//	imgMinimize.align = 'absmiddle';
//	imgMinimize.jsWindow = this;
//	imgMinimize.onmousedown = JSWindow.prototype.onMinimize;
//	oTd2_title.appendChild(imgMinimize);
	
	// create and append close button
	var imgClose = document.createElement('IMG');
	imgClose.src = 'http://www.kaser.or.kr/images/popup_c2.gif';
	imgClose.align = 'absmiddle';
	imgClose.onmousedown = JSWindow.prototype.onClose;
	imgClose.jsWindow = this;
	oTd2_title.appendChild(imgClose);
	
	// add a row for the content
	var oTR_content = this.oTable.insertRow(1);
	
	var oTd_content = oTR_content.insertCell(0);
	oTd_content.colSpan = '3';
	oTd_content.align = 'center';
	//oTd_content.innerHTML = document.all["popupDiv" + this.id].innerHTML;
	
	document.all["popupDiv" + this.id].style.display = 'inline-block';
	oTd_content.appendChild(document.all["popupDiv" + this.id]);
	
		
	//add a row for close in bottom
	var oTR_bottom = this.oTable.insertRow(2);
	
	// add a cell for close in bottom tr
	var oTd1_bottom = oTR_bottom.insertCell(0);
	oTd1_bottom.width = '3%';
	oTd1_bottom.height = '28';
	oTd1_bottom.style.paddingLeft = '3px';
	//oTd1_bottom.innerHTML = "<input type='checkbox' name='event' value='checkbox' onClick='closeWin();'>";
	
	var chkClose = document.createElement("<input type='checkbox' id='chk'" + this.id + "' name='event' value='checkbox'>");
	chkClose.jsWindow = this;
	chkClose.onclick = JSWindow.prototype.onCloseWithCookie;
	oTd1_bottom.appendChild(chkClose);		
	
	var oTd2_bottom = oTR_bottom.insertCell(1);
	//oTd2_bottom.width = '64%';
	oTd2_bottom.align = 'left';
	oTd2_bottom.innerHTML = '30ÀÏ°£ ÀÌÃ¢À» ¿­Áö ¾Ê½À´Ï´Ù.';
	
	var oTd3_bottom = oTR_bottom.insertCell(2);
	oTd3_bottom.align = 'right';
	oTd3_bottom.style.paddingRight = '5px';
	//oTd3_bottom.innerHTML = "<a href='#'><img src='http://image.neonet.co.kr/service/newbank/images/common/popup_close.gif' width='51' height='13'></a>";
	
	var btnClose = document.createElement('IMG');
	btnClose.src = 'http://www.kaser.or.kr/images/popup_close.gif';
	btnClose.width = '51';
	btnClose.height = '13';
	btnClose.jsWindow = this;
	//btnClose.onmousedown = JSWindow.prototype.onCloseWithCookie
	btnClose.onmousedown = JSWindow.prototype.onClose;
	oTd3_bottom.appendChild(btnClose);	
}

JSWindow.prototype.onBringToFront = function()
{
	this.jsWindow.bringToFront();
}

JSWindow.prototype.bringToFront = function()
{
	// if not already the last child of the document.body, make it so
	if ( document.body.childNodes[document.body.childNodes.length-1] != this.oDiv )
	{
		// move to bottom of document
		document.body.appendChild(this.oDiv);
	}
}

JSWindow.prototype.tdOnMouseDown = function()
{
	this.jsWindow.onMouseDown();
}

JSWindow.prototype.onMouseDown = function()
{
	// record that an onmousedown has just occurred
	this.bDown = true;
	    
	// link from body to this JSWindow object
	document.body.jsWindow = this;
	
	// save body mouse handlers
	this.saveMouseMove = document.body.onmousemove;
	this.saveMouseUp = document.body.onmouseup;
	
	// set new handlers.
//	document.body.onmousemove = JSWindow.prototype.bodyOnMouseMove;
	document.body.onmouseup = JSWindow.prototype.bodyOnMouseUp;
}

JSWindow.prototype.bodyOnMouseMove = function(evt)
{
	var e = window.event ? window.event : evt;
	this.jsWindow.onMouseMove(e);
}

JSWindow.prototype.onMouseMove = function(evt)
{
	// if mouse not down, stop the move (for IE only)
	if ( (document.all) && !(evt.button & 1) )
	{
		this.onMouseUp();
		return;
	}
	if ( this.bDown )
	{
		this.dx = parseInt(this.oDiv.style.left, 10) - evt.clientX;
		this.dy = parseInt(this.oDiv.style.top, 10) - evt.clientY;
		this.bDown = false;
	}else{
		this.oDiv.style.left = Math.max((this.dx + evt.clientX),0) + "px";
		this.oDiv.style.top = Math.max((this.dy + evt.clientY),0) + "px";		
	}
}

JSWindow.prototype.bodyOnMouseUp = function()
{
	this.jsWindow.onMouseUp();
}

JSWindow.prototype.onMouseUp = function()
{
	document.body.onmouseup = this.saveMouseUp;
	document.body.onmousemove = this.saveMouseMove;
	document.body.jsWindow = null;
}


JSWindow.prototype.onMinimize = function()
{
	this.jsWindow.minimize();
}

JSWindow.prototype.minimize = function()
{
	// hide the content
	this.oContent.style.visibility = "hidden";
	this.oContent.style.position = "absolute";
	document.body.appendChild(this.oContent);
	
	this.oDiv.removeChild(this.oDiv.children(0));
	    
	// save current position
	this.saveX = this.oDiv.style.left;
	this.saveY = this.oDiv.style.top;
	    
	// get the "window bar"
	if ( !window.jsWindowBar )
	{
		window.jsWindowBar = document.createElement("span");
		document.body.appendChild(window.jsWindowBar);
	}
	    
	window.jsWindowBar.appendChild(this.oDiv);
	this.oDiv.style.position = "static";
	this.oDiv.style.left = "0px";
	this.oDiv.style.top = "0px";
	    
	this.oDiv.innerHTML = "<img src='" + imageDir + "maximize.jpg'>";
	this.oDiv.align = 'right';
	this.oDiv.className = 'p_001';
	this.oDiv.onmousedown = JSWindow.prototype.onMaximize;
	this.oDiv.style.width = "220px";
	this.oDiv.style.height = "20px";
	this.oDiv.style.borderBottom = "0px";
}

JSWindow.prototype.onMaximize = function()
{
	this.jsWindow.maximize();
}

JSWindow.prototype.maximize = function()
{
	document.body.appendChild(this.oDiv);
	this.oDiv.style.position = "absolute";
	this.oDiv.innerHTML = '';    
	this.oDiv.style.left = this.saveX;
	this.oDiv.style.top = this.saveY;
	this.oDiv.style.width = this.width + "px"
	this.oDiv.style.borderBottom = "1px solid #000000";
		
	//make the content	
	this.makeContentArea();
}

JSWindow.prototype.onMaximize = function()
{
	this.jsWindow.maximize();
}

JSWindow.prototype.close = function()
{    
	// remove from browser document
	this.oDiv.parentNode.removeChild(this.oDiv);
}

JSWindow.prototype.onClose = function()
{
	this.jsWindow.close();
}

JSWindow.prototype.onCloseWithCookie = function()
{	
	this.jsWindow.closeWithCookie();		
}

//ÇÏ·çµ¿¾È ÆË¾÷Ã¢À» º¸ÀÌÁö ¾Ê°Ô ÇÏ±âÀ§ÇØ ¼³Á¤ÇÔ - by byung gu
function setCookie( name, value, expireHours ) 
{ 	
	expireHours = 24 * 30 ;
	var todayDate = new Date();
	todayDate.setTime (todayDate.getTime() +  parseInt(expireHours,10) * 60 * 60 * 1000) ;
	document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + todayDate.toGMTString() + ";"
}

JSWindow.prototype.closeWithCookie = function()
{		
	setCookie(this.cookieName, 'NO' , '1' );
	this.close();
}

JSWindow.prototype.checkCookie = function(cookieName){
	var i = 0 ;
	var start, end;
	
	while ( i <= document.cookie.length )
	{
		start = i;
		end = start + cookieName.length;
		if ( document.cookie.substring(start,end) == cookieName )
		{
			return true;
		}
		i++;
	}
	
	return false;
}

function hideDiv(divNumber) {
	//for (var count = 0; count < divNumber; count++) {
	//	document.getElementById('popupDiv' + count).style.display = 'none';
	//}
	document.getElementById(divNumber).style.display = 'none';
}



