function translator(pattern)
{
	var URL="http://translate.google.com/translate_c?langpair="+pattern+"&u="+window.location;
	
	msgWindow=window.open(URL, 'subwindow', 'toolbar=yes,location=yes,directories=yes,status=yes,scrollbars=yes,menubar=yes,resizable=yes,left=0,top=0');
	msgWindow.focus();
}

function formatAsMoney(mnt)
{
	mnt-=0;
	mnt=(Math.round(mnt*100))/100;
	return (mnt==Math.floor(mnt)) ? mnt+'.00' : ((mnt*10==Math.floor(mnt*10)) ? mnt+'0' : mnt);
}

function cambiarFormEnvio(idioma)
{
	var display=document.getElementById("envio_fecha_nacimiento").style.display;
	
	if(document.formulario.envio_tipo[0].checked==true)
	{
		if(idioma=="ingles")
		{
			document.getElementById('envio_nombre2').innerHTML="First Name";
			document.getElementById('envio_apellidos2').innerHTML="Last Name";
			document.getElementById('envio_nif2').innerHTML="NIF";
		}
		else if(idioma=="frances")
		{
			document.getElementById('envio_nombre2').innerHTML="Nom";
			document.getElementById('envio_apellidos2').innerHTML="Nom de famille";
			document.getElementById('envio_nif2').innerHTML="NIF";
		}
		else
		{
			document.getElementById('envio_nombre2').innerHTML="Nombre";
			document.getElementById('envio_apellidos2').innerHTML="Apellidos";
			document.getElementById('envio_nif2').innerHTML="NIF";
		}
		document.formulario.envio_nombre.value="";
		document.formulario.envio_apellidos.value="";
		document.formulario.envio_nif.value="";
		document.formulario.envio_nombre.focus();
		
		if(display=="none")
			new Effect.BlindDown("envio_fecha_nacimiento", { duration:1.0 });
	}
	else
	{
		if(idioma=="ingles")
		{
			document.getElementById('envio_nombre2').innerHTML="Company";
			document.getElementById('envio_apellidos2').innerHTML="Contact Person";
			document.getElementById('envio_nif2').innerHTML="NIF / CIF";
		}
		else if(idioma=="frances")
		{
			document.getElementById('envio_nombre2').innerHTML="Entreprise";
			document.getElementById('envio_apellidos2').innerHTML="Personne à contacter";
			document.getElementById('envio_nif2').innerHTML="NIF / CIF";
		}
		else
		{
			document.getElementById('envio_nombre2').innerHTML="Empresa";
			document.getElementById('envio_apellidos2').innerHTML="Persona de Contacto";
			document.getElementById('envio_nif2').innerHTML="NIF / CIF";
		}
		document.formulario.envio_nombre.value="";
		document.formulario.envio_apellidos.value="";
		document.formulario.envio_nif.value="";
		document.formulario.envio_nombre.focus();
		
		if(display=="")
			new Effect.BlindUp("envio_fecha_nacimiento", { duration:1.0 });
	}
}

function cambiarFormPago(idioma)
{
	if(document.formulario.pago_tipo[0].checked==true)
	{
		if(idioma=="ingles")
		{
			document.getElementById('pago_nombre2').innerHTML="First Name";
			document.getElementById('pago_apellidos2').innerHTML="Last Name";
			document.getElementById('pago_nif2').innerHTML="NIF";
		}
		else if(idioma=="frances")
		{
			document.getElementById('pago_nombre2').innerHTML="Nom";
			document.getElementById('pago_apellidos2').innerHTML="Nom de famille";
			document.getElementById('pago_nif2').innerHTML="NIF";
		}
		else
		{
			document.getElementById('pago_nombre2').innerHTML="Nombre";
			document.getElementById('pago_apellidos2').innerHTML="Apellidos";
			document.getElementById('pago_nif2').innerHTML="NIF";
		}
		document.formulario.pago_nombre.value="";
		document.formulario.pago_apellidos.value="";
		document.formulario.pago_nif.value="";
		document.formulario.pago_nombre.focus();
	}
	else
	{
		if(idioma=="ingles")
		{
			document.getElementById('pago_nombre2').innerHTML="Company";
			document.getElementById('pago_apellidos2').innerHTML="Contact Person";
			document.getElementById('pago_nif2').innerHTML="NIF / CIF";
		}
		else if(idioma=="frances")
		{
			document.getElementById('pago_nombre2').innerHTML="Entreprise";
			document.getElementById('pago_apellidos2').innerHTML="Personne à contacter";
			document.getElementById('pago_nif2').innerHTML="NIF / CIF";
		}
		else
		{
			document.getElementById('pago_nombre2').innerHTML="Empresa";
			document.getElementById('pago_apellidos2').innerHTML="Persona de Contacto";
			document.getElementById('pago_nif2').innerHTML="NIF / CIF";
		}
		document.formulario.pago_nombre.value="";
		document.formulario.pago_apellidos.value="";
		document.formulario.pago_nif.value="";
		document.formulario.pago_nombre.focus();
	}
}

function cambiarFormasEnvio(idioma)
{
	var oXmlHttp=zXmlHttp.createRequest();
	
	oXmlHttp.open("get", "/actualizar-formas-envio.php?pais="+document.formulario.envio_pais.value+"&rand="+Math.random(), true);
	oXmlHttp.onreadystatechange=function()
	{
		if(oXmlHttp.readyState==4)
		{
			if(oXmlHttp.status==200)
			{
				var respuesta=unescape(oXmlHttp.responseText);
				respuesta=respuesta.replace(/\+/gi," ");
				
				document.getElementById("formas_envio").innerHTML=respuesta;
				document.getElementById("transportista").innerHTML="";
			}
		}
		else
		{
			respuesta='<select name="forma_envio" id="forma_envio" class="FormCesta7" disabled="disabled">';
			if(idioma=="ingles")
				respuesta+='<option value="">Select ...</option>';
			else if(idioma=="frances")
				respuesta+='<option value="">Sélectionnez ...</option>';
			else
				respuesta+='<option value="">Seleccione ...</option>';
			respuesta+='</select>';
			
			if(document.getElementById("formas_envio"))
				document.getElementById("formas_envio").innerHTML=respuesta;
			
			if(document.getElementById("transportista"))
				document.getElementById("transportista").innerHTML="";
		}
	}
	oXmlHttp.send(null);
}

