 <!--
 // Copyright 1999, 2000 by Ray Stott - ver 2.0
 // OK to use on noncommercial sites as long as copyright is included
 // Script is available at http://www.crays.com/jsc          

var popWin = null;    					// use this when referring to pop-up window
var incrWindow = false;
var winCount = 0;
var winName = "popWinD";
var maxSize = [700, 500]; 				// Width, Height (maximos)
var winPosition = [90, 50]; 			// Top, Left
var winSize = [500, 300]; 				// Width, Height
var winLocation = ["center", "middle"];	// (fromLeft | center | fromRight), (fromTop | middle | fromBottom)
var winTitle = null;

var wfToolbar = false;
var wfLocation = false;
var wfDirectories = false;
var wfStatus = false;
var wfMenubar = false;
var wfScrollbars = false;
var wfResizable = false;

// Sets the default values for dialog window
var dlgTop = 100;
var dlgLeft = 150;
var dlgCenter = true;
var dlgHide = false;
var dlgEdge = "raised";
var dlgHelp = false;
var dlgResizable = false;
var dlgScroll = false;
var dlgStatus = false;
var dlgUnadorned = false;
var dlgCanClose = false; //determina se a janela de dialogo pode ser fechada.

// Para Popup de imagens ==========
var imgPage = "pimg.htm";
var thumbPath = "";
var thumbPrefix = "";
var thumbSufix = "";
var winImg = null;
var closeMsg = "Clique para fechar"

function openPopWin(winURL, winWidth, winHeight, winLeft, winTop){
	var argLen = openPopWin.arguments.length;
	var d_winLeft = 20;  // default, pixels from screen left to window left
	var d_winTop = 20;   // default, pixels from screen top to window top
	//if (incrWindow) 
		winName = "popWinD" + winCount++ //unique name for each pop-up window
	
	closePopWin();           // close any previously opened pop-up window
	var winFeatures = getFeatures();
	if (winFeatures.length > 0) winFeatures = "," + winFeatures;
	if (argLen == 5)  // location specified
		winFeatures += getLocation(winWidth, winHeight, getXLoc(winLeft), getYLoc(winTop))
	else
		winFeatures += getLocation(winWidth, winHeight, getXLoc(d_winLeft), getYLoc(d_winTop));
	popWin = window.open(winURL, winName, "width=" + winWidth + ",height=" + winHeight + winFeatures);
	popWin.focus();
}
 
function PopupImage(picName, windowTitle, windowWidth, windowHeight, toScreen){
	var i = 0; scrl = wfScrollbars; resz = wfResizable;
	if (PopupImage.arguments.length == 5 && toScreen) {
		var mxW = screen.Width - winPosition[0]; 
		var mxH = screen.Height - winPosition[1];
	} else {
		var mxW = (maxSize[0] == 0) ? screen.Width - winPosition[0] : maxSize[0];
		var mxH = (maxSize[1] == 0) ? screen.Height - winPosition[1] : maxSize[1];
	}
	if(windowWidth > mxW) {windowWidth = mxW; wfScrollbars = true;}
	if(windowHeight > mxH) {windowHeight = mxH; wfScrollbars = true;}
	if(wfScrollbars) wfResizable = true;
	picName = picName.replace(thumbPath,"");
	picName = picName.replace(thumbPrefix,"");
	picName = picName.replace(thumbSufix,"");
	if(winImg == picName && winOpen()){
		popWin.focus()
	}
	else{
		winImg = picName
		winTitle = windowTitle
		openPopWin(imgPage, windowWidth, windowHeight, winPosition[0], winPosition[1])
	}
	 //restaura estado inicial
	wfScrollbars = scrl;
	wfResizable = resz;
}
  
function winOpen(){
  if(popWin != null) 
    return (popWin.closed != true)
  else
    return false
}
   
function closePopWin(){    // close pop-up window if it is open 
	if (navigator.appName != "Microsoft Internet Explorer" 
	  || parseInt(navigator.appVersion) >=4) {//do not close if early IE
		if(popWin != null) {
			if(!popWin.closed) {
				popWin.close();
			}
		}
	}
}

function getLocation(winWidth, winHeight, winLeft, winTop){
   var winLocation = ""
   if (winLeft < 0)
     winLeft = screen.width - winWidth + winLeft;
   if (winTop < 0)
     winTop = screen.height - winHeight + winTop;
   if (winTop == "cen")
     winTop = (screen.height - winHeight)/2 - 20;
   if (winLeft == "cen")
     winLeft = (screen.width - winWidth)/2 - 20;
   if (winLeft>0 & winTop>0)
     winLocation =  ",screenX=" + winLeft + ",left=" + winLeft   
                 + ",screenY=" + winTop + ",top=" + winTop;
   else
     winLocation = ""
   return winLocation
   }

