function abrirFotoAmpliada(url){
	window.open(url,"","toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=yes,width=360,height=450,left=20,top=20,screenX=20,screenY=20");
	
}

function mudaMascara(tipo, nomeFrm){
	if(tipo == 'cpf'){
		document.getElementById("campoPfPj").innerHTML = "<input type=\"text\" name=\"txtCpfCnpj\" class=\"textForm\" value=\"\" size=\"25\" maxlength=\"14\" onKeyPress=\"return formataCampo(document."+nomeFrm+", 'txtCpfCnpj', '999.999.999-99', event);\" />";
		formulario.addCampo('txtCpfCnpj','CPF' , 'cpf', false);
	}
	else if(tipo == 'cnpj'){
		document.getElementById("campoPfPj").innerHTML = "<input type=\"text\" name=\"txtCpfCnpj\" class=\"textForm\" value=\"\" size=\"25\" maxlength=\"18\" onKeyPress=\"return formataCampo(document."+nomeFrm+", 'txtCpfCnpj', '99.999.999/9999-99', event);\" />";
		formulario.addCampo('txtCpfCnpj','CNPJ' , 'cnpj', false);
	}
}

/***
* Descrio.: formata um campo do formulrio de
* acordo com a mscara informada...
* Parmetros: - objForm (o Objeto Form)
* - strField (string contendo o nome
* do textbox)
* - sMask (mascara que define o
* formato que o dado ser apresentado,
* usando o algarismo "9" para
* definir nmeros e o smbolo "!" para
* qualquer caracter...
* - evtKeyPress (evento)
* Uso.......: <input type="textbox"
* name="xxx".....
* onkeypress="return formataCampo(document.rcfDownload, \'str_cep\', \'99999-999\', event);">
* Observao: As mscaras podem ser representadas como os exemplos abaixo:
* CEP -> 99.999-999
* CPF -> 999.999.999-99
* CNPJ -> 99.999.999/9999-99
* Data -> 99/99/9999
* Tel Resid -> (99) 999-9999
* Tel Cel -> (99) 9999-9999
* Processo -> 99.999999999/999-99
* C/C -> 999999-!
***/
function formataCampo(objForm, strField, sMask, evtKeyPress) {
	var i, nCount, sValue, fldLen, mskLen,bolMask, sCod, nTecla;

	if(document.all) { // Internet Explorer
		nTecla = evtKeyPress.keyCode; }
	else {
	//if(document.layers) { // Nestcape
		nTecla = evtKeyPress.which;
	}
	
	sValue = objForm[strField].value;
	
	// Limpa todos os caracteres de formatao que
	// j estiverem no campo.
	sValue = sValue.toString().replace( "-", "" );
	sValue = sValue.toString().replace( "-", "" );
	sValue = sValue.toString().replace( ".", "" );
	sValue = sValue.toString().replace( ".", "" );
	sValue = sValue.toString().replace( "/", "" );
	sValue = sValue.toString().replace( "/", "" );
	sValue = sValue.toString().replace( "(", "" );
	sValue = sValue.toString().replace( "(", "" );
	sValue = sValue.toString().replace( ")", "" );
	sValue = sValue.toString().replace( ")", "" );
	sValue = sValue.toString().replace( " ", "" );
	sValue = sValue.toString().replace( " ", "" );
	fldLen = sValue.length;
	mskLen = sMask.length;
	
	i = 0;
	nCount = 0;
	sCod = "";
	mskLen = fldLen;
	
	// Caso seja pressionado backspace, ento ignora a verificao da mscara
	if (nTecla !=8){
	   while (i <= mskLen) {
		  bolMask = ((sMask.charAt(i) == "-") || (sMask.charAt(i) == ".") || (sMask.charAt(i) == "/"))
		  bolMask = bolMask || ((sMask.charAt(i) == "(") || (sMask.charAt(i) == ")") || (sMask.charAt(i) == " "))
	
		  if (bolMask) {
			 sCod += sMask.charAt(i);
			 mskLen++; 
		  } else {
			 sCod += sValue.charAt(nCount);
		     nCount++;
		  }
	
	       i++;
	   }	
		
	   objForm[strField].value = sCod;
	   
	}
	if (nTecla != 8) { // backspace
		if (sMask.charAt(i-1) == "9") { // apenas nmeros...
			return ((nTecla > 47) && (nTecla < 58)); 
		} // nmeros de 0 a 9
		else { // qualquer caracter...
			return true;
		} 
	} else {
		return true;
	}
}

function confirmarExclusao() {
	return confirm('Tem certeza que deseja excluir o item da Cesta?');
}

function confirmarExclusao2() {
	return confirm('Tem certeza que deseja cancelar a reserva?');
}

function trocaQuantidadeProduto(obj,id){
	var campo = 'qtd_'+id;
	var novaQtd = obj[campo].value;
	location.replace('carrinho.php?retorno=index.php&op=alteraQuantidade&idProduto='+id+'&novaQtd='+novaQtd);
}
function mostraBoleto(idNotavenda){
	// window.open('http://www.livrariahumanitas.com.br/boleto/?idNotavenda='+idNotavenda, 'Boleto Livraria Hum$acirc;nitas', 'toolbar=no, location=no, status=no, menubar=no, scrollbars=yes, resizable=yes, width=695, height=550, left=10, top=10, screenX=10, screenY=10');
	window.open('http://www.livrariahumanitas.com.br/boleto/?idNotavenda='+idNotavenda, '', 'toolbar=no, location=no, status=no, menubar=no, scrollbars=yes, resizable=yes, width=695, height=550, left=10, top=10, screenX=10, screenY=10');
}
function abrirJanela2(url, larg, alt){
	window.open(url, '', 'toolbar=no, location=no, status=no, menubar=no, scrollbars=yes, resizable=yes, width='+larg+', height='+alt+', left=20, top=20, screenX=20, screenY=20');
}
function abrirJanela3(url, larg, alt){
	window.open(url, '', 'toolbar=no, location=no, status=no, menubar=no, scrollbars=no, resizable=yes, width='+larg+', height='+alt+', left=20, top=20, screenX=20, screenY=20');
}