function cambiarTransportista()
{
	var pos;
	var total2;
	var oXmlHttp=zXmlHttp.createRequest();
	
	oXmlHttp.open("get", "/actualizar-transportista.php?forma_envio="+document.formulario.forma_envio.value+"&rand="+Math.random(), true);
	oXmlHttp.onreadystatechange=function()
	{
		if(oXmlHttp.readyState==4)
		{
			if(oXmlHttp.status==200)
			{
				var respuesta=unescape(oXmlHttp.responseText);
				respuesta=respuesta.replace(/\+/gi," ");
				
				pos=respuesta.indexOf("#");
				var transportista=respuesta.substr(0, pos);
				respuesta=respuesta.substr((pos+1), respuesta.length);
				pos=respuesta.indexOf("#");
				var gastos=respuesta.substr(0, pos);
				var comision=respuesta.substr((pos+1), respuesta.length);
				
				gastos_envio=parseFloat(gastos.replace(",", "."));
				comision_cr=parseFloat(comision.replace(",", "."));
				
				if(document.formulario.forma_pago.value=="contra-reembolso")
					total=subtotal-dto_promo+gastos_envio+comision_cr;
				else
					total=subtotal-dto_promo+gastos_envio;
				
				total2=formatAsMoney(total) + "";
				total2=total2.replace(".", ",");
				
				document.getElementById("transportista").innerHTML=transportista;
				document.getElementById("gastos_envio").innerHTML=gastos;
				document.getElementById("comision_cr").innerHTML=comision;
				document.getElementById("total").innerHTML=total2;
			}
		}
		else
		{
			respuesta='';
			
			document.getElementById("transportista").innerHTML=respuesta;
		}
	}
	oXmlHttp.send(null);
}

function cambiarTarjeta(idioma)
{
	var respuesta;
	var total2;
	var display=document.getElementById("contra-reembolso").style.display;
	
	if(document.formulario.forma_pago.value=="tarjeta" || document.formulario.forma_pago.value=="paypal")
	{
		if(idioma=="ingles")
			respuesta='<img src="/img/cesta/tarjetas.png" alt="PayPal - Credit Card" width="139" height="23" align="absmiddle" title="PayPal - Credit Card" />';
		else if(idioma=="frances")
			respuesta='<img src="/img/cesta/tarjetas.png" alt="Carte PayPal - Credit" width="139" height="23" align="absmiddle" title="Carte PayPal - Credit" />';
		else
			respuesta='<img src="/img/cesta/tarjetas.png" alt="PayPal - Tarjeta de Crédito" width="139" height="23" align="absmiddle" title="PayPal - Tarjeta de Crédito" />';
		document.getElementById("tarjeta").innerHTML=respuesta;
		
		if(display!="none")
			new Effect.BlindUp("contra-reembolso", { duration:1.0 });
		
		total=subtotal-dto_promo+gastos_envio;
		
		total2=formatAsMoney(total) + "";
		total2=total2.replace(".", ",");
		
		document.getElementById("total").innerHTML=total2;
	}
	else if(document.formulario.forma_pago.value=="contra-reembolso")
	{
		document.getElementById("tarjeta").innerHTML='';
		
		if(display=="none")
			new Effect.BlindDown("contra-reembolso", { duration:1.0 });
		
		total=subtotal-dto_promo+gastos_envio+comision_cr;
		
		total2=formatAsMoney(total) + "";
		total2=total2.replace(".", ",");
		
		document.getElementById("total").innerHTML=total2;
	}
	else
	{
		document.getElementById("tarjeta").innerHTML='';
		
		if(display!="none")
			new Effect.BlindUp("contra-reembolso", { duration:1.0 });
		
		total=subtotal-dto_promo+gastos_envio;
		
		total2=formatAsMoney(total) + "";
		total2=total2.replace(".", ",");
		
		document.getElementById("total").innerHTML=total2;
	}
}

function cambiarDatosFacturacion()
{
	if(document.formulario.facturacion_igual_envio.checked==true)
	{
		if(document.formulario.envio_tipo[0].checked==true)
			document.formulario.pago_tipo[0].checked=true;
		else if(document.formulario.envio_tipo[1].checked==true)
			document.formulario.pago_tipo[1].checked=true;
		
		cambiarFormPago();
		
		document.formulario.pago_nombre.value=document.formulario.envio_nombre.value;
		document.formulario.pago_apellidos.value=document.formulario.envio_apellidos.value;
		document.formulario.pago_nif.value=document.formulario.envio_nif.value;
		document.formulario.pago_direccion.value=document.formulario.envio_direccion.value;
		document.formulario.pago_codigo_postal.value=document.formulario.envio_codigo_postal.value;
		document.formulario.pago_pais.value=document.formulario.envio_pais.value;
		document.formulario.pago_provincia.value=document.formulario.envio_provincia.value;
		document.formulario.pago_poblacion.value=document.formulario.envio_poblacion.value;
	}
	else
	{
		cambiarFormPago();
		
		document.formulario.pago_tipo[0].checked=true;
		document.formulario.pago_tipo[1].checked=false;
		document.formulario.pago_nombre.value="";
		document.formulario.pago_apellidos.value="";
		document.formulario.pago_nif.value="";
		document.formulario.pago_direccion.value="";
		document.formulario.pago_codigo_postal.value="";
		document.formulario.pago_pais.value="";
		document.formulario.pago_provincia.value="";
		document.formulario.pago_poblacion.value="";
	}
}

function mostrarCategoria(categoria)
{
	document.getElementById("categoria_"+categoria+"_visible").style.display='none';
	document.getElementById("categoria_"+categoria+"_oculta").style.display='block';
	
	new Effect.BlindDown("familias_"+categoria, { duration:1.0 });
}

function ocultarCategoria(categoria)
{
	document.getElementById("categoria_"+categoria+"_visible").style.display='block';
	document.getElementById("categoria_"+categoria+"_oculta").style.display='none';
	
	new Effect.BlindUp("familias_"+categoria, { duration:1.0 });
}

function mostrarRecordatorio()
{
	var display=document.getElementById("recordar_contrasena").style.display;
	
	if(display=="none")
		new Effect.BlindDown("recordar_contrasena", { duration:1.0 });
	else
		new Effect.BlindUp("recordar_contrasena", { duration:1.0 });
}

