
var browserName=navigator.appName; 
function obrigado(){
	document.getElementById("divForm").style.display = 'none'
	document.getElementById("divObrigado").style.display = ''
}


function alteraTipoRegisto(idGrupo){
	http.open('post', '../includes/registoCarregaFormulario.asp', true);
	http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	http.onreadystatechange = retornaConteudosIndividual;
	http.send('idGrupo='+ idGrupo);
}
function teste(){
	alert("teste")
}
function MM_findObj(n, d) { //v4.01
  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=MM_findObj(n,d.layers[i].document);
  
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function eventosOfertasEnviar(){
	if (document.getElementById("oferta").value == '0.00' || document.getElementById("oferta").value == '0'){
		alert("O valor da oferta tem que ser maior que 0")	
	}
	else
	{
		document.eventoOferta.onsubmit()
		document.getElementById("aguarde").style.display = 'none'
		document.getElementById("aguarde1").style.display = ''

	}
}
function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' deve conter um Email.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' deve conter um numero.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' deve conter um numero entre '+min+' e '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' é obrigatório.\n'; }
  } 
  if (errors) 
  {
	  alert('Ocorreram os seguintes erros:\n'+errors);
  }
  else
  {
  	document.criarAlbum.submit()
  }
  document.MM_returnValue = (errors == '');
}
function GenerateCodigo() {

    if (parseInt(navigator.appVersion) <= 3) {
        alert("Sorry this only works in 4.0+ browsers");
        return true;
    }
    var length=6;
    var sPassword = "";

    var noPunction = true;
    var randomLength = false;

    if (randomLength) {
        length = Math.random();

        length = parseInt(length * 100);
        length = (length % 7) + 6
    }
    for (i=0; i < length; i++) {

        numI = getRandomNum();
        if (noPunction) { while (checkPunc(numI)) { numI = getRandomNum(); } }

        sPassword = sPassword + String.fromCharCode(numI);
    }
    document.criarAlbum.codigo2.value = sPassword
	document.getElementById("divCodigo2").innerHTML = sPassword.toUpperCase()
    return true;
}
function getRandomNum() {

    // between 0 - 1
    var rndNum = Math.random()

    // rndNum from 0 - 1000
    rndNum = parseInt(rndNum * 1000);

    // rndNum from 33 - 127
    rndNum = (rndNum % 94) + 33;

    return rndNum;
}

function checkPunc(num) {

    if ((num >=33) && (num <=47)) { return true; }
    if ((num >=58) && (num <=64)) { return true; }
    if ((num >=91) && (num <=96)) { return true; }
    if ((num >=123) && (num <=126)) { return true; }

    return false;
}
function ver_obs(qual,imagem)
{
	if (document.getElementById(qual).style.display == 'none')
	{
		document.getElementById(imagem).src= '../imagens/menos.gif'
		document.getElementById(qual).style.display = '';
		setTimeout("changeheight1(document.getElementById('recebe').offsetHeight)",500);
	}
	else
	{
		document.getElementById(imagem).src= '../imagens/mais.gif'
		document.getElementById(qual).style.display = 'none';
		setTimeout("changeheight1(document.getElementById('recebe').offsetHeight)",500);
	}
}
function validarCarrinho2_1(url,idCliente){

		dados = document.verCarrinho.dados.value
		nomeEntrega = document.verCarrinho.nome.value
		moradaEntrega = document.verCarrinho.morada.value
		cpostal1Entrega = document.verCarrinho.cpostal1.value
		cpostal2Entrega = document.verCarrinho.cpostal2.value
		cidadeEntrega = document.verCarrinho.cidade.value
		paisEntrega = document.verCarrinho.pais.value
		locEntrega = document.verCarrinho.localizacao.value
		if (document.verCarrinho.tipoEntrega){
			tipoEntrega = document.verCarrinho.tipoEntrega.value
			idLoja = document.verCarrinho.idLoja.value
		}
		else{
			tipoEntrega = ''
			idLoja = ''
		}
		document.getElementById("fPAYPAL").src = '../includes/lab_saveProdutosPaypal.asp?idCliente='+idCliente+'&taxas='+document.verCarrinho.taxas.value+'&total='+ document.verCarrinho.total.value+'&valorDesconto='+ document.verCarrinho.valorDesconto.value + '&codigoP=' + document.verCarrinho.codigoP.value + '&tipoP=' + document.verCarrinho.tipoP.value + '&aviso=' + document.verCarrinho.aviso.value + '&dados=' + dados + '&nomeEntrega='+ escape(nomeEntrega) + '&moradaEntrega=' + escape(moradaEntrega) + '&cpostal1Entrega=' + cpostal1Entrega + '&cpostal2Entrega=' + cpostal2Entrega + '&cidadeEntrega=' + escape(cidadeEntrega) + '&paisEntrega=' + escape(paisEntrega) + '&locEntrega=' + locEntrega + '&tipoEntrega=' + tipoEntrega + '&idLoja=' + idLoja

}


function validarCarrinho2(tipoP){
	if (tipoP != 4){
		sendRequestPostFinalizarEncomenda('labFuncoes.asp', 'finalizarEncomenda', document.verCarrinho.taxas.value, document.verCarrinho.total.value, document.verCarrinho.tipoP.value, document.verCarrinho.aviso.value , document.verCarrinho.codigoP.value , document.verCarrinho.valorDesconto.value)
	}
	else
	{
		sendRequestPostFinalizarEncomenda('labFuncoes.asp', 'finalizarEncomenda', document.verCarrinho.taxas.value, document.verCarrinho.total.value, document.verCarrinho.tipoP.value, document.verCarrinho.aviso.value , document.verCarrinho.codigoP.value , document.verCarrinho.valorDesconto.value)
	}
}

// Set path to PHP script
	var phpscript = '../js/ajax.asp';
	
	
	function createRequestObject() {
	
		var req;
	
		if(window.XMLHttpRequest){
			// Firefox, Safari, Opera...
			req = new XMLHttpRequest();
		} else if(window.ActiveXObject) {
			// Internet Explorer 5+
			req = new ActiveXObject("Microsoft.XMLHTTP");
		} else {
			// There is an error creating the object,
			// just as an old browser is being used.
			alert('There was a problem creating the XMLHttpRequest object');
		}
	
		return req;
	
	}
	
	// Make the XMLHttpRequest object
	var http = createRequestObject();
	var http3 = createRequestObject();
	var vai

function cookieTestRegisto(onde){
	
	document.cookie='cookietest=ok'; 
	 if (document.cookie) {
		 if (onde==1){
			validaNovoRegisto()
		 }
		 if (onde==2){
			validaNovoRegistoEmpresa()
		 }
	}
	else 
	{
		alert("Para utilizar esta funcionalidade tem que ter o sistema de cookies activas no seu browser.")
	}
}
function carregarSaldo(){
	idPacote = document.saldoCarregamento.idPacote.value
	tipoPagamento = document.saldoCarregamento.tipoPagamento.value
	if (idPacote == '' || tipoPagamento == ''){
		alert("AVISO: Tem que escolher o Pacote e a forma de Pagamento.")
	}
	else{
		setTimeout("JavaToFlash('saldo')",2000);
		http.open('post', phpscript, true);
		http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		http.onreadystatechange = handleResponsePost;
		http.send('vai=labFuncoes.asp&action=saldoCarregamento&idPacote='+ idPacote + '&tipoPagamento=' + tipoPagamento );
	}
}

