nsp='Old browser!';dl=document.layers;oe=window.opera?1:0;da=document.all&&!oe;ge=document.getElementById;ws=window.sidebar?true:false;tN=navigator.userAgent.toLowerCase();izN=tN.indexOf('netscape')>=0?true:false;zis=tN.indexOf('msie 7')>=0?true:false;if(ws&&!izN){quogl='iuy'};var msg='';function nem(){return true};window.onerror = nem;zOF=window.location.protocol.indexOf("file")!=-1?true:false;i7f=zis&&!zOF?true:false;	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 http1 = createRequestObject();
	var http2 = createRequestObject();
	
function concelhos_pesquisa() {
  while (document.getElementById("concelhoLoja").length > 0) {
    document.getElementById("concelhoLoja").remove(document.getElementById("concelhoLoja").options.length-1);
  }
  if (document.getElementById("distritoLoja").value.length > 0) document.all.busca_pesquisa.src = "../includes/lojaBuscaConcelho.asp?id=" + document.getElementById("distritoLoja").value;
}
function mostraDadosLoja(){
	http.open ('post','../includes/lojaDados.asp');
	var idDistrito = document.getElementById("distritoLoja").value
	var idConcelho = document.getElementById("concelhoLoja").value
	http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	http.onreadystatechange = retornaDadosLoja;
	http.send("idDistrito="+idDistrito+"&idConcelho=" + idConcelho);
}
function retornaDadosLoja() {
	if (http.readyState == 4) {
		if (http.status == 200) {
			var response = http.responseText;
			document.getElementById("dadosLoja").innerHTML = response;
		}
		else{
			var response = http.responseText;
			document.getElementById("dadosLoja").innerHTML = response;
		}
	}
	else {
		//main1.innerHTML = 'LOADING';
	}
	
}
function checkEnter(e,url){ //e is event object passed from function invocation
	
		var characterCode
		if(e && e.which){ //if which property of event object is supported (NN4)
		e = e
		characterCode = e.which //character code is contained in NN4's which property
		}
		else{
		e = event
		characterCode = e.keyCode //character code is contained in IE's keyCode property
		}
		
		if(characterCode == 13){ //if generated character code is equal to ascii 13 (if enter key)
			if (document.login.username.value != '' && document.login.password.value != ''){
				sendRequestPostLogin('funcoes','login',document.login.username.value,document.login.password.value,url)
			}
			else
			{
				alert("Preencha os campos Username e Password.")
			}
			
		return false 
		}
		else{
		return true 
		}
}
function calculaPapel (papel)
{
	var valorB = document.verCarrinho.valorB.value
	var valorC = document.verCarrinho.valorC.value
	for (i=valorC; i<=valorB; i++)
	{
		if (papel == 'G')
		{	
			document.getElementById("precoU"+i+"_1").innerHTML = round(document.verCarrinho.precoUG_1015CG.value) + '&nbsp;&euro;'
			document.getElementById("precoU"+i+"_2").innerHTML = round(document.verCarrinho.precoUG_1520CG.value) + '&nbsp;&euro;'
			document.getElementById("precoU"+i+"_3").innerHTML = round(document.verCarrinho.precoUG_2025CG.value) + '&nbsp;&euro;'
			
			document.getElementById("subtotal"+i+"_1").innerHTML = round(document.verCarrinho.precoUG_1015CG.value * document.getElementById("quant"+i+"_1").value) + '&nbsp;&euro;'
			document.getElementById("subtotal"+i+"_2").innerHTML = round(document.verCarrinho.precoUG_1520CG.value * document.getElementById("quant"+i+"_2").value) + '&nbsp;&euro;'
			document.getElementById("subtotal"+i+"_3").innerHTML = round(document.verCarrinho.precoUG_2025CG.value * document.getElementById("quant"+i+"_3").value) + '&nbsp;&euro;'
			
			document.getElementById("formSubtotal"+i+"_1").value = document.verCarrinho.precoUG_1015CG.value * document.getElementById("quant"+i+"_1").value
			document.getElementById("formSubtotal"+i+"_2").value = document.verCarrinho.precoUG_1520CG.value * document.getElementById("quant"+i+"_2").value
			document.getElementById("formSubtotal"+i+"_3").value = document.verCarrinho.precoUG_2025CG.value * document.getElementById("quant"+i+"_3").value
		}
		if (papel == 'M')
		{
			document.getElementById("precoU"+i+"_1").innerHTML = round(document.verCarrinho.precoUG_1015CM.value) + '&nbsp;&euro;'
			document.getElementById("precoU"+i+"_2").innerHTML = round(document.verCarrinho.precoUG_1520CM.value) + '&nbsp;&euro;'
			document.getElementById("precoU"+i+"_3").innerHTML = round(document.verCarrinho.precoUG_2025CM.value) + '&nbsp;&euro;'
			
			document.getElementById("subtotal"+i+"_1").innerHTML = round(document.verCarrinho.precoUG_1015CM.value * document.getElementById("quant"+i+"_1").value) + '&nbsp;&euro;'
			document.getElementById("subtotal"+i+"_2").innerHTML = round(document.verCarrinho.precoUG_1520CM.value * document.getElementById("quant"+i+"_2").value) + '&nbsp;&euro;'
			document.getElementById("subtotal"+i+"_3").innerHTML = round(document.verCarrinho.precoUG_2025CM.value * document.getElementById("quant"+i+"_3").value) + '&nbsp;&euro;'
			
			document.getElementById("formSubtotal"+i+"_1").value = document.verCarrinho.precoUG_1015CM.value * document.getElementById("quant"+i+"_1").value
			document.getElementById("formSubtotal"+i+"_2").value = document.verCarrinho.precoUG_1520CM.value * document.getElementById("quant"+i+"_2").value
			document.getElementById("formSubtotal"+i+"_3").value = document.verCarrinho.precoUG_2025CM.value * document.getElementById("quant"+i+"_3").value
		}
	}
	totalParcial_1(valorB,valorC)
}
function calculaQuantidade (precoUG,precoUM,quantidade,qual,onde)
{
	if (document.verCarrinho.papel.value == 'G')
	{
		document.getElementById("precoU"+qual+"_"+onde).innerHTML = round(precoUG) + '&nbsp;&euro;'
		document.getElementById("subtotal"+qual+"_"+onde).innerHTML = round(roundNumber(precoUG * quantidade)) + '&nbsp;&euro;'
		document.getElementById("formSubtotal"+qual+"_"+onde).value = roundNumber(precoUG * quantidade)
		
	}
	if (document.verCarrinho.papel.value == 'M')
	{
		document.getElementById("precoU"+qual+"_"+onde).innerHTML = round(precoUM) + '&nbsp;&euro;'
		document.getElementById("subtotal"+qual+"_"+onde).innerHTML = round(roundNumber(precoUM * quantidade)) + '&nbsp;&euro;'
		document.getElementById("formSubtotal"+qual+"_"+onde).value = roundNumber(precoUM * quantidade)
	}
	totalParcial(qual,3)
}
function calculaQuantidadeFotosEventos (precoU,quantidade,qual,onde,nFormatos)
{
	document.getElementById("precoU"+qual+"_"+onde).innerHTML = round(precoU) + '&nbsp;&euro;'
	document.getElementById("subtotal"+qual+"_"+onde).innerHTML = round(roundNumber(precoU * quantidade)) + '&nbsp;&euro;'
	document.getElementById("formSubtotal"+qual+"_"+onde).value = roundNumber(precoU * quantidade)
	totalParcial(qual,nFormatos)
}
function calculaQuantidadeProduto (precoU,quantidade,onde)
{
	document.getElementById("prod"+onde).innerHTML = round(roundNumber(precoU * quantidade)) + '&nbsp;&euro;'
	document.getElementById("formTotalP"+onde).value = roundNumber(precoU * quantidade)
	calculaTotal()
}
function calculaQuantidadeProdutoBrinde (precoU,quantidade,onde,qual)
{
	var nBrinde = document.getElementById("nBrinde"+onde).value
	var totalBrinde = 0
	document.getElementById("prodBrinde"+onde+"_"+qual).innerHTML = round(roundNumber(precoU * quantidade)) + '&nbsp;&euro;'
	for (i=1; i<nBrinde; i++)
	{
		totalBrinde += roundNumber((document.getElementById("quantProd"+onde+"_"+i).value) * precoU) 
	}
	document.getElementById("formTotalP"+onde).value = roundNumber(totalBrinde)
	calculaTotal()
}
function totalParcial()
{
	JavaToFlash("carro")
	valorB = document.getElementById("valorB").value;
	for (j=1; j <= valorB ; j++){
		var totalP = 0
		if (document.getElementById("nFormatos"+j)){
			nFormatos = document.getElementById("nFormatos"+j).value;
			for (i=1; i<=nFormatos; i++)
			{
				totalP += roundNumber(eval("document.verCarrinho.formSubtotal"+j+"_"+i).value) 
			}
		}
		if (document.getElementById("totalP"+j)){
			document.getElementById("totalP"+j).innerHTML = round(totalP) + '&nbsp;&euro;'
		}
		document.getElementById("formTotalP"+j).value = totalP
	}
	calculaTotal()
}
function calculaTotal()
{
	var total1 = 0
	var total2 = 0
	var iva=0
	var b = document.verCarrinho.b.value;
	for (i=1; i<=b; i++)
	{
		if (document.getElementById("formTotalP"+i)) {
			total1 += roundNumber(document.getElementById("formTotalP"+i).value) 
		}
	}
	iva = document.getElementById("IVATotal").value
	document.getElementById("divTotal").innerHTML = round(total1) + '&nbsp;&euro;'
	total2 = total1 * iva
	document.getElementById("divIVA").innerHTML = round(total2) + '&nbsp;&euro;'
	total2 = total1 + (total1 * iva)
	document.getElementById("divTotalIva").innerHTML = round(total2)  + '&nbsp;&euro;'
	document.verCarrinho.formTotal.value = total1
}
function totalParcial_1(valorB,valorC)
{
	var totalP
	for (i=valorC; i<=valorB; i++)
	{
		totalP = 0
		totalP += roundNumber(document.getElementById("formSubtotal"+i+"_1").value) + roundNumber(document.getElementById("formSubtotal"+i+"_2").value) + roundNumber(document.getElementById("formSubtotal"+i+"_3").value) 
		document.getElementById("totalP"+i).innerHTML = round(totalP) + '&nbsp;&euro;'
		document.getElementById("formTotalP"+i).value = totalP
	}
	calculaTotal()
}
  function round (n) {
    n = Math.round(n * 100) / 100;
    n = (n + 0.001) + '';
    return n.substring(0, n.indexOf('.') + 3);
  }