function mostrarIdentificacion()
{
	var display=document.getElementById("recordar_contrasena").style.display;
	
	if(display=="none")
		new Effect.BlindDown("recordar_contrasena", { duration:1.0 });
	
	new Effect.ScrollTo('inicio', { duration:1.0 });
}

function mostrarPaso(paso, paso_anterior, idioma)
{
	var goodEmail;
	var error="";
	var pos;
	var dto_promo2;
	var total2;
	
	if(paso==2 || paso==3 ||  paso==4 || paso==5 || paso=="fin")
	{
		if(document.formulario.envio_nombre.value.length==0)
		{
			if(document.formulario.envio_tipo[0].checked==true)
			{
				if(idioma=="ingles")
					error+="Delivery Information: Name missing.\n";
				else if(idioma=="frances")
					error+="Information Livraison: nom manquant.\n";
				else
					error+="Datos de Envío: falta el nombre.\n";
			}
			else
			{
				if(idioma=="ingles")
					error+="Delivery Information: Firm Name Missing.\n";
				else if(idioma=="frances")
					error+="Information Livraison: nom manquant.\n";
				else
					error+="Datos de Envío: falta la razón social.\n";
			}
		}
		if(document.formulario.envio_apellidos.value.length==0)
		{
			if(document.formulario.envio_tipo[0].checked==true)
			{
				if(idioma=="ingles")
					error+="Delivery Information: Last Name Missing.\n";
				else if(idioma=="frances")
					error+="Information Livraison: les noms manquants.\n";
				else
					error+="Datos de Envío: faltan los apellidos.\n";
			}
			else
			{
				if(idioma=="ingles")
					error+="Delivery Information: Contact person missing.\n";
				else if(idioma=="frances")
					error+="Information Livraison: manque la personne de contact.\n";
				else
					error+="Datos de Envío: falta la persona de contacto.\n";
			}
		}
		if(document.formulario.envio_nif.value.length==0)
		{
			if(document.formulario.envio_tipo[0].checked==true)
			{
				if(idioma=="ingles")
					error+="Delivery Information: NIF Missing.\n";
				else if(idioma=="frances")
					error+="Information Livraison: FNI disparus.\n";
				else
					error+="Datos de Envío: falta el NIF.\n";
			}
			else
			{
				if(idioma=="ingles")
					error+="Delivery Information: NIF/CIF Missing.\n";
				else if(idioma=="frances")
					error+="Information Livraison: Missing FNI / CIF.\n";
				else
					error+="Datos de Envío: falta el NIF / CIF.\n";
			}
		}
		if(document.formulario.envio_direccion.value.length==0)
		{
			if(idioma=="ingles")
				error+="Delivery Information: Adress Missing.\n";
			else if(idioma=="frances")
				error+="Information Livraison: manque de direction.\n";
			else
				error+="Datos de Envío: falta la dirección.\n";
		}
		if(document.formulario.envio_codigo_postal.value.length==0)
		{
			if(idioma=="ingles")
				error+="Delivery Information: Zip Code Missing.\n";
			else if(idioma=="frances")
				error+="Information Livraison: absent code postal.\n";
			else
				error+="Datos de Envío: falta el código postal.\n";
		}
		if(document.formulario.envio_pais.value.length==0)
		{
			if(idioma=="ingles")
				error+="Delivery Information: Country Missing.\n";
			else if(idioma=="frances")
				error+="Information Livraison: pays manquants.\n";
			else
				error+="Datos de Envío: falta el país.\n";
		}
		if(document.formulario.envio_provincia.value.length==0)
		{
			if(idioma=="ingles")
				error+="Delivery Information: Province/State Missing.\n";
			else if(idioma=="frances")
				error+="Information Livraison: absent de la province.\n";
			else
				error+="Datos de Envío: falta la provincia.\n";
		}
		if(document.formulario.envio_poblacion.value.length==0)
		{
			if(idioma=="ingles")
				error+="Delivery Information: City Missing.\n";
			else if(idioma=="frances")
				error+="Information Livraison: personnes disparues.\n";
			else
				error+="Datos de Envío: falta la población.\n";
		}
		if(document.formulario.envio_tipo[0].checked==true)
		{
			if(document.formulario.envio_dia_nacimiento.value.length==0)
			{
				if(idioma=="ingles")
					error+="Delivery Information: Day of Birth Missing.\n";
				else if(idioma=="frances")
					error+="Information Livraison: absent le jour de naissance.\n";
				else
					error+="Datos de Envío: falta el día de nacimiento.\n";
			}
			if(document.formulario.envio_mes_nacimiento.value.length==0)
			{
				if(idioma=="ingles")
					error+="Delivery Information: Month of Birth Missing.\n";
				else if(idioma=="frances")
					error+="Information Livraison: absent le mois de naissance.\n";
				else
					error+="Datos de Envío: falta el mes de nacimiento.\n";
			}
			if(document.formulario.envio_ano_nacimiento.value.length==0)
			{
				if(idioma=="ingles")
					error+="Delivery Information: Year or Birth Missing.\n";
				else if(idioma=="frances")
					error+="Information Livraison: année manquante de naissance.\n";
				else
					error+="Datos de Envío: falta el año de nacimiento.\n";
			}
			if(document.formulario.forma_envio.value.length==0)
			{
				if(idioma=="ingles")
					error+="Delivery Information: Delivery Method Missing.\n";
				else if(idioma=="frances")
					error+="Information Livraison: absent du port.\n";
				else
					error+="Datos de Envío: falta la forma de envío.\n";
			}
		}
		else if(document.formulario.forma_envio.value.length==0)
		{
			if(idioma=="ingles")
				error+="Delivery Information: Delivery Method Missing.\n";
			else if(idioma=="frances")
				error+="Information Livraison: absent du port.\n";
			else
				error+="Datos de Envío: falta la forma de envío.\n";
		}
	}
	
	if(paso==3 || paso==4 || paso==5 || paso=="fin")
	{
		if(document.formulario.pago_nombre.value.length==0)
		{
			if(document.formulario.pago_tipo[0].checked==true)
			{
				if(idioma=="ingles")
					error+="Invoicing Information: Name Missing.\n";
				else if(idioma=="frances")
					error+="Informations de facturation: nom manquant.\n";
				else
					error+="Datos de Facturación: falta el nombre.\n";
			}
			else
			{
				if(idioma=="ingles")
					error+="Invoicing Information: Firm Name Missing.\n";
				else if(idioma=="frances")
					error+="Informations de facturation: nom manquant.\n";
				else
					error+="Datos de Facturación: falta la razón social.\n";
			}
		}
		if(document.formulario.pago_apellidos.value.length==0)
		{
			if(document.formulario.pago_tipo[0].checked==true)
			{
				if(idioma=="ingles")
					error+="Invoicing Information: Last Name Missing.\n";
				else if(idioma=="frances")
					error+="Informations de facturation: les noms manquants.\n";
				else
					error+="Datos de Facturación: faltan los apellidos.\n";
			}
			else
			{
				if(idioma=="ingles")
					error+="Invoicing Information: Contact person Missing.\n";
				else if(idioma=="frances")
					error+="Informations de facturation: manque la personne de contact.\n";
				else
					error+="Datos de Facturación: falta la persona de contacto.\n";
			}
		}
		if(document.formulario.pago_nif.value.length==0)
		{
			if(document.formulario.pago_tipo[0].checked==true)
			{
				if(idioma=="ingles")
					error+="Invoicing Information: NIF Missing.\n";
				else if(idioma=="frances")
					error+="Informations de facturation: FNI disparus.\n";
				else
					error+="Datos de Facturación: falta el NIF.\n";
			}
			else
			{
				if(idioma=="ingles")
					error+="Invoicing Information: NIF/CIF Missing.\n";
				else if(idioma=="frances")
					error+="Informations de facturation: FNI manquant / CIF.\n";
				else
					error+="Datos de Facturación: falta el NIF / CIF.\n";
			}
		}
		if(document.formulario.pago_direccion.value.length==0)
		{
			if(idioma=="ingles")
				error+="Invoicing Information: Adress Missing.\n";
			else if(idioma=="frances")
				error+="Informations de facturation: manque de direction.\n";
			else
				error+="Datos de Facturación: falta la dirección.\n";
		}
		if(document.formulario.pago_codigo_postal.value.length==0)
		{
			if(idioma=="ingles")
				error+="Invoicing Information: Zip Code Missing.\n";
			else if(idioma=="frances")
				error+="Informations de facturation: absent code postal.\n";
			else
				error+="Datos de Facturación: falta el código postal.\n";
		}
		if(document.formulario.pago_pais.value.length==0)
		{
			if(idioma=="ingles")
				error+="Invoicing Information: Country Missing.\n";
			else if(idioma=="frances")
				error+="Informations de facturation: absent du pays.\n";
			else
				error+="Datos de Facturación: falta el país.\n";
		}
		if(document.formulario.pago_provincia.value.length==0)
		{
			if(idioma=="ingles")
				error+="Invoicing Information: Province/State Missing.\n";
			else if(idioma=="frances")
				error+="Informations de facturation: absent de la province.\n";
			else
				error+="Datos de Facturación: falta la provincia.\n";
		}
		if(document.formulario.pago_poblacion.value.length==0)
		{
			if(idioma=="ingles")
				error+="Invoicing Information: City Missing.\n";
			else if(idioma=="frances")
				error+="Informations de facturation: personnes disparues.\n";
			else
				error+="Datos de Facturación: falta la población.\n";
		}
		if(document.formulario.forma_pago.value.length==0)
		{
			if(idioma=="ingles")
				error+="Invoicing Information: Method of Payment Missing.\n";
			else if(idioma=="frances")
				error+="Informations de facturation: absent le paiement.\n";
			else
				error+="Datos de Facturación: falta la forma de pago.\n";
		}
	}
	
	if(paso==4 || paso==5 || paso=="fin")
	{
		if(document.formulario.contrasena)
		{
			goodEmail=document.formulario.email.value.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\.info)|(\..{2,2}))$)\b/gi);
			
			if(document.formulario.email.value.length==0)
			{
				if(idioma=="ingles")
					error+="Account Information: E-mail Adress Missing.\n";
				else if(idioma=="frances")
					error+="Informations sur le compte: Missing e-mail.\n";
				else
					error+="Datos de Cuenta: falta el e-mail.\n";
			}
			else if(!goodEmail)
			{
				if(idioma=="ingles")
					error+="Account Information: Wrong E-mail.\n";
				else if(idioma=="frances")
					error+="Informations sur le compte: e-mail erronée.\n";
				else
					error+="Datos de Cuenta: e-mail incorrecto.\n";
			}
			if(document.formulario.contrasena.value.length==0)
			{
				if(idioma=="ingles")
					error+="Account Information: Password Missing.\n";
				else if(idioma=="frances")
					error+="Informations sur le compte: mot de passe manquant.\n";
				else
					error+="Datos de Cuenta: falta la contraseña.\n";
			}
			if(document.formulario.contrasena_repetir.value.length==0)
			{
				if(idioma=="ingles")
					error+="Account Information: Password Repeat Missing.\n";
				else if(idioma=="frances")
					error+="Informations sur le compte: la nécessité de répéter le mot de passe.\n";
				else
					error+="Datos de Cuenta: falta repetir la contraseña.\n";
			}
			if(document.formulario.contrasena.value!=document.formulario.contrasena_repetir.value)
			{
				if(idioma=="ingles")
					error+="Account Information: Both Passwords have to be the same.\n";
				else if(idioma=="frances")
					error+="Informations sur le compte: mot de passe doit être égal.\n";
				else
					error+="Datos de Cuenta: las contraseñas deben ser iguales.\n";
			}
			
			if(error=="")
			{
				var oXmlHttp=zXmlHttp.createRequest();
				
				oXmlHttp.open("get", "/comprobar-email.php?email="+document.formulario.email.value+"&rand="+Math.random(), false);
				oXmlHttp.onreadystatechange=function()
				{
					if(oXmlHttp.readyState==4)
						if(oXmlHttp.status==200)
						{
							var respuesta=unescape(oXmlHttp.responseText);
							respuesta=respuesta.replace(/\+/gi," ");
							
							if(respuesta==1)
							{
								if(idioma=="ingles")
									error+="Account Information: E-mail Adress aldready exists.\n";
								else if(idioma=="frances")
									error+="Informations sur le compte: e-mail existe déjà.\n";
								else
									error+="Datos de Cuenta: el e-mail ya existe.\n";
							}
							else
							{
								document.formulario.email.disabled="disabled";
								document.formulario.contrasena.disabled="disabled";
								document.formulario.contrasena_repetir.disabled="disabled";
							}
						}
				}
				oXmlHttp.send(null);
			}
		}
	}
	
	if(paso==5 || paso=="fin")
	{
		if(document.formulario.clave_promo.disabled==false && document.formulario.clave_promo.value.length!=0)
		{
			var oXmlHttp=zXmlHttp.createRequest();
			
			oXmlHttp.open("get", "/comprobar-promocion.php?clave="+document.formulario.clave_promo.value+"&rand="+Math.random(), false);
			oXmlHttp.onreadystatechange=function()
			{
				if(oXmlHttp.readyState==4)
					if(oXmlHttp.status==200)
					{
						var respuesta=unescape(oXmlHttp.responseText);
						respuesta=respuesta.replace(/\+/gi," ");
						
						pos=respuesta.indexOf("#");
						var num_error=respuesta.substr(0, pos);
						var dto=respuesta.substr((pos+1), respuesta.length);
						
						if(num_error==1)
						{
							if(idioma=="ingles")
								error+="Promotion Information: Incorrect Code.\n";
							else if(idioma=="frances")
								error+="Informations sur la promotion: code erroné.\n";
							else
								error+="Datos de Promoción: código incorrecto.\n";
							
							document.formulario.clave_promo.value="";
						}
						else
						{
							dto_promo=parseFloat(dto.replace(",", "."));
							dto_promo=(subtotal*dto_promo)/100;
							
							if(document.formulario.forma_pago.value=="contra-reembolso")
								total=subtotal-dto_promo+gastos_envio+comision_cr;
							else
								total=subtotal-dto_promo+gastos_envio;
							
							dto_promo2=formatAsMoney(dto_promo) + "";
							dto_promo2=dto_promo2.replace(".", ",");
							
							total2=formatAsMoney(total) + "";
							total2=total2.replace(".", ",");
							
							new Effect.BlindDown('codigo_promo_ok', { duration:1.0 });
							new Effect.BlindDown('descuento', { duration:1.0 });
							
							document.getElementById("dto_porcentaje").innerHTML='('+dto+'%)';
							document.getElementById("dto").innerHTML=dto_promo2;
							document.getElementById("total").innerHTML=total2;
							
							document.formulario.clave_promo.disabled="disabled";
						}
					}
			}
			oXmlHttp.send(null);
		}
	}
	
	if(error=="")
	{
		if(paso==5 && document.formulario.clave_promo.value.length==0)
		{
			new Effect.BlindUp("paso4", { duration:1.0 });
			setTimeout('new Effect.BlindDown(\'paso'+paso+'\', { duration:1.0 });', 1000);
			setTimeout('new Effect.ScrollTo(\''+paso+'\', { duration:1.0 });', 2000);
		}
		else if(paso=="fin")
		{
			if(document.formulario.email)
				document.formulario.email.disabled="";
			if(document.formulario.contrasena)
				document.formulario.contrasena.disabled="";
			document.formulario.clave_promo.disabled="";
			
			document.formulario.action="/procesar-pedido/";
			document.formulario.method="post";
			document.formulario.submit();
		}
		else
		{
			new Effect.BlindUp("paso"+paso_anterior+"_check", { duration:1.0 });
			setTimeout('new Effect.BlindDown(\'paso'+paso+'\', { duration:1.0 });', 1000);
			setTimeout('new Effect.ScrollTo(\''+paso+'\', { duration:1.0 });', 2000);
		}
	}
	else
		alert(error);
}

