// function to set focus when page loads
function setFirst(){
    document.forms[0].elements[0].focus();
}


// function to check for empty text box
function isEmpty(strVal){
    if(strVal == ''){
        return true;
    }
    else{
        return false;
    }
}

// function to validate email address
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					
}


// function to check form input

function checkForm(){

    var fmForm = document.forms['adoptform'];

  
    if(isEmpty(fmForm.t001.value)){
        
        fmForm.t001.focus();
        fmForm.t001.select();   
        alert('Please enter your name');
        return false;        
    }
    
    if(isEmpty(fmForm.t002.value)){
        fmForm.t001.focus();
        fmForm.t002.focus();
        fmForm.t002.select();   
        alert('Please enter your address');
        return false;        
    }
    
    if(isEmpty(fmForm.t003.value)){
        fmForm.t002.focus();
        fmForm.t003.focus();
        fmForm.t003.select();
        alert('Please enter your city');
        return false;
    }
    
    if(isEmpty(fmForm.t004.value)){
        fmForm.t003.focus();
        fmForm.t004.focus();
        fmForm.t004.select();
        alert('Please enter your zipcode');
        return false;
    }    
    
    
    
    if(isEmpty(fmForm.t005.value)){
        fmForm.t004.focus();
        fmForm.t005.focus();
        fmForm.t005.select();   
        alert('Please enter your phone number');
        return false;        
    }    
    
    if(isEmpty(fmForm.t006.value)){
        fmForm.t005.focus();
        fmForm.t006.focus();
        fmForm.t006.select();   
        alert('Please enter a time');
        return false;        
    }     
    
    if(isEmpty(fmForm.t007.value)){
        fmForm.t006.focus();
        fmForm.t007.focus();
        fmForm.t007.select();   
        alert('Please enter your email address');
        return false;        
    }      
    
    
    if(!(echeck(fmForm.t007.value))){
        fmForm.t006.focus();
        fmForm.t007.focus();
        fmForm.t007.select();   
        alert('Invalid email address');
        return false;       
    }



    var sel1 = fmForm.s002;
    if(sel1.options[sel1.selectedIndex].value == "n/a"){
        fmForm.t010.focus();
        sel1.focus();
        alert('Please select an answer');
        return false; 
    }
    
    if(sel1.options[sel1.selectedIndex].value == "yes"){
        // check for explanation
        if(isEmpty(fmForm.s002t001.value)){
            sel1.focus();
            fmForm.s002t001.focus();
            fmForm.s002t001.select();
            alert('Please specify');
            return false;
        }
        
    }
   
    var txt1 = fmForm.t011;
    if(isEmpty(txt1.value)){
        sel1.focus();
        txt1.focus();
        txt1.select();
        alert('Please supply the required information');
        return false;
    }
    

 
    var sel2 = fmForm.s003;
    if(sel2.options[sel2.selectedIndex].value == 'n/a'){
        txt1.focus();
        sel2.focus();
        alert('Please select an answer');
        return false;         
    }
    
    var sel3 = fmForm.s004;
    if(sel3.options[sel3.selectedIndex].value == 'n/a'){
        sel2.focus();
        sel3.focus();
        alert('Please select an answer');
        return false
    }
    
 
    var txt2 = fmForm.s004t001;
    var txt3 = fmForm.s004t002;

    if(sel3.options[sel3.selectedIndex].value == 'yes'){
        if(isEmpty(txt2.value)){
            sel3.focus();
            txt2.focus();
            txt2.select();
            alert('Please supply required information');
            return false;
        }
        
        if(isEmpty(txt3.value)){
            sel3.focus();
            txt3.focus();
            txt3.select();
            alert('Please supply required information');
            return false;
        }        
    }


    sel1 = fmForm.s005;
    if(sel1.options[sel1.selectedIndex].value == 'n/a'){
        txt3.focus();
        sel1.focus();
        alert('Please select an answer');
        return false;
    }
    
    txt1 = fmForm.s005t001;
    txt2 = fmForm.s005t002;
    txt3 = fmForm.s005t003;
    txt4 = fmForm.s005t004;
    
    if(sel1.options[sel1.selectedIndex].value == 'yes'){
        if(isEmpty(txt1.value)){
            sel1.focus();
            txt1.focus();
            txt1.select();
            alert('Please supply required information');
            return false;
        }
        
        if(isEmpty(txt2.value)){
            sel1.focus();
            txt2.focus();
            txt2.select();
            alert('Please supply required information');
            return false;
        }
        
        
        if(isEmpty(txt3.value)){
            sel1.focus();
            txt3.focus();
            txt3.select();
            alert('Please supply required information');
            return false;
        }
        
        if(isEmpty(txt4.value)){
            sel1.focus();
            txt4.focus();
            txt4.select();
            alert('Please supply required information');
            return false;
        }
              
        
    }

//***********************************************************    

    
    txtPrev = fmForm.s005t004;
    sel1 = fmForm.s006;
    txt1 = fmForm.s006t001;
    
    if(sel1.options[sel1.selectedIndex].value == 'n/a'){
        txtPrev.focus();
        sel1.focus();
        alert('Please select an answer');
        return false;
    }    
    
    if(sel1.options[sel1.selectedIndex].value == 'yes'){
        if(isEmpty(txt1.value)){
            sel1.focus();
            txt1.focus();
            txt1.select();
            alert('Please supply required information');
            return false;
        }
    }
    
//***********************************************************    
    
    txtPrev = sel1;
    sel1 = fmForm.s007;
    txt1 = fmForm.s007t001;
    
    if(sel1.options[sel1.selectedIndex].value == 'n/a'){
        txtPrev.focus();
        sel1.focus();
        alert('Please select an answer');
        return false;
    }    
    
    if(sel1.options[sel1.selectedIndex].value == 'yes'){
        if(isEmpty(txt1.value)){
            sel1.focus();
            txt1.focus();
            txt1.select();
            alert('Please supply required information');
            return false;
        }
    }
    
//***********************************************************    

    txtPrev = sel1;
    sel1 = fmForm.s008;
    txt1 = fmForm.s008t001;
    
    if(sel1.options[sel1.selectedIndex].value == 'n/a'){
        txtPrev.focus();
        sel1.focus();
        alert('Please select an answer');
        return false;
    }    
    
    if(sel1.options[sel1.selectedIndex].value == 'yes'){
        if(isEmpty(txt1.value)){
            sel1.focus();
            txt1.focus();
            txt1.select();
            alert('Please supply required information');
            return false;
        }
    }
    
//***********************************************************  

    txtPrev = sel1;
    sel1 = fmForm.s009;
    
    if(sel1.options[sel1.selectedIndex].value == 'n/a'){
        txtPrev.focus();
        sel1.focus();
        alert('Please select an answer');
        return false;
    }    
       
//***********************************************************  

    txtPrev = sel1;
    sel1 = fmForm.s010;
    
    if(sel1.options[sel1.selectedIndex].value == 'n/a'){
        txtPrev.focus();
        sel1.focus();
        alert('Please select an answer');
        return false;
    }    
       
//***********************************************************  


    txtPrev = sel1;
    sel1 = fmForm.s011;
    txt1 = fmForm.s011t001;
    
    if(sel1.options[sel1.selectedIndex].value == 'n/a'){
        txtPrev.focus();
        sel1.focus();
        alert('Please select an answer');
        return false;
    }    
    
    if(sel1.options[sel1.selectedIndex].value == 'yes'){
        if(isEmpty(txt1.value)){
            sel1.focus();
            txt1.focus();
            txt1.select();
            alert('Please supply required information');
            return false;
        }
    }
    
//***********************************************************  

    txtPrev = sel1;    
    txt1 = fmForm.t012;

    if(isEmpty(txt1.value)){
        txtPrev.focus();
        txt1.focus();
        txt1.select();
        alert('Please supply required information');
        return false;
    }

//***********************************************************  
    
    txtPrev = txt1;   
    txt1 = fmForm.t013;    
    
    if(isEmpty(txt1.value)){
        txtPrev.focus();
        txt1.focus();
        txt1.select();
        alert('Please supply required information');
        return false;
    }


//***********************************************************  
    
    txtPrev = txt1;   
    txt1 = fmForm.t014;    
    
    if(isEmpty(txt1.value)){
        txtPrev.focus();
        txt1.focus();
        txt1.select();
        alert('Please supply required information');
        return false;
    }


//***********************************************************   
    
    txtPrev = txt1;   
    txt1 = fmForm.t015;    
    
    if(isEmpty(txt1.value)){
        txtPrev.focus();
        txt1.focus();
        txt1.select();
        alert('Please supply required information');
        return false;
    }


//***********************************************************       
/*    removed question 16 - jl 04/11/2003
    txtPrev = txt1;   
    txt1 = fmForm.t016;    
    
    if(isEmpty(txt1.value)){
        txtPrev.focus();
        txt1.focus();
        txt1.select();
        alert('Please supply required information');
        return false;
    }

*/
//***********************************************************       
    
    txtPrev = txt1;   
    txt1 = fmForm.t017;    
    
    if(isEmpty(txt1.value)){
        txtPrev.focus();
        txt1.focus();
        txt1.select();
        alert('Please supply required information');
        return false;
    }


//***********************************************************    
    
    txtPrev = txt1;   
    txt1 = fmForm.t018;    
    
    if(isEmpty(txt1.value)){
        txtPrev.focus();
        txt1.focus();
        txt1.select();
        alert('Please supply required information');
        return false;
    }


//***********************************************************  
/* removed question t019 - jl - 04/11/2003    
    txtPrev = txt1;   
    txt1 = fmForm.t019;    
    
    if(isEmpty(txt1.value)){
        txtPrev.focus();
        txt1.focus();
        txt1.select();
        alert('Please supply required information');
        return false;
    }

*/
//***********************************************************  
    
    txtPrev = txt1;   
    txt1 = fmForm.t020;    
    
    if(isEmpty(txt1.value)){
        txtPrev.focus();
        txt1.focus();
        txt1.select();
        alert('Please supply required information');
        return false;
    }


//***********************************************************  
    
    txtPrev = txt1;   
    txt1 = fmForm.t021;    
    
    if(isEmpty(txt1.value)){
        txtPrev.focus();
        txt1.focus();
        txt1.select();
        alert('Please supply required information');
        return false;
    }


//***********************************************************  
/* - removed question t022 - jl - 04/11/2003    
    txtPrev = txt1;   
    txt1 = fmForm.t022;    
    
    if(isEmpty(txt1.value)){
        txtPrev.focus();
        txt1.focus();
        txt1.select();
        alert('Please supply required information');
        return false;
    }

*/
//***********************************************************  
/* - removed question t023 - jl - 04/11/2003    
    
    txtPrev = txt1;   
    txt1 = fmForm.t023;    
    
    if(isEmpty(txt1.value)){
        txtPrev.focus();
        txt1.focus();
        txt1.select();
        alert('Please supply required information');
        return false;
    }

*/
//***********************************************************  
    
    txtPrev = txt1;   
    txt1 = fmForm.t024;    
    
    if(isEmpty(txt1.value)){
        txtPrev.focus();
        txt1.focus();
        txt1.select();
        alert('Please supply required information');
        return false;
    }


//***********************************************************  
/* - removed question t025 - jl - 04/11/2003    
    
    txtPrev = txt1;   
    txt1 = fmForm.t025;    
    
    if(isEmpty(txt1.value)){
        txtPrev.focus();
        txt1.focus();
        txt1.select();
        alert('Please supply required information');
        return false;
    }

*/
//***********************************************************  


    txtPrev = txt1;
    sel1 = fmForm.s012;
    txt1 = fmForm.s012t001;
    
// removed question s012t002 - jl - 04/11/2003
//    txt2 = fmForm.s012t002;    
    
    if(sel1.options[sel1.selectedIndex].value == 'n/a'){
        txtPrev.focus();
        sel1.focus();
        alert('Please select an answer');
        return false;
    }    
    
    if(sel1.options[sel1.selectedIndex].value == 'yes'){
        if(isEmpty(txt1.value)){
            sel1.focus();
            txt1.focus();
            txt1.select();
            alert('Please supply required information');
            return false;
        }

// removed question s012t002 - jl - 04/11/2003
/*        
        if(isEmpty(txt2.value)){
            sel1.focus();
            txt2.focus();
            txt2.select();
            alert('Please supply required information');
            return false;
        }        
        
*/        
    }
    
//***********************************************************  

    txtPrev = txt1;
    sel1 = fmForm.s013;
    
    if(sel1.options[sel1.selectedIndex].value == 'n/a'){
        txtPrev.focus();
        sel1.focus();
        alert('Please select an answer');
        return false;
    }   

//***********************************************************  


    txtPrev = sel1;
    sel1 = fmForm.s014;
    txt1 = fmForm.s014t001;
    
    if(sel1.options[sel1.selectedIndex].value == 'n/a'){
        txtPrev.focus();
        sel1.focus();
        alert('Please select an answer');
        return false;
    }    
    
    if(sel1.options[sel1.selectedIndex].value == 'yes'){
        if(isEmpty(txt1.value)){
            sel1.focus();
            txt1.focus();
            txt1.select();
            alert('Please supply required information');
            return false;
        }
        
  
    }
    
//***********************************************************  

    txtPrev = sel1;
    sel1 = fmForm.s015;
    txt1 = fmForm.s015t001;
    
    if(sel1.options[sel1.selectedIndex].value == 'n/a'){
        txtPrev.focus();
        sel1.focus();
        alert('Please select an answer');
        return false;
    }    
    
    if(sel1.options[sel1.selectedIndex].value == 'yes'){
        if(isEmpty(txt1.value)){
            sel1.focus();
            txt1.focus();
            txt1.select();
            alert('Please supply required information');
            return false;
        }
        
  
    }
    
//***********************************************************  

    txtPrev = txt1;
    sel1 = fmForm.s016;
    
    if(sel1.options[sel1.selectedIndex].value == 'n/a'){
        txtPrev.focus();
        sel1.focus();
        alert('Please select an answer');
        return false;
    }   

//***********************************************************  

    txtPrev = sel1;
    sel1 = fmForm.s017;
    
// removed question s017s001 - jl - 04/11/2003    
//    sel2 = fmForm.s017s001;
    
    if(sel1.options[sel1.selectedIndex].value == 'n/a'){
        txtPrev.focus();
        sel1.focus();
        alert('Please select an answer');
        return false;
    }    

// removed question s017s001 - jl - 04/11/2003    
/*    if(sel1.options[sel1.selectedIndex].value == 'yes'){
        if(sel2.options[sel2.selectedIndex].value == 'n/a'){
            sel1.focus();
            sel2.focus();
            alert('Please supply required information');
            return false;
        }
        
 
   }
*/    
//***********************************************************  

    txtPrev = sel1;
    sel1 = fmForm.s019;
    
    if(sel1.options[sel1.selectedIndex].value == 'n/a'){
        txtPrev.focus();
        sel1.focus();
        alert('Please select an answer');
        return false;
    }   

//***********************************************************  

    txtPrev = sel1;
    sel1 = fmForm.s020;
    
    if(sel1.options[sel1.selectedIndex].value == 'n/a'){
        txtPrev.focus();
        sel1.focus();
        alert('Please select an answer');
        return false;
    }   

//***********************************************************  
    
    txtPrev = sel1;   
    txt1 = fmForm.t026;    
    
    if(isEmpty(txt1.value)){
        txtPrev.focus();
        txt1.focus();
        txt1.select();
        alert('Please supply required information');
        return false;
    }


//***********************************************************  
    
    txtPrev = txt1;   
    txt1 = fmForm.t027;    
    
    if(isEmpty(txt1.value)){
        txtPrev.focus();
        txt1.focus();
        txt1.select();
        alert('Please supply required information');
        return false;
    }


//***********************************************************  
/* removed question t028 - jl - 04/11/2003    
    txtPrev = txt1;   
    txt1 = fmForm.t028;    
    
    if(isEmpty(txt1.value)){
        txtPrev.focus();
        txt1.focus();
        txt1.select();
        alert('Please supply required information');
        return false;
    }

*/
//***********************************************************  
    
    txtPrev = txt1;   
    txt1 = fmForm.t029;    
    
    if(isEmpty(txt1.value)){
        txtPrev.focus();
        txt1.focus();
        txt1.select();
        alert('Please supply required information');
        return false;
    }


//*********************************************************** 
/* removed question t030 - jl - 04/11/2003    
    
    txtPrev = txt1;   
    txt1 = fmForm.t030;    
    
    if(isEmpty(txt1.value)){
        txtPrev.focus();
        txt1.focus();
        txt1.select();
        alert('Please supply required information');
        return false;
    }

*/
//*********************************************************** 
    
    txtPrev = txt1;   
    txt1 = fmForm.t031;    
    
    if(isEmpty(txt1.value)){
        txtPrev.focus();
        txt1.focus();
        txt1.select();
        alert('Please supply required information');
        return false;
    }


//*********************************************************** 
/* removed email address requirements for references - jl - 04/11/2003    
    txtPrev = txt1;   
    txt1 = fmForm.t032;    
    
    if(isEmpty(txt1.value)){
        txtPrev.focus();
        txt1.focus();
        txt1.select();
        alert('Please supply required information');
        return false;
    }

    if(!(echeck(txt1.value))){
        txtPrev.focus();
        txt1.focus();
        txt1.select();   
        alert('Invalid email address');
        return false;       
    }
*/    
//*********************************************************** 
    
    txtPrev = txt1;   
    txt1 = fmForm.t033;    
    
    if(isEmpty(txt1.value)){
        txtPrev.focus();
        txt1.focus();
        txt1.select();
        alert('Please supply required information');
        return false;
    }


//*********************************************************** 
    
    txtPrev = txt1;   
    txt1 = fmForm.t034;    
    
    if(isEmpty(txt1.value)){
        txtPrev.focus();
        txt1.focus();
        txt1.select();
        alert('Please supply required information');
        return false;
    }


//*********************************************************** 
/* removed question t032 - jl - 04/11/2003    
    
    txtPrev = txt1;   
    txt1 = fmForm.t035;    
    
    if(isEmpty(txt1.value)){
        txtPrev.focus();
        txt1.focus();
        txt1.select();
        alert('Please supply required information');
        return false;
    }

*/
//*********************************************************** 
    
    txtPrev = txt1;   
    txt1 = fmForm.t036;    
    
    if(isEmpty(txt1.value)){
        txtPrev.focus();
        txt1.focus();
        txt1.select();
        alert('Please supply required information');
        return false;
    }


//*********************************************************** 
/* removed question t032 - jl - 04/11/2003    

    txtPrev = txt1;   
    txt1 = fmForm.t037;    
    
    if(isEmpty(txt1.value)){
        txtPrev.focus();
        txt1.focus();
        txt1.select();
        alert('Please supply required information');
        return false;
    }

*/
//*********************************************************** 
    
    txtPrev = txt1;   
    txt1 = fmForm.t038;    
    
    if(isEmpty(txt1.value)){
        txtPrev.focus();
        txt1.focus();
        txt1.select();
        alert('Please supply required information');
        return false;
    }


//*********************************************************** 
/* removed email address requirements for references - jl - 04/11/2003    

    
    txtPrev = txt1;   
    txt1 = fmForm.t039;    
    
    if(isEmpty(txt1.value)){
        txtPrev.focus();
        txt1.focus();
        txt1.select();
        alert('Please supply required information');
        return false;
    }

    if(!(echeck(txt1.value))){
        txtPrev.focus();
        txt1.focus();
        txt1.select();   
        alert('Invalid email address');
        return false;       
    }
    
*/    
//*********************************************************** 
    
    txtPrev = txt1;   
    txt1 = fmForm.t040;    
    
    if(isEmpty(txt1.value)){
        txtPrev.focus();
        txt1.focus();
        txt1.select();
        alert('Please supply required information');
        return false;
    }


//*********************************************************** 
    

document.forms['adoptform'].submit();
return true;
}

