// JavaScript Document
function comprobar(desde){
	if (document.contacto.nombre.value == '') {
		alert ('Por favor, escriba su nombre');	
	} else {
		if (document.contacto.telefono.value == ''){
			alert ('Por favor, escriba su teléfono');
		} else {
			enviar(desde);	
		}
	}
}

var tabla_contacto = '<table width="728" border="0" cellpadding="0" cellspacing="0">';
tabla_contacto +=  '<tr><td height="27" background="img/top_formulario.gif">&nbsp;</td></tr>';
tabla_contacto +=  '<tr><td height="259" align="center" bgcolor="#FFF3E8" class="borde_FFD0A3_izq borde_FFD0A3_der verdana txt14 granate"><p>Gr&aacute;cias por su solicitud de informaci&oacute;n,<br />    En breve uno de nuestros agentes se pondr&aacute; en contacto con usted. </p><p>&nbsp;</p></td></tr>';
tabla_contacto +=  '</table>';
tabla_contacto +=  '<table width="728" border="0" cellpadding="0" cellspacing="0">';
tabla_contacto +=  '<tr><td height="15" bgcolor="#FFF3E8" class="borde_FFD0A3_izq"><span class="borde_FFD0A3_der"><img src="img/pixel.gif" width="1" height="1" /></span></td><td width="688" rowspan="2" align="right" valign="middle" bgcolor="#FFF3E8" class="borde_FFD0A3_inf">&nbsp;</td><td height="15" bgcolor="#FFF3E8" class="borde_FFD0A3_der"><img src="img/pixel.gif" width="1" height="1" /></td></tr>';
tabla_contacto +=  '<tr><td width="20" height="19"><img src="img/esquina_catalogo_inf_izq.gif" width="20" height="20" /></td><td width="20" height="19"><img src="img/esquina_catalogo_inf_der.gif" width="20" height="20" /></td></tr>';
tabla_contacto +=  '</table>';


var tabla_ficha = '<table width="728" border="0" cellpadding="0" cellspacing="0">';
tabla_ficha += '<tr><td width="19" height="28" bgcolor="#FFDBB8" class="borde_E9D7D3 borde_FFD0A3_izq ">&nbsp;</td>';
tabla_ficha += '<td width="709" height="28" bgcolor="#FFDBB8" class="borde_E9D7D3 verdana txt14 negrita granate_form">&nbsp;</td></tr>';
tabla_ficha += '<tr><td height="151" colspan="2" align="center" bgcolor="#FFF3E8" class="borde_FFD0A3_izq borde_FFD0A3_der verdana txt14 granate"><p>Gr&aacute;cias por su solicitud de informaci&oacute;n,<br />En breve uno de nuestros agentes se pondr&aacute; en contacto con usted. </p></td></tr>';
tabla_ficha += '</table>';
tabla_ficha += '<table width="728" border="0" cellpadding="0" cellspacing="0">';
tabla_ficha += '<tr><td height="15" bgcolor="#FFF3E8" class="borde_FFD0A3_izq"><span class="borde_FFD0A3_der"><img src="img/pixel.gif" width="1" height="1" /></span></td><td width="688" rowspan="2" align="right" valign="middle" bgcolor="#FFF3E8" class="borde_FFD0A3_inf">&nbsp;</td><td height="15" bgcolor="#FFF3E8" class="borde_FFD0A3_der"><img src="img/pixel.gif" width="1" height="1" /></td></tr>';
tabla_ficha += '<tr><td width="20" height="19"><img src="img/esquina_catalogo_inf_izq.gif" width="20" height="20" /></td><td width="20" height="19"><img src="img/esquina_catalogo_inf_der.gif" width="20" height="20" /></td></tr>';
tabla_ficha += '</table> ';



function enviar(desde){
	document.getElementById('boton').innerHTML = '';
	var con_enviar= new XHConn();
	var nombre = document.contacto.nombre.value;
	var telefono = document.contacto.telefono.value;	
	var email = document.contacto.email.value;	
	var comentarios = document.contacto.comentarios.value;
	if (desde == 'ficha') { 
		var info = document.contacto.info.value;
		var fin_enviar = function (oXML) { document.getElementById('div_enviar').innerHTML = tabla_ficha; };
		con_enviar.connect('form_contacto.php', 'GET', 'desde='+desde+'&nombre='+nombre+'&telefono='+telefono+'&email='+email+'&comentarios='+comentarios+'&info='+info, fin_enviar);		
	}
	if (desde == 'contacto') {
		var empresa = document.contacto.empresa.value;
		var direccion = document.contacto.direccion.value;		
		var cp = document.contacto.cp.value;		
		var poblacion = document.contacto.poblacion.value;		
		var provincia = document.contacto.provincia.value;			
		var fin_enviar = function (oXML) { document.getElementById('div_enviar').innerHTML = tabla_contacto; };	
		con_enviar.connect('form_contacto.php', 'GET', 'desde='+desde+'&nombre='+nombre+'&telefono='+telefono+'&email='+email+'&comentarios='+comentarios+'&empresa='+empresa+'&direccion='+direccion+'&cp='+cp+'&poblacion='+poblacion+'&provincia='+provincia, fin_enviar);			
	}

}


function comprobar_envio_boletines(){
	if (document.getElementById('nombre').value != ''){		
		if (document.getElementById('email').value != ''){			
			if (document.getElementById('poblacion').value != ''){
					var nombre = document.getElementById('nombre').value;
					var poblacion = document.getElementById('poblacion').value;					
					var email = document.getElementById('email').value;	
					var con_enviar_boletines= new XHConn();
					var fin_enviar_boletines = function (oXML) { document.getElementById('div_enviar').innerHTML = oXML.responseText; };
					con_enviar_boletines.connect('suscripcion_boletines/agregar_boletines.php', 'GET', 'nombre='+nombre+'&email='+email+'&poblacion='+poblacion, fin_enviar_boletines);		
					
			} else {
				alert("Introduzca su poblacion");	
			}
		} else {
			alert("Introduzca una dirección de correo");			
		}
	} else {
		alert("Introduzca su nombre");
	}
}