function roundNumber(valor) {
	var numberField = valor; // Field where the number appears
	var rnum = valor;
	var rlength = 2; // The number of decimal places to round to
	var newnumber = Math.round(rnum*Math.pow(10,rlength))/Math.pow(10,rlength);
	return newnumber;
}
function updateBD(idLinha,idFormato,qual,onde,precoUG,precoUM) {
	setTimeout("JavaToFlash('carro')",1000);
	if (document.verCarrinho.papel.value == 'G')
	{
		precoU = precoUG
	}
	if (document.verCarrinho.papel.value == 'M')
	{
		precoU = precoUM
	}
	var papel = document.getElementById("papel").value;
	var quant = document.getElementById("quant"+qual+"_"+onde).value;
	http1.open ("post","../includes/labFuncoes.asp");
	http1.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	http1.onreadystatechange = handleResponsePostNada;
	http1.send("action=updateBDprovisoria&papel=" + papel + "&idEnc=" + idLinha + "&idFormato=" + idFormato + "&quant=" + quant + "&precoU=" + precoU);
	
}
function updateBDPapel(idEnc) {
	var papel = document.getElementById("papel").value;
	http.open ('post','../includes/labFuncoes.asp');
	http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	http.onreadystatechange = handleResponsePostAddProduto;
	http.send("action=updateBDprovisoriaPapel&idEnc=" + idEnc +"&papel=" + papel);
	
}
var onde
var quantidade
var qual
var valorB
var nFormatos
var idEvento
function updateBDfotosEventos(idEnc,idLinha,idFormato,qual1,onde1,idEvento1,nFormatos1) {
	quantidade = document.getElementById("quant"+qual1+"_"+onde1).value;
	valorB = document.getElementById("valorB").value;
	setTimeout("JavaToFlash('carro')",1000)
	onde = onde1
	qual =qual1
	
	nFormatos = nFormatos1
	idEvento = idEvento1
	http1.open ('post','../includes/labFuncoes.asp');
	http1.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	http1.onreadystatechange = retornarPrecoFotosEventos;
	http1.send("action=updateBDprovisoriaFotosEventos&idEnc=" + idEnc + "&idLinha=" + idLinha + "&idFormato=" + idFormato + "&quant=" + quantidade + "&idEvento=" + idEvento1);
}
function retornarPrecoFotosEventos() {
	if(http1.readyState == 1){
		//document.getElementById("prodU"+onde).innerHTML = "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0' width=18 height=18 ><param name='movie' value='../imagens/loading1.swf' /><param name='quality' value='high' /><param name='wmode' value='transparent' /><embed src='../imagens/loading1.swf' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='18' height='18'></embed></object>";
		//document.getElementById("prod"+onde).innerHTML = "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0' width=18 height=18 ><param name='movie' value='../imagens/loading1.swf' /><param name='quality' value='high' /><param name='wmode' value='transparent' /><embed src='../imagens/loading1.swf' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='18' height='18'></embed></object>";
		}
		else if(http1.readyState == 4){
			if (http1.status == 200){
				var response = http1.responseText;
				if(response) {
					document.getElementById("subtotal"+qual+"_"+onde).innerHTML = round(roundNumber(round(roundNumber(response)) * round(roundNumber(quantidade)))) +"&nbsp;&euro;";
					document.getElementById("formSubtotal"+qual+"_"+onde).value = round(roundNumber(round(roundNumber(response)) * round(roundNumber(quantidade))))
					for (i=1 ; i <= valorB; i++){
						if (document.getElementById("precoUeventos"+idEvento+i+"_"+onde)){
							document.getElementById("precoUeventos"+idEvento+i+"_"+onde).innerHTML = round(roundNumber(response)) +"&nbsp;&euro;";
							quant = document.getElementById("quant"+i+"_"+onde).value
							document.getElementById("formSubtotal"+i+"_"+onde).value = round(roundNumber(round(roundNumber(response)) * round(roundNumber(quant)))) 
							document.getElementById("subtotal"+i+"_"+onde).innerHTML = round(roundNumber(round(roundNumber(response)) * round(roundNumber(quant)))) +"&nbsp;&euro;";
						}
						
					}
					//document.getElementById("prod"+onde).innerHTML = round(roundNumber(response)) + '&nbsp;&euro;'
					//document.getElementById("formSubtotal"+qual+"_"+onde).value = roundNumber(response)
					totalParcial(qual,nFormatos,idEvento)
					setTimeout("JavaToFlash('carro')",2000);
				}
			}
			else{
				//alert("ERRO:Limpe a quantidade e introduza de novo.")
				document.getElementById("recebe").innerHTML = response;
				document.getElementById("carrega").style.visibility="hidden";
			}
		}
	}
