function Winpop(popId,width,height,url,title,titleColor,titleBgColor,borderWidth,borderColor,shadowColor,innerColor,innerBgColor,padding,xPos,yPos) {

	// parametros de configuracao
	var id,url,xPos,yPos,width,height,title,titleColor,titleBgColor,innerContentFont;
	var innerColor,innerBgColor,innerPad,borderHeight,borderColor,borderWidth,shadowSize;
	var shadowColor,canClose,moveByContent,isVisible,isTitle,isShadow,isCentered,isFrame;
	var isScrollBars,isUpdateScroll,isResizeable,isMovable,isDropIn,isBounce;
	var isSlideIn,isFadeIn,isFadeOut,minWidth,minHeight,maxInnerPad,maxBorderWidth;
	// variaveis internas
	var popShowFor,popDelayFor,moving,resizing,fadeInAmount,fadeOutAmount;
	var bounceAmount,popTimer,fxTimer,dropDownTimer,bounceTimer,slideInTimer,fadeInTimer;
	var fadeOutTimer,updatescrolltimer,cookietimer,maintimer,MoveXDiff,MoveYDiff;
	var resizeXDiff,resizeYDiff,MouseX,mouseY,shimElement,shadowElement,borderElement;
	var titleElement,contentElement,resizeElement,closeElement,widthCopy,heightCopy;

	// inicializa variaveis
	this.setup=function(popId,width,height,url,title,titleColor,titleBgColor,borderWidth,borderColor,shadowColor,innerColor,innerBgColor,padding,xPos,yPos) {
		if(!document.getElementById) {
			if(language=='portuguese') {
				alert('Desculpe. Seu navegador não é compatível com os padrões W3C. A janela não pode ser aberta. Por favor atualize seu navegador.');
			} else if(language=='spanish') {
				alert('Desculpe. Su navegador no es compatible con los padrones W3C. La ventana no puede ser abierta. Por favor actualize su navegador.');
			} else {
				alert('Sorry. Your browser is not compatible with W3C standards. The window cannot be opened. Please update your browser.');
			}
			return;
		}
		// parametros de inicializacao
		this.id=popId; // id da janela
		this.url=url; // url a carregar
		this.xPos=(typeof(xPos)=='undefined' || !xPos)?0:xPos; // distancia da margem esquerda
		this.yPos=(typeof(yPos)=='undefined' || !yPos)?0:yPos; // distancia da margem superior
		this.width=(typeof(width)=='undefined' || !width)?'auto':width; // largura da janela
		this.height=(typeof(height)=='undefined' || !height)?'auto':height; // altura da janela
		this.widthCopy=this.width;
		this.heightCopy=this.height;
		this.title=(typeof(title)=='undefined' || !title)?sitetitle:title; // titulo da janela
		this.titleColor=(typeof(titleColor)=='undefined' || !titleColor)?'#000000':titleColor; // cor do titulo
		this.titleBgColor=(typeof(titleBgColor)=='undefined' || !titleBgColor)?'#cccccc':titleBgColor; // cor do fundo do titulo
		this.borderWidth=(typeof(borderWidth)=='undefined' || borderWidth=='')?1:borderWidth; // largura da borda
		this.borderHeight=0; // altura do relevo da borda
		this.borderColor=(typeof(borderColor)=='undefined' || !borderColor)?'#666666':borderColor; // cor da borda
		this.shadowSize=7; // largura da sombra
		this.shadowColor=(typeof(shadowColor)=='undefined' || !shadowColor)?'#808080':shadowColor; // cor da sombra
		this.innerColor=(typeof(innerColor)=='undefined' || !innerColor)?'#000000':innerColor; // cor do texto da janela
		this.innerBgColor=(typeof(innerBgColor)=='undefined' || !innerBgColor)?'#ffffff':innerBgColor; // cor de fundo da janela
		this.innerContentFont='11pt Verdana'; // fonte da janela
		this.innerPad=(typeof(padding)=='undefined' || padding=='')?5:padding; // padding interno da janela
		this.canClose=1; // a janela pode ser fechada
		this.moveByContent=0; // permite mover janela pelo conteudo
		this.isVisible=1; // 0=invisivel, 1=visivel
		this.isResizeable=1; // 0=janela de tamanho fixo, 1=ajustavel
		this.isMovable=1; // 0=janela fixa, 1=janela movel
		this.isTitle=1; // 0=janela sem titulo, 1=com titulo
		this.isShadow=1; // 1=janela com sombra
		this.isCentered=1; // 1=janela centralizada
		this.isScrollBars=1; // 1=janela com barras de rolagem
		this.isFrame=0; // usa frame ou nao
		this.isUpdateScroll=0; // 1=janela move-se com a pagina
		this.isFadeIn=0; // 1=entrada esmaecida
		this.isFadeOut=0; // 1=saida esmaecida
		this.isDropIn=0; // 1=entrada em queda
		this.isBounce=0; // ricochete na entrada em queda
		this.isSlideIn=0; // 1=entrada deslizante
		// limites maximos
		this.minWidth=25; // largura minima da janela
		this.minHeight=25; // altura minima da janela
		this.maxInnerPad=20; // padding maximo
		this.maxBorderWidth=15; // largura maxima de borda
		this.maxborderHeight=5; // altura maxima do relevo da borda
		// inicializacao das variaveis internas
		this.popShowFor=0; this.popDelayFor=0; this.moving=0; this.resizing=0;
		this.fadeInAmount=0; this.fadeOutAmount=100; this.bounceAmount=0;
		this.popTimer=0; this.fxTimer=0; this.dropDownTimer=0; this.bounceTimer=0;
		this.slideInTimer=0; this.fadeInTimer=0; this.fadeOutTimer=0;
		this.updatescrolltimer; this.cookietimer=0; this.maintimer=0; this.MoveXDiff=0;
		this.MoveYDiff=0; this.resizeXDiff=0; this.resizeYDiff=0; this.MouseX=0;
		this.mouseY=0; this.shimElement=null; this.shadowElement=null;
		this.borderElement=null; this.titleElement=null; this.contentElement=null;
		this.resizeElement=null; this.closeElement=null;
	}

	// cria conexao e obtem dados
	this.create=function() {
		var that=this;
		if(this.maintimer) clearTimeout(this.maintimer);
		if(isIE && !document.loaded) {
      this.maintimer=setTimeout(function(){that.create();},500);
		} else {
			if(this.xPos>0 && this.yPos>0) this.isCentered=0;
			if(this.isFrame) {
				if(this.url.indexOf(session_name)<0) {
					if(this.url.indexOf('?')<0) {
						this.url+='?'+session_name+'='+session_id;
					} else {
						this.url+='&'+session_name+'='+session_id;
					}
				}
				this.url+='&session_name='+session_name;
				var html='<iframe id="'+this.id+'" name="'+this.id+'" ';
				html+='src="'+this.url+'" width="100%" height="100%" ';
				html+='frameborder="no" marginheight="0" marginwidth="0" scrolling="';
				if(this.isScrollBars) {
					html+='auto';
					this.isScrollBars=0;
				} else html+='no';
				html+='" style="z-index:'+(zIndex()+2)+'"></iframe>';
				this.build(html);
			} else {
				if(/auto/i.test(this.widthCopy) || /auto/i.test(this.heightCopy)) {
					get_data(function(remotedata){that.autosize(remotedata);},this.url);
				} else {
					this.build('<div id="'+this.id+'" width="100%" height="100%"></div>');
					get_remote(this.id,this.url,false,false);
				}
			}
			var that=this;
      register_event('onmouseup',function(){that.moving=0;that.resizing=0;});
      register_event('onmousemove',function(evt){that.mouseMove(evt);});
		}
	}

	// tamanho automatico para a janela
	this.autosize=function(remotedata) {
		var contentDiv=document.createElement('DIV');
		//contentDiv.setAttribute('id','contentDiv');
		contentDiv.style.padding='0px';
		contentDiv.style.marging='0px';
		contentDiv.style.overflow='scroll';
		contentDiv.style.display='block';
		contentDiv.style.position='absolute';
		contentDiv.style.left='0px';
		contentDiv.style.top='0px';
		contentDiv.style.visibility='hidden';
		if(!/auto/i.test(this.widthCopy)) {
			contentDiv.style.width=this.widthCopy-(2*this.innerPad+2*this.borderWidth+2*this.borderHeight);
		} else {
			contentDiv.style.width='auto';
		}
		if(!/auto/i.test(this.heightCopy)) {
			contentDiv.style.height=this.heightCopy-(2*this.innerPad+2*this.borderWidth+2*this.borderHeight);
		} else {
			contentDiv.style.height='auto';
		}
		contentDiv.innerHTML=remotedata;
		document.body.appendChild(contentDiv);
		var innerSize=getInnerSize();
		if(/auto/i.test(this.widthCopy)) {
			this.width=contentDiv.offsetWidth+(2*this.innerPad+2*this.borderWidth+2*this.borderHeight);
			if(this.width>innerSize.width) {
				this.width=innerSize.width;
				this.xPos=0;
			}
		}
		if(/auto/i.test(this.heightCopy)) {
			this.height=contentDiv.offsetHeight+(2*this.innerPad+2*this.borderWidth+2*this.borderHeight);
			if(this.isTitle) this.height+=20;
			if(this.height>innerSize.height) {
				this.height=innerSize.height;
				this.yPos=0;
			}
		}
		contentDiv.parentNode.removeChild(contentDiv);
		//this.isScrollBars=0;
		this.build('<div id="'+this.id+'" width="100%" height="100%">'+remotedata+'</div>');
	}

	// constroi a janela
	this.build=function(htmlcontent) {
		// verifica limites
		var innerSize=getInnerSize();
		var maxW=innerSize.width-((2*this.borderWidth)+(2*this.borderHeight)+this.shadowSize+(isIE?28:27));
		var maxH=innerSize.height-((2*this.borderWidth)+(2*this.borderHeight)+this.shadowSize+(isIE?11:7));
		this.width=Math.max(this.width,this.minWidth);
		this.width=Math.min(this.width,maxW);
		this.height=Math.max(this.height,this.minHeight);
		this.height=Math.min(this.height,maxH);
		this.borderWidth=Math.min(this.borderWidth,this.maxBorderWidth);
		this.innerPad=Math.min(this.innerPad,this.maxInnerPad);
		this.borderHeight=Math.min(this.borderHeight,this.maxborderHeight);
    if(this.isCentered) this.centered(innerSize.width,innerSize.height);
		// remove janela anterior
		if(el(this.id+'_border')) {
			removeElement(this.id+'_shadow');
			removeElement(this.id+'_shim');
			removeElement(this.id+'_border');
		}
		// monta janela
		this.shadowElement=this.newElement('shadow',this.xPos+this.shadowSize,this.yPos+this.shadowSize,this.width+2*this.borderWidth+2*this.borderHeight,this.height+2*this.borderWidth+2*this.borderHeight,this.shadowColor);
		if(isIE) this.shadowElement.style.filter='alpha(opacity=30)';
		else this.shadowElement.style.opacity='0.3';
		this.shadowElement.style.zIndex=zIndex();
		this.shimElement=this.newElement('shim',this.xPos,this.yPos,this.width+2*this.borderWidth+((isIE)?2*this.borderHeight:0),this.height+2*this.borderWidth+((isIE)?2*this.borderHeight:0),this.borderColor);
		this.shimElement.style.zIndex=zIndex();
    this.shimElement.style.overflow='hidden';
		if(isIE) {
			this.shimElement.innerHTML='<iframe width="100%" height="100%" scrolling="no" frameborder="no" marginheight="0" marginwidth="0"></iframe>';
		}
		this.borderElement=this.newElement('border',this.xPos,this.yPos,this.width+2*this.borderWidth+((isIE)?2*this.borderHeight:0),this.height+2*this.borderWidth+((isIE)?2*this.borderHeight:0),this.borderColor);
		this.borderElement.style.borderStyle='outset';
		this.borderElement.style.borderWidth=this.borderHeight;
		this.borderElement.style.borderColor=this.borderColor;
		this.borderElement.style.overflow='hidden';
		var border_index=zIndex()+1;
		this.borderElement.style.zIndex=border_index;
		var that=this;
		if(isNS && this.isScrollBars) {
			this.borderElement.onmouseover=function() {
				that.contentElement.style.overflow='auto';
			}
			this.borderElement.onmouseout=function() {
				that.contentElement.style.overflow='hidden';
			}
		}
    this.titleElement=this.newElement('title',this.borderWidth,this.borderWidth,this.width,20,this.titleBgColor);
		this.titleElement.style.overflow='hidden';
		this.titleElement.style.borderStyle='solid';
		this.titleElement.style.borderWidth='0px';
		this.titleElement.style.borderColor='';
		this.titleElement.style.padding='0px';
		this.titleElement.style.margin='0px';
		this.titleElement.style.zIndex=(border_index-1);
		this.titleElement.innerHTML='<span style="position:absolute; left:5px; top:2px; font:bold 9pt arial; color:'+this.titleColor+'; height:15px; overflow:hidden;">'+this.title+'</span>';
		if(this.isTitle) {
			this.contentElement = this.newElement('innercontent',this.borderWidth,this.borderWidth+20,this.width-(!isIE7?2*this.innerPad:0),this.height-20-(!isIE7?2*this.innerPad:0),this.innerBgColor);
		} else {
			this.contentElement = this.newElement('innercontent',this.borderWidth,this.borderWidth,this.width-((!isIE7)?2*this.innerPad:0),this.height-(!isIE7?2*this.innerPad:0),this.innerBgColor);
		}
		this.contentElement.style.borderColor='';
		this.contentElement.style.borderStyle='inset';
		this.contentElement.style.borderWidth='0px';
		if(this.isScrollBars) {
			this.contentElement.style.overflow='auto';
		} else {
			this.contentElement.style.overflow='hidden';
		}
		this.contentElement.style.padding=(this.innerPad+'px');
		this.contentElement.style.font=this.innerContentFont;
		this.contentElement.style.color=this.innerColor;
		this.contentElement.innerHTML=htmlcontent;
		this.resizeElement=this.newElement('resize',this.width+2*this.borderWidth-13,this.height+2*this.borderWidth-13,12,12,'');
		this.closeElement=this.newElement('close',this.width+this.borderWidth-21,this.borderWidth+2,18,16,'');
		// envia para o documento
		this.borderElement.appendChild(this.closeElement);
		this.borderElement.appendChild(this.resizeElement);
		this.borderElement.appendChild(this.titleElement);
		this.borderElement.appendChild(this.contentElement);
		document.body.appendChild(this.borderElement);
		document.body.appendChild(this.shimElement);
		document.body.appendChild(this.shadowElement);
		if(this.isResizeable) {
			this.resizeElement.style.background='url('+libpath+'resize.gif) no-repeat';
			this.resizeElement.style.cursor='move';
			this.resizeElement.style.zIndex=zIndex();
			this.resizeElement.onmousedown=function(){that.resizeInit();}
		}
		if(this.canClose) {
			this.closeElement.style.background='url('+libpath+'close.gif) no-repeat';
			this.closeElement.style.cursor='pointer';
			this.closeElement.style.zIndex=zIndex();
			this.closeElement.onclick=function(){that.close();}
		}
		if(!this.isShadow) this.shadowElement.style.visibility='hidden';
		if(!this.isTitle) this.titleElement.style.visibility='hidden';
		if(this.isMovable) {
			this.titleElement.style.cursor='move';
			this.titleElement.onmousedown=function(){that.moveInit();}
			if(this.moveByContent) {
				this.contentElement.onmousedown=function(){that.moveInit();}
			} else {
				this.contentElement.onmousedown=function(){that.toFront();}
			}
		} else {
			this.contentElement.onmousedown=function(){that.toFront();}
		}
		if(!this.isVisible || this.popDelayFor!=0) this.visibility('hidden');
		if((this.popShowFor!=0 || this.popDelayFor!=0) && this.isVisible) {
			this.showTimeMethod(this.isFadeOut,this.isFadeIn,this.isDropIn,this.isSlideIn,this.popShowFor,this.popDelayFor);
		}
		if(this.isDropIn && this.popDelayFor==0) this.moveToOutsideTop();
		if(this.isSlideIn && this.popDelayFor==0) this.moveToOutsideLeft();
		if(this.isFadeIn && this.popDelayFor==0 && this.isVisible) this.fadeInInit();
		if(this.isFadeOut && this.popShowFor==0 && this.popDelayFor==0 && this.isVisible) {
			this.fadeOutInit();
		}
		if(this.isUpdateScroll) {
			var that=this;
			this.updatescrolltimer=setInterval(function(){that.updateScroll();},100);
		}
	}

	this.IEbody=function() {
		return (document.compatMode && document.compatMode!='BackCompat')?document.documentElement:document.body;
	}

	// cria layers da janela
	this.newElement=function(id,xPos,yPos,width,height,bgColor) {
		var newdiv=document.createElement('div');
		newdiv.setAttribute('id',this.id+'_'+id);
		newdiv.style.backgroundColor=bgColor;
		newdiv.style.visibility='visible';
		newdiv.style.padding='0px';
		newdiv.style.margin='0px';
		newdiv.style.position='absolute';
		newdiv.style.left=xPos+'px';
		newdiv.style.top=yPos+'px';
		newdiv.style.width=width+'px';
		newdiv.style.height=height+'px';
		return newdiv;
	}

	// define posicionamento da janela no centro da tela
  this.centered=function(innerWidth,innerHeight) {
		var pageScroll=getPageScroll();
    this.xPos=(innerWidth/2)-(((isIE?22:20)+this.width+2*this.borderWidth+2*this.borderHeight+this.shadowSize)/2)+pageScroll.x;
    this.yPos=(innerHeight/2)-(((isIE?4:1)+this.height+2*this.borderWidth+2*this.borderHeight+this.shadowSize)/2)+pageScroll.y;
		if(isIE) this.xPos+=10;
		if(this.xPos<0) this.xPos=0;
		if(this.yPos<0) this.yPos=0;
	}

	// centraliza a janela
	this.center=function() {
		var innerSize=getInnerSize();
		this.centered(innerSize.width,innerSize.height);
		this.borderElement.style.left=(this.xPos)+'px';
		this.borderElement.style.top=(this.yPos)+'px';
		this.shimElement.style.left=(this.xPos)+'px';
		this.shimElement.style.top=(this.yPos)+'px';
		this.shadowElement.style.left=(this.xPos+this.shadowSize)+'px';
		this.shadowElement.style.top=(this.yPos+this.shadowSize)+'px';
	}

	// define visibilidade da janela
	this.visibility=function(visibility) {
		this.shimElement.style.visibility=visibility;
		this.borderElement.style.visibility=visibility;
		if(this.isShadow) {
			this.shadowElement.style.visibility=visibility;
		}
		this.resizeElement.style.visibility=visibility;
		this.closeElement.style.visibility=visibility;
		this.contentElement.style.visibility=visibility;
		this.titleElement.style.visibility=visibility;
	}

	// oculta a janela
	this.hide=function() {
		var elements=this.borderElement.getElementsByTagName('DIV');
		for(var loop=0;loop<elements.length;loop++) {
			elements[loop].saved_visibility=elements[loop].style.visibility;
			elements[loop].style.visibility='hidden';
		}
		if(this.popTimer) clearTimeout(this.popTimer);
		if(isNS && this.isScrollBars) {
			this.contentElement.style.overflow='hidden';
		}
		this.visibility('hidden');
	}

	// exibe a janela
	this.show=function() {
		this.shadowElement.style.zIndex=zIndex();
		this.shimElement.style.zIndex=zIndex();
		this.borderElement.style.zIndex=zIndex();
		this.visibility('visible');
		var elements=this.borderElement.getElementsByTagName('DIV');
		var elem_visibility=null;
		for(var loop=0;loop<elements.length;loop++) {
			elements[loop].style.visibility=elements[loop].saved_visibility;
		}
		if(isIE) {
			this.borderElement.style.filter="alpha(opacity=100)";
			this.shimElement.style.filter="alpha(opacity=100)";
			this.shadowElement.style.filter="alpha(opacity=30)";
		} else {
			this.borderElement.style.opacity='.99';
			this.shimElement.style.opacity='.99';
			this.shadowElement.style.opacity='0.3';
		}
		if(isNS && this.isScrollBars) {
			this.contentElement.style.overflow='auto';
		}
	}

	// fecha a janela removendo os layers
	this.close=function() {
		removeElement(this.id+'_shadow');
		removeElement(this.id+'_shim');
		removeElement(this.id+'_border');
		if(this.popTimer) clearTimeout(this.popTimer);
	}

	// movimenta/altera tamanho da janela com o mouse
  this.mouseMove=function(evt) {
		this.MouseX=(isIE)?event.clientX+this.IEbody().scrollLeft:evt.pageX;
		this.mouseY=(isIE)?event.clientY+this.IEbody().scrollTop:evt.pageY;
		if(isIE) if(event.button!=1) { this.moving=0; this.resizing=0; return true; }
		var that=this;
		if(this.moving) window.setTimeout(function(){that.move();},10);
		if(this.resizing) window.setTimeout(function(){that.resize();},10);
		if(isNS) {
			if(this.MouseX<=10 || this.mouseY<=window.pageYOffset+5 || this.MouseX>=window.innerWidth+window.pageXOffset-16 || this.mouseY>=window.innerHeight+window.pageYOffset-16) {
				this.moving=0; this.resizing=0; return true;
			}
		}
		return false;
	}

	// movimenta a janela
	this.move=function() {
		var movex=this.MouseX+this.MoveXDiff;
		var movey=this.mouseY+this.MoveYDiff;
		this.borderElement.style.left=movex+'px';
		this.borderElement.style.top=movey+'px';
		this.shimElement.style.left=movex+'px';
		this.shimElement.style.top=movey+'px';
		this.shadowElement.style.left=movex+this.shadowSize+'px';
		this.shadowElement.style.top=movey+this.shadowSize+'px';
		return false;
	}

	// inicia movimento
	this.moveInit=function() {
		this.shadowElement.style.zIndex=zIndex();
		this.shimElement.style.zIndex=zIndex();
		this.borderElement.style.zIndex=zIndex();
		this.MoveXDiff=parseInt(this.borderElement.style.left)-this.MouseX;
		this.MoveYDiff=parseInt(this.borderElement.style.top)-this.mouseY;
		this.moving=1; var that=this;
		if(isIE) {
			document.onselectstart=function(){return false;}
		}
		this.titleElement.onmouseup=function() {
			if(rights.charAt(2)!='1' && isIE) {
				document.onselectstart=function(){return true;}
			}
			that.moving=0;
		}
		if(this.moveByContent) {
			this.contentElement.onmouseup=function() {
				if(rights.charAt(2)!='1' && isIE) {
					document.onselectstart=function(){return true;}
				}
				that.moving=0;
			}
		}
		return false;
	}

	// coloca janela na frente
	this.toFront=function() {
		this.shadowElement.style.zIndex=zIndex();
		this.shimElement.style.zIndex=zIndex();
		this.borderElement.style.zIndex=zIndex();
		if(isNS && this.isScrollBars) {
			this.contentElement.style.overflow='auto';
		}
		return false;
	}

	// altera tamanho da janela
	this.resize=function(width,height) {
		if(typeof(width)!='undefined' && width>0) var resizex=width;
		else var resizex=this.MouseX+this.resizeXDiff;
		if(typeof(height)!='undefined' && height>0) var resizey=height;
		else var resizey=this.mouseY+this.resizeYDiff;
		this.resizeElement.style.left=Math.max(resizex,this.minWidth)+'px';
		this.resizeElement.style.top=Math.max(resizey,this.minHeight)+'px';
		this.shadowElement.style.width=Math.max(resizex+13+2*this.borderHeight,this.minWidth+13+2*this.borderHeight)+'px';
		this.shadowElement.style.height=Math.max(resizey+13+2*this.borderHeight,this.minHeight+13+2*this.borderHeight)+'px';
		this.shimElement.style.width=Math.max((resizex+((isIE)?13+2*this.borderHeight:13)),((isIE)?this.minWidth+13+2*this.borderHeight:this.minWidth+13))+'px';
		this.shimElement.style.height=Math.max((resizey+((isIE)?13+2*this.borderHeight:13)),((isIE)?this.minHeight+13+2*this.borderHeight:this.minHeight+13))+'px';
		this.borderElement.style.width=Math.max((resizex+((isIE)?13+2*this.borderHeight:13)),((isIE)?this.minWidth+13+2*this.borderHeight:this.minWidth+13))+'px';
		this.borderElement.style.height=Math.max((resizey+((isIE)?13+2*this.borderHeight:13)),((isIE)?this.minHeight+13+2*this.borderHeight:this.minHeight+13))+'px';
		this.titleElement.style.width=Math.max((resizex-2*this.borderWidth+13),((isIE)?this.minWidth-2*this.borderWidth+13:this.minWidth-2*this.borderWidth+8))+'px';
		this.contentElement.style.width=Math.max((resizex-2*this.borderWidth+(13-2*this.innerPad)),(this.minWidth-2*this.borderWidth+13-2*this.innerPad))+'px';
		if(this.isTitle) {
			this.contentElement.style.height= Math.max((resizey-2*this.borderWidth-20+(13-2*this.innerPad)),(this.minHeight-2*this.borderWidth-18+13-2*this.innerPad))+'px';
		} else {
			this.contentElement.style.height=Math.max((resizey-2*this.borderWidth+(13-2*this.innerPad)),(this.minHeight-2*this.borderWidth+13-2*this.innerPad))+'px';
		}
		this.closeElement.style.left=Math.max(resizex-this.borderWidth-8,this.minWidth-this.borderWidth-8)+'px';
		this.width=resizex;
		this.height=resizey;
		return false;
	}

	// inicia alteracao do tamanho
	this.resizeInit=function() {
		this.shadowElement.style.zIndex=zIndex();
		this.shimElement.style.zIndex=zIndex();
		this.borderElement.style.zIndex=zIndex();
		this.resizeXDiff=parseInt(this.resizeElement.style.left)-this.MouseX;
		this.resizeYDiff=parseInt(this.resizeElement.style.top)-this.mouseY;
		this.resizing=1; var that=this;
		if(isIE) document.onselectstart=function(){return false;}
		this.resizeElement.onmouseup=function() {
			if(rights.charAt(2)!='1' && isIE) {
				document.onselectstart=function(){return true;}
			}
			that.resizing=0;
		}
		return false;
	}

	// atualiza o conteudo da janela
	this.updateContent=function(htmlcontent) {
		this.contentElement.innerHTML=htmlcontent;
	}

	// atualiza a posicao da janela
	this.updatePosition=function(xPos,yPos) {
		this.shadowElement.style.left=(xPos+this.shadowSize)+'px';
		this.shadowElement.style.top=(yPos+this.shadowSize)+'px';
		this.shimElement.style.left=xPos+'px';
		this.shimElement.style.top=yPos+'px';
		this.borderElement.style.left=xPos+'px';
		this.borderElement.style.top=yPos+'px';
	}

	// atualiza scroll da janela
	this.updateScroll=function() {
		var btop=(isIE)?this.IEbody().scrollTop:window.pageYOffset;
		this.borderElement.style.top=(btop+this.yPos)+'px';
		this.shimElement.style.top=(btop+this.yPos)+'px';
		this.shadowElement.style.top=(btop+this.yPos+this.shadowSize)+'px';
	}

	// exibe efeito de transicao
	this.showTimeMethod=function(fadeOut,fadeIn,dropIn,slideIn,showFor,delayFor) {
		if(this.popTimer) clearTimeout(this.popTimer);
		if(this.fxTimer) clearTimeout(this.fxTimer);
		var that=this;
		if(delayFor) {
			if(fadeIn && !dropIn && !slideIn) {
				this.fxTimer=setTimeout(function(){that.fadeInInit();},1000*delayFor);
			} else if(dropIn && !fadeIn) {
				this.fxTimer=setTimeout(function(){that.moveToOutsideTop();},1000*delayFor);
				this.fxTimer=setTimeout(function(){that.show();},1000*delayFor);
			} else if(slideIn && !fadeIn) {
				this.fxTimer=setTimeout(function(){that.moveToOutsideLeft();},1000*delayFor);
				this.fxTimer=setTimeout(function(){that.show();},1000*delayFor);
			} else if(slideIn && fadeIn) {
				this.fxTimer=setTimeout(function(){that.moveToOutsideLeft();},1000*delayFor);
				this.fxTimer=setTimeout(function(){that.fadeInInit();},1000*delayFor);
				this.fxTimer=setTimeout(function(){that.show();},1000*delayFor);
			} else if(dropIn && fadeIn) {
				this.fxTimer=setTimeout(function(){that.moveToOutsideTop();},1000*delayFor);
				this.fxTimer=setTimeout(function(){that.fadeInInit();},1000*delayFor);
				this.fxTimer=setTimeout(function(){that.show();},1000*delayFor);
			} else {
				this.fxTimer=setTimeout(function(){that.show();},1000*delayFor);
			}
		}
		if(showFor) {
			if(fadeOut) {
				clearInterval(this.fadeOutTimer);
				clearInterval(this.bounceTimer);
				this.popTimer=setTimeout(function(){that.fadeOutInit();},1000*(showFor+delayFor));
			} else {
				clearInterval(this.bounceTimer);
				this.popTimer=setTimeout(function(){that.visibility('hidden');},1000*(showFor+delayFor));
			}
		}
	}

	// inicia esmaecimento para exibir a janela
	this.fadeInInit=function() {
		clearInterval(this.fadeInTimer);
		clearInterval(this.fadeOutTimer);
		this.fadeInAmount=0;
		if(isIE) {
			this.borderElement.style.filter='alpha(opacity=0)';
			this.shimElement.style.filter='alpha(opacity=0)';
			this.shadowElement.style.filter='alpha(opacity=0)';
		} else {
			this.borderElement.style.opacity='0';
			this.shimElement.style.opacity='0';
			this.shadowElement.style.opacity='0';
		}
		this.shadowElement.style.zIndex=zIndex();
		this.shimElement.style.zIndex=zIndex();
		this.borderElement.style.zIndex=zIndex();
		this.visibility('visible');
		var that=this;
		this.fadeInTimer=setInterval(function(){that.fadeIn();},5);
	}

	// esmaecimento para exibir a janela
	this.fadeIn=function() {
		this.fadeInAmount+=10;
		if(this.fadeInAmount<=99) {
			if(isIE) {
				this.borderElement.style.filter='alpha(opacity='+this.fadeInAmount+')';
				this.shimElement.style.filter='alpha(opacity='+this.fadeInAmount+')';
				this.shadowElement.style.filter='alpha(opacity='+3*this.fadeInAmount/10+')';
			} else {
				this.borderElement.style.opacity=(this.fadeInAmount/100);
				this.shimElement.style.opacity=(this.fadeInAmount/100);
				this.shadowElement.style.opacity=(3*this.fadeInAmount/1000);
			}
		} else {
			this.show();
			clearInterval(this.fadeInTimer);
		}
	}

	// inicia esmaecimento para ocultar a janela
	this.fadeOutInit=function() {
		this.visibility('visible');
		clearInterval(this.fadeOutTimer);
		clearInterval(this.fadeInTimer);
		this.fadeOutAmount=99;
		if(isIE) {
			this.borderElement.style.filter="alpha(opacity=100)";
			this.shimElement.style.filter="alpha(opacity=100)";
			this.shadowElement.style.filter="alpha(opacity=30)";
		} else {
			this.borderElement.style.opacity='0.99';
			this.shimElement.style.opacity='0.99';
			this.shadowElement.style.opacity='0.3';
		}
		var that=this;
		this.fadeOutTimer=setInterval(function(){that.fadeOut();},5);
	}

	// esmaecimento para ocultar a janela
	this.fadeOut=function() {
		this.fadeOutAmount-=10;
		if(this.fadeOutAmount>=1) {
			if(isIE) {
				this.borderElement.style.filter="alpha(opacity="+this.fadeOutAmount+")";
				this.shimElement.style.filter="alpha(opacity="+this.fadeOutAmount+")";
				this.shadowElement.style.filter="alpha(opacity="+3*this.fadeOutAmount/10+")";
			} else {
				this.borderElement.style.opacity=this.fadeOutAmount/100;
				this.shimElement.style.opacity=this.fadeOutAmount/100;
				this.shadowElement.style.opacity=3*this.fadeOutAmount/1000;
			}
		} else {
			this.hide();
			clearInterval(this.fadeOutTimer);
		}
	}

	// move a janela para fora do topo da tela
	this.moveToOutsideTop=function() {
		clearInterval(this.dropDownTimer);
		var scroll_top=(isIE)?this.IEbody().scrollTop:window.pageYOffset;
		this.shadowElement.style.zIndex=zIndex();
		this.shimElement.style.zIndex=zIndex();
		this.borderElement.style.zIndex=zIndex();
		this.shadowElement.style.left=(this.xPos+this.shadowSize)+'px';
		this.shimElement.style.left=this.xPos+'px';
		this.borderElement.style.left=this.xPos+'px';
		var delta=this.yPos-10*Math.floor(this.yPos/10);
		var oa=-10*Math.round((this.height+(2*this.borderWidth+2*this.borderHeight))/10)+delta;
		this.borderElement.style.top=(scroll_top+oa-100)+'px';
		this.shimElement.style.top=(scroll_top+oa-100)+'px';
		this.shadowElement.style.top=scroll_top+(oa-100+this.shadowSize)+'px';
		this.bounceAmount=40;
		var that=this;
		this.dropDownTimer=setInterval(function(){that.dropdown();},20);
	}

	// move a janela para fora da esquerda da tela
	this.moveToOutsideLeft=function() {
		clearInterval(this.slideInTimer);
		this.shadowElement.style.zIndex=zIndex();
		this.shimElement.style.zIndex=zIndex();
		this.borderElement.style.zIndex=zIndex();
		this.shadowElement.style.top=(this.yPos+this.shadowSize)+'px';
		this.shimElement.style.top=this.yPos+'px';
		this.borderElement.style.top=this.yPos+'px';
		var delta=this.xPos-10*Math.floor(this.xPos/10);
		var oa=-10*Math.round((this.width+(2*this.borderWidth+2*this.borderHeight))/10)+delta;
		this.borderElement.style.left=(oa-100)+'px';
		this.shimElement.style.left=(oa-100)+'px';
		this.shadowElement.style.left=(oa-100+this.shadowSize)+'px';
		var that=this;
		this.slideInTimer=setInterval(function(){that.slideIn();},20);
	}

	// desliza a janela da esquerda para dentro da tela
	this.slideIn=function() {
		if(parseInt(this.borderElement.style.left)<=(this.xPos)-10) {
			this.borderElement.style.left=parseInt(this.borderElement.style.left)+20+'px';
			this.shimElement.style.left=parseInt(this.borderElement.style.left)+20+'px';
			this.shadowElement.style.left=parseInt(this.shadowElement.style.left)+20+'px';
		} else {
			clearInterval(this.slideInTimer);
		}
	}

	// desliza a janela do topo para dentro da tela
	this.dropdown=function() {
		clearInterval(this.bounceTimer);
		var scroll_top=(isIE)?this.IEbody().scrollTop:window.pageYOffset;
		if(parseInt(this.borderElement.style.top)<=this.yPos+scroll_top-10) {
			this.borderElement.style.top=parseInt(this.borderElement.style.top)+20+'px';
			this.shimElement.style.top=parseInt(this.borderElement.style.top)+20+'px';
			this.shadowElement.style.top=parseInt(this.shadowElement.style.top)+20+'px';
		} else {
			clearInterval(this.dropDownTimer);
			if(this.isBounce) {
				var that=this;
				this.bounceTimer=setInterval(function(){that.bouncedown();},50);
			}
		}
	}

	// desliza do topo e quica a janela na tela
	this.bouncedown=function() {
		this.borderElement.style.top=(parseInt(this.borderElement.style.top)-this.bounceAmount)+'px';
		this.shimElement.style.top=(parseInt(this.borderElement.style.top)-this.bounceAmount)+'px';
		this.shadowElement.style.top=(parseInt(this.shadowElement.style.top)-this.bounceAmount)+'px';
		if(this.bounceAmount<0) this.bounceAmount+=10;
		this.bounceAmount=-(this.bounceAmount);
		if(this.bounceAmount==0) {
			clearInterval(this.bounceTimer);
		}
	}

	// inicializa
	this.setup(popId,width,height,url,title,titleColor,titleBgColor,borderWidth,borderColor,shadowColor,innerColor,innerBgColor,padding,xPos,yPos);

} // fim da classe Winpop


