var AvcSendFriend = 
{
	init : function(siteUrl)
	{
		$form  = $("#senfriend_form");
		$form.submit(
			function()
			{
				$.ajax({
		            type: 'POST',
		            url: siteUrl + 'avc/contact/send-friend',
		            data: $form.serialize(),
		            dataType: 'json',
		            success: function(data, textStatus) {
						if(!data.isValid)
						{
							$('#senfriend_form_error').get(0).style.visibility = 'visible';
							$('#senfriend_form_error').html("");
							for (i=0; i< data.messages.length; i++)
							{
								var currentHtml = $('#senfriend_form_error').html();
								$('#senfriend_form_error').html(currentHtml + data.messages[i] + "<br />"); 
							}
						}
						else
						{
							document.location.href = $form.get(0).action;
						}
		            }
		        });
				
				return false;
			}
		);
	}
}