// JavaScript Document
// for gailminogue.com
//Uncover your life path program.
//December 17, 2007

function clearAnyInvalidValue(){

	document.dateOfBirthForm.titleCompound.style.color = "#000000";
    document.dateOfBirthForm.titleCompound.value = "";
	document.dateOfBirthForm.titleCompoundBody.style.color = "#000000";
    document.dateOfBirthForm.titleCompoundBody.value = ""; 
	document.dateOfBirthForm.titlePath.style.color = "#000000";
    document.dateOfBirthForm.titlePath.value = "";
	document.dateOfBirthForm.titlePathBody.style.color = "#000000";
    document.dateOfBirthForm.titlePathBody.value = "";

}
	

function addDegitsFromYear(yearToBeAdded){
	var modBase = 1000;
	var digitsAdded=0;
	yearToBeAdded = parseInt(yearToBeAdded);
	while (modBase >= 10){
		digitsAdded = ((Math.floor(yearToBeAdded/modBase)) + digitsAdded);
		yearToBeAdded = yearToBeAdded % modBase;
		modBase = modBase/10;
	}
	digitsAdded = digitsAdded + yearToBeAdded;
	return digitsAdded;
}

function checkIfIsaLeapYear(yearCheckLeap){

	yearCheckLeap = parseInt(yearCheckLeap);

	if(yearCheckLeap%4 == 0){
	
		if(yearCheckLeap%100 != 0){
			return true;
		}else{
			if(yearCheckLeap%400 == 0)
				return true;
			else
				return false;
		}
	}
	return false;
}