function produtosAssociados(idProduto){
	http.open('post', '../includes/produtosAssociados.asp', true);
	http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	http.onreadystatechange = handleResponsePost;
	http.send('idProduto='+ idProduto);
}

function ordenarProdutos(css,nivel,nivelID0,nivelID1,nivelID2,pagina,lingua) {
	var ordenar = document.getElementById("ordenar").value;
	var ordem = document.getElementById("ordem").value;
	http.open ("post","../includes/produtos.asp");
	http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	http.onreadystatechange = handleResponsePost;
	http.send("action=ordenar&ordenar="+ordenar+"&ordem="+ordem+"&css=" + css + "&nivel=" + nivel + "&nivelID0=" + nivelID0 + "&nivelID1=" + nivelID1 + "&nivelID2=" + nivelID2 + "&pagina=" + pagina + "&lingua=" + lingua);
}

function verFamilia(css,nivel) {
	var lingua = document.getElementById("lingua").value;
	http.open ("post","../includes/produtos.asp");
	http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	http.onreadystatechange = handleResponsePost;
	http.send("css=" + css + "&nivel=" + nivel + "&lingua=" + lingua);
}

	function sendRequestPost(vai1, css1, id_produto1, promo1, fazer1, codigo1_1, codigo2_2, username1, password1, pagina1, codeFriend) {
		window.focus();
		vai = vai1;
		
		var pagina = pagina1
		if (pagina){
		    
		}else{
		    pagina=''
		}
		if (codeFriend){
		    
		}else{
		    codeFriend=''
		}
		
		if (vai == 'registoNlogado.asp' || vai == 'labCarrinho1.asp'){
			if (document.verCarrinho){
				if (document.verCarrinho.formTotal){
						if (document.verCarrinho.formTotal.value == 0.00){
							alert("Introduza as respectivas quantidades que pretende encomendar.")
							return;
						}
				}
			}
			
		}
		if (vai == 'labCarrinho.asp' || vai == 'logout'){
			setTimeout("JavaToFlash('carro')",3000);
		}

		var css = css1;
		var id_produto = id_produto1;
		var promo = promo1;
		var fazer = fazer1;
		var codigo1 = codigo1_1;
		var codigo2 = codigo2_2;
		var username = username1;
		var password = password1;
		setTimeout("JavaToFlash('saldo')",2000);

		http.open('post', phpscript, true);
		http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		http.onreadystatechange = handleResponsePost;
		http.send('vai='+ vai + '&css='+ css + '&qual=' + id_produto + '&promo=' + promo + '&fazer=' + fazer + '&codigo1=' + codigo1 + '&codigo2=' + codigo2 + '&username=' + username + '&password=' + password + '&pagina=' + pagina+ '&codeFriend=' + codeFriend);
	}

	function sendRequestPostLabCarrinho1_1(vai,onde) {
		window.focus();
			var tipoP = ''
			if (document.verCarrinho.dados.value == 0){
				if (document.verCarrinho.nome.value == '' || document.verCarrinho.morada.value == '' || document.verCarrinho.cpostal1.value == '' || document.verCarrinho.cpostal2.value == '' || document.verCarrinho.cidade.value == '' || document.verCarrinho.pais.value == '' || document.verCarrinho.localizacao.value == 0){
					alert("Preencha todos os campos assinalados com *.")
					return;
				}else{
					dados = 0
					nomeEntrega = document.verCarrinho.nome.value
					moradaEntrega = document.verCarrinho.morada.value
					cpostal1Entrega = document.verCarrinho.cpostal1.value
					cpostal2Entrega = document.verCarrinho.cpostal2.value

					cidadeEntrega = document.verCarrinho.cidade.value
					paisEntrega = document.verCarrinho.pais.value
					locEntrega = document.verCarrinho.localizacao.value
				}
			}else{
				if (document.getElementById('confMorada')){
					if (document.getElementById('confMorada').checked){
						dados = 1
						nomeEntrega = ''
						moradaEntrega = ''
						cpostal1Entrega = ''
						cpostal2Entrega = ''
						cidadeEntrega = ''
						paisEntrega = ''
						locEntrega = ''
					}else{
						alert("Tem que confirmar a sua morada de entrega.\nAtenção moradas erradas poderão inviabilizar a entrega da sua encomenda.\nClique na caixa que se encontra á frente de CONFIRMAR.")
						return;
					}
				}
			}
			if (onde == 2){
				tipoP = document.verCarrinho.tipoP.value
			}
		setTimeout("JavaToFlash('saldo')",2000);
		http.open('post', vai, true);
		http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		http.onreadystatechange = handleResponsePost;
		http.send('dados=' + dados + '&nomeEntrega='+ escape(nomeEntrega) + '&moradaEntrega=' + escape(moradaEntrega) + '&cpostal1Entrega=' + cpostal1Entrega + '&cpostal2Entrega=' + cpostal2Entrega + '&cidadeEntrega=' + escape(cidadeEntrega) + '&paisEntrega=' + escape(paisEntrega) + '&locEntrega=' + locEntrega +'&tipoP=' + tipoP);
	}
	
	
	
	function sendRequestPostLabCarrinho1_2(vai,onde) {
		window.focus();
		var tipoP = ''
		dados = 1
		nomeEntrega = ''
		moradaEntrega = ''
		cpostal1Entrega = ''
		cpostal2Entrega = ''
		cidadeEntrega = ''
		paisEntrega = ''
		locEntrega = ''
		setTimeout("JavaToFlash('saldo')",2000);
		http.open('post', vai, true);
		http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		http.onreadystatechange = handleResponsePost;
		http.send('fotoDownload=1&dados=' + dados + '&nomeEntrega='+ nomeEntrega + '&moradaEntrega=' + moradaEntrega + '&cpostal1Entrega=' + cpostal1Entrega + '&cpostal2Entrega=' + cpostal2Entrega + '&cidadeEntrega=' + cidadeEntrega + '&paisEntrega=' + paisEntrega + '&locEntrega=' + locEntrega +'&tipoP=' + tipoP);
	}
	
	var varPortes
	var varPagamento
	var varTipoEntrega
	
	function sendRequestPostLabCarrinho2(vai,onde,varPortes1) {
		window.focus();
			var tipoP = ''
			varPortes = varPortes1
			if (document.verCarrinho.tipoP.value != 0 && document.verCarrinho.tipoEntrega.value != 0 && document.verCarrinho.idLoja.value != 0){
				if (document.verCarrinho.dados.value == 0){
					if (document.verCarrinho.nome.value == '' || document.verCarrinho.morada.value == '' || document.verCarrinho.cpostal1.value == '' || document.verCarrinho.cpostal2.value == '' || document.verCarrinho.cidade.value == '' || document.verCarrinho.pais.value == '' || document.verCarrinho.localizacao.value == 0){
						alert("Preencha todos os campos assinalados com *.")
						return;
					}else{
						dados = 0
						nomeEntrega = document.verCarrinho.nome.value
						moradaEntrega = document.verCarrinho.morada.value
						cpostal1Entrega = document.verCarrinho.cpostal1.value
						cpostal2Entrega = document.verCarrinho.cpostal2.value
						cidadeEntrega = document.verCarrinho.cidade.value
						paisEntrega = document.verCarrinho.pais.value
						locEntrega = document.verCarrinho.localizacao.value
					}
				}else{
						dados = 1
						nomeEntrega = ''
						moradaEntrega = ''
						cpostal1Entrega = ''
						cpostal2Entrega = ''
						cidadeEntrega = ''
						paisEntrega = ''
						locEntrega = ''
				}
				if (onde == 2){
					tipoP = document.verCarrinho.tipoP.value
					varPagamento = tipoP
					tipoEntrega = document.verCarrinho.tipoEntrega.value
					idLoja = document.verCarrinho.idLoja.value
					varTipoEntrega = tipoEntrega
				}
				setTimeout("JavaToFlash('saldo')",2000);
				http.open('post', vai, true);
				http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
				http.onreadystatechange = handleResponsePostCarrinho2;
				http.send('dados=' + dados + '&nomeEntrega='+ escape(nomeEntrega) + '&moradaEntrega=' + escape(moradaEntrega) + '&cpostal1Entrega=' + cpostal1Entrega + '&cpostal2Entrega=' + cpostal2Entrega + '&cidadeEntrega=' + escape(cidadeEntrega) + '&paisEntrega=' + escape(paisEntrega) + '&locEntrega=' + locEntrega +'&tipoP=' + tipoP +'&tipoEntrega=' + tipoEntrega +'&idLoja=' + idLoja);
			}
			else{
				if (document.verCarrinho.tipoP.value == 0){
					alert("Escolha o tipo de pagamento.")
				}
				else{
					if (document.verCarrinho.tipoEntregaPermissao.value == 1){
						if (document.verCarrinho.tipoEntrega.value == 0){
							alert("Escolha o tipo de entrega dos seus produtos.")
						}
						else{
							if (document.verCarrinho.idLoja.value == 0){
								alert("Escolha a loja onde pretende levantar a sua encomenda.")
							}
						}
					}
					else{
						setTimeout("JavaToFlash('saldo')",2000);
						http.open('post', vai, true);
						http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
						http.onreadystatechange = handleResponsePostCarrinho2;
					}
				}
			}
	}
	

	function sendRequestPostLabCarrinho2_1(vai,onde) {
		window.focus();
		var tipoP = ''
		dados = 1
		nomeEntrega = ''
		moradaEntrega = ''
		cpostal1Entrega = ''
		cpostal2Entrega = ''
		cidadeEntrega = ''
		paisEntrega = ''
		locEntrega = ''
		if (document.verCarrinho.tipoP.value != 0){
			if (onde == 2){
				tipoP = document.verCarrinho.tipoP.value
				varPagamento = tipoP
			}
			setTimeout("JavaToFlash('saldo')",2000);
			http.open('post', vai, true);
			http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			http.onreadystatechange = handleResponsePost;
			http.send('dados=' + dados + '&nomeEntrega='+ nomeEntrega + '&moradaEntrega=' + moradaEntrega + '&cpostal1Entrega=' + cpostal1Entrega + '&cpostal2Entrega=' + cpostal2Entrega + '&cidadeEntrega=' + cidadeEntrega + '&paisEntrega=' + paisEntrega + '&locEntrega=' + locEntrega +'&tipoP=' + tipoP);
		}
		else{
			alert("Escolha o tipo de pagamento.")
		}
	}


	function sendRequestPdetalhe(vai1, css1, id_produto1, promo1, fazer1, codigo1_1, codigo2_2, username1, password1) {
		window.focus();
		vai = vai1;
		var css = css1;
		var id_produto = id_produto1;
		var promo = promo1;
		var fazer = fazer1;
		var codigo1 = codigo1_1;
		var codigo2 = codigo2_2;
		var username = username1;
		var password = password1;
		setTimeout("JavaToFlash('saldo')",2000);
		http.open('post', phpscript, true);
		http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');

		http.onreadystatechange = handleResponsePost;
		
		http.send('vai='+ vai + '&css='+ css + '&qual=' + id_produto + '&promo=' + promo + '&fazer=' + fazer + '&codigo1=' + codigo1 + '&codigo2=' + codigo2 + '&username=' + username + '&password=' + password );
	}

	function sendRequestPostFORM(vai) {
		window.focus();
		var theData
		var eName
		var eValue
		for( var i=0; i<document.formulario.elements.length; i++ )
		{
			eName = document.formulario.elements[i].name;
			eValue = document.formulario.elements[i].value
			theData = theData + '&' + eName + '='+ eValue ;
		}
		setTimeout("JavaToFlash('saldo')",2000);
		http.open('post', '../includes/testeForm.asp', true);
		http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		
		http.onreadystatechange = handleResponsePost;
		
		http.send(theData);
	
	}

	function sendRequestPostCA(vai1, css1, id_produto1, promo1, fazer1, codigo1_1, codigo2_2, username1, password1) {
		window.focus();
		vai = vai1;
		var css = css1;
		var id_produto = id_produto1;
		var promo = promo1;
		var fazer = fazer1;
		var codigo1 = codigo1_1;
		var codigo2 = codigo2_2;
		var username = username1;
		var password = password1;
		setTimeout("JavaToFlash('saldo')",2000);
		/*
		alert (vai);
		alert (css);
		alert (id_produto);
		*/
		// Open PHP script for requests
		http.open('post', phpscript, true);
		http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		http.onreadystatechange = handleResponsePostCA;
		http.send('vai='+ vai + '&css='+ css + '&qual=' + id_produto + '&promo=' + promo + '&fazer=' + fazer + '&codigo1=' + codigo1 + '&codigo2=' + codigo2 + '&username=' + username + '&password=' + password );
	
	}

	function handleResponsePost() {
		if(http.readyState == 1){
			window.scrollBy(0,-11000);
			document.getElementById("recebe").innerHTML = "" ;
			document.getElementById("carrega").style.visibility="visible";
		}
		else if(http.readyState == 4){
			if(http.status == 200){
				var response = http.responseText;
				if(response) {
					document.getElementById("recebe").style.visibility="visible";
					document.getElementById("recebe").innerHTML = response;
					var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1", "zip_code", {validateOn:["blur"], format:"zip_custom", pattern:"0000-000", useCharacterMasking:true, isRequired:false});
var sprytextfield2 = new Spry.Widget.ValidationTextField("sprytextfield2", "email", {hint:"DSAD SADA DA", isRequired:false, useCharacterMasking:true, validateOn:["change"]});
var sprytextfield3 = new Spry.Widget.ValidationTextField("sprytextfield3");

					if (vai=='labCarrinho.asp'){
						setTimeout("JavaToFlash('saldo')",3000);
					}
					JavaToFlash('carro')
					novo_conteudo = document.getElementById("recebe");
					h = novo_conteudo.offsetHeight;
					setTimeout("changeheight1(h)",1000);
					document.getElementById("carrega").style.visibility="hidden";
				}
			}
			else{
				var response = http.responseText;
				document.getElementById("recebe").innerHTML = response;
				document.getElementById("carrega").style.visibility="hidden";
			}
		}
	}
	function handleResponsePostCarrinho2() {
	if(http.readyState == 1){
		window.scrollBy(0,-11000);
		document.getElementById("recebe").innerHTML = "" ;
		document.getElementById("carrega").style.visibility="visible";
		}
		else if(http.readyState == 4 ){
			if(http.status == 200){
				var response = http.responseText;
				if(response) {
					document.getElementById("recebe").style.visibility="hidden";
					document.getElementById("recebe").innerHTML = response;
					if (varTipoEntrega == 1){
						calculaPortes(varPortes)
					}
					if (varTipoEntrega == 2){

						if (document.getElementById("DIVsaldoUtilizado")){
							saldoApos = roundNumber(document.getElementById("saldoActual").value) - (roundNumber(document.getElementById("formTotal").value)); 
							total1 = roundNumber(document.getElementById("formTotal").value);
							document.getElementById("DIVsaldoUtilizado").innerHTML = roundNumber(total1)  + "&nbsp;€"
							document.getElementById("DIVsaldoApos").innerHTML = roundNumber(saldoApos)  + "&nbsp;€"
							if (saldoApos >= 0){
								document.getElementById("txtSaldo").style.display = 'none'
								document.getElementById("botAlterarTipoP").style.display = 'none'
								document.getElementById("tabPagamentos").style.display = ''
								document.getElementById("tabAvisos").style.display = ''
								document.getElementById("botFinalizar").style.display = ''
								document.getElementById("DIVsaldoApos").style.color='#00CC00'
							}
							else{
								document.getElementById("txtSaldo").style.display = ''
								document.getElementById("botAlterarTipoP").style.display = ''
								document.getElementById("tabPagamentos").style.display = 'none'
								document.getElementById("tabAvisos").style.display = 'none'
								document.getElementById("botFinalizar").style.display = 'none'
								document.getElementById("DIVsaldoApos").style.color='#FF0000'
							}
							
						}
					}


					novo_conteudo = document.getElementById("recebe");
					h = novo_conteudo.offsetHeight;
					setTimeout("changeheight1(h)",1000);
					document.getElementById("carrega").style.visibility="hidden";
				}
			}
			else{
				var response = http.responseText;
				document.getElementById("recebe").innerHTML = response;
				document.getElementById("carrega").style.visibility="hidden";
			}
		}
			
	}

	function handleResponsePostCA() {
	if(http.readyState == 1){
		window.scrollBy(0,-11000);
		document.getElementById("recebe").innerHTML = "" ;
		
		document.getElementById("carrega").style.visibility="visible";
		}
		else if(http.readyState == 4){
			if(http.status == 200){
				var response = http.responseText;
				if(response) {
						document.getElementById("recebe").style.visibility="hidden";
						document.getElementById("recebe").innerHTML = response;
						GenerateCodigo()
						var arVersion = navigator.appVersion.split("MSIE")
						var version = parseFloat(arVersion[1])
						if ((version >= 5.5) && (document.body.filters)) 
						{
						   for(var i=0; i<document.images.length; i++)
						   {
							  var img = document.images[i]
							  var imgName = img.src.toUpperCase()
							  if (imgName.substring(imgName.length-3, imgName.length) == "PNG")

							  {
								 var imgID = (img.id) ? "id='" + img.id + "' " : ""
								 var imgClass = (img.className) ? "class='" + img.className + "' " : ""
								 var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
								 var imgStyle = "display:inline-block;" + img.style.cssText 
								 if (img.align == "left") imgStyle = "float:left;" + imgStyle
								 if (img.align == "right") imgStyle = "float:right;" + imgStyle
								 if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
								 var strNewHTML = "<span " + imgID + imgClass + imgTitle
								 + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
								 + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
								 + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
								 img.outerHTML = strNewHTML
								 i = i-1
							  }
						   }
						}
						novo_conteudo = document.getElementById("recebe");
						h = novo_conteudo.offsetHeight;
						setTimeout("changeheight1(h)",800);
						document.getElementById("carrega").style.visibility="hidden";
				}
			}
			else{
				var response = http.responseText;
				document.getElementById("recebe").innerHTML = response;
				document.getElementById("carrega").style.visibility="hidden";
			}
		}	
	}
	
