
var jsWindowCreate=false;
var jsWindowShowing=false;
var jsWindowResult=null;
var jsWindowStrCommand=null;
var jsWindowMoving=false;
var jsWindowCursor={x:0,y:0};
var jsWindowCursorRel={x:0,y:0};
var jsWindowParentDim=null;if(!Nav){
	try{Nav=new verif_navegador();
	}catch(e){}}
	
function jsWindowCriar(){
	var html_janela;
	html_janela='<div id="jswindow_esconde_fundo" style="position: absolute; display: none; top: 0px; left: 0px; width: 100%; height: 100%; z-index: 1001; height: 100%; _background: #000000; _filter: Alpha(opacity=0);"></div>';
	html_janela+='<div id="jswindow_janela" class="janela_jswindow" style="position: absolute; display: none; top: 0; left: 0; height: 150px; width: 400px; overflow: hidden; padding: 0; text-align: center; z-index: 1002;" align="center">';
	html_janela+='<div id="jswindow_barra_titulo" onmousedown="jsWindowStartMove()" onmouseup="jsWindowEndMove()" style="position: relative; height: 27px; overflow:hidden; cursor: move;">';
	html_janela+='<h5 id="jswindow_titulo" class="janela" style="position: absolute; top: 0px; left: 0px; width: 100%;"></h5>';
	html_janela+='<button onclick="jsWindowClose(null)" style="position: absolute; top: 0px; right: 0px; width: 18px; height: 18px; margin: 4px; padding: 0px; border: 1px solid #757575; background: #ffffff; font: bold 10px verdana; color: #000000; text-align: center;\">x</button>';
	html_janela+='</div>';
	html_janela+='<div id="jswindow_diviframe" style="position: relative; width: 400px; height: 150px; overflow: hidden;">';
	html_janela+='<div id="jswindow_msg_loadding" style="position: absolute; top: 0; right: 0; padding: 3px 5px; border: 1px solid #c0c0c0; background: #ffffff; font: bold 10px verdana; color: #888888;">Carregando...</div>';
	html_janela+='<iframe id="jswindow_iframe" name="jswindow_iframe" onload="jsWindowInitIframeOnLoad(this)" style="width: 100%; height: 100%; border: 0;" frameborder="0" scrolling="no"></iframe>';
	html_janela+='</div>';
	html_janela+='</div>';
	try{var elemJANELA=document.createElement('div');
	        elemJANELA.innerHTML=html_janela;
			document.body.appendChild(elemJANELA);
			jsWindowCreate=true;
			jsWindowCentralizar();
			jsWindowDesativaSelecao();
			jsWindowInitVerifCursor();
			jsWindowHide();
			}catch(e){}}
			
function jsWindowInitIframeOnLoad(jsWindowIframe){
	var jsWindowLoadding=document.getElementById('jswindow_msg_loadding');
	jsWindowIframe.contentWindow.close=function(){
		jsWindowClose(jsWindowIframe.contentWindow.returnValue);
		};
		jsWindowLoadding.style.display='none';
		}
		
function jsWindowDesativaSelecao(){
	var jsWindowElem=document.getElementById('jswindow_janela');
	jsWindowElem.onselectstart=function(){
		try{document.selection.clear();
		}catch(e){}return false;
		};
		jsWindowElem.ondragstart=function(){try{document.selection.clear();
		}catch(e){}return false;};}
		
function jsWindowCentralizar(){
	var jsWindowElem=document.getElementById('jswindow_janela');
	if(jsWindowElem!=null){
		var janelaPrincipalWidth=document.body.clientWidth;
		var janelaPrincipalHeight=document.body.clientHeight
        var jsWindowElemWidth=parseInt(jsWindowElem.style.width);
		var jsWindowElemHeight=parseInt(jsWindowElem.style.height);
		var posLeft=parseInt((janelaPrincipalWidth/2)-(jsWindowElemWidth/2));
		var posTop=parseInt((janelaPrincipalHeight/2)-(jsWindowElemHeight/2)+document.body.scrollTop);
		if(posTop<0){posTop=0;}
        jsWindowElem.style.left=posLeft+'px';jsWindowElem.style.top=posTop+'px';
		}}
		
function jsWindowShow(urlIframe,width,height,titulo){
	if(!jsWindowCreate){jsWindowCriar();}
    var jsWindowElem=document.getElementById('jswindow_janela');
	var jsWindowFundo=document.getElementById('jswindow_esconde_fundo');
	var jsWindowIframe=document.getElementById('jswindow_iframe');
	var jsWindowTitulo=document.getElementById('jswindow_titulo');
	var jsWindowLoadding=document.getElementById('jswindow_msg_loadding');
	try{jsWindowElem.style.display='block';
	jsWindowFundo.style.display='block';
	jsWindowLoadding.style.display='';
	if(urlIframe!=null){
		jsWindowIframe.src=urlIframe;
		}
    if(width!=null&&height!=null){
		jsWindowResize(width,height);
		}
    if(titulo!=null){
		jsWindowTitulo.innerHTML=titulo;
		}
        jsWindowShowing=true;
		}catch(e){}}
		
