// JavaScript Document
function comprobar(idioma,imagen,producto){
	if (document.contacto.nombre.value == '') {
		if (idioma == 'cast'){
			alert ('Por favor, escriba su nombre');	
		}
		if (idioma == 'cat'){
			alert ('Si us plau, escrigui el seu nom');	
		}
		if (idioma == 'ingl'){
			alert ('Please,  fill in your name');	
		}		
		if (idioma == 'fr'){
			alert ('Veuillez indiquer vos nom et prénom');	
		}
	} else {
		if (document.contacto.telefono.value == ''){
			if (idioma == 'cast'){
				alert ('Por favor, escriba su teléfono');	
			}
			if (idioma == 'cat'){
				alert ('Si us plau, escrigui el seu telèfon');	
			}
			if (idioma == 'ingl'){
				alert ('Please, fill in your contact number');	
			}				
			if (idioma == 'fr'){
				alert ('Veuillez indiquer votre numéro de téléphone');	
			}	
		} else {
			enviar(idioma,imagen,producto);	
		}
	}
}


function enviar(idioma,imagen,producto){
	if (idioma == 'cast'){
		var tabla_contacto = '<table width="486" height="320" border="0" cellpadding="0" cellspacing="0">';
		tabla_contacto +=   '<tr><td width="486" colspan="3" align="center" class="atencion_form_si">Gr&aacute;cias por su solicitud de informaci&oacute;n,<br />    En breve uno de nuestros agentes se pondr&aacute; en contacto con usted.&nbsp;</td></tr>';
		tabla_contacto +=	'</table>';
	}
	if (idioma == 'cat'){
		var tabla_contacto = "<table width='486' height='320' border='0' cellpadding='0' cellspacing='0'>";
		tabla_contacto +=   "<tr><td width='486' colspan='3' align='center' class='atencion_form_si'>Gr&agrave;cies per la seva sol&middot;licitud d'informaci&oacute;. En breu un dels nostres agents   es posar&agrave; en contacte amb vost&egrave;.</td></tr>";
		tabla_contacto +=	"</table>";
	}
	if (idioma == 'ingl'){
		var tabla_contacto = "<table width='486' height='320' border='0' cellpadding='0' cellspacing='0'>";
		tabla_contacto +=   "<tr><td width='486' colspan='3' align='center' class='atencion_form_si'>Thank you for your interest in our products. Our technical advisors will contact you soon.</td></tr>";
		tabla_contacto +=	"</table>";
	}	
	if (idioma == 'fr'){
		var tabla_contacto = "<table width='486' height='320' border='0' cellpadding='0' cellspacing='0'>";
		tabla_contacto +=   "<tr><td width='486' colspan='3' align='center' class='atencion_form_si'>Merci de votre demande d'informations. Nous nous  mettrons en contact avec vous dans les meilleurs d&eacute;lais.</td></tr>";
		tabla_contacto +=	"</table>";

	}		
	var con_enviar= new XHConn();
	var nombre = document.contacto.nombre.value;
	var empresa = document.contacto.empresa.value;
	var direccion = document.contacto.direccion.value;
	var poblacion = document.contacto.poblacion.value;
	var provincia = document.contacto.provincia.value;	
	var telefono = document.contacto.telefono.value;	
	var email = document.contacto.email.value;	
	var comentarios = document.contacto.comentarios.value;
	var casilla = document.contacto.casilla.checked;
	var producto = document.contacto.producto.value;
	var idioma = document.contacto.idioma.value;
	var unidades = document.contacto.unidades.value;
	comentarios = new String(comentarios.replace(/\n/g,"<br>"));
	comentarios = new String(comentarios.replace(/\r/g,"<br>"));	

	if (idioma == 'cast'){
		volver = "volver";		
	}
	if (idioma == 'cat'){	
		volver = "tornar";		
	}
	if (idioma == 'ingl'){
		volver = "back";
	}
	if (idioma == 'fr'){
		volver = "retour";
	}	

	var fin_enviar = function (oXML) { document.getElementById('div_enviar').innerHTML = tabla_contacto; document.getElementById('div_boton').innerHTML = "<a class=\"atencion_enviar\" href=\"javascript:carga_formulario('"+producto+"','"+imagen+"','"+idioma+"');\">"+volver+"</a>";
	if (idioma == 'cast'){
		pageTracker._trackPageview('/mail_contacto_ficha_cast.php'); 
	}
	if (idioma == 'cat'){	
		pageTracker._trackPageview('/mail_contacto_ficha_cat.php'); 	
	}
	if (idioma == 'ingl'){
		pageTracker._trackPageview('/mail_contacto_ficha_ingl.php'); 
	}
	if (idioma == 'fr'){
		pageTracker._trackPageview('/mail_contacto_ficha_fr.php'); 
	}
	};	
	document.getElementById('div_boton').innerHTML = "";	
	con_enviar.connect('../dinamic/form_ficha.php', 'GET', 'unidades='+unidades+'&idioma='+idioma+'&nombre='+nombre+'&telefono='+telefono+'&empresa='+empresa+'&direccion='+direccion+'&poblacion='+poblacion+'&provincia='+provincia+'&email='+email+'&comentarios='+comentarios+'&casilla='+casilla+'&producto='+producto, fin_enviar);			


}

function carga_formulario (producto,imagen,idioma){
	var con_formu= new XHConn();
	var fin_formu = function (oXML) { document.getElementById('formulario_ajax').innerHTML = oXML.responseText; };	
	con_formu.connect('../dinamic/formulario.php', 'GET', 'producto='+producto+'&imagen='+imagen+'&idioma='+idioma, fin_formu);				
}