function imprimirRecibo(pedido)
{
	document.formulario.action="/recibo-compra/";
	document.formulario.pedido.value=pedido;
	document.formulario.method="post";
	document.formulario.target="_blank";
	document.formulario.submit();
}

function comprobarContacto(idioma)
{
	var goodEmail;
	goodEmail=document.formulario.email.value.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\.info)|(\..{2,2}))$)\b/gi);
	
	if(document.formulario.nombre.value.length==0)
	{
		if(idioma=="ingles")
			alert("It is essential to add your name.");
		else if(idioma=="frances")
			alert("Il est impératif de fournir votre nom.");
		else
			alert("Es imprescindible que indique su nombre.");
		document.formulario.nombre.focus();
	}
	else if(document.formulario.apellidos.value.length==0)
	{
		if(idioma=="ingles")
			alert("It is essential to add your last name.");
		else if(idioma=="frances")
			alert("Il est essentiel d'indiquer leurs noms.");
		else
			alert("Es imprescindible que indique sus apellidos.");
		document.formulario.apellidos.focus();
	}
	else if(document.formulario.poblacion.value.length==0)
	{
		if(idioma=="ingles")
			alert("It is essential to add your city.");
		else if(idioma=="frances")
			alert("Il est essentiel d'indiquer sa population.");
		else
			alert("Es imprescindible que indique su población.");
		document.formulario.poblacion.focus();
	}
	else if(document.formulario.provincia.value.length==0)
	{
		if(idioma=="ingles")
			alert("It is essential to add your Province/State.");
		else if(idioma=="frances")
			alert("Il est essentiel d'indiquer leur province.");
		else
			alert("Es imprescindible que indique su provincia.");
		document.formulario.provincia.focus();
	}
	else if(document.formulario.codigo_postal.value.length==0)
	{
		if(idioma=="ingles")
			alert("It is essential to add your Zip Code.");
		else if(idioma=="frances")
			alert("Il est impératif d'indiquer votre code postal.");
		else
			alert("Es imprescindible que indique su código postal.");
		document.formulario.codigo_postal.focus();
	}
	else if(document.formulario.email.value.length==0)
	{
		if(idioma=="ingles")
			alert("It is essential to add your e-mail adress.");
		else if(idioma=="frances")
			alert("Il est impératif de fournir votre adresse e-mail.");
		else
			alert("Es imprescindible que indique su e-mail.");
		document.formulario.email.focus();
	}
	else if(!goodEmail)
	{
		if(idioma=="ingles")
			alert("E-Mail Format incorrect.");
		else if(idioma=="frances")
			alert("Le format de votre e-mail est incorrecte.");
		else
			alert("El formato de su e-mail es incorrecto.");
		document.formulario.email.focus();
	}
	else if(document.formulario.consulta.value.length==0)
	{
		if(idioma=="ingles")
			alert("It is essential to add your consult.");
		else if(idioma=="frances")
			alert("Il est impératif d'indiquer votre requête.");
		else
			alert("Es imprescindible que indique su consulta.");
		document.formulario.consulta.focus();
	}
	else
	{
		document.formulario.action="/enviaremail-contacto/";
		document.formulario.method="post";
		document.formulario.submit();
	}
}

