/******************************************************************
*  Function: getNavBarImages                                      *
*  Purpose:  to pre-load navigation bar images into an array      *
*            accessed by each web page within the navigation bar  *
*						 						 							 									 					*
*  Input:  None     		 							 									 					*
*  Output: an associative array containing navigation bar images  *
*  Author: Lesley Parker                                          *
*  Date: 4 July 2006                                              *
******************************************************************/
function getNavBarImages(){
var navBarItems = new Array();//create an array to contain the nav bar items
	  //item 1 - WELCOME
   navBarItems["welcome"]= new Array();//create another array at each item to contain the 3 images
	      //place an image object at each value and set the source property of the image
	    navBarItems["welcome"]["off"]= new Image ;navBarItems["welcome"]["off"].src="images/welcomeOff.jpg";
			navBarItems["welcome"]["on"]= new Image ;navBarItems["welcome"]["on"].src="images/welcomeOn.jpg";
			
		//item 2 - DRAXPARK PIX
	navBarItems["draxparkPix"]= new Array();
	    navBarItems["draxparkPix"]["off"]= new Image ;navBarItems["draxparkPix"]["off"].src="images/draxparkPixOff.jpg";
			navBarItems["draxparkPix"]["on"]= new Image ;	navBarItems["draxparkPix"]["on"].src="images/draxparkPixOn.jpg";
			
			//item 3 - SHOW RESULTS
	navBarItems["showResults"]= new Array();
	    navBarItems["showResults"]["off"]= new Image ;navBarItems["showResults"]["off"].src="images/showResultsOff.jpg";
			navBarItems["showResults"]["on"]= new Image ;	navBarItems["showResults"]["on"].src="images/showResultsOn.jpg";
			
			//item 4 - GIANT STRUCTURE
	navBarItems["giantStructure"]= new Array();
	    navBarItems["giantStructure"]["off"]= new Image ;navBarItems["giantStructure"]["off"].src="images/giantStructureOff.jpg";
			navBarItems["giantStructure"]["on"]= new Image ;	navBarItems["giantStructure"]["on"].src="images/giantStructureOn.jpg";
	
		
			//item 5 - GIANT LINKS
	navBarItems["giantLinks"]= new Array();
	    navBarItems["giantLinks"]["off"]= new Image ;navBarItems["giantLinks"]["off"].src="images/giantLinksOff.jpg";
			navBarItems["giantLinks"]["on"]= new Image ;	navBarItems["giantLinks"]["on"].src="images/giantLinksOn.jpg";
	
			//item 6 - CONTACT US
	navBarItems["contactUs"]= new Array();
	    navBarItems["contactUs"]["off"]= new Image ;navBarItems["contactUs"]["off"].src="images/contactUsOff.jpg";
			navBarItems["contactUs"]["on"]= new Image ;	navBarItems["contactUs"]["on"].src="images/contactUsOn.jpg";
			
			//item 7 - PORTRAITS
	navBarItems["portraits"]= new Array();
	    navBarItems["portraits"]["off"]= new Image ;navBarItems["portraits"]["off"].src="images/portraitsOff.jpg";
			navBarItems["portraits"]["on"]= new Image ;	navBarItems["portraits"]["on"].src="images/portraitsOn.jpg";
			
			//item - PUPPY LIST FORM
	navBarItems["puppyList"]= new Array();
	    navBarItems["puppyList"]["off"]= new Image ;navBarItems["puppyList"]["off"].src="images/puppyListOff.jpg";
			navBarItems["puppyList"]["on"]= new Image ;	navBarItems["puppyList"]["on"].src="images/puppyListOn.jpg";
	
			//item - ANATOMY
	navBarItems["anatomy"]= new Array();
	    navBarItems["anatomy"]["off"]= new Image ;navBarItems["anatomy"]["off"].src="images/anatomyOff.jpg";
			navBarItems["anatomy"]["on"]= new Image ;	navBarItems["anatomy"]["on"].src="images/anatomyOn.jpg";
	
	
					  
return	navBarItems	//return the array of images
     }	
	
/******************************************************************
*  Function: swapImages                                           *
*  Purpose:  to swap an image at a specified field with another   *
*            image from a specified array accessed by each web    *
*            page in the navigation bar                           *
*						 						 							 									 					*
*  Input:  imageArray: an associative array of images		 					*
*          fieldName: name of field containing image to swap      *
*          newImage: key where new image is located in the array  *
*  Output: None                                                   *
*  Author: Lesley Parker                                          *
*  Date: 4 July 2006                                              *
******************************************************************/				 	
function swapImages(imageArray, fieldName, newImage){
//test if browser understands image objects
if(document.images){
   //test if the field name and image exist in the array
   if(imageArray[fieldName] && imageArray[fieldName][newImage]){
	 
	 //set the current image source property to the source property of the new image in the array
		document[fieldName].src = imageArray[fieldName][newImage].src; 
	}	 
	//create a debug window if field name is invalid or image does not exist 
   else {
	   var debugWin=window.open("","debugWin","height=200,width=300,resize=yes");
		  //if the field name does not exist write invalid field message
	     if(!imageArray[fieldName]){
	     debugWin.document.write("NAVBAR ERROR:"+"<br>"+"Field named: " +fieldName +" invalid" +"<br>");
			 debugWin.document.close();
			 }   //otherwise write an image not found message
        else {debugWin.document.write("NAVBAR ERROR:"+"<br>"+"image at: " +newImage +" not found" +"<br>" );
			 debugWin.document.close();
			 }
   }																											 
}
}


