var block=false;
	jQuery(document).ready(function($) {
		
	      $('a[rel*=facebox]').facebox({
	        //close_image   : 'images/closelabel.gif'
			//loading_image : 'loading.gif',
			loadingImage : '/images/loading.gif',
			closeImage : '/images/closelabel.gif'
		  })
		
	})

function faceExtension() {
	//set depending on DIV or AJAX
	var myForm=document.forms[1];
	var regEmail=/^(?:(?:[\.\w\d_-ñ]{2,})@(?:[A-Z0-9_-]+)(?:\.[a-z\d_-ñ]+);?)+$/i;
	var regName=/^[^\d]+$/i;
	//var regName=/^[^\d]+$/i;
	var error=null;
	var valuesOK=[];
		
	
	$('.close').click(function () {
		jQuery(document).trigger('close.facebox');
	});
	
	if (block)
		$("input:submit",myForm).attr('disabled','true');
	
	$(myForm).submit(function() {
				
		$("input:text",myForm).each(function(i) {
					
			if ( $(this).val() =='' || $(this).val() ==null ){
					return doTheSame(this);
				}
			
			else if( ( $(this).attr("id") == 'envio_emails' || $(this).attr("id") == 'remitente_email') && !regEmail.test($(this).val()) ) {
				return doTheSame(this);
			}
			
			else if( ( $(this).attr("id") == 'envio_nombres' || $(this).attr("id") == 'remitente_nombre') && !regName.test($(this).val())  ) {
				return doTheSame(this);
			}
					
			else { 
				error=false;
				valuesOK[i]=$(this).val();
				$(this).removeClass("novalida");
				$(this).addClass("fb_text_input");
				
			};

		 });
				
		if (! error) {
			var eF = valuesOK[0];
			var nF = valuesOK[1];
			var yE = valuesOK[2];
			var yN = valuesOK[3];
			var ck = $("input[@id='envio_email']",myForm).attr('checked');
			var cmt = $("#envio_email_comentario",myForm).val();
			var tipo = $("#tipo",myForm).val();
			var lk = location.href;
			
			//jQuery.facebox({ ajax: '{http://sdes1lnx:33274/sendEFriend.html} {emailFriend='+eF+'&nameFriend='+nF+'&yourEmail='+yE+'&yourName='+yN+'&comment='+cmt+'&checkB='+ck+'&link='+lk+'}' });
			jQuery.facebox({ ajax: '{http:/sendEFriend.html} {tipo='+tipo+'&emailFriend='+eF+'&nameFriend='+nF+'&yourEmail='+yE+'&yourName='+yN+'&comment='+cmt+'&checkB='+ck+'&link='+lk+'}' });
			
			block=true;
			
		}
	
	return false;
	});
	
	
	function doTheSame(obj) {
		$(obj).focus();
		$('#mostrar_error_enviar','.faceContent').show();
		$(obj).removeClass("fb_text_input");
		$(obj).addClass("novalida");
		error=true;
		return false;
	}
}