// FICHA CLIENTE

function sendRequestPostFichaCliente(vai, fazer, nome, apelido, morada, cpostal1, cpostal2, cidade, pais, telefone, telemovel, fax, email, nif, sexo, newsletter, localizacao, estadoCivil) {
		window.focus();
		setTimeout("JavaToFlash('saldo')",2000);
		http.open('post', phpscript, true);
		http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		http.onreadystatechange = handleResponsePost;
		http.send('vai='+ vai + '&fazer='+ fazer + '&nome=' + escape(nome) + '&apelido=' + escape(apelido) + '&morada=' + escape(morada) + '&cpostal1=' + cpostal1 + '&cpostal2=' + cpostal2 + '&cidade=' + escape(cidade) + '&pais=' + escape(pais) + '&telefone=' + telefone+ '&telemovel=' + telemovel+ '&fax=' + fax+ '&email=' + email+ '&nif=' + nif + '&sexo=' + sexo + '&newsletter=' + newsletter + '&localizacao=' + localizacao + '&estadoCivil=' + estadoCivil );
	}

	function sendRequestPostFinalizarEncomenda(vai, fazer, taxas, total, pagamento, aviso, codigoP, valorDesconto) {
		setTimeout("JavaToFlash('saldo')",2000);
		window.focus();
		dados = document.verCarrinho.dados.value
		nomeEntrega = document.verCarrinho.nome.value
		moradaEntrega = document.verCarrinho.morada.value
		cpostal1Entrega = document.verCarrinho.cpostal1.value
		cpostal2Entrega = document.verCarrinho.cpostal2.value
		cidadeEntrega = document.verCarrinho.cidade.value
		paisEntrega = document.verCarrinho.pais.value
		locEntrega = document.verCarrinho.localizacao.value
		if (document.verCarrinho.tipoEntrega){
			tipoEntrega = document.verCarrinho.tipoEntrega.value
			idLoja = document.verCarrinho.idLoja.value
		}
		else{
			tipoEntrega = ''
			idLoja = ''
		}
		http.open('post', phpscript, true);
		http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		http.onreadystatechange = handleResponsePost;
		http.send('vai='+ vai + '&action='+ fazer + '&taxas=' + taxas + '&total=' + total + '&tipoP=' + pagamento + '&aviso=' + aviso + '&codigoP=' + codigoP + '&valorDesconto=' + valorDesconto + '&dados=' + dados + '&nomeEntrega='+ escape(nomeEntrega) + '&moradaEntrega=' + escape(moradaEntrega) + '&cpostal1Entrega=' + cpostal1Entrega + '&cpostal2Entrega=' + cpostal2Entrega + '&cidadeEntrega=' + escape(cidadeEntrega) + '&paisEntrega=' + escape(paisEntrega) + '&locEntrega=' + locEntrega + '&tipoEntrega=' + tipoEntrega + '&idLoja=' + idLoja);
	}
	function sendRequestPostLogin(vai, fazer, username, password, url, codigo, accao, idProduto, promocao) {
		
		document.cookie='cookietest=ok'; 
		 if (document.cookie) {
			setTimeout("JavaToFlash('login')",3000);
			window.focus();
			http.open('post', phpscript, true);
			http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			http.onreadystatechange = handleResponsePost;
			http.send('vai='+ vai + '&fazer='+ fazer + '&username=' + escape(username) + '&password=' + escape(password) + '&url=' + url + '&codigo=' + codigo + '&action=' + accao + '&idProduto=' + idProduto + '&promocao=' + promocao);
		}
		else 
		{
			alert("Para utilizar esta funcionalidade tem que ter o sistema cookies activas no seu browser.")
		}

	}
	function loginHeader(username,password) {
		document.cookie='cookietest=ok'; 
		 if (document.cookie) {
			setTimeout("JavaToFlash('login')",1500);
			window.focus();
			http.open('post', '../includes/funcoes.asp', true);
			http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			http.onreadystatechange = handleResponsePost;
			http.send('fazer=loginHeader&username=' + escape(username) + '&password=' + escape(password) + '&url=indexUser.asp');
		}
		else 
		{
			alert("Para utilizar esta funcionalidade tem que ter o sistema cookies activas no seu browser.")
		}

	}
	function sendRequestPostNlogadoProduto(vai, redirect, idLinha, promocao, fazer) {
		window.focus();
		http.open('post', phpscript, true);
		http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		http.onreadystatechange = handleResponsePost;
		http.send('vai='+ vai + '&css='+ redirect + '&qual=' + idLinha + '&promocao=' + promocao + '&fazer=' + fazer);
	}

	// NOVOREGISTO

	function sendRequestPostNovoRegisto(vai, fazer, url, codigoAmigo, nome, apelido, morada, cpostal1, cpostal2, cidade, pais, localizacao, telefone, telemovel, fax, email ,estadoCivil, nif, dia, mes, ano, sexo, newsletter, username, password, password1) {
		window.focus();
		setTimeout("JavaToFlash('saldo')",2000);
		setTimeout("JavaToFlash('login')",3000);
		http.open('post', phpscript, true);
		http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		http.onreadystatechange = handleResponsePost;
		http.send('vai='+ vai + '&fazer='+ fazer + '&url='+ url + '&codigoAmigo=' + codigoAmigo + '&nome=' + escape(nome) + '&apelido=' + escape(apelido) + '&morada=' + escape(morada) + '&cpostal1=' + cpostal1 + '&cpostal2=' + cpostal2 + '&cidade=' + escape(cidade) + '&pais=' + escape(pais) + '&localizacao=' + localizacao + '&telefone=' + telefone+ '&telemovel=' + telemovel+ '&fax=' + fax+ '&email=' + email+ '&estadoCivil=' + estadoCivil+ '&nif=' + nif + '&dia=' + dia + '&mes=' + mes + '&ano=' + ano + '&sexo=' + sexo+ '&newsletter=' + newsletter + '&username=' + username + '&password=' + password + '&password1=' + password1 );
		
	}
	function sendRequestPostNovoRegistoEmpresa(vai, fazer, url, empresa, nome, apelido, morada, cpostal1, cpostal2, cidade, pais, localizacao, telefone, telemovel, fax, email , nif, newsletter,username) {
		window.focus();
		setTimeout("JavaToFlash('saldo')",2000);
		http.open('post', phpscript, true);
		http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		http.onreadystatechange = handleResponsePost;
		http.send('vai='+ vai + '&fazer='+ fazer + '&url='+ url + '&empresa=' + escape(empresa) + '&nome=' + escape(nome) + '&apelido=' + escape(apelido) + '&morada=' + escape(morada) + '&cpostal1=' + cpostal1 + '&cpostal2=' + cpostal2 + '&cidade=' + escape(cidade) + '&pais=' + escape(pais) + '&localizacao=' + localizacao + '&telefone=' + telefone+ '&telemovel=' + telemovel+ '&fax=' + fax+ '&email=' + email + '&nif=' + nif + '&newsletter=' + newsletter + '&username=' + username);
	}
	


	function validaNovoRegisto(){
		var erro = 0

		if (document.novoRegisto.nome.value == ''){ erro = 1}
		//if (document.novoRegisto.apelido.value == ''){ erro = 1}
		if (document.novoRegisto.morada.value == ''){ erro = 1}
		if (document.novoRegisto.cpostal1.value == ''){	erro = 1}
		
		if (document.novoRegisto.cidade.value == ''){ erro = 1}
		if (document.novoRegisto.pais.value == ''){	erro = 1}
		if (document.novoRegisto.telefone.value == ''){ erro = 1}
		if (document.novoRegisto.email.value == ''){ erro = 1}
		if (document.novoRegisto.estadoCivil.value == ''){ erro = 1}
		if (document.novoRegisto.username.value == ''){	erro = 1}
		if (document.novoRegisto.password.value == ''){ erro = 1}
		
		if (document.novoRegisto.password1.value != document.novoRegisto.password.value){ erro = 2}
		if (erro == 0){
			document.getElementById("tr1").style.display = 'none'
			document.getElementById("tr2").style.display = ''
			document.novoRegisto.onsubmit();
			//sendRequestPostNovoRegisto('funcoes','registo','labCarrinho.asp',document.novoRegisto.codigoAmigo.value,document.novoRegisto.nome.value,document.novoRegisto.apelido.value,document.novoRegisto.morada.value,document.novoRegisto.cpostal1.value,document.novoRegisto.cpostal2.value,document.novoRegisto.cidade.value,document.novoRegisto.pais.value,document.novoRegisto.localizacao.value,document.novoRegisto.telefone.value,document.novoRegisto.telemovel.value,document.novoRegisto.fax.value,document.novoRegisto.email.value,document.novoRegisto.estadoCivil.value,document.novoRegisto.nif.value,document.novoRegisto.dia.value,document.novoRegisto.mes.value,document.novoRegisto.ano.value,document.novoRegisto.sexo.value,document.novoRegisto.newsletter.value,document.novoRegisto.username.value,document.novoRegisto.password.value,document.novoRegisto.password1.value)
		}
		if (erro == 1)
		{
			document.getElementById("txtErro").innerHTML = 'Preencha os campos assinalados com *'
			window.scrollBy(0,-100);
		}
		if (erro == 2)
		{
			document.getElementById("txtErro").innerHTML = 'As passwords que introduziu são diferentes'
			window.scrollBy(0,-100);
		}
	}
	function validaNovoRegistoEmpresa(){
		var erro = 0
		
		if (document.novoRegisto.empresa.value == ''){ erro = 1}
		if (document.novoRegisto.nome.value == ''){ erro = 1}
		//if (document.novoRegisto.apelido.value == ''){ erro = 1}
		if (document.novoRegisto.morada.value == ''){ erro = 1}
		if (document.novoRegisto.cpostal1.value == ''){	erro = 1}
		if (document.novoRegisto.cpostal2.value == ''){ erro = 1}
		if (document.novoRegisto.cidade.value == ''){ erro = 1}
		if (document.novoRegisto.pais.value == ''){	erro = 1}
		if (document.novoRegisto.telefone.value == ''){ erro = 1}
		if (document.novoRegisto.email.value == ''){ erro = 1}
		
		if (erro == 0){
			document.novoRegisto.onsubmit()
			//sendRequestPostNovoRegistoEmpresa('funcoes','registoEmpresa','registoSucessoEmpresa.asp',document.novoRegisto.Eempresa.value,document.novoRegisto.Enome.value,document.novoRegisto.Eapelido.value,document.novoRegisto.Emorada.value,document.novoRegisto.Ecpostal1.value,document.novoRegisto.Ecpostal2.value,document.novoRegisto.Ecidade.value,document.novoRegisto.Epais.value,document.novoRegisto.Elocalizacao.value,document.novoRegisto.Etelefone.value,document.novoRegisto.Etelemovel.value,document.novoRegisto.Efax.value,document.novoRegisto.Eemail.value,document.novoRegisto.Enif.value,document.novoRegisto.newsletterE.value,document.novoRegisto.Eusername.value)
		}
		if (erro == 1)
		{
			document.getElementById("txtErro").innerHTML = 'Preencha os campos assinalados com *'
			window.scrollBy(0,-100);
		}
	}
	function sendRequestPostPaginacao(vai, idEvento, pagina) {
		window.focus();
		setTimeout("JavaToFlash('saldo')",2000);
		http.open('post', phpscript, true);
		http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		http.onreadystatechange = handleResponsePost;
		http.send('vai='+ vai + '&qual='+ idEvento + '&pagina='+ pagina);
	}
	function sendRequestPostPaginacaoAlbuns(vai, idAlbum, pagina) {
		window.focus();
		setTimeout("JavaToFlash('saldo')",2000);
		http.open('post', phpscript, true);
		http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		http.onreadystatechange = handleResponsePost;
		http.send('vai='+ vai + '&qual='+ idAlbum + '&pagina='+ pagina);
	}
	function sendRequestPostAddFotosEvento(vai, idEvento, fazer, idFoto) {
		window.focus();
		setTimeout("JavaToFlash('saldo')",2000);
		http.open('post', phpscript, true);
		http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		http.onreadystatechange = handleResponsePost;
		http.send('vai='+ vai + '&idEvento='+ idEvento + '&fazer='+ fazer + '&idFoto='+ idFoto);
		JavaToFlash('barra');
	}
	function sendRequestPostAddFotosEventoAlbum(idEvento, fazer, idFoto) {
		window.focus();
		setTimeout("JavaToFlash('saldo')",2000);
		http.open('post', '../includes/evAlbumFotos.asp', true);
		http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		http.onreadystatechange = handleResponsePost;
		http.send('idEvento='+ idEvento + '&fazer='+ fazer + '&idFoto='+ idFoto);
		JavaToFlash('barra');
	}
	///////////////////////
	function sendRequestPostSelFotosAlbum(vai, idEvento, fazer, idFoto) {
		window.focus();
		if (Math.abs(document.getElementById("fotoSel").value) > Math.abs(document.getElementById("maxFotos").value)){
			alert("Só pode selecionar um maximo de "+document.getElementById("maxFotos").value+" fotografias")
		}
		else{
			setTimeout("JavaToFlash('saldo')",2000);
			http.open('post', '../includes/ev_eventosFotosAlbumSel.asp', true);
			http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			http.onreadystatechange = handleResponsePost;
			http.send('qual='+ idEvento + '&fazer=addFotosEventoAlbum');
		}
	}
	function sendRequestPostDelFotosAlbum(idEvento, idFoto) {
		window.focus();
		setTimeout("JavaToFlash('saldo')",2000);
		http.open('post', '../includes/ev_eventosFotosAlbumSel.asp', true);
		http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		http.onreadystatechange = handleResponsePost;
		http.send('qual='+ idEvento + '&fazer=delFoto&idFoto='+idFoto);
	}
	function sendRequestPostValidaFotosAlbum(idEvento) {
		window.focus();
		var inf = document.getElementById("inf").value
		http.open('post', '../includes/ev_eventosFotosAlbumSelFinal.asp', true);
		http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		http.onreadystatechange = handleResponsePost;
		http.send('qual='+ idEvento + '&fazer=validaAlbum&inf='+escape(inf));
	}
	/////////////////
	function sendRequestPostAddFotosAlbuns(vai, idAlbum, fazer, papel ,idFoto) {
		window.focus();
		setTimeout("JavaToFlash('saldo')",2000);
		http.open('post', phpscript, true);
		http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		http.onreadystatechange = handleResponsePost;
		http.send('vai='+ vai + '&idAlbum='+ idAlbum + '&fazer='+ fazer + '&idFoto='+ idFoto + '&papel='+ papel);
		JavaToFlash('barra');
	}
	function sendRequestPostCriarAlbum(vai, fazer, nomeAlbum, descAlbum, codigo1, codigo2, idAlbum) {
		window.focus();
		setTimeout("JavaToFlash('saldo')",2000);
		http.open('post', phpscript, true);
		http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		http.onreadystatechange = handleResponsePost;
		http.send('vai='+ vai + '&action='+ fazer + '&nomeAlbum='+ escape(nomeAlbum) + '&descAlbum='+ escape(descAlbum) + '&codigo1='+ codigo1 + '&codigo2='+ codigo2 + '&idAlbum='+ idAlbum);
	}
	function sendRequestPostApagarAlbum(vai, fazer, idAlbum) {
	if (confirm("Tem a certeza que deseja apagar este album?") == true) 
		{
		setTimeout("JavaToFlash('saldo')",2000);
		window.focus();
		http.open('post', phpscript, true);
		http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		http.onreadystatechange = handleResponsePost;
		http.send('vai='+ vai + '&action='+ fazer + '&idAlbum='+ idAlbum);
		JavaToFlash('barra');
		}
	}
	function sendRequestPostApagarFotoAlbum(vai, fazer, idAlbum, idFoto) {
	if (confirm("Tem a certeza que deseja apagar esta foto do album?") == true) 
		{
			setTimeout("JavaToFlash('saldo')",2000);
			window.focus();
			http.open('post', phpscript, true);
			http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			http.onreadystatechange = handleResponsePost;
			http.send('vai='+ vai + '&action='+ fazer + '&idAlbum='+ idAlbum + '&idFoto='+ idFoto);
			JavaToFlash('barra');
		}
	}
	
	function sendRequestPostApagarFotosAlbuns(vai, fazer, idAlbum) {
	if (confirm("Tem a certeza que deseja apagar as fotos selecionadas?") == true) 
		{
			setTimeout("JavaToFlash('saldo')",2000);
			window.focus();
			http.open('post', phpscript, true);
			http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			http.onreadystatechange = handleResponsePost;
			http.send('vai='+ vai + '&action='+ fazer + '&idAlbum='+ idAlbum);
			JavaToFlash('barra');
		}
	}
	
	function sendRequestPostEnviarMsg(vai, fazer, assunto, mensagem) {
		window.focus();
		setTimeout("JavaToFlash('saldo')",2000);
		for (i=0 ; i < assunto.length; i++){ assunto = assunto.replace(/ /,"%20"); }
		for (i=0 ; i < mensagem.length; i++){ mensagem = mensagem.replace(/ /,"%20"); }
		http.open('post', phpscript, true);
		http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		http.onreadystatechange = handleResponsePost;
		http.send('vai='+ vai + '&fazer='+ fazer + '&assunto='+ assunto + '&mensagem='+ mensagem);
	}
	function sendRequestPostVerMsg(vai, idMsg) {
		window.focus();
		setTimeout("JavaToFlash('saldo')",2000);
		http.open('post', phpscript, true);
		http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		http.onreadystatechange = handleResponsePost;
		http.send('vai='+ vai + '&idMsg='+ idMsg);
	}
	function sendRequestPostDelMsg(vai, fazer ,idMsg) {
	if (confirm("Tem a certeza que deseja apagar esta mensagem?") == true) 
		{
			setTimeout("JavaToFlash('saldo')",2000);
		window.focus();
		http.open('post', phpscript, true);
		http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		http.onreadystatechange = handleResponsePost;
		http.send('vai='+ vai + '&fazer='+ fazer + '&idMsg='+ idMsg);
		}
	}
	function sendRequestPostaddEvento(vai, fazer, codigo) {
		window.focus();
		setTimeout("JavaToFlash('saldo')",2000);
		if(codigo){
		}else{
			codigo = document.getElementById("codigo").value
		}
		//codigo = document.getElementById("codigo"+i).value
		http.open('post', phpscript, true);
		http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		http.onreadystatechange = handleResponsePost;
		http.send('vai='+ vai + '&fazer='+ fazer + '&codigo='+ codigo);
	}
	function sendRequestPostaddEvento1(vai, fazer, i) {
		window.focus();
		setTimeout("JavaToFlash('saldo')",2000);
		codigo = document.getElementById("codigo"+i).value
		http.open('post', phpscript, true);
		http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		http.onreadystatechange = handleResponsePost;
		http.send('vai='+ vai + '&fazer='+ fazer + '&codigo='+ codigo);
	}
	
	function sendRequestPostPesquisar(vai, txtPesquisa) {
		window.focus();
		setTimeout("JavaToFlash('saldo')",2000);
		http.open('post', phpscript, true);
		http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		http.onreadystatechange = handleResponsePost;
		//for (i=0 ; i < txtPesquisa.length; i++){ txtPesquisa = txtPesquisa.replace(/ /,"%20"); }
		http.send('vai='+ vai + '&pesquisa='+ escape(txtPesquisa));
	}
	function sendRequestPostPaginacaoPesquisa(vai, txtPesquisa111, pagina) {
		window.focus();
		setTimeout("JavaToFlash('saldo')",2000);
		http.open('post', phpscript, true);
		http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		http.onreadystatechange = handleResponsePost;
		txtPesquisa2 = document.getElementById("txtPesquisa").value
		http.send('vai='+ vai + '&pesquisa='+ escape(txtPesquisa2) + '&pagina='+ pagina);
	}
	function sendRequestPostPaginacaoAssociados(idProduto, pagina) {
		window.focus();
		setTimeout("JavaToFlash('saldo')",2000);
		http.open('post', '../includes/produtosAssociados.asp', true);
		http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		http.onreadystatechange = handleResponsePost;
		http.send('idProduto='+ idProduto + '&pagina='+ pagina);
	}
	function sendRequestPostPaginacaoProdutosDNP(vai, onde, pagina) {
		window.focus();
		setTimeout("JavaToFlash('saldo')",2000);
		http.open('post', phpscript, true);
		http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		http.onreadystatechange = handleResponsePost;
		http.send('vai='+ vai + '&qual='+ onde + '&pagina='+ pagina);
	}

	function sendRequestPostPaginacaoProdutos(vai, css, pagina) {
		window.focus();
		setTimeout("JavaToFlash('saldo')",2000);
		http.open('post', phpscript, true);
		http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		http.onreadystatechange = handleResponsePost;
		http.send('vai='+ vai + '&css='+ css + '&pagina='+ pagina);
	}
	function sendRequestPostPaginacaoCarrinho(vai, pagina, tamanhoPagina, tipoP, tipoEntrega, idLoja, qual, dados) {
		window.focus();
		if (tipoEntrega){
			varTipoEntrega = tipoEntrega ;
		}
		if (tipoP){
			
		}
		else{
			tipoP=''
		}
		var i;
		var inteiro = 1
		for (i = 0; i < tamanhoPagina.length; i++)
		{   
			// Check that current character is number.
			var c = tamanhoPagina.charAt(i);
			if (((c < "0") || (c > "9"))){
				var inteiro = 0
			}

		}
		if (inteiro==0){
			document.getElementById("tamanhoPagina").value = document.getElementById("tamanhoPaginaOLD").value
			document.getElementById("tamanhoPagina1").value = document.getElementById("tamanhoPaginaOLD").value
			alert("Caracter Inválido!")
		}
		else
		{
			setTimeout("JavaToFlash('saldo')",2000);
			http.open('post', '../includes/'+vai, true);
			http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			if (vai=='labCarrinho2.asp'){
				http.onreadystatechange = handleResponsePostCarrinho2;
			}
			else{
				http.onreadystatechange = handleResponsePost;
			}
			http.send('vai='+ vai  + '&pagina='+ pagina + '&tamanhoPagina='+ tamanhoPagina + '&tipoP='+ tipoP + '&tipoEntrega='+ tipoEntrega + '&idLoja='+ idLoja + '&qual='+ qual + '&dados='+ dados);
		}
	}

