// function to toggle display of form sections.
// activated on click or on load or whatever.
// tracking array (sectionStatus) is set in the form include
// so is thesectionNameConvention var... in case it changes....
// sections are named sectionNameConvention+1, sectionNameConvention+2, ect
// pass the number of the section to toggle as whichSection
// ex. toggleSection (1) for div#section1
// requires sectionStatus array to be correctly set, reflecting the open/closed status of the section
function toggleSection (whichSection) 
{
  // get yer section id
  var sectionID = sectionNameConvention + whichSection;
  var headerID = sectionHeaderConvention + whichSection;

  if (sectionStatus[whichSection] == "open")
  {
    // the section is open so close it
    document.getElementById(sectionID).style.display = "none";
    document.getElementById(headerID).className = "headerTextclosed";
    // update the tracker variable
    sectionStatus[whichSection] = "closed";
  } else {
    // the section is closed so open it
    document.getElementById(sectionID).style.display = "block";
    document.getElementById(headerID).className = "headerTextopen";
    // update the tracker variable
    sectionStatus[whichSection] = "open";
  }

} // end of function toggleSection()




// function to display chosen sign
// pass it a reference to the form select (ie, this)
// or a sign num
// sign num is the case if a sign is passed to the form to begin with,
// or if form submission fails & the page reloads with the same values
function showAOLHoro (selectObjOrSignNum)
{
  var chosenSignNum = 0;
 // figure out if a form select ref is being passed, or a sign id, & deal with it
  if (isNaN(selectObjOrSignNum)) {
    chosenSignNum = selectObjOrSignNum.selectedIndex;
  } else {
    chosenSignNum = selectObjOrSignNum;
  }

  var f = document.getElementById('footer_content'); 
  f.style.position = 'static'; 
  if (chosenSignNum > 0)
  {
    // the chosen sign is not the default placeholder, so display the sign
    // gimmee the container div
    document.getElementById("aolHoroSigns").style.display = "block";
    
    //image swap for sign icon (see array below)
    document['aolHoroSignImg'].src = signImages[chosenSignNum].src;
    // string replacements
    document.getElementById("aolHoroSignName").innerHTML = signNames[chosenSignNum];
    document.getElementById("aolHoroSignDates").innerHTML = signDates[chosenSignNum];
    // oneLiner is an array filled by php function in the form php file
    document.getElementById("aolHoroSignOneLiner").innerHTML = oneLiner[chosenSignNum];
  } else {
    //default (non sign) is chosen, hide the div
    document.getElementById("aolHoroSigns").style.display = "none";
  }
  f.style.position = 'relative'; 
}


// used for the save buttons, which are not within the form.
// relies on the verify function in signup-default.js
// verify returns true or false
// and does the alert telling you what to fix
function formSubmit(formRef) {
  if (verify(formRef)) {
    formRef.submit();
  }
} // end of function formSubmit

// image swap for the save & cancel buttons
function buttonSwap (whichButton, imageObj, swapState)
{
  document[whichButton].src = imageObj[swapState].src;
}


// cancel form submission & send them back to where they came from
// set the default here, in case they got here without a returnUrl
function formCancel(returnUrl)
{
  document.regform.reset();
  if (returnUrl.length > 0)
  {
    location.href = returnUrl;
  } else {
    location.href = "http://horoscopes.aol.tarot.com";
  }
} // end of function form Cancel 

/* ************************************************
image preloads below 
**************************************************/

// preload images for button image swap
// arrays o info for the button images
var btnImgPath = "/images/aol/settings/";
var btnSaveImages = new Object();
var btnCancelImages = new Object();
var btnGoToImages = new Object();
var btnContinueImages = new Object();

btnSaveImages['default'] = new Image();
btnSaveImages['default'].src = btnImgPath + "save-btn-default.jpg";
btnSaveImages['over'] = new Image();
btnSaveImages['over'].src = btnImgPath + "save-btn-rollover.jpg";
btnSaveImages['down'] = new Image();
btnSaveImages['down'].src = btnImgPath + "save-btn-down.jpg";

btnCancelImages['default'] = new Image();
btnCancelImages['default'].src = btnImgPath + "cancel-btn-default.jpg";
btnCancelImages['over'] = new Image();
btnCancelImages['over'].src = btnImgPath + "cancel-btn-rollover.jpg";
btnCancelImages['down'] = new Image();
btnCancelImages['down'].src = btnImgPath + "cancel-btn-down.jpg";

// for the confirmation page
btnGoToImages['default'] = new Image();
btnGoToImages['default'].src = btnImgPath + "goto_btn_default.jpg";
btnGoToImages['over'] = new Image();
btnGoToImages['over'].src = btnImgPath + "goto_btn_rollover.jpg";
btnGoToImages['down'] = new Image();
btnGoToImages['down'].src = btnImgPath + "goto_btn_down.jpg";

// for the confirmation page
btnContinueImages['default'] = new Image();
btnContinueImages['default'].src = btnImgPath + "continue_btn_default.jpg";
btnContinueImages['over'] = new Image();
btnContinueImages['over'].src = btnImgPath + "continue_btn_rollover.jpg";
btnContinueImages['down'] = new Image();
btnContinueImages['down'].src = btnImgPath + "continue_btn_down.jpg";


// preload images for horo swap
// arrays o info for the horo swap
var signImgPath = "/images/aol/settings/sign_75x75_";
var signImages = new Object();
var signNames = new Array();
var signDates = new Array();
signImages[1] = new Image();
signImages[1].src = signImgPath + "aries.gif";
signNames[1] = "Aries";
signDates[1] = "(Mar 21 - Apr 19)";

signImages[2] = new Image();
signImages[2].src = signImgPath + "taurus.gif";
signNames[2] = "Taurus";
signDates[2] = "(Apr 20 - May 20)";

signImages[3] = new Image();
signImages[3].src = signImgPath + "gemini.gif";
signNames[3] =  "Gemini";
signDates[3] =  "(May 21 - Jun 20)";

signImages[4] = new Image();
signImages[4].src = signImgPath + "cancer.gif";
signNames[4] =  "Cancer";
signDates[4] =  "(June 21 - Jul 22)";

signImages[5] = new Image();
signImages[5].src = signImgPath + "leo.gif";
signNames[5] =  "Leo";
signDates[5] =  "(Jul 23 - Aug 22)";

signImages[6] = new Image();
signImages[6].src = signImgPath + "virgo.gif";
signNames[6] =  "Virgo";
signDates[6] =  "(Aug 23 - Sep 22)";

signImages[7] = new Image();
signImages[7].src = signImgPath + "libra.gif";
signNames[7] =  "Libra";
signDates[7] =  "(Sep 23 - Oct 22)";

signImages[8] = new Image();
signImages[8].src = signImgPath + "scorpio.gif";
signNames[8] =  "Scorpio";
signDates[8] =  "(Oct 23 - Nov 21)";

signImages[9] = new Image();
signImages[9].src = signImgPath + "sagittarius.gif";
signNames[9] =  "Sagittarius";
signDates[9] =  "(Nov 22 - Dec 21)";

signImages[10] = new Image();
signImages[10].src = signImgPath + "capricorn.gif";
signNames[10] =  "Capricorn";
signDates[10] = "(Dec 22 - Jan 19)"; 

signImages[11] = new Image();
signImages[11].src = signImgPath + "aquarius.gif";
signNames[11] =  "Aquarius";
signDates[11] =  "(Jan 20 - Feb 18)";

signImages[12] = new Image();
signImages[12].src = signImgPath + "pisces.gif";
signNames[12] =  "Pisces";
signDates[12] =  "(Feb 19 - Mar 20)";