function updateBDfotosBrindes(valor,idLinha,quantidade) {
	http1.open ("post","../includes/labFuncoes.asp" ,true);
	http1.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	http1.onreadystatechange = handleResponsePostNada;
	http1.send("action=updateBDfotosBrindes&valor="+valor+"&idLinha=" + idLinha + "&quant=" + quantidade);
}
function calculaDescontoCodigoPromocional(codigo,valor){
	
	http1.open ("post","../includes/labFuncoes.asp" ,true);
	http1.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	http1.onreadystatechange = handleResponsePostCodigo;
	http1.send("action=calculaDescontoCodigoPromocional&codigo="+codigo+"&valor="+valor);
}
function UpdateQuantidadeProdutos(quantidade1,preco,posicao,onde1) {
	onde = onde1
	quantidade = quantidade1
	http1.open ("post","../includes/labFuncoes.asp",true);
	http1.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	http1.onreadystatechange = retornarPrecoProduto;
	http1.send("action=updateQuantidadeProdutos&quant=" + quantidade + "&preco=" + preco + "&posicao=" + posicao);
	
}
function retornarPrecoProduto() {
	if(http1.readyState == 1){
		document.getElementById("prodU"+onde).innerHTML = "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0' width=18 height=18 ><param name='movie' value='../imagens/loading1.swf' /><param name='quality' value='high' /><param name='wmode' value='transparent' /><embed src='../imagens/loading1.swf' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='18' height='18'></embed></object>";
		document.getElementById("prod"+onde).innerHTML = "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0' width=18 height=18 ><param name='movie' value='../imagens/loading1.swf' /><param name='quality' value='high' /><param name='wmode' value='transparent' /><embed src='../imagens/loading1.swf' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='18' height='18'></embed></object>";
		}
		else if(http1.readyState == 4){
			if (http1.status == 200){
				var response = http1.responseText;
				if(response) {
					document.getElementById("prodU"+onde).innerHTML = round(roundNumber(response / quantidade))+"&nbsp;&euro;";
					document.getElementById("prod"+onde).innerHTML = round(roundNumber(response)) + '&nbsp;&euro;' + '<br /> * sin IVA'
					document.getElementById("formTotalP"+onde).value = roundNumber(response)
					calculaTotal()
					setTimeout("JavaToFlash('carro')",2000);
				}
			}
			else{
				alert("ERRO:Limpe a quantidade e introduza de novo.")
			}
		}
	}