function jsWindowHide(){
	if(!jsWindowCreate){return;}
    var jsWindowElem=document.getElementById('jswindow_janela');
	var jsWindowFundo=document.getElementById('jswindow_esconde_fundo');
	var jsWindowIframe=document.getElementById('jswindow_iframe');
	var jsWindowTitulo=document.getElementById('jswindow_titulo');
	try{jsWindowIframe.src='';
	jsWindowElem.style.display='none';
	jsWindowFundo.style.display='none';
	jsWindowTitulo.innerHTML='';
	jsWindowShowing=false;
	}catch(e){}
   jsWindowRunCommandByResult();}
   
function jsWindowClose(result){
	jsWindowResult=result;
	jsWindowHide();
	if(jsWindowVerifOpenCascade()){
		parent.jsWindowResize(jsWindowParentDim.width,jsWindowParentDim.height);
		}}
		
function jsWindowGetContentDim(){
	var jsWindowElem=document.getElementById('jswindow_diviframe');
	var result={width:parseInt(jsWindowElem.style.width),height:parseInt(jsWindowElem.style.height)};
	return result;}
	
function jsWindowResize(width,height){
	if(jsWindowVerifOpenCascade()){
		var parentDim=parent.jsWindowGetContentDim();
		if(parentDim.width<width&&parentDim.height<height){
			jsWindowParentDim=parentDim;parent.jsWindowResize(width+4,height+31);
			}}
        var jsWindowElem=document.getElementById('jswindow_janela');
		var jsWindowDivIfr=document.getElementById('jswindow_diviframe');
		jsWindowDivIfr.style.width=width+'px';
		jsWindowDivIfr.style.height=height+'px';
		jsWindowElem.style.width=(width+4)+'px';
		jsWindowElem.style.height=(height+31)+'px';
		jsWindowCentralizar();}
		
function jsWindowShowInputResult(urlIframe,width,height,titulo,idElemInput){
	jsWindowShowProcessResult(urlIframe,width,height,titulo,"document.getElementById('"+idElemInput+"').value = '#ModalReturn#'");
	}
	
function jsWindowShowProcessResult(urlIframe,width,height,titulo,sCommand){
	jsWindowShow(urlIframe,width,height,titulo);
	jsWindowStrCommand=sCommand;
	}
	
function jsWindowRunCommandByResult(){
	if(jsWindowResult==null||jsWindowResult==''){
		return;}		
    if(jsWindowStrCommand==null||jsWindowStrCommand==''){return;}
       jsWindowStrCommand=jsWindowStrCommand.toString();
	   jsWindowStrCommand=jsWindowStrCommand.replace('#ModalReturn#',jsWindowResult.toString());
	   eval(jsWindowStrCommand);}
	   
function jsWindowScrolling(scroll){
	var jsWindowIframe=document.getElementById('jswindow_iframe');
	var url=jsWindowIframe.src;
	jsWindowIframe.scrolling=(scroll)?'yes':'no';
	jsWindowIframe.src='';
	jsWindowIframe.src=url;
	}
	
function jsWindowStartMove(){
	try{if(jsWindowVerifOpenCascade()){
		document.getElementById('jswindow_barra_titulo').style.cursor='default';
		return;}}catch(e){}		
        var jsWindowElem=document.getElementById('jswindow_janela');
		var jsWindowIframe=document.getElementById('jswindow_iframe');
		jsWindowCursorRel.y=jsWindowCursor.y-parseInt(jsWindowElem.style.top);
		jsWindowCursorRel.x=jsWindowCursor.x-parseInt(jsWindowElem.style.left);
		jsWindowIframe.style.display='none';
		jsWindowMoving=true;
		jsWindowMove();}
		
function jsWindowEndMove(){
	var jsWindowIframe=document.getElementById('jswindow_iframe');
	jsWindowIframe.style.display='';
	jsWindowMoving=false;}
	
function jsWindowMove(){
	if(!jsWindowMoving){
		return;}
    try{
		var jsWindowElem=document.getElementById('jswindow_janela');
		jsWindowElem.style.top=(jsWindowCursor.y-jsWindowCursorRel.y)+'px';
		jsWindowElem.style.left=(jsWindowCursor.x-jsWindowCursorRel.x)+'px';window.setTimeout('jsWindowMove()',1);
		}catch(e){}}
		
function jsWindowGetPosCursor(e){
	if(!Nav){return;}
    try{jsWindowCursor.y=(Nav.ns?e.pageY:event.clientY+document.body.scrollTop);
	jsWindowCursor.x=(Nav.ns?e.pageX:event.clientX+document.body.scrollLeft);
	}catch(e){}}
	
function jsWindowInitVerifCursor(){
	add_mousemove_event(jsWindowGetPosCursor);}
	
function jsWindowVerifOpenCascade(){
	if(parent==self){return false;}
    return(parent.jsWindowShowing==true);}