function mainFunction()
{	
	var MonthNameString= new Array(12);	
	MonthNameString[0] = "January";
	MonthNameString[1] = "February";
	MonthNameString[2] = "March";
	MonthNameString[3] = "April";
	MonthNameString[4] = "May";
	MonthNameString[5] = "June";
	MonthNameString[6] = "July";
	MonthNameString[7] = "August";
	MonthNameString[8] = "September";
	MonthNameString[9] = "October";
	MonthNameString[10] = "November";
	MonthNameString[11] = "December";
	
	var yourMessege= new Array(13);
	yourMessege[0] = "Individuality, independence, self-reliance, self-assertion,\n"+ 
					 "self-development, leadership, innovation. You must pursue your own\n"+ 
					 "personal vision while respecting the rights of others. You function\n"+ 
					 "best in environments which encourage self-reliance.";
					 
	yourMessege[1] = "Cooperation, sensitivity to the needs of others, to learn tact,\n"+ 
			         "diplomacy, persuasion and not force, patience and the ability to see\n"+ 
					 "both sides. It is important to be decisive as there is a tendency to\n"+
					 "be indecisive and procrastinate.";
					 
	yourMessege[2] = "Creativity, self-expression, joy, communication skills (writing,\n"+ 
				     "speaking). Express life through creativity, beauty, friends and\n"+ 
					 "happiness. You have a gift with words.";
					 
	yourMessege[3] = "Organized, disciplined, a methodical approach to live, productive,\n"+ 
					 "hardworking, results oriented, practical. You have the ability to get\n"+ 
					 "the job done.\n";
					 
	yourMessege[4] = "Freedom, change, adaptability, salesperson, trainer, versatile, the\n"+ 
					 "seeker, the teacher. You are the catalyst of change for others and\n"+
					 "need your freedom to try the new. You must learn to make constructive\n"+ 
					 "rather than destructive change.";
					 
	yourMessege[5] = "Healer, teacher, counselor, family responsibility and service.You\n"+ 
					 "are a harmonizing influence for others and you are learning\n"+ 
					 "compassion. Artistic and loving you need to feel needed and\n"+ 
					 "appreciated.";
					 
	yourMessege[6] = "Philosophical, analytical, introspective, wanting to know. Likes to\n"+ 
					 "uncover the truth. Interested in the Spiritual rather than the\n"+ 
					 "religious. Need to be around smart people and find work that uses\n"+ 
					 "your mind. You will benefit by higher education and specialization.";
					 
	yourMessege[7] = "Ability to combine the Spiritual and material worlds. The leader,\n"+ 
					 "boss, and person in authority. You don't want anyone to tell you\n"+ 
					 "what to do. Need to learn the laws of money, energy and time.\n"+
					 "Important to surround yourself with powerful people so you can\n"+ 
					 "see how power does or doesn't work.";
					 
	yourMessege[8] = "Tolerance, compassion, understanding of the human condition. Letting\n"+ 
					 "go and learning the law of discard. Give without worrying what is to\n"+ 
					 "be returned to you. Forgiveness. Detachment. An appreciation of beauty\n"+ 
					 "and the arts. Learning to give to sustain usefulness of purpose."; 
					 
	yourMessege[9] = "Your compound number is 11, Lead and inspire. Bring light into the\n"+ 
					 "weary world through writing, acting, politics and peacekeeping. Learn\n"+ 
					 "to be the bridge between the worlds. Spiritual, altruistic, a leader,\n"+ 
					 "magnetic, romantic and prophetic.";
					 
	yourMessege[10] ="Your compound number is 22, Philanthropy and service to the masses.\n"+
					 "You must improve society's lot on whatever level you manifest.\n"+ 
					 "Improve society in very useful and practical ways.";
					 
	yourMessege[11] ="Your compound number is 33, Service the needs of humanity. Primarily\n"+
					 "direct your life towards benefiting, serving, helping and ministering\n"+ 
					 "to as many people as possible. Be a firm believer in maintaining\n"+ 
					 "justice and human rights.";
					 
	yourMessege[12] ="If your compound number is 44, Your Spiritual goal is to further\n"+ 
					 "material good for humanity. Help the world's underprivileged. Help\n"+ 
					 "others to achieve their own success. Benefit large numbers of people.";
					 
	

	var monthIn = parseInt(document.dateOfBirthForm.birthdayMonth.value);
	var dayIn = parseInt(document.dateOfBirthForm.birthdayDay.value);
	var yearIn = parseInt(document.dateOfBirthForm.birthdayYear.value);
	var compoundNumIndex=0;
	var isItLeap;
	var flagWrownDate = 0;
	
	clearAnyInvalidValue();

	if ( monthIn == 0 || dayIn == 0 || yearIn == 0){
		flagWrownDate = 1;
		alert ("Please select a proper date of birth");
	}
		
	if ( monthIn == 4 || monthIn == 6 || monthIn == 9 || monthIn == 11){
		if(dayIn == 31){
			flagWrownDate = 1;
			alert("Error... "+MonthNameString[monthIn-1]+ " has only 30 days.\nPlease select a proper date of birth");
		}
	}
	 
		isItLeap = checkIfIsaLeapYear(yearIn);
		if(isItLeap)
		{
		 	if ( monthIn == 2){
			 	if(dayIn == 30 || dayIn == 31){
					flagWrownDate = 1;
					alert("Error... February has only 29 days on a leap year.\nPlease select a proper date of birth");
				}
			}
		}
		else
		{

		 	if ( monthIn == 2){
		 		if(dayIn == 29 || dayIn == 30 || dayIn == 31){
					flagWrownDate = 1;
					alert("Error... February has only 28 days on a non-leap year.\nPlease select a proper date of birth");
				}
			}
		}
	
	yearIn = addDegitsFromYear(yearIn);
	var addLink = monthIn + dayIn + yearIn;
		
	while( addLink > 9){
		if(addLink == 11 || addLink == 22 || addLink == 33 || addLink == 44 ){
		
			if (addLink == 11)
				compoundNumIndex = 9;
			else if ( addLink == 22)
				compoundNumIndex = 10;
			else if (addLink == 33)
				compoundNumIndex = 11;
			else
				compoundNumIndex = 12;
				
			
			document.dateOfBirthForm.titleCompound.style.color = "#000000";
    		document.dateOfBirthForm.titleCompound.value = "Your compound # is "+addLink;
			document.dateOfBirthForm.titleCompoundBody.style.color = "#000000";
    		document.dateOfBirthForm.titleCompoundBody.value = yourMessege[compoundNumIndex]; 
		}
			
			addLink = (addDegitsFromYear(addLink));				 
	}
	
	
	document.dateOfBirthForm.titlePath.style.color = "#000000";
    document.dateOfBirthForm.titlePath.value = "Your Life Path is # "+addLink; 
	document.dateOfBirthForm.titlePathBody.style.color = "#000000";
    document.dateOfBirthForm.titlePathBody.value = yourMessege[addLink-1];
	if (flagWrownDate){
		clearAnyInvalidValue();
	}	
  dateOfBirthForm.blankText.focus();

return false;
}