function comprobarCesta(num_tallas, idioma)
{
	if(num_tallas>0)
	{
		if(document.formulario.item.value.length==0)
		{
			if(idioma=="ingles")
				alert("It is essential to add your Size.");
			else if(idioma=="frances")
				alert("Il est essentiel d'indiquer sa taille.");
			else
				alert("Es imprescindible que indique su talla.");
			document.formulario.item.focus();
		}
		else
		{
			document.formulario.action="/cesta/";
			document.formulario.method="post";
			document.formulario.submit();
		}
	}
	else
	{
		document.formulario.action="/cesta/";
		document.formulario.method="post";
		document.formulario.submit();
	}
}

function comprobarEmail(idioma)
{
	var goodEmail=document.formulario.email2.value.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\.info)|(\..{2,2}))$)\b/gi);
	
	if(document.formulario.email2.value.length==0)
	{
		if(idioma=="ingles")
			alert("It is essential to add your e-mail adress.");
		else if(idioma=="frances")
			alert("Il est impératif de fournir votre adresse e-mail.");
		else
			alert("Es imprescindible que indique su e-mail.");
		document.formulario.email2.focus();
	}
	else if(!goodEmail)
	{
		if(idioma=="ingles")
			alert("E-Mail Format incorrect.");
		else if(idioma=="frances")
			alert("Le format de votre e-mail est incorrecte.");
		else
			alert("El formato de su e-mail es incorrecto.");
		
		document.formulario.email2.focus();
	}
	else
	{
		var oXmlHttp=zXmlHttp.createRequest();
		
		oXmlHttp.open("get", "/enviaremail-contrasena.php?email="+document.formulario.email2.value+"&rand="+Math.random(), true);
		oXmlHttp.onreadystatechange=function()
		{
			if(oXmlHttp.readyState==4)
				if(oXmlHttp.status==200)
				{
					var respuesta=unescape(oXmlHttp.responseText);
					respuesta=respuesta.replace(/\+/gi," ");
					
					if(respuesta==1)
					{
						if(idioma=="ingles")
							document.getElementById("respuesta_recordar_contrasena").innerHTML='<img src="/img/cesta/alerta.png" alt="" width="16" height="16" align="absmiddle" style="margin-right:3px;" />&nbsp;Wrong Information.';
						else if(idioma=="frances")
							document.getElementById("respuesta_recordar_contrasena").innerHTML='<img src="/img/cesta/alerta.png" alt="" width="16" height="16" align="absmiddle" style="margin-right:3px;" />&nbsp;Des données incorrectes.';
						else
							document.getElementById("respuesta_recordar_contrasena").innerHTML='<img src="/img/cesta/alerta.png" alt="" width="16" height="16" align="absmiddle" style="margin-right:3px;" />&nbsp;Datos incorrectos.';
					}
					else
					{
						if(idioma=="ingles")
							document.getElementById("respuesta_recordar_contrasena").innerHTML='<img src="/img/cesta/email.png" alt="" width="16" height="16" align="absmiddle" style="margin-right:3px;" />&nbsp;Your password has been sent to the e-mail adress you typed.';
						else if(idioma=="frances")
							document.getElementById("respuesta_recordar_contrasena").innerHTML='<img src="/img/cesta/email.png" alt="" width="16" height="16" align="absmiddle" style="margin-right:3px;" />&nbsp;Votre mot de passe a été envoyé à l\'e-mail fournie.';
						else
							document.getElementById("respuesta_recordar_contrasena").innerHTML='<img src="/img/cesta/email.png" alt="" width="16" height="16" align="absmiddle" style="margin-right:3px;" />&nbsp;Su contraseña ha sido enviada al correo electrónico facilitado.';
					}
				}
		}
		oXmlHttp.send(null);
	}
}

