// JavaScript Document

var maxchars = 4000;
function validateForm()
{
	CheckFormInput();	
	var chx_Accept_td = document.getElementById('chx_Accept_td');
	var txt_email2 = document.getElementById("email2");
	txt_email2.style.background = "";
	chx_Accept_td.style.background = "";
	//validate textboxes and areas
	errors += required($("#slt_companyCat"));

	errors += required($("#slt_assistance"));
	errors += required($("input[name='rg_esriuser']"),"radiogroup",$("#divrg_esriuser"));
		if( $("input[name='slt_industry_required']").length )
		{
		if ( $("#slt_industry option:selected").length == 0 )
		{
		$("#slt_industry").css("background-color","#E48028");
		$("#slt_industry").css("color","#FFFFFF");
		errors = errors + 'Error.';
		}
		else
		{
			if ($('#slt_industry').val() != '')
			 {
				$("#slt_industry").css("background-color","");
				$("#slt_industry").css("color","#000000");
				errors = errors + '';
			}
			else 
				{
				$("#slt_industry").css("background-color","#E48028");
				$("#slt_industry").css("color","#FFFFFF");
				errors = errors + 'Error.';
				}
		}
		}
	var txta_g = document.getElementById('txta_grantsrch'); 
	if(txta_g.value.length > maxchars)
	{
		alert("Please describe the projects in less than 4000 charecters. Additional charcters will be deleted");
		txta_g.value = txta_g.value.substr(0,maxchars);
		return false;
	}
	if(document.getElementById('chx_Accept').checked != true)
	{
		errors = errors + "Error";
		chx_Accept_td.style.background = "#E48028";
	}
	if ( errors ){
		alert("Please fill out all the required fields. \n\n The required fields will be highlighted for you.");
		window.location='#top';
		return false;
	}
	else{
		$("#register").attr("disabled","true")
		return true;
	}


}

function checkcount(txtaid) {
	var txta = document.getElementById(txtaid);	
	if((txta.value.length) > maxchars)
	{
	alert("Please describe the projects in less than 4000 charecters. Additional charcters will be deleted");
	txta.value = txta.value.substr(0,maxchars);
	}
}

function updateDisplayForm (selectedassistance)
{

	if (selectedassistance =="Request grant search (customized funding solution)")
	{
				var getonedisplay = document.getElementById('div_grantsrch');
				getonedisplay.style.display = "";
				var gettwodisplay = document.getElementById('div_onemore');
				gettwodisplay.style.display = "none";
				var getthreedisplay = document.getElementById('div_prepare');
				getthreedisplay.style.display = "none";
				var getthreedisplay = document.getElementById('div_other');
				getthreedisplay.style.display = "none";				
	}
	else
	{
			if (selectedassistance == "Request information on one or more specific grants from the Recurring Grants list")

			{
				var getonedisplay = document.getElementById('div_grantsrch');
				getonedisplay.style.display = "none";
				var getthreedisplay = document.getElementById('div_prepare');
				getthreedisplay.style.display = "none";
				var gettwodisplay = document.getElementById('div_onemore');
				gettwodisplay.style.display = "";
				var getthreedisplay = document.getElementById('div_other');
				getthreedisplay.style.display = "none";


			}

			else
			{
				if (selectedassistance =="Request assistance in preparing a grant application")

				{var getonedisplay = document.getElementById('div_grantsrch');
				getonedisplay.style.display = "none";
				var gettwodisplay = document.getElementById('div_onemore');
				gettwodisplay.style.display = "none";
				var getthreedisplay = document.getElementById('div_prepare');
				getthreedisplay.style.display = "";
				var getthreedisplay = document.getElementById('div_other');
				getthreedisplay.style.display = "none";
				}
			else
			{
				if (selectedassistance =="Other")

				{var getonedisplay = document.getElementById('div_grantsrch');
				getonedisplay.style.display = "none";
				var gettwodisplay = document.getElementById('div_onemore');
				gettwodisplay.style.display = "none";
				var getthreedisplay = document.getElementById('div_prepare');
				getthreedisplay.style.display = "none";
				var getonedisplay = document.getElementById('div_other');
				getonedisplay.style.display = "";				

				}

				else
				{
				var getonedisplay = document.getElementById('div_grantsrch');
				getonedisplay.style.display = "none";
				var gettwodisplay = document.getElementById('div_onemore');
				gettwodisplay.style.display = "none";
				var getthreedisplay = document.getElementById('div_prepare');
				getthreedisplay.style.display = "none";
				var getthreedisplay = document.getElementById('div_other');
				getthreedisplay.style.display = "none";


				}
			  }
			}
	}
}
