
var status1 = new Array();
var status2 = new Array();
var i;
for (i=0; i<=10; i++){
status[i]=new Array();}
var step=1;
status1[0] = [10, 11, 15, 16, 19, 20];
status1[1] = [6, 8, 9, 16, 20, 21, 24];
status1[2] = [1, 2, 3, 5, 12, 14];
status1[3] = [1, 4, 7, 12, 16, 17, 22];
status1[4] = [6, 8, 18, 23, 24];
status1[5] = [9, 10, 11, 14, 19, 21, 23];
status1[6] = [1, 3, 4, 7, 10, 13, 17, 25];
status1[7] = [6, 8, 9, 18, 24];
status1[8] = [1, 2, 5, 11, 14, 21, 23];
status1[9] = [1, 4, 10, 16, 17, 19];
for (i=0; i<=10; i++){
status2[i]=new Array();}
status2[0] = [2, 4, 9, 14, 16, 18];
status2[1] = [1, 6, 9, 19, 21];
status2[2] = [4, 11, 14, 23];
status2[3] = [8, 11, 18, 20, 22, 24];
status2[4] = [4, 7, 10, 13, 14, 19];
status2[5] = [1, 5, 6, 9, 15, 16, 18, 21, 25];
status2[6] = [2, 11, 13, 15, 16, 20];
status2[7] = [3, 13, 15, 25];
status2[8] = [5, 10, 11, 22, 23];
status2[9] = [1, 12, 17, 24];
facIndex1 = new Array();
facIndex1 = [1,2,3,4,5,6,7,8,9,10];
facIndex2 = new Array();
facIndex2 = [1,2,3,4,5,6,7,8,9,10];
score11=new Array();
score21=new Array();
score1=new Array();
score2=new Array();
facdes1 = new Array();
facdes1 = ["Business Planning", "Leadership", "Profit", "Marketing", "Personal Development", "Continuous Improvement",
"Sales", "Team Morale", "Waste Reduction", "Customer Service"];
facdes2 = new Array();
facdes2 = ["Stress", "Time Management", "Life Barriers", "Belief Systems", "Locus of Control", "Life Balance", "Energy", "Health", "Personal Growth", "Family"];
var t_score1=0.0;
var len=0;
var life_f=0;
var loop =10;
var frm = document.forms["frm_gps"];
$(document).ready(function() {

	var frm = document.forms["frm_gps"];
	var e;

	$("#growth-ques select").change(function(){
		var val1;
		for(i=0;i<=9;i++)
		{
			len = status1[i].length;
			t_score1=0.0;
			for(var j=0;j<status1[i].length;j++)
			{
				e = status1[i][j];
				if($("#option_"+e).val()!=""){
					//alert($("#option_"+e).val());
					val1=parseFloat($("#option_"+e).val());
					t_score1 =t_score1+ val1;
				}
			}
			score1[i]=(t_score1/parseInt(len)).toFixed(3);
			score11[i] = score1[i];
			$("#pro_score_"+(i+1)).html(score1[i]);
			$("#p_score_"+(i+1)).val(score1[i]);
			if(score1[i]>2){
				$("#pro_score_"+(i+1)).attr("class","scores color3");
			}
			else if(score1[i]>=0 && score1[i]<=2){
				$("#pro_score_"+(i+1)).attr("class","scores color2");
			}
			else if(score1[i]>=-5 && score1[i]<0){
				$("#pro_score_"+(i+1)).attr("class","scores color1");
			}
		}
		facIndex1 = [1,2,3,4,5,6,7,8,9,10];
		var s="";

		var i, j;
		var temp, temp1; 
		for (i=0; i< 9; i++)
		{
			for(j = (i+1); j < 10; j++)
			{
				if (parseFloat(score11[i]) > parseFloat(score11[j]))
				{
					temp= score11[i];
					temp1= facIndex1[i];
					score11[i] = score11[j];
					facIndex1[i] = facIndex1[j];
					score11[j] = temp;
					facIndex1[j] = temp1;
				}
			}
		}
		s="";
		var slevel;
		for(i=0;i<=2;i++)
		{
			$("#growth_factor .scores-level"+(i+1)).remove();
			slevel ="<span class=\"scores-level"+(i+1)+"\">"+(i+1)+"</span>";
			$("#growth_factor #pro_score_"+facIndex1[i]).after(slevel);

		}
		


	});
	$(".tab-menu li a").click(function(){
			var index =$(".tab-menu li a").index(this);
			if((parseInt(index)+1) < parseInt(step)){
			$(".tool-cont").hide();
			$(".tab-menu li a").attr("class", "off");
			$("#menu-"+(parseInt(index)+1)).attr("class", "on");
			$("#step-"+(parseInt(index)+1)).show();
			step = parseInt(index)+1;
			if(step == "1")
			{
				$("#btud_cal").show();
			}
			else{
				$("#btud_cal").hide();
			}
			}

		});
	//----------------------------------------------------------------
	$("#life-ques select").change(function(){
		var val1,t_score2=0.0;
		for(i=0;i<=9;i++)
		{
			len = status2[i].length;
			t_score2=0.0;
			for(var j=0;j<len;j++)
			{
				e = status2[i][j];
				if($("#option1_"+e).val()!=""){
					//alert($("#option_"+e).val());
					val1=parseFloat($("#option1_"+e).val());
					t_score2 =t_score2+ val1;
				}
			}
			score2[i]=(t_score2/parseInt(len)).toFixed(3);
			$("#l_score_"+(i+1)).val(score2[i]);
			$("#pro_score1_"+(i+1)).html(score2[i]);
			if(score2[i]>2){
				$("#pro_score1_"+(i+1)).attr("class","scores color3");
			}
			else if(score2[i]>=0 && score2[i]<=2){
				$("#pro_score1_"+(i+1)).attr("class","scores color2");
			}
			else if(score2[i]>=-5 && score2[i]<0){
				$("#pro_score1_"+(i+1)).attr("class","scores color1");
			}
		}
		score21=new Array();
		score21 = score2;
		facIndex2 = [1,2,3,4,5,6,7,8,9,10];
		var i, j;
		var temp, temp1; 
		for (i=0; i< 9; i++)
		{
			for(j = (i+1); j < 10; j++)
			{
				if (parseFloat(score21[i]) > parseFloat(score21[j]))
				{
					temp= score21[i];
					temp1= facIndex2[i];
					score21[i] = score21[j];
					facIndex2[i] = facIndex2[j];
					score21[j] = temp;
					facIndex2[j] = temp1;
				}
			}
		}
		var slevel;
		for(i=0;i<=2;i++)
		{
			$("#life_factor .scores-level"+(i+1)).remove();
			slevel ="<span class=\"scores-level"+(i+1)+"\">"+(i+1)+"</span>";
			$("#life_factor #pro_score1_"+facIndex2[i]).after(slevel);
		}

	});
	//----------------------------------------------------------
	$("#growth_factor a").click(function(){
		$("#growth_factor a").removeClass("on");
		$(this).addClass("on");
		var index = $("#growth_factor a").index(this);
		$("#growth-ques tr").removeClass("activer");
		for(var l=0;l<status1[index].length;l++)
		{
			$("#growth-ques tr").eq((status1[index][l])-1).addClass("activer");
		}
	});

	//-------------------------------------------


	$("#life_factor a").click(function(){
		$("#life_factor a").removeClass("on");
		$(this).addClass("on");
		var index = $("#life_factor a").index(this);
		$("#life-ques tr").removeClass("activer");
		for(var i=0;i<status2[index].length;i++)
		{
			$("#life-ques tr").eq((status2[index][i])-1).addClass("activer");
		}
	});

});
function validate_input(elem)
{
	
	aField = document.getElementById(elem); 
	e_val = aField.value;
	if(e_val > 10 || e_val < 0)
	{
		alert("Please enter a value between 1 and 10");
		setTimeout("aField.focus();", 50);
		return false; 
	}
}

