  function getCookie(name) {
		var first;
		var str = name + "=";
		if (document.cookie.length > 0) {
			find = document.cookie.indexOf(str);
			if (find == -1) return null;
			first = find + str.length;
			end = document.cookie.indexOf(";", first);
			if (end == -1) end = document.cookie.length;
			return unescape(document.cookie.substring(first, end));
		}
	}

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

	function closeWin(not_open_name) 
	{ 
		if (document.forms[0].not_open.checked) 
			setCookie( not_open_name, "done" , 1); 

		self.close(); 
	}

	function setCookie_time( name, value, expiretimes)
    {
		var todayDate = new Date();
		todayDate.setTime( todayDate.getTime() + 1000*60*60*expiretimes );
		document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + todayDate.toGMTString() + "; domain=kbs.co.kr"
	}

	function closeWin_time(not_open_name, times) 
	{ 
		if (document.forms[0].not_open.checked) 
			setCookie_time( not_open_name, "done" , times); 

		self.close(); 
	}

	PopupMenu = function(param){
		this.url = new Array();
		this.width = new Array();
		this.height = new Array();
		this.title = new Array();
		this.left = new Array();
		this.top = new Array();
		this.scrollbar = new Array();
		this.resizable = new Array();
		this.toolbar = new Array();
		this.menubar = new Array();
		this.statusbar = new Array();
		this.not_open = new Array();

		this.num = 0; 
		this.url[this.num] = param.url;							
		this.width[this.num] = param.width;					
		this.height[this.num] = param.height;				
		this.title[this.num] = param.title;						
		this.left[this.num] = param.left;							
		this.top[this.num] = param.top;						
		this.scrollbar[this.num] = param.scrollbar;		
		this.resizable[this.num] = param.resizable;	
		this.toolbar[this.num] = param.toolbar				
		this.menubar[this.num] = param.menulbar		
		this.statusbar[this.num] = param.statusbar		
		this.not_open[this.num] = param.not_open		
	}

	PopupMenu.prototype.setValue = function(param){
		this.num++;
		this.url[this.num] = param.url;							
		this.width[this.num] = param.width;					
		this.height[this.num] = param.height;				
		this.title[this.num] = param.title;						
		this.left[this.num] = param.left;							
		this.top[this.num] = param.top;						
		this.scrollbar[this.num] = param.scrollbar;		
		this.resizable[this.num] = param.resizable;	
		this.toolbar[this.num] = param.toolbar				
		this.menubar[this.num] = param.menulbar		
		this.statusbar[this.num] = param.statusbar		
		this.not_open[this.num] = param.not_open		
	}

	PopupMenu.prototype.Open = function(){
		if(getCookie(this.not_open[this.num]) == null){
			if(this.url[this.num] != '' && this.width[this.num] != '' && this.height[this.num] != '' && this.title[this.num] != ''){	
				var option = "width="+this.width[this.num]+", height="+this.height[this.num];

				if(this.left[this.num]) option += ",left="+this.left[this.num];
				if(this.top[this.num]) option += ",top="+this.top[this.num];
				if(this.scrollbar[this.num]) option += ",scrollbars="+this.scrollbar[this.num];
				if(this.resizable[this.num]) option += ",resizable="+this.resizable[this.num];
				if(this.toolbar[this.num]) option += ",toolbar="+this.toolbar[this.num];
				if(this.menubar[this.num]) option += ",menubar="+this.menubar[this.num];
				if(this.statusbar[this.num]) option += ",statusbar="+this.statusbar[this.num];
				
				if(this.not_open[this.num])
				{
					if(getCookie(this.not_open[this.num]) == null){
						window.open(this.url[this.num], this.title[this.num], option);
					}
				}else{
					window.open(this.url[this.num], this.title[this.num], option);
				}
			}
		}
	}

	PopupMenu.prototype.Random = function(){
		var popnum = this.num + 1;	
		var rndindex = Math.floor(popnum*Math.random()) % popnum;

		var j = rndindex;
		var k = j;
		var i = 1;
		var flag = false;
		var found = false;

		do{
			if(getCookie(this.not_open[j]) == null){
				flag = true;
				found = true;
			}

			if(flag == false){			
				j = (i+j)%popnum;
			}
		}while ((k != j) && (!found));

		if(flag == true)
		{
			this.num = j;
			this.Open();
		}
	}

