var send = 0, multirg = 0;
function confirmReset()
{
	var resetform = confirm("Are you sure you want to cancel your map submission?");
	if (resetform == true){
		return true;
		}
	return false;
}

function confirmSubmit(frmSurveyMap)
{
	var size , LS = "", nbr = document.frmSurveyMap.LSnbr.value, i;
	var strError = ""
	document.frmSurveyMap.command.value="Update"
	
	if (document.frmSurveyMap.SurveyName.value == '')
	{
		strError +="Last Name of Surveyor is required."; 
		LS = 1;
	}	
	if  (document.frmSurveyMap.LSnbr.value == '' )
	{
		strError +="Surveyor license number is required. \n"; 
		LS = 1;
	}	
	if  (isNaN(nbr))
	{
		strError +="Surveyor license number is incorrect. \n"; 
		LS = 1;
	}	
	if (document.frmSurveyMap.ClientName.value == '')
	{
		strError +="Client last name is required. \n"; 
		LS = 1;
	}	
	if (document.frmSurveyMap.Submitter.value == '')
	{
		strError +="Name of Contact Person is required. \n"; 
		LS = 1;
	}	
	if (document.frmSurveyMap.Phone.value == '')
	{
		strError +="Contact phone number is required. \n"; 
		LS = 1;
	}
	nbr = document.frmSurveyMap.Phone.value;
	i = (nbr.length);
	if (i < 8){
		strError +="A valid phone number is required. \n"; 
		LS = 1;
	}
	i = i - 1;
	nbr = (nbr.substring(i));
	
	if  (isNaN(nbr))
	{
		strError +="A valid phone number is required. \n"; 
		LS = 1;
	}	
	if (document.frmSurveyMap.Email.value == '')
	{
		strError +="A valid e-mail address is required. \n"; 
		LS = 1;
	}
	if (echeck(document.frmSurveyMap.Email.value)==false)
	{
		strError +="The e-mail entered is invalid. \n"; 
		LS = 1;
	}
	if (document.frmSurveyMap.MapSize.value == '')
	{
		strError +="Size of Map is required. \n"; 
		LS = 1;
	}
	if (document.frmSurveyMap.MapDate.value == '')
	{
		strError +="Date of Map Survey is required. \n"; 
		LS = 1;
	}
	nbr = document.frmSurveyMap.MapDate.value;
	i = (nbr.length);
	i = i - 1;
	nbr = (nbr.substring(i));
	if  (isNaN(nbr))
	{
		strError +="Please enter a date in Month Year format. \n"; 
		LS = 1;
	}	
	
	nbr = document.frmSurveyMap.values.value;
	if  (document.frmSurveyMap.values.value == '' || isNaN(nbr))
	{
		strError +="Enter the number of value sets that pertain to this map. \n"; 
		LS = 1;
	}	
	nbr = document.frmSurveyMap.pages.value;
	if  (document.frmSurveyMap.pages.value == '' || isNaN(nbr))
	{
		strError +="Enter the number of pages or files that apply to this map. \n"; 
		LS = 1;
	}	
	if (document.frmSurveyMap.MapType.value == '')
	{
		strError +="Type of Map is required. \n"; 
		LS = 1;
	}
		if (document.frmSurveyMap.txtVerify.value == '')
	{
		strError +="Please enter the letters that appear in the image. \n"; 
		LS = 1;
	}
	if (LS == ""){
		document.frmSurveyMap.command.value = 'valid';
		window.send.value = '1';
		document.frmSurveyMap.action = 'MapSubmit.asp';
		document.frmSurveyMap.submit();
	}
	else{
		alert(strError);
		document.frmSurveyMap.SurveyName.focus();
	}
}
function custom()
{
  var test = frmSurveyMap.MapSize.options[frmSurveyMap.MapSize.selectedIndex].value;

	if (test == "Custom")
	{
		window.document.getElementById('showh').style.visibility = 'visible';
		window.document.getElementById('showf').style.visibility = 'visible';
		document.frmSurveyMap.CustSize.focus();
	}
	else
	{
		document.getElementById("showh").style.visibility = 'hidden';
		document.getElementById("showf").style.visibility = 'hidden';
	}
}
function advance(start,next)
{
   if(start.getAttribute&&start.value.length==start.getAttribute("maxlength")){
   next.focus();
   }
     
}
function imgchk(){
var ltrs = document.frmSurveyMap.txtVerify.value;
switch (ltrs){

	case "DC":
		break;
	case "dc":
		break;
	default:
		alert("Please re-enter the letters in the image.");
		document.frmSurveyMap.txtVerify.focus();
	}
}

/**
 * DHTML email validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
 */

function echeck(str) {

	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
	if (str.indexOf(at)==-1){
	   alert("Invalid E-mail ID")
	   return false
	}

	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
	   alert("Invalid E-mail ID")
	   return false
	}

	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		alert("Invalid E-mail ID")
		return false
	}

	 if (str.indexOf(at,(lat+1))!=-1){
		alert("Invalid E-mail ID")
		return false
	 }

	 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		alert("Invalid E-mail ID")
		return false
	 }

	 if (str.indexOf(dot,(lat+2))==-1){
		alert("Invalid E-mail ID")
		return false
	 }
	
	 if (str.indexOf(" ")!=-1){
		alert("Invalid E-mail ID")
		return false
	 }

	 return true					
}