function sendRequestPostEvTemplate(idEvento){
		window.focus();
		setTimeout("JavaToFlash('saldo')",2000);
		http.open('post', phpscript, true);
		http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		http.onreadystatechange = handleResponsePost;
		http.send('vai=ev_template.asp&idEvento='+idEvento);
}
function sendRequestPostAddProduto(idLinha,promo,fazer){
		window.focus();
		setTimeout("JavaToFlash('saldo')",2000);
		http.open('post', phpscript, true);
		http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		http.onreadystatechange = handleResponsePostAddProduto;
		http.send('vai=labCarrinho.asp&qual='+idLinha+'&promo='+promo+'&fazer='+fazer);
}
function handleResponsePostAddProduto() {
	if(http.readyState == 1){
		window.scrollBy(0,-11000);
		document.getElementById("recebe").innerHTML = "" ;
		document.getElementById("carrega").style.visibility="visible";
		}
		else if(http.readyState == 4){
			if (http.status == 200){
				var response = http.responseText;
				if(response) {
					document.getElementById("recebe").style.visibility="hidden";
					document.getElementById("recebe").innerHTML = response;
					setTimeout("JavaToFlash('carro')",3000);
					novo_conteudo = document.getElementById("recebe");
					h = novo_conteudo.offsetHeight;
					setTimeout("changeheight1(h)",1000);
					document.getElementById("carrega").style.visibility="hidden";
				}
			}
			else{
				var response = http.responseText;
				document.getElementById("recebe").innerHTML = response;
				document.getElementById("carrega").style.visibility="hidden";
			}
		}
			
	}

