var empty = new Image(); empty.src = "fieldempty.gif";
var haveerrors = 0;

function showImage(imagename, imageurl, errors) {
document[imagename].src = imageurl;

if (!haveerrors && errors) haveerrors = errors;
}
function validateForm(f) {
haveerrors = 0;
(f.BName.value.length < 1)
?showImage("bnameerrors", "fieldempty.gif", true) 
:showImage("bnameerrors", "blankimage.gif", false);
(f.BName.value.length < 1) 
?document.AgencyForm.BName.style.borderColor='red'
:document.AgencyForm.BName.style.borderColor='#9ACCCD';

(f.BAddress1.value.length < 1)
?showImage("baddress1errors", "fieldempty.gif", true) 
:showImage("baddress1errors", "blankimage.gif", false);
(f.BAddress1.value.length < 1) 
?document.AgencyForm.BAddress1.style.borderColor='red'
:document.AgencyForm.BAddress1.style.borderColor='#9ACCCD';

(f.BCity.value.length < 1)
?showImage("bcityerrors", "fieldempty.gif", true) 
:showImage("bcityerrors", "blankimage.gif", false);
(f.BCity.value.length < 1) 
?document.AgencyForm.BCity.style.borderColor='red'
:document.AgencyForm.BCity.style.borderColor='#9ACCCD';

(f.BState.value.length < 1)
?showImage("bstateerrors", "fieldempty.gif", true) 
:showImage("bstateerrors", "blankimage.gif", false);
(f.BState.value.length < 1)
?document.AgencyForm.BState.style.bordercolor='red'
:document.AgencyForm.BState.style.bordercolor='#9ACCCD';

(f.BZip.value.length < 1)
?showImage("bziperrors", "fieldempty.gif", true) 
:showImage("bziperrors", "blankimage.gif", false);
(f.BZip.value.length < 1) 
?document.AgencyForm.BZip.style.borderColor='red'
:document.AgencyForm.BZip.style.borderColor='#9ACCCD';

(f.BCountry.value == "Select a Country")
?showImage("bcountryerrors", "fieldempty.gif", true) 
:showImage("bcountryerrors", "blankimage.gif", false);
(f.BCountry.value == "Select a Country")
?document.AgencyForm.BCountry.style.color='red'
:document.AgencyForm.BCountry.style.color='black';

(f.OTitle.value.length < 1)
?showImage("otitleerrors", "fieldempty.gif", true) 
:showImage("otitleerrors", "blankimage.gif", false);
(f.OTitle.value.length < 1) 
?document.AgencyForm.OTitle.style.borderColor='red'
:document.AgencyForm.OTitle.style.borderColor='#9ACCCD';

(f.OFirstName.value.length < 1)
?showImage("ofirstnameerrors", "fieldempty.gif", true) 
:showImage("ofirstnameerrors", "blankimage.gif", false);
(f.OFirstName.value.length < 1) 
?document.AgencyForm.OFirstName.style.borderColor='red'
:document.AgencyForm.OFirstName.style.borderColor='#9ACCCD';

(f.OFamName.value.length < 1)
?showImage("ofamnameerrors", "fieldempty.gif", true) 
:showImage("ofamnameerrors", "blankimage.gif", false);
(f.OFamName.value.length < 1) 
?document.AgencyForm.OFamName.style.borderColor='red'
:document.AgencyForm.OFamName.style.borderColor='#9ACCCD';

(f.BName.value.length < 1) || (f.BAddress1.value.length < 1) || (f.BCity.value.length < 1) || (f.BState.value.length < 1) || (f.BZip.value.length < 1) || (f.BCountry.value == "Select a Country") || (f.OTitle.value.length < 1) || (f.OFirstName.value.length < 1) || (f.OFamName.value.length < 1) 
?NAV.innerHTML = 'Please complete all required information before proceeding to Page 2.'
:NAV.innerHTML = '';
return(!haveerrors);
}


var empty = new Image(); empty.src = "fieldempty.gif";
var haveerrors = 0;

function showImage(imagename, imageurl, errors) {
document[imagename].src = imageurl;

if (!haveerrors && errors) haveerrors = errors;
}
function validateSecondForm(f) {
haveerrors = 0;
(f.OpInc.value.length < 1)
?showImage("opincerrors", "fieldempty.gif", true) 
:showImage("opincerrors", "blankimage.gif", false);
(f.OpInc.value.length < 1) 
?document.AgencyForm2.OpInc.style.borderColor='red'
:document.AgencyForm2.OpInc.style.borderColor='#9ACCCD';

(f.pSendAbroad.value.length < 1)
?showImage("psendabroaderrors", "fieldempty.gif", true) 
:showImage("psendabroaderrors", "blankimage.gif", false);
(f.pSendAbroad.value.length < 1) 
?document.AgencyForm2.pSendAbroad.style.borderColor='red'
:document.AgencyForm2.pSendAbroad.style.borderColor='#9ACCCD';


(f.OpSendUSA.value.length < 1)
?showImage("opsendusaerrors", "fieldempty.gif", true) 
:showImage("opsendusaerrors", "blankimage.gif", false);
(f.OpSendUSA.value.length < 1) 
?document.AgencyForm2.OpSendUSA.style.borderColor='red'
:document.AgencyForm2.OpSendUSA.style.borderColor='#9ACCCD';


(f.IsLicensed.value == "Select One")
?showImage("islicensederrors", "fieldempty.gif", true) 
:showImage("islicensederrors", "blankimage.gif", false);
(f.IsLicensed.value == "Select One") 
?document.AgencyForm2.IsLicensed.style.borderColor='red'
:document.AgencyForm2.IsLicensed.style.borderColor='#9ACCCD';

(f.pCountry1.value == "Select a Country")
?showImage("pcountry1errors", "fieldempty.gif", true) 
:showImage("pcountry1errors", "blankimage.gif", false);
(f.pCountry1.value == "Select a Country") 
?document.AgencyForm2.pCountry1.style.borderColor='red'
:document.AgencyForm2.pCountry1.style.borderColor='#9ACCCD';


(f.OpInc.value.length < 1) || (f.pSendAbroad.value.length < 1) || (f.OpSendUSA.value.length < 1) || (f.pCountry1.value == "Select a Country") || (f.IsLicensed.value == "Select One")
?NAV2.innerHTML = 'Please complete all required information before proceeding to Page 3.'
:NAV2.innerHTML = '';
return(!haveerrors);
}



