// Global variables
var logDebug = new Boolean(false);

/*
 * This function sets the form select option based upon the session scoped bean property.
 */
function setIndustryReports(pOptionSelect,pIsGeneralContent) {
	var optionId = "#" + pOptionSelect + "Option";
	$(optionId).attr("selected","true");
	
	// Show the appropriate content based upon the session scoped bean property
	var CLOSED_ARROW = new String("/qb/products/premier/premier_standard/premier_convertible_benefits/images/arrow_closed.gif");
	var OPEN_ARROW = new String("/qb/products/premier/premier_standard/premier_convertible_benefits/images/arrow_open.gif");
	switch (pOptionSelect) {
	case "general":
		if (pIsGeneralContent == true) {
			$("#contentStandard").slideDown(1000);
		}
		break;
	case "contractor":
			$("#contentContractor").slideDown(1000);
		break;
	case "manufacturer":
			$("#contentManufacturer").slideDown(2250);
		break;
	case "nonprofit":
			$("#contentNonprofit").slideDown(1000);
		break;
	case "proservices":
			$("#contentProservices").slideDown(1000);
		break;
	case "retail":
			$("#contentRetail").slideDown(1750);
		break;
	}
}

/*
 * This function sets the form select option based upon the session scoped bean property.
 */
function setIndustryFeatures(pOptionSelect,pIsGeneralContent) {
	var optionId = "#" + pOptionSelect + "Option";
	$(optionId).attr("selected","true");
	
	// Show the appropriate content based upon the session scoped bean property
	var CLOSED_ARROW = new String("/qb/products/premier/premier_standard/premier_convertible_benefits/images/arrow_closed.gif");
	var OPEN_ARROW = new String("/qb/products/premier/premier_standard/premier_convertible_benefits/images/arrow_open.gif");
	switch (pOptionSelect) {
	case "general":
		if (pIsGeneralContent == true) {
			$("#contentStandard").css("display","block");
			$("#toggleAll").animate({opacity: 1.0}, 500, function() {
				$("#standardContainer").slideDown(1250);
				$("#standardArrow").attr("src",OPEN_ARROW);
				$("#standardContainer").attr("src",CLOSED_ARROW);
			});
		}
		break;
	case "contractor":
		$("#contentContractor").css("display","block");
		$("#toggleAll").animate({opacity: 1.0}, 500, function() {
			$("#contractorContainer").slideDown(1250);
			$("#contractorArrow").attr("src",OPEN_ARROW);
			$("#contractorContainer").attr("src",CLOSED_ARROW);
		});
		break;
	case "manufacturer":
		$("#contentManufacturer").css("display","block");
		$("#toggleAll").animate({opacity: 1.0}, 500, function() {
			$("#manufacturerContainer").slideDown(1250);
			$("#manufacturerArrow").attr("src",OPEN_ARROW);
			$("#manufacturerContainer").attr("src",CLOSED_ARROW);
		});
		break;
	case "nonprofit":
		$("#contentNonprofit").css("display","block");
		$("#toggleAll").animate({opacity: 1.0}, 500, function() {
			$("#nonprofitContainer").slideDown(1250);
			$("#nonprofitArrow").attr("src",OPEN_ARROW);
			$("#nonprofitContainer").attr("src",CLOSED_ARROW);
		});
		break;
	case "proservices":
		$("#contentProservices").css("display","block");
		$("#toggleAll").animate({opacity: 1.0}, 500, function() {
			$("#proservicesContainer").slideDown(1250);
			$("#proservicesArrow").attr("src",OPEN_ARROW);
			$("#proservicesContainer").attr("src",CLOSED_ARROW);
		});
		break;
	case "retail":
		$("#contentRetail").css("display","block");
		$("#toggleAll").animate({opacity: 1.0}, 500, function() {
			$("#retailContainer").slideDown(1250);
			$("#retailArrow").attr("src",OPEN_ARROW);
			$("#retailContainer").attr("src",CLOSED_ARROW);
		});
		break;
	default:
		if (pIsGeneralContent == true) {
			$("#contentStandard").css("display","block");
			$("#toggleAll").animate({opacity: 1.0}, 500, function() {
				$("#standardContainer").slideDown(1250);
				$("#standardArrow").attr("src",OPEN_ARROW);
				$("#standardContainer").attr("src",CLOSED_ARROW);
			});
		}
	}
}