function sendRequestPostUploaFotosAlbuns(idAlbum){
	setTimeout("JavaToFlash('saldo')",2000);
	http.open('post', phpscript, true);
	http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	http.onreadystatechange = handleResponsePostUploaFotosAlbuns;
	http.send('vai=labEnviarFotosAlbum.asp&idAlbum='+idAlbum);
}

function handleResponsePostUploaFotosAlbuns() {
	if(http.readyState == 1){
		window.scrollBy(0,-11000);
		document.getElementById("recebe").innerHTML = "" ;
		document.getElementById("carrega").style.visibility="visible";
		}
		else if(http.readyState == 4){
			if (http.status == 200){
				var response = http.responseText;
				if(response) {
					document.getElementById("recebe").innerHTML = response;
					document.getElementById("carrega").style.visibility="hidden";
				}
			}
			else{
				var response = http.responseText;
				document.getElementById("recebe").innerHTML = response;
				document.getElementById("carrega").style.visibility="hidden";
			}
		}
	}
	
function sendRequestPostUploadFotos(){
		if (browserName=="Netscape" || browserName=="Opera")
		{ 
			setTimeout("JavaToFlash('saldo')",2000);
			http.open('post', phpscript, true);
			http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			http.onreadystatechange = handleResponsePostUploaFotosAlbuns;
			http.send('vai=labEnviarFotos.asp');
		}
		else 
		{ 
		 if (browserName=="Microsoft Internet Explorer")
		 {
			if (estaInstalado == true) {	
				setTimeout("JavaToFlash('saldo')",2000);
				http.open('post', phpscript, true);
				http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
				http.onreadystatechange = handleResponsePostUploaFotosAlbuns;
				http.send('vai=labEnviarFotos.asp');
			} else {
				setTimeout("JavaToFlash('saldo')",2000);
				http.open('post', '../includes/labInstalaFRAME.asp', true);
				http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
				http.onreadystatechange = handleResponsePost;
				http.send('vai=fotos');
			}
		 }
		 else
		  {
			setTimeout("JavaToFlash('saldo')",2000);
			http.open('post', phpscript, true);
			http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			http.onreadystatechange = handleResponsePostUploaFotosAlbuns;
			http.send('vai=labEnviarFotos.asp');
		   }
		}
}
function handleResponsePostUploadFotos() {
	if(http.readyState == 1){
		window.scrollBy(0,-11000);
		document.getElementById("recebe").innerHTML = "" ;
		document.getElementById("carrega").style.visibility="visible";
		}
		else if(http.readyState == 4){
			if (http.status == 200){
				var response = http.responseText;
				if(response) {
					document.getElementById("recebe").innerHTML = response;
					document.getElementById("carrega").style.visibility="hidden";
				}
			}
			else{
				var response = http.responseText;
				document.getElementById("recebe").innerHTML = response;
				document.getElementById("carrega").style.visibility="hidden";
			}
		}
	}	
