//javascript for ROI analisys report tool

function validation(quelStep, showDiv, hideDiv, msgAlert){
		msg = msgAlert;
		submitOK = true;
		
		if(quelStep == "step1"){
			if(!document.form1.employees_require_internet[0].checked && !document.form1.employees_require_internet[1].checked){
				//msg += "- Do your employees require internet access when away from the office?\n";			
				DivObj = document.getElementById("employees_require_internet_div");
				DivObj.style.color = "red";
				submitOK = false;
			}else{
				DivObj = document.getElementById("employees_require_internet_div");
				DivObj.style.color = "#666666";
			}
			
			if(!document.form1.employees_have_laptop[0].checked && !document.form1.employees_have_laptop[1].checked){
				//msg += "- Do your employees have laptops?\n";	
				DivObj = document.getElementById("employees_have_laptop_div");
				DivObj.style.color = "red";
				submitOK = false;
			}else{
				DivObj = document.getElementById("employees_have_laptop_div");
				DivObj.style.color = "#666666";
			}
			
			if(document.form1.employees_have_laptop[0].checked && document.form1.how_many_laptop.value==""){
				//msg += "- How many laptops are used in total?\n";		
				DivObj = document.getElementById("how_many_laptop_div");
				DivObj.style.color = "red";
				submitOK = false;
			}else{
				DivObj = document.getElementById("how_many_laptop_div");
				DivObj.style.color = "#666666";
			}
			
			if(document.form1.how_many_employee.value==""){
				//msg += "- How many employees do you have?\n";	
				DivObj = document.getElementById("how_many_employee_div");
				DivObj.style.color = "red";
				submitOK = false;
			}else{
				DivObj = document.getElementById("how_many_employee_div");
				DivObj.style.color = "#666666";
			}
			
			if(document.form1.how_many_require_away_internet.value==""){
				DivObj = document.getElementById("how_many_require_away_internet_div");
				DivObj.style.color = "red";
				submitOK = false;
			}else{
				DivObj = document.getElementById("how_many_require_away_internet_div");
				DivObj.style.color = "#666666";
			}
		}
		
		if(quelStep == "step2"){
			if(!document.form1.company_reimburse_internet[0].checked && !document.form1.company_reimburse_internet[1].checked){
				//msg += "- Does the company reimburse the cost of internet access to employees?\n";
				DivObj = document.getElementById("company_reimburse_internet_div");
				DivObj.style.color = "red";
				submitOK = false;
			}else{
				DivObj = document.getElementById("company_reimburse_internet_div");
				DivObj.style.color = "#666666";
			}
			
			if(document.form1.company_reimburse_internet[0].checked && document.form1.home_internet_company_paid.value==""){
				//msg += "- How many employees have internet services at home, paid by the company?\n";	
				DivObj = document.getElementById("home_internet_company_paid_div");
				DivObj.style.color = "red";
				submitOK = false;
			}else{
				DivObj = document.getElementById("home_internet_company_paid_div");
				DivObj.style.color = "#666666";
			}
			
			if(!document.form1.hotels_internet_purchased[0].checked && !document.form1.hotels_internet_purchased[1].checked){
				//msg += "- When employees are travelling, is internet service purchased from hotels?\n";	
				DivObj = document.getElementById("hotels_internet_purchased_div");
				DivObj.style.color = "red";
				submitOK = false;
			}else{
				DivObj = document.getElementById("hotels_internet_purchased_div");
				DivObj.style.color = "#666666";
			}
			
			if(document.form1.hotels_internet_purchased[0].checked && document.form1.hotels_internet_days.value==""){
				//msg += "- In an average month, how many days of internet service will one employee purchase from a hotel?\n";
				DivObj = document.getElementById("hotels_internet_days_div");
				DivObj.style.color = "red";
				submitOK = false;
			}else{
				DivObj = document.getElementById("hotels_internet_days_div");
				DivObj.style.color = "#666666";
			}
			
			if(document.form1.how_many_hours_outside.value==""){
				//msg += "- How many hours does an average employee work outside the office in a week?\n";	
				DivObj = document.getElementById("how_many_hours_outside_div");
				DivObj.style.color = "red";
				submitOK = false;
			}else{
				DivObj = document.getElementById("how_many_hours_outside_div");
				DivObj.style.color = "#666666";
			}
			
			if(document.form1.how_many_payPerUseWiFi.value==""){
				DivObj = document.getElementById("how_many_payPerUseWiFi_div");
				DivObj.style.color = "red";
				submitOK = false;
			}else{
				DivObj = document.getElementById("how_many_payPerUseWiFi_div");
				DivObj.style.color = "#666666";
			}
			
			if(document.form1.how_many_payPerUseWiFi_hoursUse.value==""){
				DivObj = document.getElementById("how_many_payPerUseWiFi_hoursUse_div");
				DivObj.style.color = "red";
				submitOK = false;
			}else{
				DivObj = document.getElementById("how_many_payPerUseWiFi_hoursUse_div");
				DivObj.style.color = "#666666";
			}
		}
		
		if(quelStep == "step3"){
			if(document.form1.use_dataCollectionORdispatch.value==""){
				//msg += "- How many employees use a data collection or dispatch service online or on a corporate network?\n";	
				DivObj = document.getElementById("use_dataCollectionORdispatch_div");
				DivObj.style.color = "red";
				submitOK = false;
			}else{
				DivObj = document.getElementById("use_dataCollectionORdispatch_div");
				DivObj.style.color = "#666666";
			}
			
			if(document.form1.use_dataCollectionORdispatch.value>=1 && document.form1.use_dataCollectionORdispatch_laptop.value==""){
				//msg += "- How many employees use a data collection or dispatch... How many of these employees have laptops?\n";	
				DivObj = document.getElementById("use_dataCollectionORdispatch_laptop_div");
				DivObj.style.color = "red";
				submitOK = false;
			}else{
				DivObj = document.getElementById("use_dataCollectionORdispatch_laptop_div");
				DivObj.style.color = "#666666";
			}
			
			/*if(document.form1.provide_accessTOsales_people.value==""){
				//msg += "- How many employees require access to online sales tools?\n";	
				DivObj = document.getElementById("use_dataCollectionORdispatch_none");
				DivObj.style.color = "red";
				submitOK = false;
			}else{
				DivObj = document.getElementById("use_dataCollectionORdispatch_none");
				DivObj.style.color = "#666666";
			}
			
			if(document.form1.provide_accessTOsales_people.value>=1 && document.form1.provide_accessTOsales_people_laptop.value==""){
				//msg += "- How many employees provide access to online sales... How many of these employees have laptops?\n";	
				DivObj = document.getElementById("provide_accessTOsales_people_laptop_div");
				DivObj.style.color = "red";
				submitOK = false;
			}else{
				DivObj = document.getElementById("provide_accessTOsales_people_laptop_div");
				DivObj.style.color = "#666666";
			}*/
		}
		
		if(!submitOK){
			alert(msg);
		}else{
			if(quelStep == "step3"){
				document.form1.submit();
			}else{
				showHide(showDiv, hideDiv); 
			}
		}
		
	}
	
	function isNumeric(elemID, helperMsg){
		
		var numericExpression = /^[0-9-.]+$/;
		if(document.getElementById(elemID).value.match(numericExpression)){
			return true;
		}else if(document.getElementById(elemID).value!=""){
			alert(helperMsg);
			document.getElementById(elemID).value='';
			document.getElementById(elemID).focus();
			return false;
		}
	}
	
	function showHide(div_stepShow, div_stepHide){
		document.getElementById(div_stepShow).style.display="block";
		document.getElementById(div_stepHide).style.display="none";
	}