function openAjax() {
	var ajax;
	try{
            ajax = new XMLHttpRequest(); // XMLHttpRequest para Firefox, Safari, dentre outros.
	}catch(ee){
    	try{
        	ajax = new ActiveXObject("Msxml2.XMLHTTP"); // Para o Internet Explorer
    	}catch(e){
        	try{
                    ajax = new ActiveXObject("Microsoft.XMLHTTP"); // Para o Internet Explorer
        	}catch(E){
                    ajax = false;
        	}
    	}
    }
    return ajax;
}
//************************************************************************************************
function PassaValor(){
		
		var indice = document.frm_foto.cbo_lista.selectedIndex 
		var valor = document.frm_foto.cbo_lista.options[indice].value 
		var tamanho = document.frm_foto.cbo_lista.options[indice].text 
		document.frm_foto.txt_formato.value = tamanho;
		
		if(tamanho == ""){
			document.frm_foto.txt_preco.value = "";
			document.frm_foto.txt_preco.disabled = true;
			document.frm_foto.txt_hpreco.value = "";
			document.frm_foto.txt_qtde.value = "1";
		}
		if(tamanho == "Foto 13x18 - R$3,00"){
			document.frm_foto.txt_preco.value = "3,00";
			document.frm_foto.txt_preco.disabled = true;
			document.frm_foto.txt_hpreco.value = "3,00";
			document.frm_foto.txt_qtde.value = "1";
		}
		if(tamanho == "Foto 20x30 - R$7,00"){
			document.frm_foto.txt_preco.value = "7,00";
			document.frm_foto.txt_preco.disabled = true;
			document.frm_foto.txt_hpreco.value = "7,00";
			document.frm_foto.txt_qtde.value = "1";
		}
		if(tamanho == "Envio por Email - R$2,00"){
			document.frm_foto.txt_preco.value = "2,00";
			document.frm_foto.txt_preco.disabled = true;
			document.frm_foto.txt_hpreco.value = "2,00";
			document.frm_foto.txt_qtde.value = "1";
		}
		if(tamanho == "CD Alta Definição - R$80,00"){
			document.frm_foto.txt_preco.value = "80,00";
			document.frm_foto.txt_preco.disabled = true;
			document.frm_foto.txt_hpreco.value = "80,00";
			document.frm_foto.txt_qtde.value = "1";
		}
		if(tamanho == "Mouse Pad - R$25,00"){
			document.frm_foto.txt_preco.value = "25,00";
			document.frm_foto.txt_preco.disabled = true;
			document.frm_foto.txt_hpreco.value = "25,00";
			document.frm_foto.txt_qtde.value = "1";
		}
		if(tamanho == "Quebra-Cabeça 30x45 - R$45,00"){
			document.frm_foto.txt_preco.value = "45,00";
			document.frm_foto.txt_preco.disabled = true;
			document.frm_foto.txt_hpreco.value = "45,00";
			document.frm_foto.txt_qtde.value = "1";			
		}
		if(tamanho == "Jogo da Memória - R$55,00"){
			document.frm_foto.txt_preco.value = "55,00";
			document.frm_foto.txt_preco.disabled = true;
			document.frm_foto.txt_hpreco.value = "55,00";
			document.frm_foto.txt_qtde.value = "1";
		}
}
//************************************************************************************************
function CalculoQtde(){
		campoQtde = document.frm_foto.txt_qtde.value;
		
		if (campoQtde == ""){
			document.frm_foto.txt_preco.value = "";
			return false;
		}
	
		var qtde = eval("document.frm_foto.txt_qtde.value");
		var preco = eval("document.frm_foto.txt_hpreco.value").replace(",",".");
		var total = parseFloat(qtde) * parseFloat(preco);
		somando = (Math.round(total*100))/100;
		document.frm_foto.txt_preco.value = somando+",00"
}
//************************************************************************************************
function setUsuario(){
	var ResultadoProcesso = document.getElementById("status_proc");
	
	var nome    = document.getElementById("txt_nome").value;    //0
	var tel     = document.getElementById("txt_tel").value;		//1
	var end     = document.getElementById("txt_end").value;		//2
	var bairro  = document.getElementById("txt_bairro").value;	//3
	var cep     = document.getElementById("txt_cep").value;		//4
	var cidade  = document.getElementById("txt_cidade").value;	//5
	var uf      = document.getElementById("txt_uf").value;		//6
	var mail    = document.getElementById("id_email").value;	//7
	var usuario = document.getElementById("id_usuario").value;	//8
	var senha   = document.getElementById("txt_senha").value;	//9
	
	if(nome == ""){
		alert("Nome não preenchido!");
		document.getElementById("txt_nome").focus();
		return false;
	}
	if(tel == ""){
		alert("Tel não preenchido!");
		document.getElementById("txt_tel").focus();
		return false;
	}
	if(end == ""){
		alert("Endereço não preenchido!");
		document.getElementById("txt_end").focus();
		return false;
	}
	if(bairro == ""){
		alert("Bairro não preenchido!");
		document.getElementById("txt_bairro").focus();
		return false;
	}
	if(cep == ""){
		alert("Cep não preenchido!");
		document.getElementById("txt_cep").focus();
		return false;
	}
	if(cidade == ""){
		alert("Cidade não preenchido!");
		document.getElementById("txt_cidade").focus();
		return false;
	}
	if(uf == ""){
		alert("UF não preenchido!");
		document.getElementById("txt_uf").focus();
		return false;
	}
	if(mail == ""){
		alert("E-mail não preenchido!");
		document.getElementById("id_email").focus();
		return false;
	}
	if(usuario == ""){
		alert("Usuário não preenchido!");
		document.getElementById("id_usuario").focus();
		return false;
	}
	if(senha == ""){
		alert("Senha não pode ser vazia!");
		document.getElementById("txt_senha").focus();
		return false;
	}
	
		var ajax = openAjax(); 
		ajax.open("POST", "insert_cad.asp?nome="+nome+"&tel="+tel+"&end="+end+"&bairro="+bairro+"&cep="+cep+"&cidade="+cidade+"&uf="+uf+"&mail="+mail+"&usuario="+usuario+"&senha="+senha, true); 
		ajax.onreadystatechange = function(){
			if(ajax.readyState == 1){
				ResultadoProcesso.innerHTML = "Processando...";
			}
			if(ajax.readyState == 4){
				if(ajax.status == 200){
					var resultado = ajax.responseText;
					window.location = "index.asp";
				}else{
					ResultadoProcesso.innerHTML = "Erro Motor Interno";
				}
			}
		 }
		 ajax.send(null);
}
//**************************************************************************************************
function updateUsuario(){
	var ResultadoProcesso = document.getElementById("status_proc");
	
	var nome    = document.getElementById("txt_nome").value;    //0
	var tel     = document.getElementById("txt_tel").value;		//1
	var end     = document.getElementById("txt_end").value;		//2
	var bairro  = document.getElementById("txt_bairro").value;	//3
	var cep     = document.getElementById("txt_cep").value;		//4
	var cidade  = document.getElementById("txt_cidade").value;	//5
	var uf      = document.getElementById("txt_uf").value;		//6
	var mail    = document.getElementById("id_email").value;	//7
	var usuario = document.getElementById("id_usuario").value;	//8
	var senha   = document.getElementById("txt_senha").value;	//9
	
	if(nome == ""){
		alert("Nome não preenchido!");
		document.getElementById("txt_nome").focus();
		return false;
	}
	if(tel == ""){
		alert("Tel não preenchido!");
		document.getElementById("txt_tel").focus();
		return false;
	}
	if(end == ""){
		alert("Endereço não preenchido!");
		document.getElementById("txt_end").focus();
		return false;
	}
	if(bairro == ""){
		alert("Bairro não preenchido!");
		document.getElementById("txt_bairro").focus();
		return false;
	}
	if(cep == ""){
		alert("Cep não preenchido!");
		document.getElementById("txt_cep").focus();
		return false;
	}
	if(cidade == ""){
		alert("Cidade não preenchido!");
		document.getElementById("txt_cidade").focus();
		return false;
	}
	if(uf == ""){
		alert("UF não preenchido!");
		document.getElementById("txt_uf").focus();
		return false;
	}
	if(mail == ""){
		alert("E-mail não preenchido!");
		document.getElementById("id_email").focus();
		return false;
	}
	if(usuario == ""){
		alert("Usuário não preenchido!");
		document.getElementById("id_usuario").focus();
		return false;
	}
	if(senha == ""){
		alert("Senha não pode ser vazia!");
		document.getElementById("txt_senha").focus();
		return false;
	}
	
		var ajax = openAjax(); 
		ajax.open("POST", "update_cad.asp?nome="+nome+"&tel="+tel+"&end="+end+"&bairro="+bairro+"&cep="+cep+"&cidade="+cidade+"&uf="+uf+"&mail="+mail+"&usuario="+usuario+"&senha="+senha, true); 
		ajax.onreadystatechange = function(){
			if(ajax.readyState == 1){
				ResultadoProcesso.innerHTML = "Atualizando...";
			}
			if(ajax.readyState == 4){
				if(ajax.status == 200){
					var resultado = ajax.responseText;
					alert(resultado);
					window.location = "user.asp";
				}else{
					ResultadoProcesso.innerHTML = "Erro Motor Interno";
				}
			}
		 }
		 ajax.send(null);
}
//*************************************************************************************************
function setItem(caminho,w,h,id_user,pag,nomefesta,statuslogin){
	
	if(statuslogin == 0){
		window.location = "caduser.asp";
		return false;
	}else{
		
		formato = document.getElementById("id_formato").value
		qtde = document.frm_foto.txt_qtde.value
		precounit = document.getElementById("txt_hpreco").value
		precototal = document.getElementById("id_preco").value
		
		if(formato == ""){
			alert("Escolha um Tamanho!");
			return false;
		}
		if(qtde == "0" || qtde == ""){
			alert("Quantidade Inválida!");
			return false;
		}
	
		window.location = "carrinho.asp?id="+id_user+"&caminho="+caminho+"&w="+w+"&h="+h+"&formato="+formato+"&qtde="+qtde+"&precounit="+precounit+"&precototal="+precototal+"&pag="+pag+"&nomefesta="+nomefesta;
	}
}
//***********************************************************************************************
function AbrirFoto(img_path,w,h,id_festa,nomefesta,desconto,pag,id_user,anterior,proxima,numfoto){    
    window.location = "VisualizaFoto.asp?img_path="+img_path+"&w="+w+"&h="+h+"&pag="+pag+"&id_user="+id_user+"&desconto="+desconto+"&festa="+nomefesta+"&anterior="+anterior+"&proxima="+proxima+"&numfoto="+numfoto;
}
//***********************************************************************************************