function handleResponsePostAddFotoAlbum() {
	if(http.readyState == 1){
		window.scrollBy(0,-11000);
		document.getElementById("recebe").innerHTML = "" ;
		document.getElementById("carrega").style.visibility="visible";
		}
		else if(http.readyState == 4){
			if (http.status == 200){
				var response = http.responseText;
				if(response) {
					document.getElementById("recebe").style.visibility="hidden";
					document.getElementById("recebe").innerHTML = response;
					JavaToFlash("barra");
					novo_conteudo = document.getElementById("recebe");
					h = novo_conteudo.offsetHeight;
					setTimeout("changeheight1(h)",1000);
					document.getElementById("carrega").style.visibility="hidden";
				}
			}
			else{
				var response = http.responseText;
				document.getElementById("recebe").innerHTML = response;
				document.getElementById("carrega").style.visibility="hidden";
			}
		}
			
	}
function sendRequestPostBanner(css){
		window.focus();
		setTimeout("JavaToFlash('saldo')",2000);
		if (css ==0){
			http.open('post', phpscript, true);
			http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			http.onreadystatechange = handleResponsePost;
			http.send('vai=labEnviarFotos.asp');
		}
		else
		{
			http.open('post', phpscript, true);
			http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			http.onreadystatechange = handleResponsePost;
			http.send('vai=tgeral.asp&css='+css);
		}
}
///////////////////////////////////////////////
///////////////////////////////////////////////
///////////////////////////////////////////////
///////////////////////////////////////////////
///////////////////////////////////////////////
///////////////////////////////////////////////
function verEncomendas(onde){
		window.focus();
		setTimeout("JavaToFlash('saldo')",2000);
		http.open('post', onde, true);
		http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		http.onreadystatechange = handleResponsePost;
		http.send("");
}

