var step1val = null;
var step2val = null;
var step3val = null;

function applyVals() {
	$$("#li1 input").each(function(i) {
		if ((i.readAttribute("name") == "step1") && (i.checked)) 
			step1val = i.value;
	});
	$$("#li2 input").each(function(i) {
		if ((i.readAttribute("name") == "step2") && (i.checked)) 
			step2val = i.value;
	});
	$$("#li3 input").each(function(i) {
		if ((i.readAttribute("name") == "step3") && (i.checked)) 
			step3val = i.value;
	});
}

var result1 = "For the volume of transactions you deal with, we have a team of agents including your own Relationship Manager and Risk Management staff, all ready to help you with everything you need to streamline your business effectively and securely.";
var result2 = "We offer a variety of supplies that can be customized to suit your specific business needs. Please contact one of our agents, who will be happy to help set you up and get you started with free set-up and training.";
var result3 = "For your type of business, we will need a little more information to help get you started. With the broad range of products and services we offer, we&rsquo;re confident that we'll find the right solution for you.";
var resultdef = "Let&rsquo;s chat a little more about your business and what sort of solutions we can help you with. With the variety of reliable products and services we offer, we'll find the right match that&rsquo;s tailored just for you.";

function results() {
	applyVals();
	if ((step1val == null) || (step2val == null) || (step3val == null)) {
		window.alert("Please make a selection before clicking 'Submit'.");
		return;
	}
	var fadeOuts = [
		"naToolIntro",
		"naToolForm",
		"stepsMenu",
		"naMenu",
		"prevButton",
		"submitButton"
	];
	fadeOuts.each(function(ele) {
		new Effect.Opacity(ele, {
			from: 1.0,
			to: 0.0,
			duration: 1.0
		});
	});
	//window.alert(step2val);
	var answ = null;
	if (step2val == "true") 
		answ = result1;
	else if (step3val == "true") 
		answ = result2;
	else if (step1val == "true") 
		answ = result3;
	else 
		answ = resultdef;
	$("answer").insert(answ);
	$("frame4").setStyle({
		opacity: 0,
		width: "562px",
		position: "absolute",
		left: "19px",
		top: "65px",
		display: "block"
	});
	new Effect.Opacity("frame4", {
		from: 0.0,
		to: 1.0,
		duration: 1.0
	});
	
	// Added by CJUS to compensate for a scriptaculous bug under IE8
		$("li3").hide();
		$("li2").hide();
	// End of CJUS patch
}

var step1x = 0;
var step2x = -562;
var step3x = -1124;

var currStep = 1;

function moveSteps(step) {
	applyVals();
	if (((currStep == 1) && (step1val == null)) 
		|| ((currStep == 1) && (step == 3) && (step2val == null) && (step3val == null)) 
		|| ((currStep == 2) && (step == 3) && (step2val == null))) {
		window.alert("Please make a selection before clicking 'Next'.");
		return
	};
	var move = null;
	switch (step) {
		case 1 : 
			move = step1x;
			$("prevButton").setStyle("display: none;");
			$("nextButton").up().writeAttribute("href", "javascript:moveSteps(2);");
			break;
		case 2 : 
			move = step2x;
			$("submitButton").setStyle("display: none;")
			$("prevButton").setStyle("display: block;").up().writeAttribute("href", "javascript:moveSteps(1);");
			$("nextButton").setStyle("display: block;").up().writeAttribute("href", "javascript:moveSteps(3);");
			break;
		case 3 : 
			move = step3x;
			$("prevButton").up().writeAttribute("href", "javascript:moveSteps(2);");
			$("nextButton").setStyle("display: none;");
			$("submitButton").setStyle("display: block;").observe("click", results);
			break;
	}
	new Effect.Move("naScroll", {
		x: move,
		y: 0,
		mode: "absolute",
		duration: 0.5
	});
	$("naMenu").writeAttribute("src", "../images/menu_na_step" + step + ".gif");
	currStep = step;
}

function naTool() {
	$$("#content ul.contentSubNav").each(function(ul) {
		ul.remove();
	});
	$("naToolIntro").setStyle("display: block;");
	$("naToolForm").setStyle("display: block;");
	$("stepsMenu").setStyle("display: inline;");
	$("naMenu").setStyle("display: block;");
	$("nextButton").setStyle("display: block;").up().writeAttribute("href", "javascript:moveSteps(2);");
	$("answer").remove();
	$("recHeading").insert({
		after: "<p id='answer'></a>"
	});
	
	$("naToolForm").setStyle({
		width: "562px",
		height: "240px",
		marginTop: "35px",
		overflow: "hidden",
		position: "relative"
	});
	$("naScroll").setStyle({
		width: "2000px",
		height: "240px",
		position: "absolute",
		left: "0",
		top: "0"
	});
	$$("#naToolForm fieldset ol").each(function(ol) {
		ol.setStyle({
			width: "1686px",
			height: "240px"
		});
	});
	$$("#naToolForm fieldset ol li").each(function(li) {
		li.setStyle({
			width: "562px",
			height: "240px",
			float: "left"
		});
	});
	if (browser != "Not IE") {
		$("li1").insert("<em class='numeral'>1.</em>").setStyle("width: 557px;");
		$("li2").insert("<em class='numeral'>2.</em>").setStyle("width: 557px;");
		$("li3").insert("<em class='numeral'>3.</em>").setStyle("width: 538px;");
	}
	// $("submitButton").observe("click", results);
}
