//-------------------------------------------------------------------------------------

//

// Autor: Carlos Martínez

// Email: carlos.martinez@fusiona.cl

// Descripción:

//	Envia mensaje a amigo por correo.

//

// Última modificación: 2010-07-24 - Carlos Martínez <carlos.martinez@fusiona.cl>

//

//-------------------------------------------------------------------------------------

  $(document).ready(function(){
			
				
				$("#chasis").alphanumeric({allow:" .,()="});
					$("#rut").numeric({allow:" .-kK"});
$("#nombre").alphanumeric({allow:" .-"});

$("#fono").numeric({allow:" -"});
$("#celular").numeric({allow:" -"});
$("#correo").alphanumeric({allow:" @._-"});
				
			   });

function sendToMyFriend(form)

{

	if (!checkForm(form))

	{

		return false;

	}

	else

	{

		var data_mail = {};

		data_mail['amigo_mail']		= $('#amigo_mail').val();

		data_mail['amigo_asunto']	= $('#amigo_asunto').val();

		data_mail['amigo_comentario']	= $('#amigo_comentario').val()

		data_mail['amigo_url']		= window.location.href;



		$.ajax({

			url: '/ajax/auto/sendToMyFriend.php',

			data: data_mail,

			dataType: 'json',

			success: closeFriendBox

		});



		return false;

	}

}



function closeFriendBox(data)

{

	if (data == 'true')

	{

		alert('Tu invitación fue enviada correctamente');

		$('.comparte_amigo').colorbox.close();

		$('#amigo_mail').val('');

		$('#amigo_asunto').val('');

		$('#amigo_comentario').val('')

	}

	else if (data == 'false')

	{

		alert('No es posible enviar la invitación en este momento. Por favor intente más tarde.');

	}

}



function send()
{
	document.getElementById('form_consulta').submit();
	
	}
	
	
	
function enviar()
{
	document.getElementById('envia_datos').submit();
	
	}
	
	