function sendRequestPostEsquecime(){
		window.focus();
		setTimeout("JavaToFlash('saldo')",2000);
		email = document.esquecimePass.email.value
		http.open('post', phpscript, true);
		http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		http.onreadystatechange = handleResponsePost;
		http.send('vai=funcoes&fazer=enviar_pass&email='+email);
}

function sendRequestPostGuestbook(){
		window.focus();
		nome = document.visitas.nome.value
		morada = document.visitas.morada.value
		cpostal1 = document.visitas.cpostal1.value
		cpostal2 = document.visitas.cpostal2.value
		telefone = document.visitas.telefone.value
		telemovel = document.visitas.telemovel.value
		email = document.visitas.email.value
		conheceu = document.visitas.conheceu.value
		achou = document.visitas.achou.value
		comentarios = document.visitas.comentarios.value
		setTimeout("JavaToFlash('saldo')",2000);
		http.open('post', '../includes/obrigadoGuestbook.asp', true);
		http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		http.onreadystatechange = handleResponsePost;
		http.send('fazer=guestbook&nome='+escape(nome)+'&morada='+escape(morada)+'&cpostal1='+escape(cpostal1)+'&cpostal2='+escape(cpostal2)+'&telefone='+escape(telefone)+'&telemovel='+escape(telemovel)+'&email='+escape(email)+'&conheceu='+escape(conheceu)+'&achou='+escape(achou)+'&comentarios='+escape(comentarios));
}

