function validateSteps(stepNumber, lookUpMap){
	var arr = new Array();
	var aTab = document.getElementById("form"+stepNumber+"-tab");

	var turnPage = findAnswers(aTab, "", true, lookUpMap);
	if(turnPage == true){
		nextStep = stepNumber+1;
		ScrollSection('form'+nextStep+'-pane', 'scroller', 'form1-pane');
	}
}


function findAnswers(parent, processedElements, isTheFormOk, lookUpMap){
	//Find the valid question object from the DB through ASP call while page is generated
	name = parent.name;
	alreadyProcessed = processedElements;

	if((parent.nodeName == "INPUT" || parent.nodeName == "SELECT" || parent.nodeName == "TEXTAREA" || parent.nodeName == "RADIO") && 
	    name.substring(0,3) == "ans" && (alreadyProcessed == null || alreadyProcessed.indexOf(name) == -1)){

		//Mark it as processed
		alreadyProcessed += name +",";

		if(parent.type =="checkbox" || parent.type =="radio"){
			//Add this to the list
			var checkboxFlag = false;
			arr = document.getElementsByName(name);
			for(i=0; i < arr.length; i++){
				if (arr[i].checked == true){
					checkboxFlag = true;
					break;
				}
			}
			if (checkboxFlag == false){
				return sendAlertMessage(lookUpMap, name.substring(3));
			}
		}
		else{
			if (parent.value == ""){
				return sendAlertMessage(lookUpMap, name.substring(3));
			}
		}
	}


	if(parent.hasChildNodes() == true){
		var children = parent.childNodes;
		for(var i = 0; i < children.length; i++){
			isTheFormOk = findAnswers(children[i], alreadyProcessed, isTheFormOk,lookUpMap);
			if(isTheFormOk==false){
				//Let us stop after we found the first invalid one.
				break;
			}
		}
	}
	return isTheFormOk;
}


function sendAlertMessage(lookUpMap, qsOrderId){
	var temp = new Array();
	questions = lookUpMap.split('||');
	for(var i = 0; i < questions.length; i++){
		orderAndQs = questions[i].split('|');
		if(orderAndQs[0] == qsOrderId){
			alert ('Please answer the question: "'+orderAndQs[1]+'"');
			return false;
		}
	}
	return true;
}


function isNumeric(what)
 {
	if (what.search(/^[-+]?\d+(\.\d+)?$/) != -1)
		{
		return true;
		}
	else
		{
		return false;
		}
 }

function chkEmail(email)
{}

function validate()
{

	return validateAllCommonFormFields(document.frmreq.firstname,document.frmreq.lastname,document.frmreq.company,document.frmreq.street,document.frmreq.city,document.frmreq.state,document.frmreq.zip,document.frmreq.phone,document.frmreq.email,document.frmreq.employee,document.frmreq.industry,document.frmreq.url,document.frmreq.position);
}			