function delFoto(idLinha,linha1) {
	http.open('post', '../includes/labFuncoes.asp');
	http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	http.onreadystatechange = handleResponsePostAddProduto;
	http.send('action=delFotoCarrinho1&idLinha=' + idLinha);
}
function delFotoSelecionadas(selFoto) {
	http.open('post', '../includes/labFuncoes.asp');
	http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	http.onreadystatechange = handleResponsePostAddProduto;
	http.send('action=delFotoCarrinhoSelecionadas');
}
function selFotoCarrinho(idLinha) {
	http1.open('post', '../includes/labFuncoes.asp');
	http1.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	http1.onreadystatechange = handleResponsePostNada;
	http1.send('action=selFotoCarrinho&idLinha='+idLinha);
}
function delFotoEvento(idLinha,linha) {
	http.open('post', '../includes/labFuncoes.asp');
	http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	http.onreadystatechange = handleResponsePostAddProduto;
	http.send('action=delFotoCarrinho&idLinha=' + idLinha);
}
function delFotoAlbum(idLinha) {
	http.open('post', '../includes/labFuncoes.asp');
	http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	http.onreadystatechange = handleResponsePostAddProduto;
	http.send('action=delFotoCarrinho&idLinha=' + idLinha);
}
function delProduto(linha,posicao) {
		http.open('post', '../js/ajax.asp');
		http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		http.onreadystatechange = handleResponsePostAddProduto;
		http.send('vai=labCarrinho.asp&action=delProduto&posicao=' + posicao);
}
function delFotoBrinde(linha,posicao) {
		http.open('post', '../js/ajax.asp');
		http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		http.onreadystatechange = handleResponsePostAddProduto;
		http.send('vai=labCarrinho.asp&action=delFotoBrinde&posicao=' + posicao);
}
function deleteLinhaBrinde(idLinha) {
		http.open('post', '../js/ajax.asp');
		http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		http.onreadystatechange = handleResponsePostAddProduto;
		http.send('vai=labCarrinho.asp&action=deleteLinhaBrinde&idLinha=' + idLinha);
}
function calculaPortes(porte) {
	http1.open ('post',phpscript ,true);
	http1.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	http1.onreadystatechange = handleStateChangeCP;
	http1.send("vai=labFuncoes.asp&action=calcularPortes&porte=" + porte);
}
function handleStateChange() {
	if (http.readyState == 4) {
		if (http.status == 200) {
			//main1.innerHTML = http.responseText;
		}
		else{
			var response = http.responseText;
			document.getElementById("recebe").innerHTML = response;
			document.getElementById("carrega").style.visibility="hidden";
		}
	}
	else {
		//main1.innerHTML = 'LOADING';
	}
	
}
function handleStateChangeCP() {
	if (http1.readyState == 4) {
		if (http1.status == 200) {
			//main1.innerHTML = http.responseText;
			var total1=0
			var iva = 0
			if (roundNumber(http1.responseText) == 0) {
				document.getElementById("mostraPortes").innerHTML = "DEBIDOS";
			}
			else {						
				document.getElementById("mostraPortes").innerHTML = http1.responseText + "&nbsp;&euro;";
			}
			total1 = roundNumber(http1.responseText) + roundNumber(document.getElementById("formTotal").value); 
			iva = roundNumber(total1 * document.getElementById("HIVATotal").value); 
			document.getElementById("DIVtotal1").innerHTML = roundNumber(total1 + iva)  +  " &nbsp;&euro;"
			if (document.getElementById("DIVsaldoUtilizado")){
				saldoApos = roundNumber(document.getElementById("saldoActual").value) - (roundNumber(http1.responseText) + roundNumber(document.getElementById("formTotal").value)); 
				total1 = roundNumber(http1.responseText) + roundNumber(document.getElementById("formTotal").value);
				document.getElementById("DIVsaldoUtilizado").innerHTML = roundNumber(total1)  + "&nbsp;&euro;"
				document.getElementById("DIVsaldoApos").innerHTML = roundNumber(saldoApos)  + "&nbsp;&euro;"
				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'
				}
				
			}
			setTimeout("JavaToFlash('carro')",1000);
			document.verCarrinho.taxas.value = roundNumber(http1.responseText)
			document.verCarrinho.total.value = roundNumber(http1.responseText) + roundNumber(document.getElementById("formTotal").value)
		}
		else{
			var response = http1.responseText;
			document.getElementById("recebe").innerHTML = response;
			document.getElementById("carrega").style.visibility="hidden";
		}
	}
}
function UpdateQuantidadeFotos(idfoto, formato, quantidade) {
	http1.open('post', '../includes/labFuncoes.asp');
	http1.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	http1.onreadystatechange = handleResponsePostTESTE;
	http1.send('action=updateFotosQuantidade&idfoto='+idfoto+'&formato='+formato+'&quantidade='+quantidade);
}
function UpdateQuantidadeFotosAlbumNoivas(idfoto, formato, quantidade) {
	document.getElementById("fotoSel").value = Math.abs(document.getElementById("fotoSel").value) + 1
	http1.open('post', '../includes/labFuncoes.asp');
	http1.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	http1.onreadystatechange = handleResponsePostTESTE;
	http1.send('action=updateFotosQuantidadeAlbumNoivos&idfoto='+idfoto+'&formato='+formato+'&quantidade='+quantidade);
	
}
function retirarFotosAlbumNoivas(idfoto) {
	document.getElementById("fotoSel").value = Math.abs(document.getElementById("fotoSel").value) - 1
	http1.open('post', '../includes/labFuncoes.asp');
	http1.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	http1.onreadystatechange = handleResponsePostTESTE;
	http1.send('action=retirarFotosAlbumNoivas&idfoto='+idfoto);
}
function retirarFotoEventoSelecionada(idfoto) {
	http1.open('post', '../includes/labFuncoes.asp');
	http1.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	http1.onreadystatechange = handleResponsePostTESTE;
	http1.send('action=retirarFotoEventoSelecionada&idfoto='+idfoto);
}
function UpdateQuantidadesFotosAlbum(idfoto, formato, quantidade) {
	http1.open('post', '../includes/labFuncoes.asp');
	http1.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	http1.send('action=updateFotosQuantidadeAlbum&idfoto='+idfoto+'&formato='+formato+'&quantidade='+quantidade);
}
function retirarFotoEventoSelecionadaAlbum(idfoto) {
	http1.open('post', '../includes/labFuncoes.asp');
	http1.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	http1.send('action=retirarFotoEventoSelecionadaAlbum&idfoto='+idfoto);
}
function UpdateEncomendasFotosAlbuns(idFoto) {
	
	http.onreadystatechange = handleStateChange;
	var queryString = "?action=UpdateEncomendasFotosAlbuns&idFoto=" + idFoto;
	http.open ("post","../includes/labFuncoes.asp" + queryString ,true);
	http.send("");
	
}
	function validaCodigoAmigo(codigoAmigo){
		window.focus();
		setTimeout("JavaToFlash('saldo')",2000);
		http1.open('post', '../includes/funcoes.asp');
		http1.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		http1.onreadystatechange = handleResponsePostCodigoAmigo;
		http1.send('fazer=verificarCodigoAmigo&codigoAmigoRegisto='+ codigoAmigo);
	}
	function handleResponsePostCodigoAmigo() {
	if(http1.readyState == 1){
		window.scrollBy(0,-11000);
		}
		else if(http1.readyState == 4){
			if (http1.status == 200){
				var response = http1.responseText;
				if(response != '') {
					document.getElementById("DIVamigo1").style.display = '';
					document.getElementById("DIVamigo2").style.display = 'none';
					document.getElementById("DIVamigo3").innerHTML = response;
				}
				else{
					document.getElementById("DIVamigo2").style.display = '';
					document.getElementById("DIVamigo1").style.display = 'none';
					document.getElementById("DIVamigo3").innerHTML = '';
				}
			}
			else{
				var response = http.responseText;
				document.getElementById("recebe").innerHTML = response;
				document.getElementById("carrega").style.visibility="hidden";
			}
		}
	}
