
function getSuma(fecha)
{
	var conta, i, longitud;
	
	conta = 0;
	
	longitud = fecha.length;
	
	for (i = 0;i<longitud;i++)
	{
		if (!((fecha.charAt(i) >= 0) && (fecha.charAt(i) <= 9)))
		{
			return(-1);
		}
		
		conta = conta + parseInt(fecha.charAt(i))
	} 
	
	if (conta > 9)
	{
		return(getSuma(conta.toString()));
	}
	else
	{
		return(conta);
	}
}

function getLetterNumber(letter_orig)
{
	letter = (letter_orig.toString()).toUpperCase();

	if ((letter == 'A') || (letter == 'J') || (letter == 'S') || (letter == 'Á'))
		return 1;
	if ((letter == 'B') || (letter == 'K') || (letter == 'T'))
		return 2;
	if ((letter == 'C') || (letter == 'L') || (letter == 'U') || (letter == 'Ú'))
		return 3;
	if ((letter == 'D') || (letter == 'M') || (letter == 'V'))
		return 4;
	if ((letter == 'E') || (letter == 'N') || (letter == 'W') || (letter == 'É'))
		return 5;
	if ((letter == 'F') || (letter == 'O') || (letter == 'X') || (letter == 'Ó'))
		return 6;
	if ((letter == 'G') || (letter == 'P') || (letter == 'Y'))
		return 7;
	if ((letter == 'H') || (letter == 'Q') || (letter == 'Z'))
		return 8;
	if ((letter == 'I') || (letter == 'R') || (letter == 'Í'))
		return 9;
	if (letter == ' ')
		return 0;
	return -1;
}

function getSumaName(fecha)
{
	var conta, conta_aux, i, longitud;
	
	conta = 0;
	
	longitud = fecha.length;
	
	for (i = 0;i<longitud;i++)
	{
		conta_aux = getLetterNumber(fecha.charAt(i));
		if (conta_aux >= 0)
		{ 	conta = conta + conta_aux; }
		else
		{   
			return(-1);
		}
	} 
	
	if (conta > 9)
	{
		return(getSuma(conta.toString()));
	}
	else
	{
		return(conta);
	}
}

function openMision(tu, tupareja)
{
//	alert(pagina);
    window.open("http://www.mipunto.com/punto_fusion/compatibilidad/juntos.jsp?tu="+tu+"&tupareja="+tupareja, 'Mision', 'scrollbars=yes,resizable=no,status=no,toolbar=no,width=420,height=400,top=100,left=100');	
}

function openMisionName(tu, tupareja)
{
//	alert(pagina);
    window.open("http://www.mipunto.com/punto_fusion/compatibilidad/juntos_nombre.jsp?tu="+tu+"&tupareja="+tupareja, 'Mision', 'scrollbars=yes,resizable=no,status=no,toolbar=no,width=420,height=400,top=100,left=100');	
}

function getMision()
{
	var mision1, mision2;
	
	mision1 = getSuma(document.frmnumero.cb_dia1.options[document.frmnumero.cb_dia1.selectedIndex].value + document.frmnumero.cb_mes1.options[document.frmnumero.cb_mes1.selectedIndex].value + document.frmnumero.cb_anio1.options[document.frmnumero.cb_anio1.selectedIndex].value);
	mision2 = getSuma(document.frmnumero.cb_dia2.options[document.frmnumero.cb_dia2.selectedIndex].value + document.frmnumero.cb_mes2.options[document.frmnumero.cb_mes2.selectedIndex].value + document.frmnumero.cb_anio2.options[document.frmnumero.cb_anio2.selectedIndex].value);
	openMision(mision1,mision2);
	
}

function getMisionName()
{
	var mision1, mision2;
	
	mision1 = getSumaName(document.frmnombres.txt_tu.value);
	mision2 = getSumaName(document.frmnombres.txt_tupareja.value);
	if ((mision1 == -1) || (mision2 == -1))
	{
		alert("Los nombres no deben contener acentos, espacios o caracteres especiales."); 
	}
	else
	{
		openMisionName(mision1,mision2);
	}
}