/* This function will bind the form functionality to the change event for the industrySelect element.  This function
 * will deal with the display of the industry specific content on both the features and benefits tab.
 */
function bindIndustryDropdown(pSpeedSlow,pSpeedMedium,pSpeedFast,pIsGeneralContent) {
	if (($.browser.mozilla) && (logDebug == true)) {
		console.log("Dropdown select - binding change event");
		console.log("Dropdown select - speed: " + pSpeedFast + "," + pSpeedMedium + "," + pSpeedSlow);
	}
	
	// Global variables
	var CLOSED_ARROW = new String("/qb/products/premier/premier_standard/premier_convertible_benefits/images/arrow_closed.gif");
	var OPEN_ARROW = new String("/qb/products/premier/premier_standard/premier_convertible_benefits/images/arrow_open.gif");
	
	// Set the industry specific content slide speeds
	var standardSpeed = pSpeedSlow;
	var contractorSpeed = pSpeedFast;
	var manufacturerSpeed = pSpeedSlow;
	var nonprofitSpeed = pSpeedFast;
	var proservicesSpeed = pSpeedFast;
	var retailSpeed = pSpeedMedium;
	
	$("#industryDropdownSelect").bind("change", function() {
		_hbLink("#" + $("#industryDropdownSelect").val() + "Dropdown");
		switch ($("#industryDropdownSelect").val()) {
		case "general":
			if (!($("#contentContractor").is(":hidden"))) {
				$("#contentContractor").slideUp(contractorSpeed, function() {
					if (pIsGeneralContent == true) {
						$("#contentStandard").slideDown(standardSpeed, function() {
							$("#toggleAll").animate({opacity: 1.0}, 500, function() {
								$("#standardArrow").attr("src",OPEN_ARROW);
								$("#standardContainer").slideDown(standardSpeed);
							});
						});
					}
				});
			}
			else if (!($("#contentManufacturer").is(":hidden"))) {
				$("#contentManufacturer").slideUp(manufacturerSpeed, function() {
					if (pIsGeneralContent == true) {
						$("#contentStandard").slideDown(standardSpeed, function() {
							$("#toggleAll").animate({opacity: 1.0}, 500, function() {
								$("#standardArrow").attr("src",OPEN_ARROW);
								$("#standardContainer").slideDown(standardSpeed);
							});
						});
					}
				});
			}
			else if (!($("#contentNonprofit").is(":hidden"))) {
				$("#contentNonprofit").slideUp(nonprofitSpeed, function() {
					if (pIsGeneralContent == true) {
						$("#contentStandard").slideDown(standardSpeed, function() {
							$("#toggleAll").animate({opacity: 1.0}, 500, function() {
								$("#standardArrow").attr("src",OPEN_ARROW);
								$("#standardContainer").slideDown(standardSpeed);
							});
						});
					}
				});
			}
			else if (!($("#contentProservices").is(":hidden"))) {
				$("#contentProservices").slideUp(proservicesSpeed, function() {
					if (pIsGeneralContent == true) {
						$("#contentStandard").slideDown(standardSpeed, function() {
							$("#toggleAll").animate({opacity: 1.0}, 500, function() {
								$("#standardArrow").attr("src",OPEN_ARROW);
								$("#standardContainer").slideDown(standardSpeed);
							});
						});
					}
				});
			}
			else if (!($("#contentRetail").is(":hidden"))) {
				$("#contentRetail").slideUp(retailSpeed, function() {
					if (pIsGeneralContent == true) {
						$("#contentStandard").slideDown(standardSpeed, function() {
							$("#toggleAll").animate({opacity: 1.0}, 500, function() {
								$("#standardArrow").attr("src",OPEN_ARROW);
								$("#standardContainer").slideDown(standardSpeed);
							});
						});
					}
				});
			}
			else {
				if (pIsGeneralContent == true) {
					$("#contentStandard").slideDown(standardSpeed, function() {
						$("#toggleAll").animate({opacity: 1.0}, 500, function() {
							$("#standardArrow").attr("src",OPEN_ARROW);
							$("#standardContainer").slideDown(standardSpeed);
						});
					});
				}
			}
			break;
		case "contractor":
			if (!($("#contentStandard").is(":hidden"))) {
				$("#contentStandard").slideUp(standardSpeed, function() {
					$("#contentContractor").slideDown(contractorSpeed, function() {
						$("#toggleAll").animate({opacity: 1.0}, 500, function() {
							$("#contractorArrow").attr("src",OPEN_ARROW);
							$("#contractorContainer").slideDown(contractorSpeed);
						});
					});
				});
			}
			else if (!($("#contentManufacturer").is(":hidden"))) {
				$("#contentManufacturer").slideUp(manufacturerSpeed, function() {
					$("#contentContractor").slideDown(contractorSpeed, function() {
						$("#toggleAll").animate({opacity: 1.0}, 500, function() {
							$("#contractorArrow").attr("src",OPEN_ARROW);
							$("#contractorContainer").slideDown(contractorSpeed);
						});
					});
				});
			}
			else if (!($("#contentNonprofit").is(":hidden"))) {
				$("#contentNonprofit").slideUp(nonprofitSpeed, function() {
					$("#contentContractor").slideDown(contractorSpeed, function() {
						$("#toggleAll").animate({opacity: 1.0}, 500, function() {
							$("#contractorArrow").attr("src",OPEN_ARROW);
							$("#contractorContainer").slideDown(contractorSpeed);
						});
					});
				});
			}
			else if (!($("#contentProservices").is(":hidden"))) {
				$("#contentProservices").slideUp(proservicesSpeed, function() {
					$("#contentContractor").slideDown(contractorSpeed, function() {
						$("#toggleAll").animate({opacity: 1.0}, 500, function() {
							$("#contractorArrow").attr("src",OPEN_ARROW);
							$("#contractorContainer").slideDown(contractorSpeed);
						});
					});
				});
			}
			else if (!($("#contentRetail").is(":hidden"))) {
				$("#contentRetail").slideUp(retailSpeed, function() {
					$("#contentContractor").slideDown(contractorSpeed, function() {
						$("#toggleAll").animate({opacity: 1.0}, 500, function() {
							$("#contractorArrow").attr("src",OPEN_ARROW);
							$("#contractorContainer").slideDown(contractorSpeed);
						});
					});
				});
			}
			else {
				$("#contentContractor").slideDown(contractorSpeed, function() {
					$("#toggleAll").animate({opacity: 1.0}, 500, function() {
						$("#contractorArrow").attr("src",OPEN_ARROW);
						$("#contractorContainer").slideDown(contractorSpeed);
					});
				});
			}
			break;
		case "manufacturer":
			if (!($("#contentStandard").is(":hidden"))) {
				$("#contentStandard").slideUp(standardSpeed, function() {
					$("#contentManufacturer").slideDown(manufacturerSpeed, function() {
						$("#toggleAll").animate({opacity: 1.0}, 500, function() {
							$("#manufacturerArrow").attr("src",OPEN_ARROW);
							$("#manufacturerContainer").slideDown(manufacturerSpeed);
						});
					});
				});
			}
			else if (!($("#contentContractor").is(":hidden"))) {
				$("#contentContractor").slideUp(contractorSpeed, function() {
					$("#contentManufacturer").slideDown(manufacturerSpeed, function() {
						$("#toggleAll").animate({opacity: 1.0}, 500, function() {
							$("#manufacturerArrow").attr("src",OPEN_ARROW);
							$("#manufacturerContainer").slideDown(manufacturerSpeed);
						});
					});
				});
			}
			else if (!($("#contentNonprofit").is(":hidden"))) {
				$("#contentNonprofit").slideUp(nonprofitSpeed, function() {
					$("#contentManufacturer").slideDown(manufacturerSpeed, function() {
						$("#toggleAll").animate({opacity: 1.0}, 500, function() {
							$("#manufacturerArrow").attr("src",OPEN_ARROW);
							$("#manufacturerContainer").slideDown(manufacturerSpeed);
						});
					});
				});
			}
			else if (!($("#contentProservices").is(":hidden"))) {
				$("#contentProservices").slideUp(proservicesSpeed, function() {
					$("#contentManufacturer").slideDown(manufacturerSpeed, function() {
						$("#toggleAll").animate({opacity: 1.0}, 500, function() {
							$("#manufacturerArrow").attr("src",OPEN_ARROW);
							$("#manufacturerContainer").slideDown(manufacturerSpeed);
						});
					});
				});
			}
			else if (!($("#contentRetail").is(":hidden"))) {
				$("#contentRetail").slideUp(retailSpeed, function() {
					$("#contentManufacturer").slideDown(manufacturerSpeed, function() {
						$("#toggleAll").animate({opacity: 1.0}, 500, function() {
							$("#manufacturerArrow").attr("src",OPEN_ARROW);
							$("#manufacturerContainer").slideDown(manufacturerSpeed);
						});
					});
				});
			}
			else {
				$("#contentManufacturer").slideDown(manufacturerSpeed, function() {
					$("#toggleAll").animate({opacity: 1.0}, 500, function() {
						$("#manufacturerArrow").attr("src",OPEN_ARROW);
						$("#manufacturerContainer").slideDown(manufacturerSpeed);
					});
				});
			}
			break;
		case "nonprofit":
			if (!($("#contentStandard").is(":hidden"))) {
				$("#contentStandard").slideUp(standardSpeed, function() {
					$("#contentNonprofit").slideDown(nonprofitSpeed, function() {
						$("#toggleAll").animate({opacity: 1.0}, 500, function() {
							$("#nonprofitArrow").attr("src",OPEN_ARROW);
							$("#nonprofitContainer").slideDown(nonprofitSpeed);
						});
					});
				});
			}
			else if (!($("#contentContractor").is(":hidden"))) {
				$("#contentContractor").slideUp(contractorSpeed, function() {
					$("#contentNonprofit").slideDown(nonprofitSpeed, function() {
						$("#toggleAll").animate({opacity: 1.0}, 500, function() {
							$("#nonprofitArrow").attr("src",OPEN_ARROW);
							$("#nonprofitContainer").slideDown(nonprofitSpeed);
						});
					});
				});
			}
			else if (!($("#contentManufacturer").is(":hidden"))) {
				$("#contentManufacturer").slideUp(manufacturerSpeed, function() {
					$("#contentNonprofit").slideDown(nonprofitSpeed, function() {
						$("#toggleAll").animate({opacity: 1.0}, 500, function() {
							$("#nonprofitArrow").attr("src",OPEN_ARROW);
							$("#nonprofitContainer").slideDown(nonprofitSpeed);
						});
					});
				});
			}
			else if (!($("#contentProservices").is(":hidden"))) {
				$("#contentProservices").slideUp(proservicesSpeed, function() {
					$("#contentNonprofit").slideDown(nonprofitSpeed, function() {
						$("#toggleAll").animate({opacity: 1.0}, 500, function() {
							$("#nonprofitArrow").attr("src",OPEN_ARROW);
							$("#nonprofitContainer").slideDown(nonprofitSpeed);
						});
					});
				});
			}
			else if (!($("#contentRetail").is(":hidden"))) {
				$("#contentRetail").slideUp(retailSpeed, function() {
					$("#contentNonprofit").slideDown(nonprofitSpeed, function() {
						$("#toggleAll").animate({opacity: 1.0}, 500, function() {
							$("#nonprofitArrow").attr("src",OPEN_ARROW);
							$("#nonprofitContainer").slideDown(nonprofitSpeed);
						});
					});
				});
			}
			else {
				$("#contentNonprofit").slideDown(nonprofitSpeed, function() {
					$("#toggleAll").animate({opacity: 1.0}, 500, function() {
						$("#nonprofitArrow").attr("src",OPEN_ARROW);
						$("#nonprofitContainer").slideDown(nonprofitSpeed);
					});
				});
			}
			break;
		case "proservices":
			if (!($("#contentStandard").is(":hidden"))) {
				$("#contentStandard").slideUp(standardSpeed, function() {
					$("#contentProservices").slideDown(proservicesSpeed, function() {
						$("#toggleAll").animate({opacity: 1.0}, 500, function() {
							$("#proservicesArrow").attr("src",OPEN_ARROW);
							$("#proservicesContainer").slideDown(proservicesSpeed);
						});
					});
				});
			}
			else if (!($("#contentContractor").is(":hidden"))) {
				$("#contentContractor").slideUp(contractorSpeed, function() {
					$("#contentProservices").slideDown(proservicesSpeed, function() {
						$("#toggleAll").animate({opacity: 1.0}, 500, function() {
							$("#proservicesArrow").attr("src",OPEN_ARROW);
							$("#proservicesContainer").slideDown(proservicesSpeed);
						});
					});
				});
			}
			else if (!($("#contentManufacturer").is(":hidden"))) {
				$("#contentManufacturer").slideUp(manufacturerSpeed, function() {
					$("#contentProservices").slideDown(proservicesSpeed, function() {
						$("#toggleAll").animate({opacity: 1.0}, 500, function() {
							$("#proservicesArrow").attr("src",OPEN_ARROW);
							$("#proservicesContainer").slideDown(proservicesSpeed);
						});
					});
				});
			}
			else if (!($("#contentNonprofit").is(":hidden"))) {
				$("#contentNonprofit").slideUp(nonprofitSpeed, function() {
					$("#contentProservices").slideDown(proservicesSpeed, function() {
						$("#toggleAll").animate({opacity: 1.0}, 500, function() {
							$("#proservicesArrow").attr("src",OPEN_ARROW);
							$("#proservicesContainer").slideDown(proservicesSpeed);
						});
					});
				});
			}
			else if (!($("#contentRetail").is(":hidden"))) {
				$("#contentRetail").slideUp(retailSpeed, function() {
					$("#contentProservices").slideDown(proservicesSpeed, function() {
						$("#toggleAll").animate({opacity: 1.0}, 500, function() {
							$("#proservicesArrow").attr("src",OPEN_ARROW);
							$("#proservicesContainer").slideDown(proservicesSpeed);
						});
					});
				});
			}
			else {
				$("#contentProservices").slideDown(proservicesSpeed, function() {
					$("#toggleAll").animate({opacity: 1.0}, 500, function() {
						$("#proservicesArrow").attr("src",OPEN_ARROW);
						$("#proservicesContainer").slideDown(proservicesSpeed);
					});
				});
			}
			break;
		case "retail":
			if (!($("#contentStandard").is(":hidden"))) {
				$("#contentStandard").slideUp(standardSpeed, function() {
					$("#contentRetail").slideDown(retailSpeed, function() {
						$("#toggleAll").animate({opacity: 1.0}, 500, function() {
							$("#retailArrow").attr("src",OPEN_ARROW);
							$("#retailContainer").slideDown(retailSpeed);
						});
					});
				});
			}
			else if (!($("#contentContractor").is(":hidden"))) {
				$("#contentContractor").slideUp(contractorSpeed, function() {
					$("#contentRetail").slideDown(retailSpeed, function() {
						$("#toggleAll").animate({opacity: 1.0}, 500, function() {
							$("#retailArrow").attr("src",OPEN_ARROW);
							$("#retailContainer").slideDown(retailSpeed);
						});
					});
				});
			}
			else if (!($("#contentManufacturer").is(":hidden"))) {
				$("#contentManufacturer").slideUp(manufacturerSpeed, function() {
					$("#contentRetail").slideDown(retailSpeed, function() {
						$("#toggleAll").animate({opacity: 1.0}, 500, function() {
							$("#retailArrow").attr("src",OPEN_ARROW);
							$("#retailContainer").slideDown(retailSpeed);
						});
					});
				});
			}
			else if (!($("#contentNonprofit").is(":hidden"))) {
				$("#contentNonprofit").slideUp(nonprofitSpeed, function() {
					$("#contentRetail").slideDown(retailSpeed, function() {
						$("#toggleAll").animate({opacity: 1.0}, 500, function() {
							$("#retailArrow").attr("src",OPEN_ARROW);
							$("#retailContainer").slideDown(retailSpeed);
						});
					});
				});
			}
			else if (!($("#contentProservices").is(":hidden"))) {
				$("#contentProservices").slideUp(proservicesSpeed, function() {
					$("#contentRetail").slideDown(retailSpeed, function() {
						$("#toggleAll").animate({opacity: 1.0}, 500, function() {
							$("#retailArrow").attr("src",OPEN_ARROW);
							$("#retailContainer").slideDown(retailSpeed);
						});
					});
				});
			}
			else {
				$("#contentRetail").slideDown(400, function() {
					$("#toggleAll").animate({opacity: 1.0}, 500, function() {
						$("#retailArrow").attr("src",OPEN_ARROW);
						$("#retailContainer").slideDown(retailSpeed);
					});
				});
			}
			break;
		}
		this.blur();
		if (($.browser.mozilla) && (logDebug == true)) {
			console.log("Dropdown select - case " + $("#industryDropdownSelect").val());
		}
		
		parameterString = "name=convertiblePosition&value=" + $("#industryDropdownSelect").val();
		$.ajax({
			type: "POST",
			url: "/qb/common/utility_droplets/update_source_tracking.jsp",
			data: parameterString
		});
		
		return(false);
	});
}

