function cadastraImagem(){
 abreJanela2('mod_imagem_cadastra.php','nova');
}


//////////////////////////////////////////////////////////
function abreJanelaCentro(theURL,winName,larg,alt) { 

	
pos1 = (document.body.offsetWidth - larg) /2;
pos2 = ((document.body.offsetHeight - alt) /2 )+ 50;

	 features = 'toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,top='+ pos2 +',left=' +pos1 + ',screenY='+pos2+',screenX='+ pos1 +',width='+ larg + ',height=' +alt;
	 
  myWindow = window.open(theURL,winName,features);
//  myWindow.setFocus();
}

function busca(){
	document.formbusca.submit();
}
function configura(valor){
	document.form1.nop_seclink.value = valor + document.form1.nop_seclink.value;
}

function move(valor) {
	document.form1.action.value = "listar";
	document.form1.acao_pag.value = valor;	
	document.form1.submit();
}


function movePag(valor) { //pag receitas
	document.form1.acao_pag.value = valor;
	document.form1.action.value = "listar";
	document.form1.submit();
}

function processa(ac){
	document.form1.action.value = ac;
	document.form1.submit();

}

function setaCampoTroca(novaOrdem,codigo,ordem,secao){
 	document.form1.action.value = "troca";
 	document.form1.nop_novaordem.value = novaOrdem;
	document.form1.nop_codigoatual.value = codigo;
	document.form1.nop_ordematual.value = ordem;
	document.form1.sel_secao.value = secao;
	document.form1.submit();
}


function gravaMateria(){
 document.form1.action.value = "cadastrar";
	document.form1.submit();

}
function setCod(cod){
  window.opener.document.form1.nop_imacodigo.value = cod;
  window.opener.document.form1.btSemImg.disabled = false;
  window.opener.frames[2].formimg.nop_imacodigo.value=cod;
  window.opener.frames[2].formimg.submit();
  window.close();
  }
  
  
function semImagem(){
	document.form1.nop_imacodigo.value = -1; //retira o valor da imagem
	document.frames[2].formimg.nop_imacodigo.value=-1; //retira valor da imagem do preview
	document.frames[2].formimg.submit(); //dá submit no preview
// 	document.form1.action.value = "sem imagem";
//	document.form1.submit();
}

function openWin(URL,nome)
	 {

 	myWindow = window.open(URL, nome,'width=800,height=600,'+ 'status=yes,toolbar=no,menubar=no,location=yes,scrollbars=yes,resizable=yes');
	  }
		 
		 
function redireciona(ref){
	window.location.href = ref;
}


//para caixa de busca!
function keyHole(evt) {
var CR = 13; // Carriage Return
var TAB = 9; // Horizontal Tab
var AMP = 38; // Ampersand (&). You get the idea...
var charCode;
if (navigator.appName == "Netscape")
charCode = evt.which 
else 
charCode = evt.keyCode;
if (charCode == CR) document.forms.formbusca.submit();
return true;
}


function popPos($sec){
if ($sec == 'index') {
	switch (document.body.offsetWidth) {
	case 1024 : 
	case 1020 : h = 275; break;
	case 800 : 
	case 796: h = 170; break;
	default: h = 150;
	}
	
	document.all.Layer1.style.left = h;
}
//alert(document.body.offsetWidth);
}


function imprimir(){
	window.print();
}

function voltar(){
	parent.frames.history.go(-1);
}


function mOvr(src,clrOver) {
     src.style.backgroundColor = clrOver;
 	 src.style.cursor = 'hand';
	 src.bgColor = clrOver;
     src.style.borderColor = 'black';

}

function mOut(src,clrIn) {
   src.style.backgroundColor = clrIn;
   src.style.cursor = 'default';
   src.bgColor = clrIn;
   src.style.borderColor = clrIn;
  }

function mClk(src) {
if(event.srcElement.tagName=='TD'){
  src.children.tags('A')[0].click();
    }
  }
//////////////////////////////////////////////////////////
function abreJanela(theURL,winName,features) { 
larg  = 640;// document.body.offsetWidth - 100;
alt = 480; //larg / 1.5;
pos1 = (document.body.offsetWidth - larg) /2;
pos2 = ((document.body.offsetHeight - alt) /2 )+ 50;

if (!features)
	 features = 'toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=no,top='+ pos2 +',left=' +pos1 + ',screenY='+pos2+',screenX='+ pos1 +',width='+ larg + ',height=' +alt;
	 

  window.open('portal_framer.php?contents=' + theURL,winName,features);
}

//////////////////////////////////////////////////////////
function abreJanela2(theURL,winName) { 
larg  = 800;// document.body.offsetWidth - 100;
alt = 480; //larg / 1.5;
pos1 = (document.body.offsetWidth - larg) /2;
pos2 = ((document.body.offsetHeight - alt) /2 )+ 50;

	 features = 'toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=no,top='+ pos2 +',left=' +pos1 + ',screenY='+pos2+',screenX='+ pos1 +',width='+ larg + ',height=' +alt;
	 
  window.open(theURL,winName,features);
}

/////////////////////////////////////////////////////////

function abreJanelaBusca() { 
larg  = 640;// document.body.offsetWidth - 100;
alt = 480; //larg / 1.5;
pos1 = (document.body.offsetWidth - larg) /2;
pos2 = ((document.body.offsetHeight - alt) /2 )+ 50;

 features = 'toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=no,top='+ pos2 +',left=' +pos1 + ',screenY='+pos2+',screenX='+ pos1 +',width='+ larg + ',height=' +alt;
	 
  window.open('portal_framer.php?contents=busca.php','busca',features);
}


//////////////////////////////////////////////////
function recomende(ref){
larg  = 600;// document.body.offsetWidth - 100;
alt = 500; //larg / 1.5;
pos1 = (document.body.offsetWidth - larg) /2;
pos2 = ((document.body.offsetHeight - alt) /2 )+ 50;

features = 'toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=no,top='+ pos2 +',left=' +pos1 + ',screenY='+pos2+',screenX='+ pos1 +',width='+ larg + ',height=' +alt;
	 
  window.open('portal_recomende/index.php?REF=' + ref,'recomende',features);
}  

function amplia(url){
larg  = 640;// document.body.offsetWidth - 100;
alt = 480; //larg / 1.5;
pos1 = (document.body.offsetWidth - larg) /2;
pos2 = ((document.body.offsetHeight - alt) /2 )+ 50;

features = 'toolbar=no,location=no,directories=no,status=yes,menubar=yes,scrollbars=yes,resizable=yes,top='+ pos2 +',left=' +pos1 + ',screenY='+pos2+',screenX='+ pos1 +',width='+ larg + ',height=' +alt;
	 
  window.open(url,'pic',features);
}  