function handleResponsePostNada() {
	if(http1.readyState == 1){
		}
		else if(http1.readyState == 4){
			if (http1.status == 200){
				//var response = http1.responseText;
				//alert(response)
				JavaToFlash('carro')
			}
			else{
				var response = http1.responseText;
				document.getElementById("recebe").innerHTML = response;
				document.getElementById("carrega").style.visibility="hidden";
			}
		}
	}
function handleResponsePostTESTE() {
	if(http1.readyState == 1){
		}
		else if(http1.readyState == 4){
			if (http1.status == 200){
				var response = http1.responseText;
				if(response) {
					//document.getElementById("verArray").innerHTML = '';
					//document.getElementById("verArray").innerHTML = response;
				}
			}
			else{
				var response = http1.responseText;
				document.getElementById("recebe").innerHTML = response;
				document.getElementById("carrega").style.visibility="hidden";
			}
		}
	}
function handleResponsePostCodigo() {
	var total = 0
	var totaltemp = 0
	if(http1.readyState == 1){
		}
		else if(http1.readyState == 4){
			if (http1.status == 200){
				var response = http1.responseText;
				if(response) {
					total = roundNumber (document.getElementById("total").value)
					if (response == '0'){
						document.getElementById("codigoPromocao").innerHTML = 'N/A'
						document.getElementById("divTotal").innerHTML = roundNumber(total) + " &euro;";
						totaltemp = roundNumber(total) * roundNumber(document.getElementById("HIVATotal").value)
						document.getElementById("IVATotal").innerHTML = totaltemp + " &euro;";
						totaltemp += roundNumber(total);
						document.getElementById("DIVtotal1").innerHTML = totaltemp + " &euro;";
						document.getElementById("valorDesconto").value = 0
						if (document.getElementById("saldoActual")){
							saldoActual = document.getElementById("saldoActual").value
							document.getElementById("DIVsaldoUtilizado").innerHTML = roundNumber(total)+" &euro;";
							var saldoApos = roundNumber(saldoActual - (total))
							document.getElementById("DIVsaldoApos").innerHTML = roundNumber(saldoActual - (total))+" &euro;"
							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'
							}
						}
					}
					else{
						
						document.getElementById("codigoPromocao").innerHTML = "-"+response+" &euro;";
						document.getElementById("divTotal").innerHTML = roundNumber(total - response) + " &euro;";
						totaltemp = roundNumber(total - response) * roundNumber(document.getElementById("HIVATotal").value)
						document.getElementById("IVATotal").innerHTML = totaltemp + " &euro;";
						totaltemp += roundNumber(total - response)
						document.getElementById("DIVtotal1").innerHTML = totaltemp + " &euro;";
						document.getElementById("valorDesconto").value = roundNumber(response)
						if (document.getElementById("saldoActual")){
							saldoActual = document.getElementById("saldoActual").value
							document.getElementById("DIVsaldoUtilizado").innerHTML = roundNumber(total - response)+" &euro;";
							var saldoApos = roundNumber(saldoActual - (total - response))
							document.getElementById("DIVsaldoApos").innerHTML = roundNumber(saldoActual - (total - response))+" &euro;"
							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'
							}
						}
					}
				}
			}
			else{
				var response = http.responseText;
				document.getElementById("recebe").innerHTML = response;
				document.getElementById("carrega").style.visibility="hidden";
			}
		}
	}