/* This function will bind the functionality for the click and hover events to the level one accordion elements in the
 * features tab.
 */
function bindAccordion1Elements(pElementNames) {

	// Global variables
	var CLOSED_ARROW = new String("/qb/products/premier/premier_standard/premier_convertible_benefits/images/arrow_closed.gif");
	var OPEN_ARROW = new String("/qb/products/premier/premier_standard/premier_convertible_benefits/images/arrow_open.gif");
	var SLIDE_TIME = 750;
	var UNHOVER_COLOR = "#000000";
	var HOVER_COLOR = "#999999";
	
	// Bind the toggle functionality to the click event of the level 1 arrows
	jQuery.each(pElementNames, function() {
		var arrowElementId = "#" + this + "Arrow";
		var containerElementId = "#" + this + "Container";
		
		if (($.browser.mozilla) && (logDebug == true)) {
			console.log("Bind level 1 toggle to click event - " + arrowElementId);
		}
		$(arrowElementId).bind("click", function() {
			_hbLink(arrowElementId);
			$(containerElementId).slideToggle(SLIDE_TIME);
			if($(arrowElementId).attr("src") == CLOSED_ARROW) {
				$(arrowElementId).attr("src",OPEN_ARROW);
			}
			else {
				$(arrowElementId).attr("src",CLOSED_ARROW);
			}
			this.blur();
			return(false);
		});
	});
	
	// Bind the toggle functionality to the click event of the level 1 text
	jQuery.each(pElementNames, function() {
		var textElementId = "#" + this + "Text";
		var arrowElementId = "#" + this + "Arrow";
		var containerElementId = "#" + this + "Container";
		
		if (($.browser.mozilla) && (logDebug == true)) {
			console.log("Bind level 1 toggle to click event - " + textElementId);
		}
		$(textElementId).bind("click", function() {
			_hbLink(textElementId);
			$(containerElementId).slideToggle(SLIDE_TIME);
			if($(arrowElementId).attr("src") == CLOSED_ARROW) {
				$(arrowElementId).attr("src",OPEN_ARROW);
			}
			else {
				$(arrowElementId).attr("src",CLOSED_ARROW);
			}
			this.blur();
			return(false);
		});
	});
	
	// Bind the toggle functionality to the click event of the level 1 text
	jQuery.each(pElementNames, function() {
		var toggleElementId = "#" + this + "Toggle";
		var arrowElementId = "#" + this + "Arrow";
		var containerElementId = "#" + this + "Container";
		
		if (($.browser.mozilla) && (logDebug == true)) {
			console.log("Bind level 1 toggle to click event - " + toggleElementId);
		}
		$(toggleElementId).bind("click", function() {
			_hbLink(toggleElementId);
			$(containerElementId).slideToggle(SLIDE_TIME);
			if($(arrowElementId).attr("src") == CLOSED_ARROW) {
				$(arrowElementId).attr("src",OPEN_ARROW);
			}
			else {
				$(arrowElementId).attr("src",CLOSED_ARROW);
			}
			this.blur();
			return(false);
		});
	});
	
	// Bind the color styling to the hover event of the level 1 text
	jQuery.each(pElementNames, function() {
		var textElementId = "#" + this + "Text";
		
		if (($.browser.mozilla) && (logDebug == true)) {
			console.log("Bind level 1 color to hover event - " + textElementId);
		}
		$(textElementId).hover(
			function () {
				$(textElementId).css("color", HOVER_COLOR);
			}, 
			function () {
				$(textElementId).css("color", UNHOVER_COLOR);
			}
		);
	});
	
	// Bind the color styling to the hover event of the level 1 toogle
	var UNHOVER_COLOR_TOGGLE = "#4995FF";
	var HOVER_COLOR_TOGGLE = "#cccccc";
	jQuery.each(pElementNames, function() {
		var toggleElementId = "#" + this + "Toggle";
		
		if (($.browser.mozilla) && (logDebug == true)) {
			console.log("Bind level 1 color to hover event - " + toggleElementId);
		}
		$(toggleElementId).hover(
			function () {
				$(toggleElementId).css("color", HOVER_COLOR_TOGGLE);
			}, 
			function () {
				$(toggleElementId).css("color", UNHOVER_COLOR_TOGGLE);
			}
		);
	});
}

