// JavaScript Document
function redirecionar(pag,iframe) {
	//SE ESTIVER EM UM IFRAME
	document.forms[0].btnVisualizar.disabled=true; 
    document.forms[0].btnVisualizar.value='Processando...';
	if(iframe == 1) {
		window.parent.location = pag;
	}//FECHA IF
	
	//SE ESTIVER EM UM IFRAME
	else if(iframe == 0) {
		alert('iframe: ' + iframe + ' pagina: ' + pag);
		window.location = pag;
	}//FECHA IF
	
	else{
		alert('nenhum - iframe: ' + iframe + ' pagina: ' + pag);
	}//FECHA IF
	
}//FECHA FUNCTION

function popup (a,b,bar,x,y) {
    vPosicao_X = ((screen.availWidth/2)-(x/2));
    vPosicao_Y = ((screen.availHeight/2)-(y/2));
	popwindow=window.open(a,b,'width=' + x + ',height=' + y + ',resizable=0,status=0,menubar=0,fullscreen=0,scrollbars=' + bar + ',top=' + vPosicao_Y + ',left=' + vPosicao_X);
	popwindow.focus();
}

function redimensionar(layer){
window.resizeBy(layer.offsetWidth-(document.body.clientWidth),layer.offsetHeight-(document.body.clientHeight));
}

function Mover(obj){
	obj.style.backgroundColor = '#CDDFF1';
}

function Mout(obj){
	obj.style.backgroundColor = '#B3CFEA';
}

function path(imagem,campo){
	var posfinal = imagem.lastIndexOf("\\");
	document.forms[0].document.getElementById(''+campo).value = imagem.substring(0,posfinal+1);
}

function recarrega(form,i){

    var myindex=document.getElementById('menu'+i).selectedIndex;

    location.href=(document.getElementById('menu'+i).options[myindex].value); 

}

function validar(campos){
	var ok=false;
	for (var i=0; i<campos.length; i++){
		if (document.forms[0].document.getElementById(campos[i]).value == "") {
			alert('Por favor, informe o '+campos[i]);
			document.forms[0].document.getElementById(campos[i]).focus();
			return false;
		} 
	}
}

function confirmar(pergunta){
	if (!confirm(pergunta)) {
		history.go(-1);
	}
}
function mascara_cep(cep){    // Esta eh a function que formata o cpf.
              var mycep = '';
              mycep = mycep + cep;
              if (mycep.length == 5){
                  mycep = mycep + '-';
                  document.forms[0].cep.value = mycep;
              }
              
}
function alturapagina() {
	return alturapagina = document.body.scrollHeight;
}
	
function mudatam() {
		var tamxvar = alturapagina();
		var aumento = 270;
		
		if (window.name=='imain') {
			if ( tamxvar <= aumento ) {
				tamxvar = aumento;
			}
			 top.document.getElementById('divcadusuario').height = parseInt(tamxvar);
			 top.document.all.imain.height = tamxvar;
		}
	}
	
	
	
// onClick="popup('<?=$lista_promocoes['url']?>?id_promocao=<?=$lista_promocoes['id_promocao']?>','promocao<?=$lista_promocoes['id_promocao']?>',0,200,200); return false;"
function popup (a,b,bar,x,y) {
    vPosicao_X = ((screen.availWidth/2)-(x/2));
    vPosicao_Y = ((screen.availHeight/2)-(y/2));
	popwindow=window.open(a,b,'width=' + x + ',height=' + y + ',resizable=0,status=0,menubar=0,fullscreen=0,scrollbars=' + bar + ',top=' + vPosicao_Y + ',left=' + vPosicao_X);
	popwindow.focus();
}

//<div id="cbody"></div> onLoad="redimensionar(cbody);"
function redimensionar(layer){
window.resizeBy(layer.offsetWidth-(document.body.clientWidth),layer.offsetHeight-(document.body.clientHeight));
}