function getXLoc(wL){
  var xLoc = wL
  if(winLocation[0]=="fromRight") 
    xLoc = xLoc * (-1)
  if(winLocation[0]=="center") 
    xLoc = "cen"
  return xLoc
}

function getYLoc(wT){
  var yLoc = wT
  if(winLocation[1]=="fromBottom") 
    yLoc = yLoc * (-1)
  if(winLocation[1]=="middle") 
    yLoc = "cen"
  return yLoc
}

function getFeatures(){
  var options=""; vrg = "";
  if(wfToolbar) {options="toolbar"; vrg = ","}
  if(wfLocation) {options+=vrg+"location"; vrg = ","}
  if(wfDirectories) {options+=vrg+"directories"; vrg = ","}
  if(wfStatus) {options+=vrg+"status"; vrg = ","}
  if(wfMenubar) {options+=vrg+"menubar"; vrg = ","}
  if(wfScrollbars) {options+=vrg+"scrollbars"; vrg = ","}
  if(wfResizable) {options+=vrg+"resizable"}
  return options
}

function testPopUp(i){
	var winImgs = [["/aprimoramento/arquivos/imagens/61417main_spitzer-062804-browse.jpg",800,520],
		["/aprimoramento/arquivos/imagens/ajuda.jpg",610,454],
		["/aprimoramento/arquivos/imagens/101587.jpg",299,468],
		["/aprimoramento/arquivos/imagens/6971908.jpg",500,375],
		["/aprimoramento/arquivos/imagens/radio.jpg",116,34]];
	winTitle = "Imagem "+i;
	PopupImage(winImgs[i][0], winTitle, winImgs[i][1], winImgs[i][2])
}

/*
dialogHeight: sHeight 							Sets the height of the dialog window (see Remarks for default unit of measure). 
dialogLeft: sXPos 								Sets the left position of the dialog window relative to the upper-left corner of the desktop. 
dialogTop: sYPos 								Sets the top position of the dialog window relative to the upper-left corner of the desktop. 
dialogWidth: sWidth 								Sets the width of the dialog window (see Remarks for default unit of measure). 
center:{ yes | no | 1 | 0 | on | off } 			Specifies whether to center the dialog window within the desktop. The default is yes. 
dialogHide:{ yes | no | 1 | 0 | on | off } 		Specifies whether the dialog window is hidden when printing or using print preview. This feature is only available when a dialog box is opened from a trusted application. The default is no. 
edge:{ sunken | raised } 						Specifies the edge style of the dialog window. The default is raised. 
help:{ yes | no | 1 | 0 | on | off } 			Specifies whether the dialog window displays the context-sensitive Help icon. The default is yes. 
resizable:{ yes | no | 1 | 0 | on | off } 		Specifies whether the dialog window has fixed dimensions. The default is no. 
scroll:{ yes | no | 1 | 0 | on | off } 			Specifies whether the dialog window displays scrollbars. The default is yes. 
status:{ yes | no | 1 | 0 | on | off } 			Specifies whether the dialog window displays a status bar. The default is yes for untrusted dialog windows and no for trusted dialog windows. 
unadorned:{ yes | no | 1 | 0 | on | off } 		Specifies whether the dialog window displays the border window chrome. This feature is only available when a dialog box is opened from a trusted application. The default is no.
*/

// shows dialog box as modal mode

function getDlgFeatures(dlgWidth, dlgHeight, dlgTop, dlgLeft){
var opt=""
	opt = "dialogWidth:" + dlgWidth + "px"
	opt += ";dialogHeight:" + dlgHeight + "px"
	if (!(dlgCenter) && (PopupImage.arguments.length = 4)){
		opt += ";dialogTop:" + dlgTop + "px"
		opt += ";dialogLeft:" + dlgLeft + "px"
	}
	opt += ";center:" + ((dlgCenter) ? "yes" : "no")
	opt += ";hide:" + ((dlgHide) ? "yes" : "no")
	opt += ";edge:" + (((dlgEdge="raised") || (dlgEdge="sunken")) ? dlgEdge : "raised")
	opt += ";help:" + ((dlgHelp) ? "yes" : "no")
	opt += ";resizable:" + ((dlgResizable) ? "yes" : "no")
	opt += ";status:" + ((dlgStatus) ? "yes" : "no")
	opt += ";scroll:" + ((dlgScroll) ? "yes" : "no")
	opt += ";unadorned:" + ((dlgUnadorned) ? "yes" : "no")
	return opt
}

function showDialog(dlgUrl, dlgWidth, dlgHeight, dlgArgs) {
var dlgFeats = getDlgFeatures(dlgWidth, dlgHeight, dlgTop, dlgLeft);
var Ret = window.showModalDialog(dlgUrl,dlgArgs,dlgFeats);
	return Ret;
}




