/**********************************************************************************/
/* CATEGORIA: DHTML
/* DESCRIÇÃO: Cria objeto dinamicamente provofando efeito de blackout na tela
/* COMPATIBILIDADE: IE5.1, IE5.5, IE6, IE7, FF1.8.1.12
/* EVENTO: (Não restringido)
/* PARÂMETROS:
/*	nome	 = Nome do objeto criado
/**********************************************************************************/

function winModal() {	
	
	//mostra a janela
	this.show = function ( wName, szW , szH , fSrc, wRoot ) {	
		//Obtem o tamanho da tela ************************************************************************************************************************************		
		if (window.innerWidth || window.innerHeight) { docwidth = window.innerWidth ; docheight = window.innerHeight ; }	//Opera Netscape 6 Netscape 4x Mozilla
		if (document.body.clientWidth || document.body.clientHeight) { docwidth = document.body.clientWidth ; docheight = document.body.clientHeight ;	}	//IE Mozilla		
		createWin ( docwidth , docheight , 'modalArea' , '' , '' ) ; //Cria a area modal
		createWin ( szW , szH , wName , 'modalArea' , fSrc  ) ; //Cria a janela
	}
		
	//destroi a janela	
	this.hide = function( wRef ){
		if (wRef=='local'){
			document.body.removeChild('modalArea');
		}else{	
			window.parent.document.body.removeChild( window.parent.document.getElementById('modalArea') ) ; 
		}
	}	
	
	//cria objetos (janelas)
	function createWin ( szW , szH , wName , wRoot , fSrc ) {		
		//Calcula o centro da janela
		//LeftPos = (screen.width)  ? (screen.width-szW)/2 : 0;
		//TopPos  = (screen.height) ? (screen.height-(szH+200))/2 : 0;	
		
		if (wRoot == '') {
			root = document.body ;
			css = 'dark' ;			
			oType = "div" ; 
			LeftPos = 0 ;
			TopPos  = 0 ;
		}else{				
			root = document.getElementById( wRoot );			
			css = 'wind' ;
			oType = "iframe" ;		
			L = root.style.width;
			T = root.style.height;		
			LeftPos = ((L.substring(0,L.length - 2 )) / 2) - (szW / 2);
			TopPos  = ((T.substring(0,T.length - 2 )) / 2) - (szH / 2);			
		}
		
		//Verifica se o objeto já existe
		if (!document.getElementById( wName )) {			
			obj = document.createElement( oType ); //tipo do objeto criado...			
			//Define os atributos do objeto (janela) criado
			with (obj) {
				setAttribute( "id", wName ) ;
				setAttribute( "name", wName ) ;
				if( oType == "iframe" ){ 
					setAttribute( "src" , fSrc );
					setAttribute( "scrolling" , 'no' );
					setAttribute( "frameborder" , 'no' );
					style.border = 'none';
				}
				className 	  = css //Class definida em folha de estilo (.CSS)
				style.width   = szW + "px" ;
				style.height  = szH + "px" ;
				style.left 	  = LeftPos + "px";
				style.top	  = TopPos + "px";
			}
			root.appendChild( obj ) ;			
		}		
	}	
	
}

wm = new winModal();