// exibe janela com as configuracoes mais usuais
function showpop(width,height,url,title,titleColor,titleBgColor,borderWidth,borderColor,shadowColor,innerColor,innerBgColor,padding,xPos,yPos) {
	popup=new Winpop('popup',width,height,url,title);
	popup.titleColor=(typeof(titleColor)=='undefined' || !titleColor)?'#000000':titleColor;
	popup.titleBgColor=(typeof(titleBgColor)=='undefined' || !titleBgColor)?'#cccccc':titleBgColor;
	popup.borderWidth=(typeof(borderWidth)=='undefined' || borderWidth=='')?1:borderWidth;
	popup.borderColor=(typeof(borderColor)=='undefined' || !borderColor)?'#666666':borderColor;
	popup.shadowColor=(typeof(shadowColor)=='undefined' || !shadowColor)?'#808080':shadowColor;
	popup.innerColor=(typeof(innerColor)=='undefined' || !innerColor)?'#000000':innerColor;
	popup.innerBgColor=(typeof(innerBgColor)=='undefined' || !innerBgColor)?'#ffffff':innerBgColor;
	popup.innerPad=(typeof(padding)=='undefined' || padding=='')?7:padding;
	popup.xPos=(typeof(xPos)=='undefined' || !xPos)?0:xPos; // distancia da borda esquerda
	popup.yPos=(typeof(yPos)=='undefined' || !yPos)?0:yPos; // distancia da borda superior
	popup.isResizeable=1;
	popup.isFrame=0;
	popup.isScrollBars=1;
	popup.create();
}

// exibe janela com o conteudo em um iframe (substituto para popups)
function framepop(width,height,url,title,scrollBars) {
	if(typeof(title)=='undefined' || !title) title=sitetitle;
	popup=new Winpop('popup',width,height,url,title);
	popup.titleColor='#000000';
	popup.titleBgColor='#cccccc';
	popup.borderWidth=3;
	popup.borderColor='#666666';
	popup.shadowColor='#808080';
	popup.innerColor='#000000';
	popup.innerBgColor='#ffffff';
	popup.innerPad=0;
	popup.isResizeable=0;
	popup.isFrame=1;
	if(typeof(scrollBars)!='undefined' && (scrollBars==false || scrollBars=='no' || scrollBars==0 || scrollBars=='false')) {
		popup.isScrollBars=0;
	} else {
		popup.isScrollBars=1;
	}
	popup.create();
}

// fecha janela pelo ID
function closepop(popId) {
	removeElement(popId+'_shadow');
	removeElement(popId+'_shim');
	removeElement(popId+'_border');
}