/************show sub menu function*****/

function toggleMenu(currMenu) {
	if (document.getElementById) {
		thisMenu = document.getElementById(currMenu).style
		if (thisMenu.display == "block") {
			thisMenu.display = "none"
		}
		else {
		thisMenu.display = "block"
		}
		return false
	}
	else {
	return true
	}
	}
	
/**********************************************/
/*Function to calculate age                   */
/**********************************************/
	function qryHowOld(varAsOfDate, varBirthDate)
   {
   var dtAsOfDate;
   var dtBirth;
   var dtAnniversary;
   var intSpan;
   var intYears;
   var intMonths;
   var strHowOld;

   // get born date
   dtBirth = new Date(varBirthDate);
   
   // get as of date
   dtAsOfDate = new Date(varAsOfDate);

   // if as of date is on or after born date
   if ( dtAsOfDate >= dtBirth )
      {

      // get time span between as of time and birth time
      intSpan = ( dtAsOfDate.getUTCHours() * 3600000 +
                  dtAsOfDate.getUTCMinutes() * 60000 +
                  dtAsOfDate.getUTCSeconds() * 1000    ) -
                ( dtBirth.getUTCHours() * 3600000 +
                  dtBirth.getUTCMinutes() * 60000 +
                  dtBirth.getUTCSeconds() * 1000       )

      // start at as of date and look backwards for anniversary 

      // if as of day (date) is after birth day (date) or
      //    as of day (date) is birth day (date) and
      //    as of time is on or after birth time
      if ( dtAsOfDate.getUTCDate() > dtBirth.getUTCDate() ||
           ( dtAsOfDate.getUTCDate() == dtBirth.getUTCDate() && intSpan >= 0 ) )
         {

         // most recent day (date) anniversary is in as of month
         dtAnniversary = 
            new Date( Date.UTC( dtAsOfDate.getUTCFullYear(),
                                dtAsOfDate.getUTCMonth(),
                                dtBirth.getUTCDate(),
                                dtBirth.getUTCHours(),
                                dtBirth.getUTCMinutes(),
                                dtBirth.getUTCSeconds()) );

         }

      // if as of day (date) is before birth day (date) or
      //    as of day (date) is birth day (date) and
      //    as of time is before birth time
      else
         {

         // most recent day (date) anniversary is in month before as of month
         dtAnniversary = 
            new Date( Date.UTC( dtAsOfDate.getUTCFullYear(),
                                dtAsOfDate.getUTCMonth() - 1,
                                dtBirth.getUTCDate(),
                                dtBirth.getUTCHours(),
                                dtBirth.getUTCMinutes(),
                                dtBirth.getUTCSeconds()) );

         // get previous month
         intMonths = dtAsOfDate.getUTCMonth() - 1;
         if ( intMonths == -1 )
            intMonths = 11;

         // while month is not what it is supposed to be (it will be higher)
         while ( dtAnniversary.getUTCMonth() != intMonths )

            // move back one day
            dtAnniversary.setUTCDate( dtAnniversary.getUTCDate() - 1 );

         }

      // if anniversary month is on or after birth month
      if ( dtAnniversary.getUTCMonth() >= dtBirth.getUTCMonth() )
         {

         // months elapsed is anniversary month - birth month
         intMonths = dtAnniversary.getUTCMonth() - dtBirth.getUTCMonth();

         // years elapsed is anniversary year - birth year
         intYears = dtAnniversary.getUTCFullYear() - dtBirth.getUTCFullYear();

         }

      // if birth month is after anniversary month
      else
         {

         // months elapsed is months left in birth year + anniversary month
         intMonths = (11 - dtBirth.getUTCMonth()) + dtAnniversary.getUTCMonth() + 1;

         // years elapsed is year before anniversary year - birth year
         intYears = (dtAnniversary.getUTCFullYear() - 1) - dtBirth.getUTCFullYear();

         }

      // to calculate weeks, days, hours, minutes and seconds
      // we can take the difference from anniversary date and as of date

      // get time span between two dates in milliseconds
      intSpan = dtAsOfDate - dtAnniversary;

     
      // create output string     
      if ( intYears > 0 )
         if ( intYears > 1 )
            strHowOld = intYears.toString() + ' Years';
         else
            strHowOld = intYears.toString() + ' Year';
      else
         strHowOld = '';

      if ( intMonths > 0 )
         if ( intMonths > 1 )
            strHowOld = strHowOld + ' ' + intMonths.toString() + ' Months';
         else
            strHowOld = strHowOld + ' ' + intMonths.toString() + ' Month';
           
      
      }
			
   else
      strHowOld = 'Not Born Yet'

   // return string representation
   return strHowOld
   }   
//                                                                            |
// qryHowOld                                