window.onload = globalsInit;	//runs the page initialization functions at load time
// interface globals
var arrCatnav = new Array()	//stores the open/closed states of category navigation
var arrRefnav = new Array()	//stores the open/closed states of refinement navigation, when present in the page
var arrCostScale = new Array();	//stores associations for the cost range selection tool, when present in the page
var PhoneSelector;	//the phone selector object, when present in the page
function globalsInit() {
//function calls to initialize various page elements
rolloversInit();
catnavInit();
// amontealegre: added to fix bug with active categories
openActiveCategories();
// amontealegre: added to fix bug with active categories
if (document.getElementById("refnavBox")) { refnavInit(); }
if (document.getElementById("nowrapContent")) { nowrapInit(); }
try {
pageInit();
} catch(e) { }
}
// amontealegre: added to fix bug with active categories
function openActiveCategories()
{
var spans = document.getElementsByTagName('span');
for (var i=0; i<spans.length; i++) {
if (spans[i].id == "selectedCategory")
{
try {
spans[i].click();
} catch(e)
{
var evObj = document.createEvent('MouseEvents');
evObj.initEvent( 'click', true, true );
spans[i].dispatchEvent(evObj);
}
}
}
}
function rolloversInit() {
// sets up all image rollovers for images with classname=="imgOver"
if (!document.getElementById) return;
var arrPreload = new Array();
var strSrcTmp;
var arrImages = document.getElementsByTagName('img');
for (var i=0; i<arrImages.length; i++) {
if (arrImages[i].className == "imgOver") {
var src = arrImages[i].src;
var imgtype = src.substring(src.lastIndexOf("."), src.length);
var altsrc = src.replace(imgtype, "_on" + imgtype);
arrImages[i].setAttribute('altsrc', altsrc);
arrPreload[i] = new Image();
arrPreload[i].src = altsrc;
arrImages[i].onmouseover = function() {
strSrcTmp = this.getAttribute('src');
this.setAttribute('src', this.getAttribute('altsrc'));
}
arrImages[i].onmouseout = function() {
if (!strSrcTmp) strSrcTmp = this.getAttribute('src').replace("_on" + imgtype, imgtype);
this.setAttribute('src', strSrcTmp);
}
}
}
// sets up all image rollovers for form submit buttons that have classname starting with "imgOver"
var arrInputs = document.getElementsByTagName('input');
for (var i=0; i<arrInputs.length; i++) {
if (arrInputs[i].className.indexOf("imgOver") == 0) {
var src = arrInputs[i].src;
var imgtype = src.substring(src.lastIndexOf("."), src.length);
var altsrc = src.replace(imgtype, "_on" + imgtype);
arrInputs[i].setAttribute('altsrc', altsrc);
arrPreload[i] = new Image();
arrPreload[i].src = altsrc;
arrInputs[i].onmouseover = function() {
strSrcTmp = this.getAttribute('src');
this.setAttribute('src', this.getAttribute('altsrc'));
}
arrInputs[i].onmouseout = function() {
if (!strSrcTmp) strSrcTmp = this.getAttribute('src').replace("_on" + imgtype, imgtype);
this.setAttribute('src', strSrcTmp);
}
}
}
}
function catnavInit() {
//initializes the main menu (category navigation)
var arrSpans = document.getElementsByTagName('span');
for (var i=0; i<arrSpans.length; i++) {
if (arrSpans[i].className == "catnavLeftSymbol") {
var currBox = arrSpans[i].parentNode.parentNode.parentNode.parentNode.parentNode;
if (document.getElementById(currBox.id.replace("_closed","_open")).className !== "catnavBox_active") {
arrCatnav[arrCatnav.length] = { Name: currBox.id.replace("_closed",""), Open: false }
currBox.style.display = "block";
arrSpans[i].onclick = function() {
catnavRefresh(this.parentNode.parentNode.parentNode.parentNode.parentNode.id.replace("_closed",""));
}
}
} else if (arrSpans[i].className == "catnavLeftSymbol_open") {
var currBox = arrSpans[i].parentNode.parentNode.parentNode.parentNode.parentNode;
if (currBox.className == "catnavBox_active") {
arrCatnav[arrCatnav.length] = { Name: currBox.id.replace("_open", ""), Open: true }
currBox.style.display = "block";
}
arrSpans[i].onclick = function() {
catnavRefresh(this.parentNode.parentNode.parentNode.parentNode.parentNode.id.replace("_open",""));
}
}
if (arrSpans[i].className == "catnavHeading") {
arrSpans[i].onclick = function() {
catnavRefresh(this.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.id.replace("_closed",""));
}
}
if (arrSpans[i].className == "catnavHeading_open") {
arrSpans[i].onclick = function() {
catnavRefresh(this.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.id.replace("_open",""));
}
}
}
}
function catnavRefresh(strCatnav) {
// refreshes the category navigation whenever a category heading is clicked
for (var i=0; i<arrCatnav.length; i++) {
currId = arrCatnav[i].Name + ((arrCatnav[i].Open) ? "_open" : "_closed");
document.getElementById(currId).style.display = "none";
if (arrCatnav[i].Name == strCatnav) {
arrCatnav[i].Open = (arrCatnav[i].Open) ? false : true;
}
}
for (var i=0; i<arrCatnav.length; i++) {
currId = arrCatnav[i].Name + ((arrCatnav[i].Open) ? "_open" : "_closed");
document.getElementById(currId).style.display = "block";
}
}
/*=========== Commented & modified by Nancy for Release 1 - 2009 - New Centered Refinement Section - START ===========*/
/* function refnavInit() {
// initialize the refinement navigation boxes - wire up all onclick events for the box headings
var arrSpans = document.getElementsByTagName('span');
for (var i=0; i<arrSpans.length; i++) {
if (arrSpans[i].className == "refnavLeftSymbol") {
var currBox = arrSpans[i].parentNode.parentNode.parentNode.parentNode.parentNode;
if (document.getElementById(currBox.id.replace("_closed","_open")).className !== "refitemBox_active") {
arrRefnav[arrRefnav.length] = { Name: currBox.id.replace("_closed",""), Open: false }
currBox.style.display = "block";
}
arrSpans[i].onclick = function() {
refnavRefresh(this.parentNode.parentNode.parentNode.parentNode.parentNode.id.replace("_closed",""));
}
} else if (arrSpans[i].className == "refnavLeftSymbol_open") {
var currBox = arrSpans[i].parentNode.parentNode.parentNode.parentNode.parentNode;
if (currBox.className == "refitemBox_active") {
arrRefnav[arrRefnav.length] = { Name: currBox.id.replace("_open", ""), Open: true }
currBox.style.display = "block";
}
if (currBox.id == "refnavPhone_open") {
arrSpans[i].onclick = function() {
PhoneSelector.Dismiss();
refnavRefresh(this.parentNode.parentNode.parentNode.parentNode.parentNode.id.replace("_open",""));
}
} else {
arrSpans[i].onclick = function() {
refnavRefresh(this.parentNode.parentNode.parentNode.parentNode.parentNode.id.replace("_open",""));
}
}
}
if (arrSpans[i].className == "refnavHeading") {
arrSpans[i].onclick = function() {
refnavRefresh(this.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.id.replace("_closed",""));
}
}
if (arrSpans[i].className == "refnavHeading_open") {
if (currBox.id == "refnavPhone_open") {
arrSpans[i].onclick = function() {
PhoneSelector.Dismiss();
refnavRefresh(this.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.id.replace("_open",""));
}
} else {
arrSpans[i].onclick = function() {
refnavRefresh(this.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.id.replace("_open",""));
}
}
}
}
document.getElementById("refnavBox").style.display = "block";
reftools_init();
}
*/
function refnavInit() {
// initialize the refinement navigation boxes - wire up all onclick events for the box headings
var arrSpans = document.getElementsByTagName('span');
for (var i=0; i<arrSpans.length; i++) {
if (arrSpans[i].className == "refnavLeftSymbol") {
arrSpans[i].style.display = "none";
} else if (arrSpans[i].className == "refnavLeftSymbol_open") {
arrSpans[i].style.display = "none";
}
if (arrSpans[i].className == "refnavHeading") {
var currBox = arrSpans[i].parentNode.parentNode.parentNode.parentNode.parentNode.parentNode;
arrRefnav[arrRefnav.length] = { Name: currBox.id.replace("_closed",""), Open: false }
currBox.style.display = "block";
if(currBox.id == "refnavPhone_closed"){
arrSpans[i].onclick = function() {
showDivAbove();
document.getElementById(this.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.id).style.zIndex= 9999;
document.getElementById("refnavPhoneSelector").style.zIndex= 9999;
closePreviousPopup("refnavPhoneSelector");
PhoneSelector.Launch();
refnavRefresh(this.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.id.replace("_closed",""));
}
} else if(currBox.id == "refnavCost_closed"){
arrSpans[i].onclick = function() {
showDivAbove();
document.getElementById(this.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.id).style.zIndex= 9999;
document.getElementById("refnavCost_closed").style.zIndex= 9999;
closePreviousPopup("refnavCostSelector");
document.getElementById("refnavCostSelector").style.display="block";
refnavRefresh(this.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.id.replace("_closed",""));
}
}else {
arrSpans[i].onclick = function() {
showDivAbove();
document.getElementById(this.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.id).style.zIndex= 9999;
document.getElementById(this.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.id).style.zIndex= 9999;
closePreviousPopup(this.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.id.replace("_closed","")+"_selector");
document.getElementById(this.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.id.replace("_closed","")+"_selector").style.display="block";
refnavRefresh(this.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.id.replace("_closed",""));
}
}
}
if (arrSpans[i].className == "refnavHeading_open") {
var currBox = arrSpans[i].parentNode.parentNode.parentNode.parentNode.parentNode.parentNode;
if (currBox.className == "refitemBox_active") {
currBox.style.display = "none";
}
if (currBox.id == "refnavPhone_open") {
arrSpans[i].onclick = function() {
alert("currBox.id before calling PhoneSelector.Dismiss()="+currBox.id);
PhoneSelector.Dismiss();
refnavRefresh(this.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.id.replace("_open",""));
}
} else {
arrSpans[i].onclick = function() {
refnavRefresh(this.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.id.replace("_open",""));
}
}
}
}
document.getElementById("refnavBox").style.display = "block";
reftools_init();
}
/*=========== Commented & modified by Nancy for Release 1 - 2009 - New Centered Refinement Section - END ===========*/
function refnavRefresh(strRefnav) {
/*	document.getElementById("refnavBox_bot").style.display = "none"; */
var intCurrRefnavHeight = document.getElementById("refnavBox").offsetHeight - 7;
var intCurrBoxHeights = 0;
var intNewBoxHeights = 0;
for (var i=0; i<arrRefnav.length; i++) {
var currId = arrRefnav[i].Name + ((arrRefnav[i].Open) ? "_open" : "_closed");
intCurrBoxHeights += document.getElementById(currId).offsetHeight;
document.getElementById(currId).style.display = "none";
if ((strRefnav) && (arrRefnav[i].Name == strRefnav)) {
/*=========== Commented & modified by Nancy for Release 1 - 2009 - New Centered Refinement Section - START ===========*/
//arrRefnav[i].Open = (arrRefnav[i].Open) ? false : true;
arrRefnav[i].Open = (arrRefnav[i].Open) ? true : false;
/*=========== Commented & modified by Nancy for Release 1 - 2009 - New Centered Refinement Section - END ===========*/
}
}
for (var i=0; i<arrRefnav.length; i++) {
var currId = arrRefnav[i].Name + ((arrRefnav[i].Open) ? "_open" : "_closed");
document.getElementById(currId).style.display = "block";
intNewBoxHeights += document.getElementById(currId).offsetHeight;
}
/*	document.getElementById("refnavBox_bot").style.display = "block"; */
}
function reftools_init() {
//initializes all refinement tools for user events
//create events for all input elements: checkboxes, etc.
var arrInputs = document.forms["refnav_form"].elements;
for (var i=0; i<arrInputs.length; i++) {
//checkbox events and corresponding text labels
if (arrInputs[i].type == "checkbox") {
var currLabelId = arrInputs[i].id.replace("check","label");
arrInputs[i].onclick = function() {
reftools_updateSummary(this.type, this.className);
}
document.getElementById(currLabelId).onclick = function() {
document.getElementById(this.id.replace("_label","_check")).click();
reftools_updateSummary(this.type, this.className.replace("_label","_check"));
}
//radio buttons and text labels
} else if (arrInputs[i].type == "radio") {
var currLabelId = arrInputs[i].id.replace("_radio","_label");
arrInputs[i].onclick = function() {
reftools_updateSummary(this.type, this.className, this.name, this.id);
}
document.getElementById(currLabelId).onclick = function() {
document.getElementById(this.id.replace("_label","_radio")).click();
}
}
}
//create events for all span elements
var arrSpans = document.getElementsByTagName("span");
for (var i=0; i<arrSpans.length; i++) {
//'select all' + 'clear all' labels
if ((arrSpans[i].className == "reftool_selectAll") || (arrSpans[i].className == "reftool_clearAll")){
var currBox = arrSpans[i].parentNode.parentNode;
arrSpans[i].onclick = function() {
reftools_setAllChecks(this.parentNode.parentNode.id.replace("_selector","_check"), (this.className == "reftool_selectAll"));
reftools_updateSummary("checkbox", this.parentNode.parentNode.id.replace("_selector","_check"));
}
}
//'update results' labels
if (arrSpans[i].className == "reftool_update") {
arrSpans[i].onclick = function() {
document.forms["refnav_form"].submit();
}
}
//phone selector call-to-action
if (arrSpans[i].id == "phoneSelector_cta") {
arrSpans[i].onclick = function() {
/*=========== Added by Nancy for Release 1 - 2009 - New Centered Refinement Section - START ===========*/
showDivAbove();
document.getElementById("refnavBoxCol_1").style.zIndex= 9999;
document.getElementById("refnavPhoneSelector").style.zIndex= 9999;
/*=========== Added by Nancy for Release 1 - 2009 - New Centered Refinement Section - END ===========*/
PhoneSelector.Launch();
}
}
//phone selector "previous" action labels
if (arrSpans[i].className == "phoneSelectorBack") {
arrSpans[i].onclick = function() {
PhoneSelector.Back(this.parentNode.parentNode);
}
}
}
//create events for all image elements
var arrImages = document.getElementsByTagName("img");
for (var i=0; i<arrImages.length; i++) {
var arrPreload = new Array();
//cost scale images and corresponding text labels
if (arrImages[i].className == "reftoolCostScale") {
var currLabelId = arrImages[i].id.replace("scale","label");
//do preload of the alternate image
if (arrImages[i].id !== "reftool_costscale0") {
var src = arrImages[i].src;
var imgtype = src.substring(src.lastIndexOf("."), src.length);
var altsrc = src.replace("_on" + imgtype, "_off" + imgtype);
arrCostScale[arrCostScale.length] = { Image: arrImages[i], On: arrImages[i].src, Off: altsrc };
arrPreload[i] = new Image();
arrPreload[i].src = altsrc;
}
arrImages[i].onclick = function() {
reftools_updateCostScale(this.id.replace("reftool_costscale",""));
}
document.getElementById(currLabelId).onclick = function() {
reftools_updateCostScale(this.id.replace("reftool_costlabel",""));
}
}
//phone selector close box
if (arrImages[i].id == "phoneSelectorClose") {
arrImages[i].onclick = function() {
PhoneSelector.Dismiss();
/*=========== Added by Nancy for Release 1 - 2009 - New Centered Refinement Section - START ===========*/
showAllDivs();
/*=========== Added by Nancy for Release 1 - 2009 - New Centered Refinement Section - END ===========*/
}
}
//phone selector "previous" arrows
if (arrImages[i].className == "phoneSelectorArrow") {
arrImages[i].onclick = function() {
PhoneSelector.Back(this.parentNode.parentNode);
}
}
/*=========== Added by Nancy for Release 1 - 2009 - New Centered Refinement Section - START ===========*/
//cost selector close box
if (arrImages[i].id == "costSelectorClose") {
arrImages[i].onclick = function() {
document.getElementById("refnavCostSelector").style.display="none";
showAllDivs();
/*=========== Added by Nancy for Release 1 - 2009 - New Centered Refinement Section - END ===========*/
}
}
}
if (document.getElementById("refnavCost_closed")) {
reftools_initCostScale();
}
arrInputs = document.forms["refnav_form"].elements;
for (i=0; i<arrInputs.length; i++) {
if ((arrInputs[i].type == "radio") && (arrInputs[i].checked)) {
reftools_updateSummary("radio", arrInputs[i].className, arrInputs[i].name, arrInputs[i].id);
}
if (arrInputs[i].type == "checkbox") {
reftools_updateSummary("checkbox", arrInputs[i].className);
}
}
if (document.getElementById("refnavPhone_closed")) {
reftools_initPhoneSelector();
}
}
function reftools_updateSummary(strInputType, strInputClass, strInputName, strInputId) {
var arrInputs = document.forms["refnav_form"].elements;
switch (strInputType) {
case "checkbox":
var intClassChecked = 0;
var intClassTotal = 0;
for (i=0; i<arrInputs.length; i++) {
if (arrInputs[i].className == strInputClass) {
intClassTotal += 1;
intClassChecked += (arrInputs[i].checked) ? 1 : 0;
}
}
document.getElementById(strInputClass.replace("_check","_summary")).innerHTML = "Selected " + intClassChecked + "/" + intClassTotal;
break;
case "radio":
var arrRadioGroup = document.forms["refnav_form"].elements[strInputName];
var intRadioIndex = -1;
for (i=0; i<arrRadioGroup.length; i++) {
if (arrRadioGroup[i].checked) {
intRadioIndex = i;
}
}
var strCheckedLabel = document.getElementById(strInputId).value;
var strCheckedLabel = document.getElementById(strInputId.replace("_radio","_label")).innerHTML;
document.getElementById(strInputClass.replace("_radio","_summary")).innerHTML = "Selected: " + strCheckedLabel;
break;
default:
break;
}
}
function reftools_setAllChecks(strInputClass, blnChecked) {
//handler for the "Select All" and "Clear All" interface event labels
var arrInputs = document.forms["refnav_form"].elements;
for (i=0; i<arrInputs.length; i++) {
if (arrInputs[i].className == strInputClass) {
arrInputs[i].checked = blnChecked;
}
}
}
function reftools_initCostScale() {
//set the cost scale display based upon the value of the hidden form input
reftools_updateCostScale(document.forms["refnav_form"].elements["reftool_cost_max"].value);
}
function reftools_updateCostScale(intScaleIndex) {
//update the refinement tool display for the tool is collapsed.
for (i=0; i<arrCostScale.length; i++) {
arrCostScale[i].Image.src = (i<intScaleIndex) ? arrCostScale[i].On : arrCostScale[i].Off;
}
var strDisplayMax = (document.getElementById("reftool_costlabel" + intScaleIndex).innerHTML.indexOf("$") < 0) ? "$" + document.getElementById("reftool_costlabel" + intScaleIndex).innerHTML : document.getElementById("reftool_costlabel" + intScaleIndex).innerHTML;
document.getElementById("refnavCost_summary").innerHTML = "Selected $0" + ((intScaleIndex > 0) ? "-" + strDisplayMax : "");
document.forms["refnav_form"].elements["reftool_cost_max"].value = intScaleIndex;
}
function reftools_initPhoneSelector() {
//instantiate and initialize the selector object
PhoneSelector = new clsPhoneSelector();
PhoneSelector.Init();
}
function nowrapInit() {
//set a minimum height for the nowrapContent box in lieu of the poorly supported "min-height" css attribute
if (document.getElementById("nowrapContent").offsetHeight < 463) {
document.getElementById("nowrapContent").style.height = "450px";
}
}
/* **** Object Prototypes **** */
Array.prototype.getIndex = arr_getIndex;
/* search an array list for a value, return the first index of that value */
function arr_getIndex(strValue) {
var intFound = -1;
for (var i=0; i<this.length; i++) {
if (this[i] == strValue) {
intFound=i;
break;
}
}
return intFound;
}
function header_dropdwn_open() {
var arrDivElements = document.getElementsByTagName('div');
if(arrDivElements != null ){
for (var i=0; i<arrDivElements.length; i++) {
if (arrDivElements[i].className != "" && arrDivElements[i].className != null){
if (arrDivElements[i].className == "topper"){
arrDivElements[i].style.zIndex = 9999;
} else {
arrDivElements[i].style.zIndex = 0;
}
} 
}
}
if(document.getElementById("wrapBody")){
document.getElementById("wrapBody").style.zIndex = -1;
}
if(document.getElementById("wrapTable")){
document.getElementById("wrapTable").style.zIndex = -1; 
}
}
function header_dropdwn_close(){
document.getElementById('forBusinessMenu').style.display = "none";
if(document.getElementById("wrapBody")){
document.getElementById("wrapBody").style.zIndex = 0;
}
if(document.getElementById("wrapTable")){
document.getElementById("wrapTable").style.zIndex = 0; 
}
}
