//Pop-up
function abrePop(pPagina,pLargura,pAltura,pScroll){
  var posX
  var posY
  posX = (window.screen.width - pLargura - 16) / 2;
  posY = (window.screen.height - pAltura) / 2;
  var win = window.open(pPagina,"Popup","width=" + pLargura + ",height=" + pAltura + ",top=" + posY + ",left=" + posX + ",scrollbars=" + pScroll);
  win.focus();
}


//Pop-up Newsletter
function abrePopNewsletter(pPagina){
  var posX
  var posY
  posX = (window.screen.width - 395 - 16) / 2;
  posY = (window.screen.height - 222) / 2;
  var win = window.open(pPagina,"News","width=395,height=222,top=" + posY + ",left=" + posX);
  win.focus();
}


// Msg STATUS no Rodapé
window.status = 'BidêouBalde';


function changeItem(moduleName, id) {
	if ( moduleName && id ) {
		frmReloads.document.location.href = 'modulos_capa.xp.php?modulo='+ moduleName +'&id='+ id;
	}
}


function MostraVideo(id) {
	changeItem('videos', id);
}


function MostraNoticia(id) {
	changeItem('noticias', id);
}


function restore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function preload() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=preload.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function find(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=find(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function swap() { //v3.0
  var i,j=0,x,a=swap.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=find(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}



/************************************************************************************************
*	Autor: Carlos Eduardo Maciel																*
*	Descrição: centraliza uma janela															*
************************************************************************************************/
function fixPosition(w, h, mw, mh) {

	fixSize(w, h);

	// Verifica se a janela nao excedeu o tamanho maximo
	if (mw && window.width > mw) {
		w = mw
	}

	if (mh && window.height > mh) {
		h = mh
	}

	fixSize(w, h);

	if ( screen ) {

		lft = (screen.availWidth - intval(window.width))/2;
		tp = (screen.availHeight - intval(window.height))/2;

		// janelas normais
		if ( !window.dialogWidth ) {
			window.moveTo( lft , tp );

		// modal dialogs
		} else {
			window.dialogLeft = lft.toString() +'px';
			window.dialogTop = tp.toString() +'px';
		}

	}
}



/************************************************************************************************
*  Autor: Carlos Eduardo Maciel																	*
*  Descrição: resize de janelas e popups														*
************************************************************************************************/
var TYPE_IFRAME = 1;
var TYPE_POPUP  = 2;

function fixSize(w, h) {

	var wType = (window.opener ? TYPE_POPUP : TYPE_IFRAME);
	if( !w ) {
		w = document.body.scrollWidth + (wType == TYPE_POPUP ? 10 : 0);
	}
	if ( !h ) {
		h = document.body.scrollHeight + (wType == TYPE_POPUP ? 31 : 0);
	}

	try {
		// janelas normais
		if ( !window.dialogWidth) {
			window.resizeTo(w , h);

		// modal dialogs
		} else {
			window.dialogWidth = w.toString() +'px';
			window.dialogHeight = (h + 20).toString() +'px';
		}
		window.width = w;
		window.height = h;

	} catch (e) {
		//do nothing
	}
}


/************************************************************************
*	Autor: Carlos Eduardo Maciel
*	Descrição: retorna o valor inteiro de um determinado valor
************************************************************************/
function intval(v) {
	v = parseInt(v*1);
	if ( isNaN(v) ) v = 0;
	return v;
}