function comprobarContrasenas(idioma)
{
	var error="";
	
	if(document.formulario.contrasena.value.length==0)
	{
		if(idioma=="ingles")
			error+="Account Information: Password Missing.\n";
		else if(idioma=="frances")
			error+="Informations sur le compte: mot de passe manquant.\n";
		else
			error+="Datos de Cuenta: falta la contraseña.\n";
	}
	if(document.formulario.contrasena_repetir.value.length==0)
	{
		if(idioma=="ingles")
			error+="Account Information: Password Repeat Missing.\n";
		else if(idioma=="frances")
			error+="Informations sur le compte: la nécessité de répéter le mot de passe.\n";
		else
			error+="Datos de Cuenta: falta repetir la contraseña.\n";
	}
	if(document.formulario.contrasena.value!=document.formulario.contrasena_repetir.value)
	{
		if(idioma=="ingles")
			error+="Account Information: Both Passwords have to be the same.\n";
		else if(idioma=="frances")
			error+="Informations sur le compte: mot de passe doit être égal.\n";
		else
			error+="Datos de Cuenta: las contraseñas deben ser iguales.\n";
	}
	
	if(error=="")
	{
		document.formulario.action="/editar-contrasena/";
		document.formulario.method="post";
		document.formulario.submit();
	}
	else
		alert(error);
}

