
function send_Obj(element)
{
	switch(element)
	{
		case "SolicitudDeCertificado": { send_SolicitudDeCertificado(); break; }
		case "Suggeriments": { send_Suggeriments(); break; }
		case "Contacta": { send_Contacta(); break; }
	}
}

function send_SolicitudDeCertificado() { $("#platformSolicitudDeCertificado").load("../../exec/solicitud_de_certificado.php", {method:'post', numero_identificacion:$("#numero_identificacion_let").val()+"-"+$("#numero_identificacion_num").val(), centro_veterinario:$("#centro_veterinario").val(), nombre_responsable_de_la_mascota:$("#nombre_responsable_de_la_mascota").val(), direccion:$("#direccion").val(), codigo_postal:$("#codigo_postal").val(), poblacion:$("#poblacion").val(), telefono:$("#telefono").val(), email:$("#email").val(), nombre_mascota:$("#nombre_mascota").val(), numero_de_microchip:$("#numero_de_microchip").val(), edad:$("#edad").val(), raza:$("#raza").val() } ); }

function sendOK_SolicitudDeCertificado(mensaje) { $("#divSolicitudDeCertificado").fadeOut("slow", function() { $("#okSolicitudDeCertificado").html('<p>'+mensaje+'</p>').fadeIn("def"); } ); }
function sendEr_SolicitudDeCertificado(mensaje) { $("#divSolicitudDeCertificado").fadeOut("slow", function() { $("#erSolicitudDeCertificado").html('<p>'+mensaje+'</p>').fadeIn("def"); } ); }

//--------------------------------------------------------------------------------------------------

function check_Suggeriments()
{
	var sErr = "";
	
	if ( $( '#nom' ).val().length == 0 ) { 
		if(idioma == 'ct'){
			sErr += "\n> Ha d'introduir el Nom";
		}
		else if(idioma == 'es'){
			sErr += "\n> Debe introducir el Nombre";
		} 
	}
	if ( !validateEmail( $( '#email' ).val() ) && !validateString( $( '#telefon' ).val(), 5 ) ) {
		if(idioma == 'ct'){ 
			sErr += "\n> Ha d'introduir un tel\u00E8fon o email v\u00E0lids";
		}
		else if(idioma == 'es'){
			sErr += "\n> Debe introducir un tel\u00E9fono o email v\u00E1lidos";
		} 
	}
	if ( $( '#assumpte' ).val().length == 0 ) { 
		if(idioma == 'ct'){
			sErr += "\n> Ha d'introduir el Assumpte";
		}
		else if(idioma == 'es'){
			sErr += "\n> Debe introducir el Asunto";
		} 
	}

	if(sErr.length > 0) { 
		if(idioma == 'ct'){
			alert( "Si us plau, comprovi els seg\u00FCents errors:" + sErr );
		}
		else if(idioma == 'es'){
			alert( "Por favor, compruebe los siguientes errores:" + sErr );
		}
		 
	}
	else{ $( '#formSuggeriments' ).submit(); }
}

function send_Suggeriments() { $("#platformSuggeriments").load("../../exec/suggeriments.php", {method:'post', nom:$("#nom").val(), telefon:$("#telefon").val(), email:$("#email").val(), assumpte:$("#assumpte").val() } ); }

function sendOK_Suggeriments() { $("#divSuggeriments").fadeOut("slow", function() { $("#okSuggeriments").fadeIn("def"); } ); }
function sendER_Suggeriments() { $("#divSuggeriments").fadeOut("slow", function() { $("#erSuggeriments").fadeIn("def"); } ); }

//--------------------------------------------------------------------------------------------------

function check_contacta()
{
	var sErr = "";
	
	if ( $( '#nom' ).val().length == 0 ) {
		if(idioma == 'ct'){
			sErr += "\n> Ha d'introduir el Nom";
		}
		else if(idioma == 'es'){
			sErr += "\n> Debe introducir el Nombre";
		} 
	}
	if ( !validateEmail( $( '#email' ).val() ) && !validateString( $( '#telefon' ).val(), 5 ) ) { 
		if(idioma == 'ct'){ 
			sErr += "\n> Ha d'introduir un tel\u00E8fon o email v\u00E0lids";
		}
		else if(idioma == 'es'){
			sErr += "\n> Debe introducir un tel\u00E9fono o email v\u00E1lidos";
		} 
	}
	if ( $( '#assumpte' ).val().length == 0 ) { 
		if(idioma == 'ct'){
			sErr += "\n> Ha d'introduir el Assumpte";
		}
		else if(idioma == 'es'){
			sErr += "\n> Debe introducir el Asunto";
		} 
	}

	if(sErr.length > 0) {
		if(idioma == 'ct'){
			alert( "Si us plau, comprovi els seg\u00FCents errors:" + sErr );
		}
		else if(idioma == 'es'){
			alert( "Por favor, compruebe los siguientes errores:" + sErr );
		}
	}
	else{ $( '#formContacta' ).submit(); }
	
	
}

function send_Contacta() { $("#platformContacta").load("../../exec/contacta.php", {method:'post', nom:$("#nom").val(), telefon:$("#telefon").val(), email:$("#email").val(), assumpte:$("#assumpte").val() } ); }