/* This function will bind the functionality for the click and hover events to the level two accordion elements in the
 * features tab.
 */
function bindAccordion2Elements(pElementNames) {

	// Global variables
	var CLOSED_ARROW = new String("/qb/products/premier/premier_standard/premier_convertible_benefits/images/arrow_sml_closed.gif");
	var OPEN_ARROW = new String("/qb/products/premier/premier_standard/premier_convertible_benefits/images/arrow_sml_open.gif");
	var SLIDE_TIME = 500;
	var UNHOVER_COLOR = "#000000";
	var HOVER_COLOR = "#999999";
	
	// Bind the toggle functionality to the click event of the level 1 arrows
	jQuery.each(pElementNames, function() {
		var arrowElementId = "#" + this + "Arrow";
		var containerElementId = "#" + this + "Container";
		
		if (($.browser.mozilla) && (logDebug == true)) {
			console.log("Bind level 2 toggle to click event - " + arrowElementId);
		}
		$(arrowElementId).bind("click", function() {
			_hbLink(arrowElementId);
			$(containerElementId).slideToggle(SLIDE_TIME);
			if($(arrowElementId).attr("src") == CLOSED_ARROW) {
				$(arrowElementId).attr("src",OPEN_ARROW);
			}
			else {
				$(arrowElementId).attr("src",CLOSED_ARROW);
			}
			this.blur();
			return(false);
		});
	});
	
	// Bind the toggle functionality to the click event of the level 1 text
	jQuery.each(pElementNames, function() {
		var textElementId = "#" + this + "Text";
		var arrowElementId = "#" + this + "Arrow";
		var containerElementId = "#" + this + "Container";
		
		if (($.browser.mozilla) && (logDebug == true)) {
			console.log("Bind level 2 toggle to click event - " + textElementId);
		}
		$(textElementId).bind("click", function() {
			_hbLink(textElementId);
			$(containerElementId).slideToggle(SLIDE_TIME);
			if($(arrowElementId).attr("src") == CLOSED_ARROW) {
				$(arrowElementId).attr("src",OPEN_ARROW);
			}
			else {
				$(arrowElementId).attr("src",CLOSED_ARROW);
			}
			this.blur();
			return(false);
		});
	});
	
	// Bind the color styling to the event of the level 1 toogle
	jQuery.each(pElementNames, function() {
		var textElementId = "#" + this + "Text";
		
		if (($.browser.mozilla) && (logDebug == true)) {
			console.log("Bind level 2 color to hover event - " + textElementId);
		}
		$(textElementId).hover(
			function () {
				$(textElementId).css("color", HOVER_COLOR);
			}, 
			function () {
				$(textElementId).css("color", UNHOVER_COLOR);
			}
		);
	});
}