function comprobarEditarUsuario(idioma)
{
	var error="";
	
	if(document.formulario.envio_nombre.value.length==0)
	{
		if(document.formulario.envio_tipo[0].checked==true)
		{
			if(idioma=="ingles")
				error+="Delivery Information: Name missing.\n";
			else if(idioma=="frances")
				error+="Information Livraison: nom manquant.\n";
			else
				error+="Datos de Envío: falta el nombre.\n";
		}
		else
		{
			if(idioma=="ingles")
				error+="Delivery Information: Firm Name Missing.\n";
			else if(idioma=="frances")
				error+="Information Livraison: nom manquant.\n";
			else
				error+="Datos de Envío: falta la razón social.\n";
		}
	}
	if(document.formulario.envio_apellidos.value.length==0)
	{
		if(document.formulario.envio_tipo[0].checked==true)
		{
			if(idioma=="ingles")
				error+="Delivery Information: Last Name Missing.\n";
			else if(idioma=="frances")
				error+="Information Livraison: les noms manquants.\n";
			else
				error+="Datos de Envío: faltan los apellidos.\n";
		}
		else
		{
			if(idioma=="ingles")
				error+="Delivery Information: Contact person missing.\n";
			else if(idioma=="frances")
				error+="Information Livraison: manque la personne de contact.\n";
			else
				error+="Datos de Envío: falta la persona de contacto.\n";
		}
	}
	if(document.formulario.envio_nif.value.length==0)
	{
		if(document.formulario.envio_tipo[0].checked==true)
		{
			if(idioma=="ingles")
				error+="Delivery Information: NIF Missing.\n";
			else if(idioma=="frances")
				error+="Information Livraison: FNI disparus.\n";
			else
				error+="Datos de Envío: falta el NIF.\n";
		}
		else
		{
			if(idioma=="ingles")
				error+="Delivery Information: NIF/CIF Missing.\n";
			else if(idioma=="frances")
				error+="Information Livraison: Missing FNI / CIF.\n";
			else
				error+="Datos de Envío: falta el NIF / CIF.\n";
		}
	}
	if(document.formulario.envio_direccion.value.length==0)
	{
		if(idioma=="ingles")
			error+="Delivery Information: Adress Missing.\n";
		else if(idioma=="frances")
			error+="Information Livraison: manque de direction.\n";
		else
			error+="Datos de Envío: falta la dirección.\n";
	}
	if(document.formulario.envio_codigo_postal.value.length==0)
	{
		if(idioma=="ingles")
			error+="Delivery Information: Zip Code Missing.\n";
		else if(idioma=="frances")
			error+="Information Livraison: absent code postal.\n";
		else
			error+="Datos de Envío: falta el código postal.\n";
	}
	if(document.formulario.envio_pais.value.length==0)
	{
		if(idioma=="ingles")
			error+="Delivery Information: Country Missing.\n";
		else if(idioma=="frances")
			error+="Information Livraison: pays manquants.\n";
		else
			error+="Datos de Envío: falta el país.\n";
	}
	if(document.formulario.envio_provincia.value.length==0)
	{
		if(idioma=="ingles")
			error+="Delivery Information: Province/State Missing.\n";
		else if(idioma=="frances")
			error+="Information Livraison: absent de la province.\n";
		else
			error+="Datos de Envío: falta la provincia.\n";
	}
	if(document.formulario.envio_poblacion.value.length==0)
	{
		if(idioma=="ingles")
			error+="Delivery Information: City Missing.\n";
		else if(idioma=="frances")
			error+="Information Livraison: personnes disparues.\n";
		else
			error+="Datos de Envío: falta la población.\n";
	}
	if(document.formulario.envio_tipo[0].checked==true)
	{
		if(document.formulario.envio_dia_nacimiento.value.length==0)
		{
			if(idioma=="ingles")
				error+="Delivery Information: Day of Birth Missing.\n";
			else if(idioma=="frances")
				error+="Information Livraison: absent le jour de naissance.\n";
			else
				error+="Datos de Envío: falta el día de nacimiento.\n";
		}
		if(document.formulario.envio_mes_nacimiento.value.length==0)
		{
			if(idioma=="ingles")
				error+="Delivery Information: Month of Birth Missing.\n";
			else if(idioma=="frances")
				error+="Information Livraison: absent le mois de naissance.\n";
			else
				error+="Datos de Envío: falta el mes de nacimiento.\n";
		}
		if(document.formulario.envio_ano_nacimiento.value.length==0)
		{
			if(idioma=="ingles")
				error+="Delivery Information: Year or Birth Missing.\n";
			else if(idioma=="frances")
				error+="Information Livraison: année manquante de naissance.\n";
			else
				error+="Datos de Envío: falta el año de nacimiento.\n";
		}
	}
	if(document.formulario.pago_nombre.value.length==0)
	{
		if(document.formulario.pago_tipo[0].checked==true)
		{
			if(idioma=="ingles")
				error+="Invoicing Information: Name Missing.\n";
			else if(idioma=="frances")
				error+="Informations de facturation: nom manquant.\n";
			else
				error+="Datos de Facturación: falta el nombre.\n";
		}
		else
		{
			if(idioma=="ingles")
				error+="Invoicing Information: Firm Name Missing.\n";
			else if(idioma=="frances")
				error+="Informations de facturation: nom manquant.\n";
			else
				error+="Datos de Facturación: falta la razón social.\n";
		}
	}
	if(document.formulario.pago_apellidos.value.length==0)
	{
		if(document.formulario.pago_tipo[0].checked==true)
		{
			if(idioma=="ingles")
				error+="Invoicing Information: Last Name Missing.\n";
			else if(idioma=="frances")
				error+="Informations de facturation: les noms manquants.\n";
			else
				error+="Datos de Facturación: faltan los apellidos.\n";
		}
		else
		{
			if(idioma=="ingles")
				error+="Invoicing Information: Contact person Missing.\n";
			else if(idioma=="frances")
				error+="Informations de facturation: manque la personne de contact.\n";
			else
				error+="Datos de Facturación: falta la persona de contacto.\n";
		}
	}
	if(document.formulario.pago_nif.value.length==0)
	{
		if(document.formulario.pago_tipo[0].checked==true)
		{
			if(idioma=="ingles")
				error+="Invoicing Information: NIF Missing.\n";
			else if(idioma=="frances")
				error+="Informations de facturation: FNI disparus.\n";
			else
				error+="Datos de Facturación: falta el NIF.\n";
		}
		else
		{
			if(idioma=="ingles")
				error+="Invoicing Information: NIF/CIF Missing.\n";
			else if(idioma=="frances")
				error+="Informations de facturation: FNI manquant / CIF.\n";
			else
				error+="Datos de Facturación: falta el NIF / CIF.\n";
		}
	}
	if(document.formulario.pago_direccion.value.length==0)
	{
		if(idioma=="ingles")
			error+="Invoicing Information: Adress Missing.\n";
		else if(idioma=="frances")
			error+="Informations de facturation: manque de direction.\n";
		else
			error+="Datos de Facturación: falta la dirección.\n";
	}
	if(document.formulario.pago_codigo_postal.value.length==0)
	{
		if(idioma=="ingles")
			error+="Invoicing Information: Zip Code Missing.\n";
		else if(idioma=="frances")
			error+="Informations de facturation: absent code postal.\n";
		else
			error+="Datos de Facturación: falta el código postal.\n";
	}
	if(document.formulario.pago_pais.value.length==0)
	{
		if(idioma=="ingles")
			error+="Invoicing Information: Country Missing.\n";
		else if(idioma=="frances")
			error+="Informations de facturation: absent du pays.\n";
		else
			error+="Datos de Facturación: falta el país.\n";
	}
	if(document.formulario.pago_provincia.value.length==0)
	{
		if(idioma=="ingles")
			error+="Invoicing Information: Province/State Missing.\n";
		else if(idioma=="frances")
			error+="Informations de facturation: absent de la province.\n";
		else
			error+="Datos de Facturación: falta la provincia.\n";
	}
	if(document.formulario.pago_poblacion.value.length==0)
	{
		if(idioma=="ingles")
			error+="Invoicing Information: City Missing.\n";
		else if(idioma=="frances")
			error+="Informations de facturation: personnes disparues.\n";
		else
			error+="Datos de Facturación: falta la población.\n";
	}
	
	if(error=="")
	{
		document.formulario.action="/editar-usuario/";
		document.formulario.method="post";
		document.formulario.submit();
	}
	else
		alert(error);
}