function cal_total()
{
	var total = 0; var val = 0;

	for(i=1;i<=10;i++)
	{
		elem = document.getElementById("benefit_"+i);
		total += parseFloat(elem.value);
	}
	if(!isNaN(total)){$("#total").html(total);
	$("#ftotal").val(total);}
	
}
var g_val=0, p_val,e_val;
function cal_subtotal(e_index)
{
	var stotal = 0; var val = 0, temp;
		sc=new Array();
	sc1=new Array();
	growth_val = 0;p_val =0; e_val = 0;
	growth_val = parseFloat($("#growth_"+e_index).val())=="0" ? 0 : parseFloat($("#growth_"+e_index).val());
	p_val = parseFloat($("#profit_"+e_index).val())=="0" ? 0 : parseFloat($("#profit_"+e_index).val());
	e_val = parseFloat($("#ease_"+e_index).val())=="0" ? 0 : parseFloat($("#ease_"+e_index).val());

	stotal = parseFloat(growth_val) + parseFloat(p_val) + parseFloat(e_val);
	if(!isNaN(stotal)){$("#score_"+e_index).html(stotal);
	$("#score"+e_index).val(stotal);}
	for (var j=0;j<10 ;j++ )
	{
		 sc[j] = parseFloat($("#score"+(j+1)).val()); 
		sc1[j] = parseFloat(sc[j]);
	}
	for (i=0; i< 9; i++)
	{
		for(j = (i+1); j < 10; j++)
		{
			if (parseFloat(sc1[i]) < parseFloat(sc1[j]))
			{
				temp= sc1[i];
				sc1[i] = sc1[j];
				sc1[j] = temp;
			}
		}
	}

	var f=0;
	for(i=1;i<=10;i++)
	{
		f=0;
		for (var j=0;j<3;j++ ){
			
		if(parseFloat(sc1[j]) == parseFloat(sc[i-1])){
			f = 1;}
		}
		if(f == 1){
			$("#score_"+i).attr("class", "txtbox1 txtboxclr");}
		else
		{$("#score_"+i).attr("class", "txtbox1");}

		
	}
}
function back(){
	$("#step-"+step).hide();
	$("#menu-"+step).attr("class", "off");
	step=parseInt(step)-1;
	$("#step-"+step).show();
	$("#menu-"+step).attr("class", "on");
	$("#top").focus();
	if(step == "1")
	{
			$("#btud_cal").show();
	}
	else{
			$("#btud_cal").hide();
	}
}