/* This function binds the accordion level 1 global toggle functionality to the toggle link at the top of the
 * expanding content section.
 */
function bindAccordion1Toggle(pElementNames) {
	
	// Bind the hover event for the toggle link 
	var UNHOVER_COLOR = "#4995FF";
	var HOVER_COLOR = "#cccccc";
	$("#toggleAll").hover(
		function () {
			$("#toggleAll").css("color", HOVER_COLOR);
		}, 
		function () {
			$("#toggleAll").css("color", UNHOVER_COLOR);
		}
	);

	// Bind the click event to the toggle link
	var CLOSED_ARROW = new String("/qb/products/premier/premier_standard/premier_convertible_benefits/images/arrow_closed.gif");
	var OPEN_ARROW = new String("/qb/products/premier/premier_standard/premier_convertible_benefits/images/arrow_open.gif");
	var SLIDE_TIME = 750;
	var action = "open";
	
	// Bind the click event to the toggle element
	$("#toggleAll").bind("click", function() {
		_hbLink("#globalToggle");
		var filteredElementNames = filterNames(pElementNames);
		jQuery.each(filteredElementNames, function() {
			var arrowElementId = "#" + this + "Arrow";
			var containerElementId = "#" + this + "Container";
			if (action == "open") {
				if ($(containerElementId).is(":hidden")) {			
					$("#toggleAll").animate({opacity: 1.0}, 500, function() {
						$(containerElementId).slideDown(SLIDE_TIME);
						$(arrowElementId).attr("src",OPEN_ARROW);
					});
				}
			}
			else {
				if (!($(containerElementId).is(":hidden"))) {
					$("#toggleAll").animate({opacity: 1.0}, 500, function() {
						$(containerElementId).slideUp(SLIDE_TIME);
						$(arrowElementId).attr("src",CLOSED_ARROW);
					});
				}
			}
		});
		
		if (action == "open") {
			action = "close";
		}
		else {
			action = "open";
		}
	});
}

