//included in solution_finder.jsp

//This line is required to disable bfbuffer (otherwise fancybox malfunctions)
jQuery(window).bind("unload", function(){});

//This function is a form of Controller, deciding the navigation route based on the industry
function checkIndustry(event)
{
	//var industry = $("#industry").val();
	if(industry === "home")
	{
		document.forms["solutionFinderForm"].submit();
		return false;
	} 
	else if(industry=="default")
	{
		return false;
	}

	
	document.getElementById('solution_finder_link').href="/solution-finder/questions.jsp?state=home&industry=" + industry;
}

//Change the industry image depending on the selected industry
/*function changeSolutionFinderImage()
{
	var sf_image = document.getElementById('solution_finder_image');
	var industry = document.getElementById('industry').value;
	sf_image.src="/images/solution_finder/" + industry + ".png";
}*/


$(document).ready(function() {
	/*var industry;
	$("#flip > li > img").each(function (index) {
		if ($(this).attr("style") === "width: 200px;") {
			industry = $(this).attr("id");
		}
	});*/
	//Reset the industry dropdown upon page reload
	/*$('#industry').ready(
		function() 
		{
			$("#industry").val('default');
		}
	);*/

	//attach fancybox to the solution finder button
	$("#solution_finder_link").css("cursor", "pointer"); 
	$("#solution_finder_link").click(function() {
		if ($("#employees").val() === "" || $("#employees").val() === "0") {
			alert("You must enter a number greater than 1 in the 'number of employees' field.");
			s.linkTrackVars = 'evar34';
			s.eVar34 = 'Number of employees entry is blank or zero';
			s.tl();
			return false;
		}

		employeeNumber = parseInt($('#employees').val());

		if (employeeNumber > 99) {
			s.linkTrackVars = 'evar34';
			s.eVar34 = 'Number of employees greater than 99';
			s.tl();
			Shadowbox.open ({
				"width" : 400,
				"height" : 120,
				"player" : "iframe",
				"content" : "/solution-finder/lightpath.jsp"
			});
		} else {

			Shadowbox.open ({
				"width" : 550,
				"height" : 500,
				"player" : "iframe",
				"content" : "/solution-finder/questions.jsp?state=home&industry=" + industry,
				"onOpen" : checkIndustry
			});
		}

	});			

	//Listen for changes to the industry dropdown
	/*$('#industry').change
	(
		function() 
		{
			changeSolutionFinderImage();
		}
	);*/

	/*$('#industry').keypress
	(
		function() 
		{
			changeSolutionFinderImage();
		}
	);*/
});
