
function today_num(a) {
	var bdtoday=new Date();
	var bdDAY = bdtoday.getDate();
	var bdMTH = bdtoday.getMonth() + 1;
	var curYR = bdtoday.getFullYear();
	var BDNUM = 0;
	var BDMTH = 0;
	var YRVALUE = 0;
	var BDVALUE = 0;
	
	if (bdDAY == 9||bdDAY == 18||bdDAY == 27) {BDNUM = 9;}
	else {BDNUM = bdDAY % 9;}
	
	if (bdMTH == 9) {BDMTH = 9;}
	else {BDMTH = (bMTH) % 9;}
	
	if (curYR == 2016||curYR == 2025) {YRVALUE = 9;}
	else {YRVALUE = (curYR + 3 - 2010) % 9;}
	
	var testCur = BDNUM + BDMTH + YRVALUE;
	if (testCur == 9||testCur == 18||testCur == 27) {BDVALUE = 9;}
	else {BDVALUE = (testCur) % 9;}

	if (a == "yr") {
		return curYR;
	}
	if (a == "bdno") {
		return BDVALUE;
	}
	if (a == "bdtxt") {
		return value_txt(BDVALUE);
	}
//document.write("Testing Year and Value:  ",curYR," is ",BDVALUE,".")
}

//switch the phrase returned based on the value set
function value_txt(bdval) {
var BDPHRASE = "";

switch(bdval) {
case 1:
	BDPHRASE = "Leadership, Independence, Originality, Desire to achieve, ambitious, creative, strong, self-reliant, and determined to get on in the world by your own ability.  Pioneer, explorer, inventor, director, manager, executive, owner or head of any business."
  	break
case 2:
	BDPHRASE = "You are a Peacemaker, Troubleshooter, or Arbitrator.  Cooperation.  You will usually be in some kind of partnership.  Occupations include diplomat, politician, psychologist, student, teacher, secretary, statistician. You work well with others and perform on behalf of your associates as well as for yourself. You usually marry. You are a good musician or dancer."
  	break
case 3:
	BDPHRASE = "You are Optimistic, Self Expressive, Creative, Cheerful, Popular, Social Friendly, Artistic, Practical, Writer, Singer, Entertainer. You have natural writing ability. Friends are important in your life. You are a true friend."
  	break
case 4:
	BDPHRASE = "The Worker, the Builder. You are practical and you establish systems, order, form, and regulation in your business and personal dealings. Honest, sincere, patient, determined, faithful. Be careful of your selection of friends. Occupations include builder, engineer, mason, contractor, electrician, skilled craftsman, technician, statistician."
  	break
case 5:
	BDPHRASE = "You love Freedom and Change. You are knowledgeable, outgoing, open-minded, and resourceful. Accept the new and drop the old. Broaden your life by mixing with people of all ages, education, thought, and social activities. You would be good in advertising, selling, entertainment, and promotions."
  	break
case 6:
	BDPHRASE = "You are a Counselor, Consultant, an Advisor. You would be good in social work. You are responsible, understanding, and sympathetic.  Your relationships are important to you. You give a helping hand where it is needed. Your career could be in nursing, medicine, restaurant owner, Chef. You will succeed in occupations connected with homes, institution, community. You would make a good teacher or professor."
  	break
case 7:
	BDPHRASE = "You are one who seeks Knowledge, Wisdom, Education, and Philosophy. You will study, test, prove, and get at the facts about the unknown. You will write, teach, and demonstrate the mysteries of life. You are a loner and others have a hard time getting to know you. They think that you are different and strange, but you are not. You live your life by spiritual truths, not by other people’s standards. You will be loved and respected for your knowledge and wisdom. You are a perfectionist. Your career should not involve physical labor or machinery. Occupations could include educator, teacher, lawyer, scientist, minister, priest, rabbi, inventor, computers, and astrology."
  	break
case 8:
	BDPHRASE = "You are an Executive by Nature. You belong in your own business or working for a corporation.  Your journey will not be an easy one and your success will come through knowledge, financial effort, and determination. If you work for personal satisfaction and not monetary rewards you will be successful. You must always keep a balance between the spiritual and the material and work for the good of all rather than just for personal gains; you will be rewarded. Occupations should include coaching, education, broker, executive positions."
  	break
case 9:
 	BDPHRASE = "You are Kind, Warm, Loving, and Understanding and will live a life of service to people. You must be free to express your emotions where kindness and understanding is needed. People from all walks of life will come to you seeking your understanding, compassion, and generosity. Don’t allow popularity to go to your head. Occupations are teacher, writer, nurse, medical profession, lawyer, philanthropist, preacher, reformer, humanitarian, painter, musician, composer, actor or actress."
  	break
}

	return BDPHRASE;

//document.write(BDPHRASE)
}

//Grab entered info to calculate other birthdays
function CalcNew(frm) {
	var tryD=new Date();
	var tryYR = tryD.getFullYear();
	var tryMth = tryD.getMonth() + 1;
	var tryDay = tryD.getDate();
	var testdays = 0;
	var NEWDAY = 0;
	var NEWMTH = 0;
	var NEWYR = 0;
	var NEWBDVALUE = 0;
	var BDPHRASE = "";
    for (var i=0; i < frm.elements.length; ++i) {
        form_field = frm.elements[i]
        form_name = form_field.name
		if (form_name == "yrPick") {tryYR = tryYR + parseInt(form_field.value)}
		if (form_name == "mthno") {
			if (form_field.value >=1&&form_field.value<=12) {tryMth = parseInt(form_field.value) }
			else {frm.mthno.value = tryMth }
		}
		if (form_name == "dayno") {
			if (form_field.value >=1) {tryDay = parseInt(form_field.value) }
			else {frm.dayno.value = tryDay }
		}
	}
//Correct for max days in month
	if (tryMth == 4||tryMth == 6||tryMth == 9||tryMth == 11) {
		testdays = 30;
	}
	if (tryMth == 1||tryMth == 3||tryMth == 5||tryMth == 7||tryMth == 8||tryMth == 10||tryMth == 12) {
		testdays = 31;
	}
	if (tryMth == 2) {
		if (tryYR == 2012||tryYR == 2016||tryYR == 2020) {testdays = 29;}
		else {testdays = 28;}
	}

	if (tryDay > testdays) {
		tryDay = testdays;
		frm.dayno.value = tryDay;
	}

//Correct for multiples of 9
	if (tryDay == 9||tryDay == 18||tryDay == 27) {NEWDAY = 9;}
	else {NEWDAY = tryDay % 9;}
	
	if (tryMth == 9) {NEWMTH = 9;}
	else {NEWMTH = tryMth % 9;}
	
	if (tryYR == 2016||tryYR == 2025) {NEWYR = 9;}
	else {NEWYR = tryYR % 9;}
	
	var testNew = NEWDAY + NEWMTH + NEWYR;
	if (testNew == 9||testNew == 18||testNew == 27) {NEWBDVALUE = 9;}
	else {NEWBDVALUE = (testNew) % 9;}

//Display the tested birthday value	
	frm.newBD.value = NEWBDVALUE
	frm.bd_text.value = value_txt(NEWBDVALUE)

	return NEWBDVALUE;
}

//Display the form to test other birthdays
function toggleMe(a){
  var e=document.getElementById(a);
  if(!e)return true;
  if(e.style.display=="none"){
    e.style.display="block"
  } else {
    e.style.display="none"
  }
  CalcNew(this.tryForm);
  return true;
}