/* This function filters out all those names of the elements that are currently hidden. */
function filterNames(pElementNames) {
	var a = new Array();
	jQuery.each(pElementNames, function() {
		
        firstCharacter = this.substring(0,1);
        remainingCharacters = this.substring(1);
        firstCharacter = firstCharacter.toUpperCase();
        finalString = firstCharacter + remainingCharacters;
			
		var elementName = "#content" + finalString;
		if (!($(elementName).is(":hidden"))) {
			a.push(this);
		}
	});
    return a;
}

/* This function binds the accordion level 2 details toggle functionality to the toggle link at the top of the
 * expanding content section.
 */
function bindAccordion2Toggle(pContainerName,pElementNames) {
	
	var toggleName = "#" + pContainerName + "DetailsToggle";
	
	// Bind the hover event for the toggle link 
	var UNHOVER_COLOR = "#4995FF";
	var HOVER_COLOR = "#cccccc";
	$(toggleName).hover(
		function () {
			$(toggleName).css("color", HOVER_COLOR);
		}, 
		function () {
			$(toggleName).css("color", UNHOVER_COLOR);
		}
	);
	
	// Bind the click event to the toggle element
	var SLIDE_TIME = 500;
	var action = "open";
	var CLOSED_ARROW = new String("/qb/products/premier/premier_standard/premier_convertible_benefits/images/arrow_sml_closed.gif");
	var OPEN_ARROW = new String("/qb/products/premier/premier_standard/premier_convertible_benefits/images/arrow_sml_open.gif");
		$(toggleName).bind("click", function() {
			_hbLink(toggleName);
			jQuery.each(pElementNames, function() {
			
			var containerElementId = "#" + this + "Container";
			var arrowElementId = "#" + this + "Arrow";
			if (action == "open") {
				if ($(containerElementId).is(":hidden")) {			
					$("#toggleAll").animate({opacity: 1.0}, 500, function() {
						$(containerElementId).slideDown(SLIDE_TIME);
						$(arrowElementId).attr("src",OPEN_ARROW);
					});
				}
			}
			else {
				if (!($(containerElementId).is(":hidden"))) {
					$("#toggleAll").animate({opacity: 1.0}, 500, function() {
						$(containerElementId).slideUp(SLIDE_TIME);
						$(arrowElementId).attr("src",CLOSED_ARROW);
					});
				}
			}
		});
		if (action == "open") {
			action = "close";
		}
		else {
			action = "open";
		}
	});
}

/* Bind the hover event to the introduction element */
function bindHoverIntroduction() {
	var UNHOVER_COLOR = "#000000";
	var HOVER_COLOR = "#999999";
	$("#introductionLink").hover(
		function () {
			$("#introductionLink").css("color", HOVER_COLOR);
		}, 
		function () {
			$("#introductionLink").css("color", UNHOVER_COLOR);
		}
	);
}