function sendRequestPostContactenos(){
		window.focus();
		setTimeout("JavaToFlash('saldo')",2000);
		nome = document.contactenos.nome.value
		morada = document.contactenos.morada.value
		cidade = document.contactenos.cidade.value
		cpostal1 = document.contactenos.cpostal1.value
		cpostal2 = document.contactenos.cpostal2.value
		telefone = document.contactenos.telefone.value
		telemovel = document.contactenos.telemovel.value
		email = document.contactenos.email.value
		assunto = document.contactenos.assunto.value

		http.open('post', '../includes/obrigadocontactenos.asp', true);
		http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		http.onreadystatechange = handleResponsePost;
		http.send('fazer=contactenos&nome='+escape(nome)+'&morada='+escape(morada)+'&cidade='+escape(cidade)+'&cpostal1='+escape(cpostal1)+'&cpostal2='+escape(cpostal2)+'&telefone='+escape(telefone)+'&telemovel='+escape(telemovel)+'&email='+escape(email)+'&assunto='+escape(assunto));
}
function sendRequestPostOrcamentos(){
		window.focus();
		setTimeout("JavaToFlash('saldo')",2000);
		nome = document.contactenos.nome.value
		morada = document.contactenos.morada.value
		cidade = document.contactenos.cidade.value
		cpostal1 = document.contactenos.cpostal1.value
		cpostal2 = document.contactenos.cpostal2.value
		telefone = document.contactenos.telefone.value
		telemovel = document.contactenos.telemovel.value
		email = document.contactenos.email.value
		info = document.contactenos.info.value
		assunto = document.contactenos.assunto.value
		http.open('post', '../includes/obrigadoOrcamentos.asp', true);
		http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		http.onreadystatechange = handleResponsePost;
		http.send('fazer=contactenos&nome='+escape(nome)+'&morada='+escape(morada)+'&cidade='+escape(cidade)+'&cpostal1='+escape(cpostal1)+'&cpostal2='+escape(cpostal2)+'&telefone='+escape(telefone)+'&telemovel='+escape(telemovel)+'&email='+escape(email)+'&info='+escape(info)+'&assunto='+escape(assunto));
}

function retornaConteudosIndividual() {
	if(http.readyState == 1){
		window.scrollBy(0,-11000);
		document.getElementById("recebeDados").innerHTML = "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,45,0' width='140' height='20' ><param name='movie' value='../imagens/loadingpt.swf' /><param name='quality' value='high' /><param name='wmode' value='transparent' /><embed src='../imagens/loadingpt.swf' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='140' height='20'></embed></object>" ;
	}
	else if(http.readyState == 4){
		if(http.status == 200){
			var response = http.responseText;
			if(response) {
				document.getElementById("recebeDados").style.visibility="visible";
				document.getElementById("recebeDados").innerHTML = response;
				JavaToFlash('carro')
			}
		}
		else{
			var response = http.responseText;
			document.getElementById("recebe").innerHTML = response;
		}
	}
}

function verConteudosREQ(req){
	onde = req.xhRequest.responseText
	alert(onde)
	http.open('post', onde);
	http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	http.onreadystatechange = handleResponsePost;
    http.send('');
}
