// JScript File

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 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 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 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+' \u00E9 obrigat\u00F3rio.\n'; }
  } 
  if (errors) 
  {
	  alert('Los seguinestes erros an ocorrido:\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 = 'block';
		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){
		document.verCarrinho.notify_url.value = url + "includes/lab_savePAYPAL.asp?idCliente="+ idCliente + "&aviso=" 
		document.verCarrinho.shipping_1.value = document.verCarrinho.taxas.value 
		document.verCarrinho.action = "https://www.paypal.com/row/cgi-bin/webscr"
		document.verCarrinho.submit()
}
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 tiene que tener el sistema de cookies activas en su browser.")
	}
}
function carregarSaldo(){
	idPacote = document.saldoCarregamento.idPacote.value
	tipoPagamento = document.saldoCarregamento.tipoPagamento.value
	if (idPacote == '' || tipoPagamento == ''){
		alert("AVISO: Tiene que escojer el Pacote e la forma de Pago.")
	}
	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 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("Ponga las cantidades que pretende pedir.")
							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("Escribe todos los campos marcados con *.")
					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
			}
		setTimeout("JavaToFlash('saldo')",2000);
		http.open('post', vai);
		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);
		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("Escribe todos los campos marcados con *.")
						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);
				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("Selecione el tipo de pago.")
				}
				else{
					if (document.verCarrinho.tipoEntregaPermissao.value == 1){
						if (document.verCarrinho.tipoEntrega.value == 0){
							alert("Selecione el tipo de entrega de sus productos.")
						}
						else{
							if (document.verCarrinho.idLoja.value == 0){
								alert("Selecione la loja donde quiere pegar su encomienda.")
							}
						}
					}
					else{
						setTimeout("JavaToFlash('saldo')",2000);
						http.open('post', vai);
						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);
			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("Selecione el tipo de pago.")
		}
	}
	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);
		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', phpscript);
		http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		
		http.onreadystatechange = handleResponsePost;
		
		http.send('vai='+ vai + theData);
	
	}

	function sendRequestPostFORMCanvas(vai) {
		window.focus();
		var i
		var theData = ""
		var eName = ""
		var eValue = ""
		var control = ""
		eName = document.getElementById("Referencia").name;
		eValue = document.getElementById("Referencia").value;
		theData = theData + '&' + eName + '='+ eValue ;
		if (document.getElementById("opcion1") != undefined) {
			eName = "opcion1";
			control = document.getElementsByName("opcion1")
			for (i=0;i<control.length;i++){ 
				if (control[i].checked) 
					break; 
			} 
			eValue = control[i].value;
			theData = theData + '&' + eName + '='+ eValue ;
		} 
		if (document.getElementById("opcion2") != undefined) {
			eName = "opcion2";
			control = document.getElementsByName("opcion2");
			for (i=0;i<control.length;i++){ 
				if (control[i].checked) 
					break; 
			} 
			eValue = control[i].value;
			theData = theData + '&' + eName + '='+ eValue ;
		} 
		if (document.getElementById("bocadillotexto") != undefined) {
			eName = "bocadillotexto";
			eValue = document.getElementById("bocadillotexto") .value;
			theData = theData + '&' + eName + '='+ eValue ;
		} 
		if (document.getElementById("opcion3") != undefined) {
			eName = "opcion3";
			control = document.getElementsByName("opcion3");
			for (i=0;i<control.length;i++){ 
				if (control[i].checked) 
					break; 
			} 
			eValue = control[i].value;
			theData = theData + '&' + eName + '='+ eValue ;
		} 
		if (document.getElementById("opcion4") != undefined) {
			eName = "opcion4";
			control = document.getElementsByName("opcion4");
			for (i=0;i<control.length;i++){ 
				if (control[i].checked) 
					break; 
			} 
			eValue = control[i].value;
			theData = theData + '&' + eName + '='+ eValue ;
		} 
		if (document.getElementById("soporte") != undefined) {
			eName = "soporte";
			eValue = escape(document.getElementById("soporte").options[document.getElementById("soporte").selectedIndex].value);
			theData = theData + '&' + eName + '='+ eValue ;
		} 
		if (document.getElementById("acabado") != undefined) {
			control = document.getElementById("acabado");
			eName = "acabado";
		  	if (control.checked) {
				eValue=escape(control.value)
			}
			else {
				eValue = escape("Sin acabado")
			}
			theData = theData + '&' + eName + '='+ eValue ;
		} 
		if (document.getElementById("tamanio") != undefined) {
			eName = "tamanio";
			eValue = document.getElementById("tamanio").options[document.getElementById("tamanio").selectedIndex].value;
			theData = theData + '&' + eName + '='+ eValue ;
		} 
		if (document.getElementById("sujeto") != undefined) {
			eName = "sujeto";
			eValue = document.getElementById("sujeto").options[document.getElementById("sujeto").selectedIndex].value;
			theData = theData + '&' + eName + '='+ eValue ;
		} 
		setTimeout("JavaToFlash('saldo')",2000);
		http.open('post', phpscript);
		http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		http.onreadystatechange = handleResponsePost;
		http.send('vai='+ vai + 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);
		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.display='none'
					document.getElementById("recebe").innerHTML = response;
					if (vai=='labCarrinho.asp'){
						setTimeout("JavaToFlash('saldo')",3000);
					}
					
					JavaToFlash('carro')
					setTimeout("document.getElementById('recebe').style.display=''",1000);
					
					setTimeout("changeheight1(document.getElementById('recebe').offsetHeight)",1000);
					setTimeout("changeheight1(document.getElementById('recebe').offsetHeight)",2000);
					setTimeout("changeheight1(document.getElementById('recebe').offsetHeight)",3000);
					setTimeout("changeheight1(document.getElementById('recebe').offsetHeight)",4000);
					setTimeout("changeheight1(document.getElementById('recebe').offsetHeight)",5000);
					setTimeout("changeheight1(document.getElementById('recebe').offsetHeight)",6000);
					setTimeout("changeheight1(document.getElementById('recebe').offsetHeight)",7000);
					setTimeout("changeheight1(document.getElementById('recebe').offsetHeight)",8000);
					setTimeout("changeheight1(document.getElementById('recebe').offsetHeight)",9000);
					setTimeout("changeheight1(document.getElementById('recebe').offsetHeight)",10000);
					setTimeout("changeheight1(document.getElementById('recebe').offsetHeight)",11000);
					setTimeout("changeheight1(document.getElementById('recebe').offsetHeight)",12000);
					setTimeout("changeheight1(document.getElementById('recebe').offsetHeight)",13000);
					setTimeout("changeheight1(document.getElementById('recebe').offsetHeight)",14000);
					setTimeout("changeheight1(document.getElementById('recebe').offsetHeight)",15000);
					setTimeout("changeheight1(document.getElementById('recebe').offsetHeight)",16000);
					setTimeout("changeheight1(document.getElementById('recebe').offsetHeight)",17000);
					setTimeout("changeheight1(document.getElementById('recebe').offsetHeight)",18000);
					setTimeout("changeheight1(document.getElementById('recebe').offsetHeight)",19000);
					setTimeout("changeheight1(document.getElementById('recebe').offsetHeight)",20000);
					
					//alert(document.getElementById("recebe").offsetHeight)
					setTimeout("document.getElementById('carrega').style.visibility='hidden'",1000);
					
				}
			}
			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;\u20AC"
							document.getElementById("DIVsaldoApos").innerHTML = roundNumber(saldoApos)  + "&nbsp;\u20AC"
							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, empresa, nome, apelido, morada, cpostal1, cpostal2, cidade, pais, telefone, telemovel, fax, email, nif, newsletter, localizacao) {
		window.focus();
		setTimeout("JavaToFlash('saldo')",2000);
		http.open('post', phpscript);
		http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		http.onreadystatechange = handleResponsePost;
		http.send('vai='+ vai + '&fazer='+ fazer +'&empresa='+ escape(empresa) + '&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 + '&newsletter=' + newsletter + '&localizacao=' + localizacao );
	}
	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);
		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);
			http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			http.onreadystatechange = handleResponsePost;
			http.send('vai='+ vai + '&fazer='+ fazer + '&username=' + username + '&password=' + password + '&url=' + url + '&codigo=' + codigo + '&action=' + accao + '&idProduto=' + idProduto + '&promocao=' + promocao);
		}
		else 
		{
			alert("Para utilizar esta funcionalidade tiene que tener el sistema de cookies activas en su browser.")
		}
	}
	function sendRequestPostNlogadoProduto(vai, redirect, idProduto, promocao, fazer) {
		window.focus();
		http.open('post', phpscript);
		http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		http.onreadystatechange = handleResponsePost;
		http.send('vai='+ vai + '&css='+ redirect + '&idProduto=' + idProduto + '&promocao=' + promocao + '&qual=' + 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);
		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);
		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.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 (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\u00E3o diferentes'
			window.scrollBy(0,-100);
		}
	}
	function validaNovoRegistoEmpresa(){
		var erro = 0

		if (document.novoRegisto.password1.value != document.novoRegisto.password.value){ erro = 2}
	        document.novoRegisto.empresa.value = document.novoRegisto.empresa.value.replace(/^\s*|\s*$/g,"")
		if (document.novoRegisto.empresa.value == ''){erro = 1}

        	document.novoRegisto.nome.value = document.novoRegisto.nome.value.replace(/^\s*|\s*$/g,"")
		if (document.novoRegisto.nome.value == ''){erro = 1}

	        document.novoRegisto.apelido.value = document.novoRegisto.apelido.value.replace(/^\s*|\s*$/g,"") 
		if (document.novoRegisto.apelido.value == ''){erro = 1}

	        document.novoRegisto.morada.value = document.novoRegisto.morada.value.replace(/^\s*|\s*$/g,"")
		if (document.novoRegisto.morada.value == ''){erro = 1}

        	document.novoRegisto.cpostal1.value = document.novoRegisto.cpostal1.value.replace(/^\s*|\s*$/g,"")
		if (document.novoRegisto.cpostal1.value == ''){erro = 1}

	        document.novoRegisto.cpostal2.value=document.novoRegisto.cpostal2.value.replace(/^\s*|\s*$/g,"")
		if (document.novoRegisto.cpostal2.value == ''){erro = 1}

        	document.novoRegisto.cidade.value=document.novoRegisto.cidade.value.replace(/^\s*|\s*$/g,"")
		if (document.novoRegisto.cidade.value == ''){erro = 1}

		/* document.novoRegisto.pais.value = document.novoRegisto.pais.value.replace(/^\s*|\s*$/g,"")
		if (document.novoRegisto.pais.value == ''){erro = 1} */

	        document.novoRegisto.telefone.value = document.novoRegisto.telefone.value.replace(/^\s*|\s*$/g,"")
		if (document.novoRegisto.telefone.value == ''){erro = 1}

        	document.novoRegisto.email.value = document.novoRegisto.email.value.replace(/^\s*|\s*$/g,"")
		if (document.novoRegisto.email.value == ''){erro = 1}

	        document.novoRegisto.username.value = document.novoRegisto.username.value.replace(/^\s*|\s*$/g,"")
		if (document.novoRegisto.username.value == ''){erro = 1}

	        document.novoRegisto.password.value = document.novoRegisto.password.value.replace(/^\s*|\s*$/g,"")
		if (document.novoRegisto.password.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 = 'Introduce los campos con un *'
			window.scrollBy(0,-100);
		}
		if (erro == 2) {
			document.getElementById("txtErro").innerHTML = 'La contraseña y su confirmación son diferentes. Verifiquelo'
			window.scrollBy(0,-100);
		}
	}
	function sendRequestPostPaginacao(vai, idEvento, pagina) {
		window.focus();
		setTimeout("JavaToFlash('saldo')",2000);
		http.open('post', phpscript);
		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);
		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);
		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');
		http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		http.onreadystatechange = handleResponsePost;
		http.send('idEvento='+ idEvento + '&fazer='+ fazer + '&idFoto='+ idFoto);
		JavaToFlash('barra');
	}
	function sendRequestPostAddFotosAlbuns(vai, idAlbum, fazer, papel ,idFoto) {
		window.focus();
		setTimeout("JavaToFlash('saldo')",2000);
		http.open('post', phpscript);
		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 sendRequestPostSelFotosAlbum(vai, idEvento, fazer, idFoto) {
		window.focus();
		if (Math.abs(document.getElementById("fotoSel").value) > Math.abs(document.getElementById("maxFotos").value)){
			alert("S\u00F3 pode selecionar um maximo de "+document.getElementById("maxFotos").value+" fotografias")
		}
		else{
			setTimeout("JavaToFlash('saldo')",2000);
			http.open('post', '../includes/ev_eventosFotosAlbumSel.asp');
			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');
		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');
		http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		http.onreadystatechange = handleResponsePost;
		http.send('qual='+ idEvento + '&fazer=validaAlbum&inf='+escape(inf));
	}
	/////////////////
	function sendRequestPostCriarAlbum(vai, fazer, nomeAlbum, descAlbum, codigo1, codigo2, idAlbum) {
		window.focus();
		setTimeout("JavaToFlash('saldo')",2000);
		http.open('post', phpscript);
		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);
		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);
			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);
			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);
		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);
		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);
		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);
		//codigo = document.getElementById("codigo"+i).value
		http.open('post', phpscript);
		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);
		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);
		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='+ txtPesquisa);
	}
	function sendRequestPostPaginacaoPesquisa(vai, txtPesquisa, pagina) {
		window.focus();
		setTimeout("JavaToFlash('saldo')",2000);
		http.open('post', phpscript);
		http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		http.onreadystatechange = handleResponsePost;
		http.send('vai='+ vai + '&pesquisa='+ txtPesquisa + '&pagina='+ pagina);
	}
	function sendRequestPostPaginacaoAssociados(idProduto, pagina) {
		window.focus();
		setTimeout("JavaToFlash('saldo')",2000);
		http.open('post', '../includes/produtosAssociados.asp');
		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);
		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);
		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=''
		}
		setTimeout("JavaToFlash('saldo')",2000);
		http.open('post', '../includes/'+vai);
		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);
		http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		http.onreadystatechange = handleResponsePost;
		http.send('vai=ev_template.asp&idEvento='+idEvento);
}
function sendRequestPostAddProduto(idProduto,promo,fazer){
		window.focus();
		setTimeout("JavaToFlash('saldo')",2000);
		http.open('post', phpscript);
		http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		http.onreadystatechange = handleResponsePostAddProduto;
		http.send('vai=labCarrinho.asp&qual='+idProduto+'&promo='+promo+'&fazer='+fazer);
}
function addProduto(idProduto){
		window.focus();
		setTimeout("JavaToFlash('saldo')",2000);
		http.open('post', phpscript);
		http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		http.onreadystatechange = handleResponsePostAddProduto;
		http.send('vai=labCarrinho.asp&qual='+idProduto+'&fazer=adicionarProduto');
}
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){
		
		if (browserName=="Netscape" || browserName=="Opera")
		{ 
			http.open('post', phpscript);
			http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			http.onreadystatechange = handleResponsePostUploaFotosAlbuns;
			http.send('vai=labEnviarFotosAlbum.asp&idAlbum='+idAlbum);
		}
		else 
		{ 
		 if (browserName=="Microsoft Internet Explorer")
		 {
			if (estaInstalado == true) {
				setTimeout("JavaToFlash('saldo')",2000);
				http.open('post', phpscript);
				http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
				http.onreadystatechange = handleResponsePostUploaFotosAlbuns;
				http.send('vai=labEnviarFotosAlbum.asp&idAlbum='+idAlbum);
			} else {
				setTimeout("JavaToFlash('saldo')",2000);
				http.open('post', '../includes/labInstalaFRAME.asp');
				http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
				http.onreadystatechange = handleResponsePost;
				http.send('vai=album&idAlbum='+idAlbum);
			}
		 }
		 else
		  {
			setTimeout("JavaToFlash('saldo')",2000);
			http.open('post', phpscript);
			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);
			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);
				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');
				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);
			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);
		http.open('post', phpscript);
		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);
		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);
		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');
		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');
		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');
		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/loadinges.swf' /><param name='quality' value='high' /><param name='wmode' value='transparent' /><embed src='../imagens/loadinges.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
	http.open("post", onde);
	http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	http.onreadystatechange = handleResponsePost;
	http.send("");
}
function eventosOfertasEnviar(){
	if (document.getElementById("oferta").value == '0.00' || document.getElementById("oferta").value == '0'){
		alert("El valor de la oferta tiene que ser maior que 0")	
	}
	else
	{
		document.eventoOferta.onsubmit()
		document.getElementById("aguarde").style.display = 'none'
		document.getElementById("aguarde1").style.display = ''
	}
}
var loginSN
function registoLogOut(){
	loginSN = 0
	http.open('post', '../includes/funcoes.asp');
	http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	http.onreadystatechange = retornaHeaderLogin;
	http.send('fazer=logout');
}
function registoREQ(req){
	onde = req.xhRequest.responseText
	document.cookie='cookietest=ok'; 
	if (document.cookie) {
		if (onde=='login'){
			loginSN = 1
			http.open('post', '../includes/headerLogin.asp');
			http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			http.onreadystatechange = retornaHeaderLogin;
			http.send('');
		}
		if (onde=='nlogin'){
			alert("Los datos que introdujo estan incorrectos.")	
		}
		if (onde=='nactivo'){
			alert("Su cuenta no esta activada.")	
		}
	}
	else 
	{
		alert("Tienes que tener el sistema de cookies abilitado.")
	}
}
function retornaHeaderLogin() {
	if(http.readyState == 1){
		window.scrollBy(0,-11000);
	}
	else if(http.readyState == 4){
		if(http.status == 200){
			var response = http.responseText;
			if(response) {
				document.getElementById("headerDados").style.visibility="visible";
				document.getElementById("headerDados").innerHTML = response;
				if (loginSN==1) sendRequestPost('indexUser.asp')
				if (loginSN==0) sendRequestPost('thome.asp')
				JavaToFlash('carro')
			}
		}
		else{
			var response = http.responseText;
			document.getElementById("recebe").innerHTML = response;
		}
	}
}