function comprobarUsuarioRegistrado(from, idioma)
{
	var goodEmail=document.formulario.email2.value.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\.info)|(\..{2,2}))$)\b/gi);
	
	if(document.formulario.email2.value.length==0)
	{
		if(idioma=="ingles")
			alert("It is essential to add your e-mail adress.");
		else if(idioma=="frances")
			alert("Il est impératif de fournir votre adresse e-mail.");
		else
			alert("Es imprescindible que indique su e-mail.");
		document.formulario.email2.focus();
	}
	else if(!goodEmail)
	{
		if(idioma=="ingles")
			alert("E-Mail Format incorrect.");
		else if(idioma=="frances")
			alert("Le format de votre e-mail est incorrecte.");
		else
			alert("El formato de su e-mail es incorrecto.");
		document.formulario.email2.focus();
	}
	else if(document.formulario.contrasena2.value.length==0)
	{
		if(idioma=="ingles")
			alert("It is essential to add your password.");
		else if(idioma=="frances")
			alert("Il est essentiel d'ajouter votre mot de passe.");
		else
			alert("Es imprescindible que indique su contraseña.");
		document.formulario.contrasena2.focus();
	}
	else
	{
		var oXmlHttp=zXmlHttp.createRequest();
		
		oXmlHttp.open("get", "/autenticar-usuario.php?usuario="+document.formulario.email2.value+"&clave="+document.formulario.contrasena2.value+"&from="+from+"&rand="+Math.random(), true);
		oXmlHttp.onreadystatechange=function()
		{
			if(oXmlHttp.readyState==4)
				if(oXmlHttp.status==200)
				{
					var respuesta=unescape(oXmlHttp.responseText);
					respuesta=respuesta.replace(/\+/gi," ");
					
					if(respuesta==1)
					{
						if(idioma=="ingles")
							document.getElementById("respuesta_recordar_contrasena").innerHTML='<img src="/img/cesta/alerta.png" alt="" width="16" height="16" align="absmiddle" style="margin-right:3px;" />&nbsp;Wrong Information.';
						else if(idioma=="frances")
							document.getElementById("respuesta_recordar_contrasena").innerHTML='<img src="/img/cesta/alerta.png" alt="" width="16" height="16" align="absmiddle" style="margin-right:3px;" />&nbsp;Des données incorrectes.';
						else
							document.getElementById("respuesta_recordar_contrasena").innerHTML='<img src="/img/cesta/alerta.png" alt="" width="16" height="16" align="absmiddle" style="margin-right:3px;" />&nbsp;Datos incorrectos.';
					}
					else
					{
						if(from=="cesta")
							window.location.href="/cesta/";
						else
							window.location.href="/";
					}
				}
		}
		oXmlHttp.send(null);
	}
}

function descargar(carpeta, nombre)
{
	descarga.document.location.href="descarga.php?carpeta=" + carpeta + "&nombre=" + nombre;
}

function popUpImagen(URL)
{
	imagen=window.open(URL, 'imagenAmpliada', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=670,height=430,left=100,top=100');
	imagen.focus();
}

function tabular(e, obj)
{ 
	tecla=(document.all) ? e.keyCode : e.which;
	
	if(tecla!=13)
		return;
	
	frm=obj.form;
	
	for(i=0; i<frm.elements.length; i++)
		if(frm.elements[i]==obj)
		{ 
			if(i==frm.elements.length-1)
				i=-1;
			
			break;
		}
	
	frm.elements[i+1].focus();
	
	return false; 
}

function intro(e, obj)
{ 
	tecla=(document.all) ? e.keyCode : e.which;
	
	if(tecla!=13)
		return;
	
	comprobarBuscar();
	
	return false; 
}

function goto(pagina, destino)
{
	form.action="privado_"+pagina+".php";
	form.accion.value="consultar";
	form.target=destino;
	form.submit();
}

function gotoinicio(pagina, destino)
{
	form.action="procesa_"+pagina+".php";
	form.method="post";
	form.enctype="multipart/form-data";
	form.accion.value="inicio";
	form.target=destino;
	form.submit();
}

function listado(pagina, destino)
{
	form.action="/listado_"+pagina+".php";
	form.method="post";
	form.target=destino;
	form.submit();
}

function guardar()
{
	var code=htmlCode.getCode();
	
	form.texto.value=code;
	form.accion.value="guardar";
	form.submit();
}

function guardar2()
{
	form.accion.value="guardar";
	form.submit();
}

function consultar()
{
	form.accion.value="consultar";
	form.submit();
}

function eliminar()
{
	var entrar;
	
	entrar=confirm("¿Está seguro que desea eliminar este registro?");
	if(entrar)
	{
		form.accion.value="eliminar";
		form.submit();
	}
	else
		event.returnValue=false;
}

function buscar(tabla)
{
	var x;
	x=window.open("buscador.php?tabla="+tabla,"v","status=0,resizable=0,toolbar=0,location=0,directories=0,menubar=0,scrollbars=0,width=645,height=465,top=50,left=50");
	
	event.returnValue=false;
}

function submitMyForm()
{ 
	form.target='foo'; 
	x=window.open('',form.target,'status=no,resizable=no,toolbar=no,location=no,directories=no,menubar=no,scrollbars=no,width=720,height=500,top=50,left=50');
	form.submit(); 
	return false; 
} 

function do_save()
{
	window.opener.currentTextArea.value=htmlCode.getCode();
	window.close();
	window.opener.focus();
}
