var win
//------------------------
function fEsconderCarregandoJanela(){

    try{fCarregando(false)}catch(e){}
    try{eval($("scriptIni").innerHTML)}catch(e){}
}

//------------------------
function fNormal(URL, TITLE, WIDTH, HEIGHT, DRAGGABLE, WIREDDRAG, DESTROYONCLOSE, RECENTERAUTO, MINIMIZABLE){
    try{fCarregando(true)}catch(e){}
	if (win != null){
		Dialog.alert("Erro: Feche a janela para poder reabrir!",{width:200, height:100}); 
		try{fCarregando(false)}catch(e){}
	}else{
		win = new Window(
			{
				className: "alphacube", 
				title: TITLE, 
				width: WIDTH, 
				height: HEIGHT, 
				
				draggable: DRAGGABLE,
				wiredDrag: WIREDDRAG,
				destroyOnClose: DESTROYONCLOSE, 
				recenterAuto: RECENTERAUTO,
				minimizable: MINIMIZABLE,
				showEffect: Element.show,
				hideEffect: Element.hide
			}
			/*
			className: "alphacube", 
			title: "Título", 
			width:300, 
			height:150, 
			draggable:true,
			wiredDrag: true,
			destroyOnClose: true, 
			recenterAuto:false,
			minimizable:false
			*/
		);
	
		win.setAjaxContent(URL, {method: 'get',onComplete:fEsconderCarregandoJanela}, true, false);
		win.setDestroyOnClose();
		win.show();
		
		myObserver = {
			onDestroy: function(eventName, contentWin) {
				if (contentWin == win ) {
					win = null;
					Windows.removeObserver(this);
				}
			}
		}
		Windows.addObserver(myObserver);
	}
}

//------------------------
function fModal( NAME, URL, TITLE, WIDTH, HEIGHT, ZINDEX, RESIZABLE, DRAGGABLE, WIREDDRAG, DESTROYONCLOSE, RECENTERAUTO, MINIMIZABLE){
    try{fCarregando(true)}catch(e){}
	win = new Window(
		NAME,
		{	
			className: "alphacube", 
			title: TITLE, 
			width: WIDTH, 
			height:HEIGHT,
			zIndex: ZINDEX, 
			resizable: RESIZABLE, 
			draggable: DRAGGABLE,
			wiredDrag: WIREDDRAG,
			destroyOnClose: DESTROYONCLOSE, 
			recenterAuto: RECENTERAUTO,
			minimizable: MINIMIZABLE,
			showEffect: Element.show,
			hideEffect: Element.hide
		}
		/*
		,
		overlayShowEffectOptions: {duration: 0.01},
		overlayHideEffectOptions: {duration: 0.01}
		title: "Sample window", 
		width:350, 
		height:400, 
		zIndex: 100, 
		resizable: true, 
		draggable:true, 
		wiredDrag: true,
		destroyOnClose: true, 
		recenterAuto:false,
		minimizable:false
		*/
	);
	win.setAjaxContent(URL, {method: 'get',onComplete:fEsconderCarregandoJanela}, true, true);
	win.showCenter();
}

//------------------------
function fFecharJanela(){
	win.close();
}

//------------------------
function fAtualizaAltura(){
    win.setSize(win.width, 400, false);
	//win.updateHeight();
}