function saveRecomendation(pAction)
{
	if(trim(document.getElementById('RECV_Name').value)=='')
	{
		window.alert('Ingrese su Nombre');
		document.getElementById('RECV_Name').focus();
		return;
	}

	if(trim(document.getElementById('RECV_Email').value)=='')
	{
		window.alert('Ingrese su E-mail');
		document.getElementById('RECV_Email').focus();
		return;
	}
	else
	{
		if(!checkEmail(trim(document.getElementById('RECV_Email').value)))
		{
			window.alert('Ingrese un E-mail valido');
			document.getElementById('RECV_Email').focus();
			return;
		}
	}

	if (isEmptyGuests()>0)
	{
		window.alert('Ingrese El nombre y correo de su(s) amigo(s)');
		return;
	}

	document.getElementById('general').action = pAction;
	document.getElementById('general').submit();
}

function cleanRecomendation()
{
	document.getElementById('RECV_Name').value='';
	document.getElementById('RECV_Email').value='';
	document.getElementById('RECV_Name_Friend').selectedIndex=0;	
}
/*
function addAnotherGuest(obj)
{
	var nro_txt_passengers = dameNrInputs_Guests();
	var inc = 2;
	
	while (inc <= nro_txt_passengers) 
	{
 		var obj1 = document.getElementById("guest_detail_block" + inc);
 		var obj2 = document.getElementById("guest_main_block" + inc);
		obj1.parentNode.removeChild(obj1);
		obj2.parentNode.removeChild(obj2);
		inc++;
	}

	var total1	= parseInt(obj.value);
	for (var i=2; i<=total1; i++)
	{
		var varTr1_main	= document.createElement('tr');
		varTr1_main.id 	= "guest_main_block" + i;
	
			var varTd1_Tr1_main			= document.createElement('td');
			varTd1_Tr1_main.width 		= "12";
			varTd1_Tr1_main.align 		= "left";
			var varImg 					= document.createElement('img');
			varImg.src 					= "images/spacer.gif";
			varImg.width 				= "12";
			varImg.height				= "10";
			varTd1_Tr1_main.appendChild(varImg);
	
			var varTd2_Tr1_main			= document.createElement('td');
			varTd2_Tr1_main.className 	= "arial10 padright15";
			var caprion 			= "Invitado " + i;		
			var nodoTextoOption 		= document.createTextNode(caprion);
			varTd2_Tr1_main.appendChild(nodoTextoOption);
		
			var varTr2_main	= document.createElement('tr');
			varTr2_main.style.height = "40px";
			varTr2_main.id = "guest_detail_block" + i;
			
			var varTd1_Tr2_main			= document.createElement('td');
			varTd1_Tr2_main.width 		= "12";
			varTd1_Tr2_main.align 		= "left";			
			var varImg					= document.createElement('img');
			varImg.src 					= "images/spacer.gif";
			varImg.width 				= "12";
			varImg.height				= "10";
			varTd1_Tr2_main.appendChild(varImg);
	
			var varTd2_Tr2_main			= document.createElement('td');
			var caption 			= 'Su nombre';
			var nodoTextoOption 		= document.createTextNode(caption);
			varTd2_Tr2_main.className 	= 'arial10 padright15';
			varTd2_Tr2_main.align 		= "left";
			varTd2_Tr2_main.width 		= "66";
			varTd2_Tr2_main.appendChild(nodoTextoOption);
					
			var varTd3_Tr2_main			= document.createElement('td');					
			varTd3_Tr2_main.width 		= "113";
			varTd3_Tr2_main.align 		= "left";
			var inputBox2 				= document.createElement("input");
			var nombreInput 			= "RECV_Name_Friend_" + i;
			inputBox2.type 				= "text";
			inputBox2.name 				= "RECV_Name_Friend[]";
			inputBox2.id 				= nombreInput;
			inputBox2.style.width 		= "141px";			
			varTd3_Tr2_main.appendChild(inputBox2);
	

			var varTd4_Tr2_main			= document.createElement('td');
			var caption 			= 'Su apellido';
			var nodoTextoOption 		= document.createTextNode(caption);
			varTd4_Tr2_main.className 	= 'arial10 padright15';
			varTd4_Tr2_main.align 		= "left";
			varTd4_Tr2_main.width 		= "60";
			varTd4_Tr2_main.appendChild(nodoTextoOption);
			
			var varTd5_Tr2_main			= document.createElement('td');					
			varTd3_Tr2_main.width 		= "109";
			varTd3_Tr2_main.align 		= "left";
			var inputBox2 				= document.createElement("input");
			var nombreInput 			= "RECV_Email_Friend" + i;
			inputBox2.type 				= "text";
			inputBox2.name 				= "RECV_Email_Friend[]";
			inputBox2.id 				= nombreInput;
			inputBox2.style.width 		= "141px";
			varTd5_Tr2_main.appendChild(inputBox2);

		varTr1_main.appendChild(varTd1_Tr1_main);
		varTr1_main.appendChild(varTd2_Tr1_main);		
		varTr2_main.appendChild(varTd1_Tr2_main);
		varTr2_main.appendChild(varTd2_Tr2_main);
		varTr2_main.appendChild(varTd3_Tr2_main);
		varTr2_main.appendChild(varTd4_Tr2_main);
		varTr2_main.appendChild(varTd5_Tr2_main);
	
		var content = document.getElementById("contenedor_guest");
		content.appendChild(varTr1_main);
		content.appendChild(varTr2_main);
	}
}
*/
function addAnotherGuest(obj)
{
	var nro_txt_passengers = dameNrInputs_Guests();
	var inc = 2;
	
	while (inc <= nro_txt_passengers) 
	{
 		var obj1 = document.getElementById("guest_detail_block" + inc);
		obj1.parentNode.removeChild(obj1);
		inc++;
	}

	var total1	= parseInt(obj.value);
	for (var i=2; i<=total1; i++)
	{
			var varTr2_main	= document.createElement('tr');
			varTr2_main.id = "guest_detail_block" + i;
			
			var varTd2_Tr2_main			= document.createElement('td');
			var caption 			= 'Nombre';
			var nodoTextoOption 		= document.createTextNode(caption);
			varTd2_Tr2_main.align 		= "right";
			varTd2_Tr2_main.appendChild(nodoTextoOption);
					
			var varTd3_Tr2_main			= document.createElement('td');					
			var inputBox2 				= document.createElement("input");
			var nombreInput 			= "RECV_Name_Friend_" + i;
			inputBox2.type 				= "text";
			inputBox2.name 				= "RECV_Name_Friend[]";
			inputBox2.id 				= nombreInput;
			inputBox2.className 		= "box_med2";			
			varTd3_Tr2_main.appendChild(inputBox2);
	

			var varTd4_Tr2_main			= document.createElement('td');
			var caption 			= 'E-mail';
			var nodoTextoOption 		= document.createTextNode(caption);
			varTd4_Tr2_main.align 		= "right";
			varTd4_Tr2_main.appendChild(nodoTextoOption);
			
			var varTd5_Tr2_main			= document.createElement('td');					
			var inputBox2 				= document.createElement("input");
			var nombreInput 			= "RECV_Email_Friend" + i;
			inputBox2.type 				= "text";
			inputBox2.name 				= "RECV_Email_Friend[]";
			inputBox2.id 				= nombreInput;
			inputBox2.className 		= "box_med2";
			varTd5_Tr2_main.appendChild(inputBox2);

		varTr2_main.appendChild(varTd2_Tr2_main);
		varTr2_main.appendChild(varTd3_Tr2_main);
		varTr2_main.appendChild(varTd4_Tr2_main);
		varTr2_main.appendChild(varTd5_Tr2_main);
	
		var content = document.getElementById("contenedor_guest");
		content.appendChild(varTr2_main);
	}
}


function dameNrInputs_Guests()
{
	var total1=0;
	var varInputs = document.getElementsByTagName('input');
	for (var i=0; i<varInputs.length;i++) 
	{
		if (varInputs[i].id.substr(0, 16) == "RECV_Name_Friend")
		{
			total1 += 1;
		}
	}
	return total1;
}


function isEmptyGuests()
{
	var total1=0;
	var varInputs = document.getElementsByTagName('input');
	for (var i=0; i<varInputs.length;i++) 
	{
		if (varInputs[i].id.substr(0, 16) == "RECV_Name_Friend")
		{
			if (varInputs[i].value=='')
			{
				total1 += 1;
			}
		}
		
		if (varInputs[i].id.substr(0, 17) == "RECV_Email_Friend")
		{
			if (varInputs[i].value=='')
			{
				total1 += 1;
			}
		}
	}
	return total1;
}