function sendOK_Contacta() { $("#divSuggeriments").fadeOut("slow", function() { $("#okContacta").fadeIn("def"); } ); }
function sendER_Contacta() { $("#divSuggeriments").fadeOut("slow", function() { $("#erContacta").fadeIn("def"); } ); }

//--------------------------------------------------------------------------------------------------
//---- VALIDATE ------------------------------------------------------------------------------------

function validateString( sValue, minSize )
{
	if ( sValue === undefined ) { return false; }
	else { return sValue.length > minSize; }
}

function validateNum( sValue )
{
	var patternNum = /^([0-9])*$/;

	return patternNum.test( sValue );
}

function validateTxt( sValue )
{
	var patternTxt = /^([a-zA-Z])*$/;

	return patternTxt.test( sValue );
}

function validateEmail( sValue )
{
	var patternEmail = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;

	return patternEmail.test( sValue );
}

//---- ******** ----

function check_SolicitudDeCertificado()
{
	var sErr = "";
	
	if ( ($( '#numero_identificacion_let' ).val().length != 3) || ($( '#numero_identificacion_num' ).val().length != 5) ) { 
		if(idioma == 'ct'){
			sErr += "\n> Ha d'introduir el Codi d'incineraci\u00F3";
		}
		else if(idioma == 'es'){
			sErr += "\n> Debe introducir el Codigo de incineraci\u00F3n";
		}
	}
	if ( $( '#centro_veterinario' ).val().length == 0 ) {
		if(idioma == 'ct'){ 
			sErr += "\n> Ha d'introduir el Centre veterinari"; 
		}
		else if(idioma == 'es'){
			sErr += "\n> Debe introducir el Centro veterinario";
		}
	}
	if ( $( '#nombre_responsable_de_la_mascota' ).val().length == 0 ) { 
		if(idioma == 'ct'){
			sErr += "\n> Ha d'introduir el Nom i cognoms del responsable de la mascota";
		}
		else if(idioma == 'es'){
			sErr += "\n> Debe introducir el Nombre y apellidos del responsable de la mascota";
		} 
	}
	if ( $( '#direccion' ).val().length == 0 ) {
		if(idioma == 'ct'){ 
			sErr += "\n> Ha d'introduir l'Adre\u00E7a";
		}
		else if(idioma == 'es'){
			sErr += "\n> Debe introducir la Direcci\u00F3n";
		} 
	}
	if ( $( '#codigo_postal' ).val().length == 0 ) {
		if(idioma == 'ct'){ 
			sErr += "\n> Ha d'introduir el Codi Postal";
		}
		else if(idioma == 'es'){
		sErr += "\n> Debe introducir el C\u00F3digo Postal";
		} 
	}
	if ( $( '#telefono' ).val().length == 0 ) { 
		if(idioma == 'ct'){
			sErr += "\n> Ha d'introduir un Tel\u00E8fon";
		}
		else if(idioma == 'es'){
			sErr += "\n> Debe introducir el  un Tel\u00E9fono";
		} 
	}
	if ( $( '#poblacion' ).val().length == 0 ) { 
		if(idioma == 'ct'){			
			sErr += "\n> Ha d'introduir la Poblaci\u00F3";
		}
		else if(idioma == 'es'){
			sErr += "\n> Debe introducir la Poblaci\u00F3n";
		}
	 }
	if ( !validateEmail( $( '#email' ).val() )  ){ 
		if(idioma == 'ct'){
			sErr += "\n> Ha d'introduir un email v\u00E0lid";
		}
		else if(idioma == 'es'){
			sErr += "\n> Debe introducir un email v\u00E1lido";
		} 
	}
	if ( $( '#nombre_mascota' ).val().length == 0 ) { 
		if(idioma == 'ct'){
			sErr += "\n> Ha d'introduir el Nom de la mascota";
		}
		else if(idioma == 'es'){
			sErr += "\n> Debe introducir el  Nombre de la mascota";
		} 
	}
	

	if(sErr.length > 0) { 
		if(idioma == 'ct'){
			alert( "Si us plau, comprovi els seg\u00FCents errors:" + sErr );
		}
		else if(idioma == 'es'){
			alert( "Por favor, compruebe los siguientes errores:" + sErr );
		}
	}
	else{ send_SolicitudDeCertificado(); }
}

function validateSolicitudDeCertificadoLet(Element)
{
	if(!validateTxt(Element.value)) { $('#'+Element.id).val($('#'+Element.id).val().substring(0, $('#'+Element.id).val().length - 1 )); }
}

function validateSolicitudDeCertificadoNum(Element)
{
	if(!validateNum(Element.value)) { $('#'+Element.id).val($('#'+Element.id).val().substring(0, $('#'+Element.id).val().length - 1 )); }
}

function EmailMesInfoFormacioFunction()
{
	if( $("#email").val().indexOf("@") > -1 )
	{
		$("#email").css("border","1px solid #bdb5ab");
		
		if( $('#acepto:checked').val() != "on" ) { $("#aceptoTxt").css("color","red"); }
		else { $("#EmailMesInfoFormacioPlatform").load("../../exec/email_mes_info_formacio.php", {method:'post', email:$("#email").val() }, function(){ $("#email").val(""); document.location.href = "index.php"; } ); }
	}
	else
	{
		$("#email").css("border","1px solid red");
	}
}