function validate_client_info(form)
{	
	if(step ==1)
	{
		if(isEmpty(form.company_name) || (form.company_name.value == "Enter company name here"))
		{ 
			alert("Please enter company name");form.company_name.focus();return false; 
		}
		if(isEmpty(form.email) || (form.email.value == "Enter your email address here"))
		{ 
			alert("Please enter your email address");form.email.focus();return false; 
		}
		else{
			if(!isEmailAddress(form.email))
			{
				alert("Please enter a valid email address");form.email.focus();return false;
			}		
		}
		if(isEmpty(form.industry) || (form.industry.value == ""))
		{ 
			alert("Please select an industry");form.industry.focus();return false; 
		}
		if(isEmpty(form.country) || (form.country.value == ""))
		{ 
			alert("Please select country");form.country.focus();return false; 
		}
		if((form.currency.value == ""))
		{ 
			alert("Please select currency symbol");form.currency.focus();return false; 
		}

		//----------------------------------------

		for(i=1;i<=25;i++)
		{
			if($("#growth-ques #option_"+i).val()=="")
			{
				alert("Please select an option for question "+i);$("#growth-ques #option_"+i).focus();return false; 
			}
		}
		$("#step-1").hide();
		$("#step-2").show();
		$("#btud_cal").hide();
		$("#money").html($("#currency").val());
		$("#money1").html($("#currency").val());
		$("#menu-"+step).attr("class", "off");
		step=parseInt(step)+1;;
		$("#menu-"+step).attr("class", "on");
		$("#top").focus();
		var slevel;
		$("span.fac-des").remove();
		
		$("#life_factor").scrollFollow(
			{
				container: 'lfactor'
			}
		);
		return false;
	}
	if(step ==2)
	{
		/*for(i=1;i<=25;i++)
		{
			if($("#option1_"+i).val()=="")
			{
				alert("Please select an option for question "+i);$("#option1_"+i).focus();return false; 
			}
		}*/
		life_f =0;
		for(i=1;i<=25;i++)
		{
			if($("#option1_"+i).val()!="")
			{
				life_f=1;
			}
		}

		var bus_tbl = "<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"100%\" class=\"questbl\">";
		bus_tbl += "<tr><th style=\"text-align:left;\" width=\"24%\">Issue</th><th width=\"8%\">Growth</th><th width=\"8%\">Profit</th><th width=\"8%\">Ease</th><th width=\"10%\"><span id=\"money1\"></span>&nbsp;Benefit</th><th width=\"8%\">Score</th><th style=\"text-align:left;\"  width=\"34%\">Non Financial Benefits to fixing this issue</th></tr>";
		j=1;
		
		if(life_f == 0)
		{
			loop =7;
		}
		else
		{
			loop=10;
		}
		for(i = 1; i <= loop; i++){
			bus_tbl += "<tr>\n";
			if(i>6){
				bus_tbl += "\t<td><input type=\"text\" name=\"issue_"+i+"\" id=\"issue_"+i+"\" class=\"txtbox2\" value=\"Enter in your issue here "+j+"\"  onfocus=\"if(this.value=='Enter in your issue here $j') {this.value='';}\" onblur=\"if(this.value=='') {this.value='Enter in your issue here $j'}\" /></td>\n";
				j=j+1;
			}
			else if(i<=3){
				bus_tbl += "\t<td><input type=\"hidden\" name=\"issue_"+i+"\" id=\"issue_"+i+"\"  /></td>\n";
				
			}
			else if(i<=6 && i>3 && life_f ==1){
				bus_tbl += "\t<td><input type=\"hidden\" name=\"issue_"+i+"\" id=\"issue_"+i+"\"  /></td>\n";
				
			}
			else if(i<=6 && i>3 && life_f ==0){
				bus_tbl += "\t<td><input type=\"text\" name=\"issue_"+i+"\" id=\"issue_"+i+"\" class=\"txtbox2\" value=\"Enter in your issue here "+j+"\"  onfocus=\"if(this.value=='Enter in your issue here "+j+"') {this.value='';}\" onblur=\"if(this.value=='') {this.value='Enter in your issue here "+j+"'}\" /></td>\n";
				j=j+1;
				
			}
			bus_tbl += "\t<td><input type=\"text\" name=\"growth_"+i+"\" id=\"growth_"+i+"\" value=\"0\" class=\"txtbox1\"  maxlength=\"5\" onkeyup='cal_subtotal("+i+");' onkeypress='cal_subtotal("+i+");return blockNonNumbers(this, event, true, true);' onfocus=\"if(this.value=='0') {this.value='';}\"  onblur=\"if(this.value==''){this.value=0;};validate_input('growth_"+i+"');cal_subtotal("+i+");\" /></td>\n";
			bus_tbl += "\t<td><input type=\"text\" name=\"profit_"+i+"\" id=\"profit_"+i+"\" value=\"0\" class=\"txtbox1\" maxlength=\"5\" onkeyup='cal_subtotal("+i+");' onkeypress='return blockNonNumbers(this, event, true, true);' onfocus=\"if(this.value=='0') {this.value='';}\"  onblur=\"if(this.value==''){this.value=0;};validate_input('profit_"+i+"');cal_subtotal("+i+");\" /></td>\n";
			bus_tbl += "\t<td><input type=\"text\" name=\"ease_"+i+"\" id=\"ease_"+i+"\" value=\"0\" class=\"txtbox1\" maxlength=\"5\" onkeyup='cal_subtotal("+i+");' onkeypress='cal_subtotal("+i+");return blockNonNumbers(this, event, true, true);' onfocus=\"if(this.value=='0') {this.value='';}\"  onblur=\"if(this.value==''){this.value=0;};validate_input('ease_"+i+"');cal_subtotal("+i+");\" /></td>\n";
			bus_tbl += "\t<td><input type=\"text\" name=\"benefit_"+i+"\" id=\"benefit_"+i+"\" value=\"0\" class=\"txtbox3\" maxlength=\"15\" onkeyup='cal_total()' onkeypress='cal_total();return blockNonNumbers(this, event, true, true);' onfocus=\"if(this.value=='0') {this.value='';}\"  onblur=\"if(this.value==''){this.value=0;};cal_total();\" /></td>\n";
			bus_tbl += "\t<td><span id=\"score_"+i+"\" class=\"txtbox1 txtboxclr\" >0</span><input type=\"hidden\" name=\"score"+i+"\" id=\"score"+i+"\" value=\"0\"  /></td>\n";
			bus_tbl += "\t<td><input type=\"text\" name=\"benefit_issue_"+i+"\" id=\"benefit_issue_"+i+"\" class=\"txtbox\" value=\"Enter in the benefit here "+i+"\" onfocus=\"if(this.value=='Enter in the benefit here "+i+"') {this.value='';}\" onblur=\"if(this.value=='') {this.value='Enter in the benefit here "+i+"'}\" /></td>\n";
			bus_tbl += "</tr>\n";
		}
		bus_tbl += "<tr>\n";
		bus_tbl += "\t<td colspan=\"3\" style=\"background-color:#fff;\">&nbsp;</td>\n";
		bus_tbl += "\t<td style=\"text-align:center;\"><b>Total</b> <span id=\"money\"></span></td>\n";
		bus_tbl += "\t<td><span id=\"total\" class=\"txtbox3\">0</span><input type=\"hidden\" name=\"ftotal\" id=\"ftotal\"  /></td>\n";
		bus_tbl += "\t<td colspan=\"2\" style=\"background-color:#fff;\">&nbsp;</td>\n</tr>";
		bus_tbl += "</table>";

	//	$("#bus").html(bus_tbl);
		$("span.fac-des1").remove();
		$("span.fac-des").remove();
		var ben="";
		for(i=0;i<=2;i++)
		{
			var index = facIndex1[i];
			slevel ="<span class=\"fac-des\">"+facdes1[index-1]+"</span>";
			$("#issue_"+(i+1)).before(slevel);
			$("#issue_"+(i+1)).val(facdes1[index-1]);
		}
		if(life_f == 1){
			$("#skip").val(1);
			for(i=0;i<=2;i++)
			{
				$("#row_"+(i+4)).show();
				var index = facIndex2[i];
				slevel ="<span class=\"fac-des1\">"+facdes2[index-1]+"</span>";
				$("#issue_"+(i+4)).before(slevel);
				$("#issue_"+(i+4)).val(facdes2[index-1]);
			}
			for(i=7;i<=10;i++)
			{
				if($("#benefit_issue_"+i).val()==("Enter in the benefit here "+(i-3)))
				{
					$("#benefit_issue_"+i).val("Enter in the benefit here "+i);
					ben = "<input type=\"text\" name=\"benefit_issue_"+i+"\" id=\"benefit_issue_"+i+"\" class=\"txtbox\" value=\"Enter in the benefit here "+(i)+"\" onfocus=\"if(this.value=='Enter in the benefit here "+(i)+"') {this.value='';}\" onblur=\"if(this.value=='') {this.value='Enter in the benefit here "+(i)+"'}\" /></td>";
					$("#bi_"+i).html(ben);
				}
			}
			
		}
		if(life_f == 0){
			$("#skip").val(0);
			for(i=0;i<=2;i++)
			{
				$("#row_"+(i+4)).hide();
				$("#issue_"+(i+4)).val("");
				$("#growth_"+(i+4)).val("0");
				$("#profit_"+(i+4)).val("0");
				$("#ease_"+(i+4)).val("0");
				$("#benefit_"+(i+4)).val("0");
				$("#score_"+(i+4)).val("0");
				$("#score"+(i+4)).val("0");
				$("#benefit_issue_"+(i+4)).val("Enter in the benefit here "+(i+4));
			}
			for(i=7;i<=10;i++)
			{
				if($("#benefit_issue_"+i).val()==("Enter in the benefit here "+i))
				{
					$("#benefit_issue_"+i).val("Enter in the benefit here "+(i-3));
					ben = "<input type=\"text\" name=\"benefit_issue_"+i+"\" id=\"benefit_issue_"+i+"\" class=\"txtbox\" value=\"Enter in the benefit here "+(i-3)+"\" onfocus=\"if(this.value=='Enter in the benefit here "+(i-3)+"') {this.value='';}\" onblur=\"if(this.value=='') {this.value='Enter in the benefit here "+(i-3)+"'}\" /></td>";
					$("#bi_"+i).html(ben);
				}
			}
		}

		$("#step-2").hide();
		$("#step-3").show();
		cal_total();
		cal_subtotal(1);
		$("#menu-"+step).attr("class", "off");
		step=parseInt(step)+1;;
		$("#menu-"+step).attr("class", "on");
		$("#top").focus();
		return false;
	}
	if(step ==3)
	{
		j=1;

		for(i=1;i<=3;i++)
		{
			if($("#growth_"+i).val()=="0" || $("#growth_"+i).val()=="")
			{
				alert("Please enter an growth value for "+($("#issue_"+i).val()));$("#growth_"+i).focus();return false; 
			}
			if(parseInt($("#growth_"+i).val()) > 10 || parseInt($("#growth_"+i).val()) < 0)
			{
				alert("Please enter a value between 1 and 10");$("#growth_"+i).focus();return false; 
			}
			if($("#profit_"+i).val()=="0" || $("#profit_"+i).val()=="")
			{
				alert("Please enter an profit value for "+($("#issue_"+i).val()));$("#profit_"+i).focus();return false; 
			}
			if(parseInt($("#profit_"+i).val()) > 10 || parseInt($("#profit_"+i).val()) < 0)
			{
				alert("Please enter a value between 1 and 10");$("#profit_"+i).focus();return false; 
			}
			if($("#ease_"+i).val()=="0" || $("#ease_"+i).val()=="0")
			{
				alert("Please enter an ease value for "+($("#issue_"+i).val()));$("#ease_"+i).focus();return false; 
			}
			if(parseInt($("#ease_"+i).val()) > 10 || parseInt($("#ease_"+i).val()) < 0)
			{
				alert("Please enter a value between 1 and 10");$("#ease_"+i).focus();return false; 
			}
			if($("#benefit_"+i).val()=="0" || $("#benefit_"+i).val()=="")
			{
				alert("Please enter a benefit value for "+($("#issue_"+i).val()));
				$("#benefit_"+i).focus();return false; 
			}
			if($("#benefit_issue_"+i).val()==("Enter in the benefit here "+i) || $("#benefit_issue_"+i).val()== "")
			{
				alert("Please enter non financial benefit "+i);$("#benefit_issue_"+i).focus();return false; 
			}
		}

		if(life_f ==1)
		{
			for(i=4;i<=6;i++)
			{
				if(($("#growth_"+i).val()!="0" && $("#growth_"+i).val()!="") || ($("#profit_"+i).val()!="0" && $("#profit_"+i).val()!="") || ($("#ease_"+i).val()!="0" && $("#ease_"+i).val()!="0") || ($("#benefit_"+i).val()!="0" && $("#benefit_"+i).val()!="") || ($("#benefit_issue_"+i).val()!=("Enter in the benefit here "+i) && $("#benefit_issue_"+i).val()!= "")){
					if($("#growth_"+i).val()=="0" || $("#growth_"+i).val()=="")
					{
						alert("Please enter an growth value for "+($("#issue_"+i).val()));$("#growth_"+i).focus();return false; 
					}
					if(parseInt($("#growth_"+i).val()) > 10 || parseInt($("#growth_"+i).val()) < 0)
					{
						alert("Please enter a value between 1 and 10");$("#growth_"+i).focus();return false; 
					}
					if($("#profit_"+i).val()=="0" || $("#profit_"+i).val()=="")
					{
						alert("Please enter an profit value for "+($("#issue_"+i).val()));$("#profit_"+i).focus();return false; 
					}
					if(parseInt($("#profit_"+i).val()) > 10 || parseInt($("#profit_"+i).val()) < 0)
					{
						alert("Please enter a value between 1 and 10");$("#profit_"+i).focus();return false; 
					}
					if($("#ease_"+i).val()=="0" || $("#ease_"+i).val()=="0")
					{
						alert("Please enter an ease value for "+($("#issue_"+i).val()));$("#ease_"+i).focus();return false; 
					}
					if(parseInt($("#ease_"+i).val()) > 10 || parseInt($("#ease_"+i).val()) < 0)
					{
						alert("Please enter a value between 1 and 10");$("#ease_"+i).focus();return false; 
					}
					if($("#benefit_"+i).val()=="0" || $("#benefit_"+i).val()=="")
					{
						alert("Please enter a benefit value for "+($("#issue_"+i).val()));
						$("#benefit_"+i).focus();return false; 
					}
					if($("#benefit_issue_"+i).val()==("Enter in the benefit here "+i) || $("#benefit_issue_"+i).val()== "")
					{
						alert("Please enter non financial benefit "+i);$("#benefit_issue_"+i).focus();return false; 
					}
				}
			}
		}
	
		var jval;
		for(i=7;i<=10;i++)
		{
			if(life_f == 0)
			{
				jval=i-3;
			}
			else if(life_f == 1)
			{
				jval=i;
			}
			if($("#issue_"+i).val()!=("Enter in your issue here "+(i-6)) || ($("#growth_"+i).val()!="0" && $("#growth_"+i).val()!="") || ($("#profit_"+i).val()!="0" && $("#profit_"+i).val()!="") || ($("#ease_"+i).val()!="0" && $("#ease_"+i).val()!="0") || ($("#benefit_"+i).val()!="0" && $("#benefit_"+i).val()!="") || ($("#benefit_issue_"+i).val()!=("Enter in the benefit here "+jval) && $("#benefit_issue_"+i).val()!= "")){
				if($("#issue_"+i).val()==("Enter in your issue here "+(i-6)))
				{
					alert("Please enter your issue  "+(i-6));$("#issue_"+i).focus();return false; 
				}
				if($("#growth_"+i).val()=="0" || $("#growth_"+i).val()=="")
				{
					alert("Please enter an growth value for "+($("#issue_"+i).val()));$("#growth_"+i).focus();return false; 
				}
				if(parseInt($("#growth_"+i).val()) > 10 || parseInt($("#growth_"+i).val()) < 0)
				{
					alert("Please enter a value between 1 and 10");$("#growth_"+i).focus();return false; 
				}
				if($("#profit_"+i).val()=="0" || $("#profit_"+i).val()=="")
				{
					alert("Please enter an profit value for "+($("#issue_"+i).val()));$("#profit_"+i).focus();return false; 
				}
				if(parseInt($("#profit_"+i).val()) > 10 || parseInt($("#profit_"+i).val()) < 0)
				{
					alert("Please enter a value between 1 and 10");$("#profit_"+i).focus();return false; 
				}
				if($("#ease_"+i).val()=="0" || $("#ease_"+i).val()=="0")
				{
					alert("Please enter an ease value for "+($("#issue_"+i).val()));$("#ease_"+i).focus();return false; 
				}
				if(parseInt($("#ease_"+i).val()) > 10 || parseInt($("#ease_"+i).val()) < 0)
				{
					alert("Please enter a value between 1 and 10");$("#ease_"+i).focus();return false; 
				}
				if($("#benefit_"+i).val()=="0" || $("#benefit_"+i).val()=="")
				{
					alert("Please enter a benefit value for "+($("#issue_"+i).val()));
					$("#benefit_"+i).focus();return false; 
				}
				if($("#benefit_issue_"+i).val()==("Enter in the benefit here "+jval) || $("#benefit_issue_"+i).val()== "")
				{
					alert("Please enter non financial benefit "+jval);$("#benefit_issue_"+i).focus();return false; 
				}
			}
		}
		
	}
	captchaValidation(form);
	return false;

}
function email_validation(form)
{
	if((isEmpty(form.email_1) || (form.email_1.value == "Enter email one here")) && (isEmpty(form.email_1) || (form.email_1.value == "Enter email one here")) && (isEmpty(form.email_1) || (form.email_1.value == "Enter email one here")) && (isEmpty(form.email_1) || (form.email_1.value == "Enter email one here")))
	{
		alert("Please enter atleast one email address");form.email_1.focus();return false;
	}
	if(!isEmpty(form.email_1) && (form.email_1.value != "Enter email one here"))
	{ 
		if(!isEmailAddress(form.email_1))
		{
			alert("Please enter a valid email address 1");form.email_1.focus();return false;
		}	
	}
	if(!isEmpty(form.email_2) && (form.email_2.value != "Enter email two here"))
	{ 
		if(!isEmailAddress(form.email_2))
		{
			alert("Please enter a valid email address 2");form.email_2.focus();return false;
		}	
	}
	if(!isEmpty(form.email_3) && (form.email_3.value != "Enter email three here"))
	{ 
		if(!isEmailAddress(form.email_3))
		{
			alert("Please enter a valid email address 3");form.email_3.focus();return false;
		}	
	}
	if(!isEmpty(form.email_4) && (form.email_4.value != "Enter email four here"))
	{ 
		if(!isEmailAddress(form.email_4))
		{
			alert("Please enter a valid email address 4");form.email_4.focus();return false;
		}	
	}
	captchaValidation(form);
	return false;
}
function showsummary()
{
	$("#step-1").show();
	$("#step-2").show();
}
function hidesummary()
{
	$("#step-1").hide();
	$("#step-2").hide();
}
function blockNonNumbers(obj, e, allowDecimal, allowNegative)
{
	var key;
	var isCtrl = false;
	var keychar;
	var reg;
	allowNegative=false;
	if(window.event) {key = e.keyCode;isCtrl = window.event.ctrlKey}
	else if(e.which) {key = e.which;isCtrl = e.ctrlKey;}
	if (isNaN(key)) return true;
	keychar = String.fromCharCode(key);
	// check for backspace or delete, or if Ctrl was pressed
	if (key == 8 || key == 13 || isCtrl){return true;}
	reg = /\d/;
	var isFirstN = allowNegative ? keychar == '-' : false;
	var isFirstD = allowDecimal ? keychar == '.' && obj.value.indexOf('.') == -1 : false;
	return isFirstN || isFirstD || reg.test(keychar);
	return isFirstN || reg.test(keychar);
}

//------------------------------------------------------


function processCaptchaResult(responseTxt)
{	
	if(responseTxt == "true")
	{	
		document.getElementById("error").display="none";
		document.frm_gps.submit();
		
	}else
	{
		document.getElementById("error").style.display="block";
		document.getElementById("captcha").value="";
		document.getElementById("captcha").focus();
		//document.getElementById("captcha_img").src="captcha.php";
		document.getElementById("captIMG").innerHTML=responseTxt;
		return false;
	}

}

//------------------------------------------------------

function captchaValidation(frm)
{

	if(isEmpty(frm.captcha))
	{
		alert('Please enter the security code');
		frm.captcha.focus();
		return false;
	}

	process		=	'validateCaptcha';
	output		=	'text';
	url		=	getURL()+ "/inc/validate_captcha.php";
	
	responseHandler	=	"processCaptchaResult";

	captchaCode	=	encodeURI(frm.captcha.value);

	qs			=	"code="+captchaCode;
	
	ajaxPostRequest(url,qs);
}

//------------------------------------------------------
function getURL()
{
	url		=	document.location.href;
	x		=	url.indexOf(".");
	x		=	url.indexOf("/",x);
	return url.substring(0,x);
}
