/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*  global.js, v.1.0                                                    *
*----------------------------------------------------------------------*
*  Author Information:                                                 *
*    Authors contributing to this module include:                      *
*             Adam Knapp, adam@knapptechnologies.com April/07          *
*                                                                      *
*----------------------------------------------------------------------*
*  Module Description:                                                 *
*    Designed to have all of the global functions and necessary values *
*    for each page that will be used throughout the whole site.        *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

/*----------------------------------------------------------------------\
| MEMBER:       GetTrBgColor                                            | 
| PARAMETERS:   vTr                                                     | 
|                 The current javascript variable                       |
|               strCurrentColor                                         |
|                 The un clicked color                                  |
|               strClickedColor                                         |
|                 The new clicked color                                 |
| RETURNS:      The new color.                                          | 
| PURPOSE:      Returns the color based on what the user chooses. If the|
|               user clicks the tr, the clicked color returns, otherwise|
|               unclicked.                                              |
\----------------------------------------------------------------------*/
function GetTrBgColor(vTr, strUnClickedColor, strClickedColor)
{
   if(vTr == strUnClickedColor) {
      vTr = strClickedColor;
   } else {
      vTr = strUnClickedColor;
   }
   return vTr;
}

/*----------------------------------------------------------------------\
| MEMBER:       PreloadBackgrounds                                      | 
| PARAMETERS:   strBackgroundDirectory                                  | 
|                 The directory where the images are located.           |
| RETURNS:      -                                                       | 
| PURPOSE:      Makes sure all of the background images are preloaded.  | 
\----------------------------------------------------------------------*/
function PreloadBackgrounds(strBackgroundDirectory)
{
   //Navbuttons
   strImage1     = new Image(11,31);
   strImage1.src = "bckgrn_navbtn_off.gif";  

   strImage2     = new Image(11,31);
   strImage2.src = "bckgrn_navbtn_on.gif";  
}

/*----------------------------------------------------------------------\
| MEMBER:       SetCardHolderInfoToMyAccount                            | 
| PARAMETERS:   strFirstName                                            |
|               strLastName                                             |
|               strAddress                                              |
|               strCity                                                 |
|               strState                                                |
|               strZip                                                  | 
| RETURNS:      -                                                       |
| PURPOSE:      Changes the current featureform for the card info to the|
|               values passed in, which should be from my account.      | 
\----------------------------------------------------------------------*/
function SetCardHolderInfoToMyAccount(strFirstName, strLastName, strAddress, strCity, strState, strZip)
{
   featureform.fdcgrfw.value   = strFirstName;
   featureform.vnbxfg.value    = strLastName;
   featureform.iuokyrty.value  = strAddress;
   featureform.ytejcm.value    = strCity;
   featureform.polijfn.value   = strState;
   featureform.po092jxhn.value = strZip;
}

/*----------------------------------------------------------------------\
| MEMBER:       SubmitPayementSchedule                                  | 
| PARAMETERS:   strDateSelected                                         |
|                 The date the user entered                             |
|               strPaymentType                                          |
|                 donation or payment                                   |
| RETURNS:      Submits the form on valid confirmation                  |
| PURPOSE:      Prompts the user to confirm if they are submitting a    |
|               payment today, if confirmed the form is submitted.      | 
\----------------------------------------------------------------------*/
function SubmitPayementSchedule(strDateSelected, strPaymentType)
{
   var bSubmit = true;
   var iCurrentTime = new Date()
   var iMonth = iCurrentTime.getMonth() + 1
   var iDay   = iCurrentTime.getDate()
   var iYear  = iCurrentTime.getFullYear()
   var strDay = iDay;
   var strMonth = iMonth;
   if ( iDay < 10 ) {
      strDay = "0" + iDay;
   }
   if (iMonth < 10) {
      strMonth = '0' + iMonth;
   }
   var iCurrentDate = strMonth + '/' + strDay + '/' + iYear;
   if ( strDateSelected == iCurrentDate ) {
      if(!confirm('You have chosen to process your ' + strPaymentType + ' today. This will happen immediately. Please confirm that everything for this instant ' + strPaymentType + ' is correct. Please press OK to submit your ' + strPaymentType + '.')) {
         bSubmit = false; 
      } else {
        //we want to really process this immediately
        featureform.ppimmed.value = 'true';
      }
   }
   if(bSubmit) {
      featureform.submit();
   }
}


//Menu
// Copyright 2006-2007 javascript-array.com

var timeout	= 100;
var closetimer	= 0;
var ddmenuitem	= 0;

// open hidden layer
function mopen(id)
{	
	// cancel close timer
	mcancelclosetime();

	// close old layer
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';

	// get new layer and show it
	ddmenuitem = document.getElementById(id);
	ddmenuitem.style.visibility = 'visible';

}
// close showed layer
function mclose()
{
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';
}

// go close timer
function mclosetime()
{
	closetimer = window.setTimeout(mclose, timeout);
}

// cancel close timer
function mcancelclosetime()
{
	if(closetimer)
	{
		window.clearTimeout(closetimer);
		closetimer = null;
	}
}

// close layer when click-out
document.onclick = mclose; 

