
function Win(key){
	this.getCookie = GetCookie;
	this.setCookie = SetCookie;
	this.register  = Register;
	this.open	= Open;
	this.key	= key?key:'AAAAA';
	this.set	= Set;
}

function Open(url,w,h,l,t,srl,rsz){
	this.url = url;
	
	if(w)this.width = 'width='+w;
	else this.width = 'width='+100
	
	if(h)this.height = 'height='+h;
	else this.height = 'height='+100;
	
	if(l)this.left = 'left='+l;
	if(top)this.top = 'top='+t;
	
	if(srl=='y')this.option = ',scrollbars='+'yes';
	else this.option = ',scrollbars='+'no';
	if(rsz=='y')this.option += ',resizable='+'yes';
	else this.option += ',resizable='+'no';
	
	if(this.getCookie(this.key)!="y" && !this.instance){
		var args = this.width+','+this.height;
		args += this.left?','+this.left:'';
		args += this.top?','+this.top:'';
		args += this.option?this.option:'';
		
//		alert(args);
//		return;
		this.instance = window.open(this.url,'_PUBLIC_WIN',args);	
	}
}


function Set(day){
	if(this.instance){
		this.register(this.key,'y',day);	
	}	
}

function GetCookie(Name) {
   var search = Name + "=";
   if (document.cookie.length > 0) { // if there are any cookies
      offset = document.cookie.indexOf(search); 
      if (offset != -1) { // if cookie exists 
         offset += search.length; 
         // set index of beginning of value
         end = document.cookie.indexOf(";", offset); 
         // set index of end of cookie value
         if (end == -1) 
            end = document.cookie.length;
         return unescape(document.cookie.substring(offset, end));
      } 
   }
}

function SetCookie(name, value, expire) {
   document.cookie = name + "=" + escape(value)
   + ((expire == null) ? "" : ("; expires=" + expire.toGMTString()));
}

function Register(name,val,lengthTime) {
   var expires = new Date();
   expires.setDate(expires.getDate() + lengthTime);
   this.setCookie(name, val, expires);
}