function OpenPopUpDefault(url,nomeTela){
	winprops = 'resizable=yes,menubar=no,scrollbars=yes,toolbar=no,left=80,top=40,';
	winprops += 'width=640,height=300';
	window.open(url, nomeTela, winprops);
}

function MaxWindow(win)
{
	win.moveTo(0,0);

	if (document.all)
	{
	  win.top.window.resizeTo(screen.availWidth,screen.availHeight);
	}
}

function OpenPopUpMaximizado(url,nomeTela){
	winprops = 'resizable=yes,menubar=no,scrollbars=yes,toolbar=no,left=80,top=40';
	MaxWindow(window.open(url, nomeTela, winprops));
}

function OpenPopUp(url,nomeTela,width,height){
	winprops = 'resizable=yes,menubar=no,scrollbars=yes,toolbar=no,left=80,top=40,';
	winprops += 'width='+width+',height='+height;
	window.open(url, nomeTela, winprops);
}

function OpenPopUpLegenda(){
	        winprops = 'resizable=no,menubar=no,scrollbars=no,toolbar=no,left=0,top=0,';
	        winprops += 'width=40,height=108';
	        window.open('legenda.aspx', 'Legenda', winprops);
        }

function OpenPopUpModal(url,width,height){
	winprops = 'dialogHeight: ' + height + 'px; dialogWidth: ' + width + 'px; center: Yes; help: No; resizable: No; status: No;';
	
	return window.showModalDialog(url, window, winprops);
}  
 
function ExibirRelatorio(url,idChkItemBase,msg){
	var checks = ObterChecksSelecionadosGrid(idChkItemBase);
	if (checks.length == 1){
		url += "?codigo="+checks[0].value;
		var dataAtual = new Date();
		OpenPopUpMaximizado(url,'relatorio'+dataAtual.getMilliseconds());
	}else{
		alert(msg);
	}
} 

function ExibirRelatorioHistorico(urlOperacional, urlEspecial, codigoPorteOperacional, idChkItemBase, msg){
	var checks = ObterChecksSelecionadosGrid(idChkItemBase);
	if (checks.length == 1){
		var valor = checks[0].value.split('|');
		var url;
		if(parseInt(codigoPorteOperacional) == parseInt(valor[1]))
			url = urlOperacional;
		else
			url = urlEspecial;
		
		url += "?codigo=" + valor[0] + "&revisao=" + valor[2];
		var dataAtual = new Date();
		OpenPopUpMaximizado(url,'relatorio'+dataAtual.getMilliseconds());
	}else{
		alert(msg);
	}
} 

function ExibirRelatorioHistoricoPorteEspecial(urlEspecial, codigoPorteOperacional, idChkItemBase, msg, msgPorteOperacional){
	var checks = ObterChecksSelecionadosGrid(idChkItemBase);
	if (checks.length == 1){
		var valor = checks[0].value.split('|');
		var url;
		if(parseInt(codigoPorteOperacional) == parseInt(valor[1])){
			alert(msgPorteOperacional);
		}else{
			url = urlEspecial;
		
			url += "?codigo=" + valor[0] + "&revisao=" + valor[2];
			var dataAtual = new Date();
			OpenPopUpMaximizado(url,'relatorio'+dataAtual.getMilliseconds());
		}
	}else{
		alert(msg);
	}
} 

			 