var empty = new Image(); empty.src = "fieldempty.gif";
var haveerrors = 0;

function showImage(imagename, imageurl, errors) {
document[imagename].src = imageurl;

if (!haveerrors && errors) haveerrors = errors;
}
function validateThirdForm(f) {
haveerrors = 0;

(f.OpOwnBrochure.value == "Yes" && f.OpPublishBrochureinMonths.value == "Select a Month")
?showImage("oppublishbrochureinmonthserrors", "fieldempty.gif", true) 
:showImage("hearaboutgrccerrors", "blankimage.gif", false);
(f.OpOwnBrochure.value == "Yes" && f.OpPublishBrochureinMonths.value == "Select a Month") 
?document.AgencyForm3.OpPublishBrochureinMonths.style.borderColor='red'
:document.AgencyForm3.OpPublishBrochureinMonths.style.borderColor='#9ACCCD';

(f.OpOwnBrochure.value == "Yes" && f.OpBrochureCopies.value.length < 1)
?showImage("opbrochurecopieserrors", "fieldempty.gif", true) 
:showImage("opbrochurecopieserrors", "blankimage.gif", false);
(f.OpOwnBrochure.value == "Yes" && f.OpBrochureCopies.value.length < 1) 
?document.AgencyForm3.OpBrochureCopies.style.borderColor='red'
:document.AgencyForm3.OpBrochureCopies.style.borderColor='#9ACCCD';

(f.HearAboutGRCC.value.length < 1)
?showImage("hearaboutgrccerrors", "fieldempty.gif", true) 
:showImage("hearaboutgrccerrors", "blankimage.gif", false);
(f.HearAboutGRCC.value.length < 1) 
?document.AgencyForm3.HearAboutGRCC.style.borderColor='red'
:document.AgencyForm3.HearAboutGRCC.style.borderColor='#9ACCCD';

(f.NoStudentsSentAbroad.value.length < 1)
?showImage("nostudentssentabroaderrors", "fieldempty.gif", true) 
:showImage("nostudentssentabroaderrors", "blankimage.gif", false);
(f.NoStudentsSentAbroad.value.length < 1) 
?document.AgencyForm3.NoStudentsSentAbroad.style.borderColor='red'
:document.AgencyForm3.NoStudentsSentAbroad.style.borderColor='#9ACCCD';

(f.CapacitytoProvideServices.value.length < 1)
?showImage("capacitytoprovideserviceserrors", "fieldempty.gif", true) 
:showImage("capacitytoprovideserviceserrors", "blankimage.gif", false);
(f.CapacitytoProvideServices.value.length < 1) 
?document.AgencyForm3.CapacitytoProvideServices.style.borderColor='red'
:document.AgencyForm3.CapacitytoProvideServices.style.borderColor='#9ACCCD';

(f.HearAboutGRCC.value.length < 1) || (f.NoStudentsSentAbroad.value.length < 1) || (f.CapacitytoProvideServices.value.length < 1) || (f.OpOwnBrochure.value == "Yes") 
?NAV3.innerHTML = 'Please complete all required information before proceeding to the Confirmation page.'
:NAV3.innerHTML = '';
return(!haveerrors);
}



function FocusFirst() {
	if (document.forms.length > 0) {
		var field = document.forms[0];
		for (i = 0; i < field.length; i++) {
		if ((field.elements[i].type == "text") || (field.elements[i].type == "textarea") || (field.elements[i].type.toString().charAt(0) == "s")) {
		document.forms[0].elements[i].focus();
		break;
         }
      }
   }
}


var isNN = (navigator.appName.indexOf("Netscape")!=-1);
function autoTab(input,len, e) {
var keyCode = (isNN) ? e.which : e.keyCode; 
var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];
if(input.value.length >= len && !containsElement(filter,keyCode)) {
input.value = input.value.slice(0, len);
input.form[(getIndex(input)+1) % input.form.length].focus();
}
function containsElement(arr, ele) {
var found = false, index = 0;
while(!found && index < arr.length)
if(arr[index] == ele)
found = true;
else
index++;
return found;
}
function getIndex(input) {
var index = -1, i = 0, found = false;
while (i < input.form.length && index == -1)
if (input.form[i] == input)index = i;
else i++;
return index;
}
return true;
}


function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
   var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
   if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

//  End -->

    