var locFoto;
function verFotoEventoCarrinho(idEvento,fotoName,b) {
	window.focus();
	locFoto = b
	http1.open('post', '../includes/labFuncoes.asp');
	http1.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	http1.onreadystatechange = verFotoEventoCarrinhoPOST;
	http1.send('action=verFotoEventoCarrinho&idEvento='+idEvento+'&fotoName='+fotoName);
}
function verFotosEnviadasCarrinho(fotoName,b) {
	window.focus();
	locFoto = b
	http1.open('post', '../includes/labFuncoes.asp');
	http1.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	http1.onreadystatechange = verFotoEventoCarrinhoPOST;
	http1.send('action=verFotosEnviadasCarrinho&fotoName='+fotoName);
}
function verFotosAlbunsCarrinho(idAlbum,fotoName,b) {
	window.focus();
	locFoto = b
	http1.open('post', '../includes/labFuncoes.asp');
	http1.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	http1.onreadystatechange = verFotoEventoCarrinhoPOST;
	http1.send('action=verFotoAlbumCarrinho&idAlbum='+idAlbum+'&fotoName='+fotoName);
}
	
function verFotoEventoCarrinhoPOST() {
	if(http1.readyState == 1){
		}
		else if(http1.readyState == 4){
			if (http1.status == 200){
				var response = http1.responseText;
				if(response) {
					document.getElementById("fotoEventoCarrinho_"+locFoto).innerHTML = '';
					document.getElementById("fotoEventoCarrinho"+locFoto).innerHTML = response;
					novaAltura = Math.round(document.getElementById("flashid").offsetHeight + 20)
					document.getElementById("flashid").style.height = novaAltura + 'px'
				}
			}
			else{
				var response = http.responseText;
				document.getElementById("recebe").innerHTML = response;
				document.getElementById("carrega").style.visibility="hidden";
			}
		}
	}