// JavaScript Document
function fnSetSearchType(sID)
{
   var SelectType;
   SelectType = document.getElementById(sID).value;
   
   if ((sID == "1")|(sID == "2")|( sID == "3")|( sID == "8"))
    {
     document.getElementById("sInput").innerHTML = " ";
    }
	
   if (sID == "4")
	{
    document.getElementById("sInput").innerHTML = " Enter zip code: <input type='text' name='zipcode' value='' size='6' maxlength='5'> ";
	document.ListChurch.zipcode.focus();
    }
	
	if (sID == "5")
    {
     document.getElementById("sInput").innerHTML = " Enter word : <input type='text' name='keyword' value='' size='20' maxlength='50'> ";
	 document.ListChurch.keyword.focus();
    }	
	
	if (sID == "6")
	{
     document.getElementById("sInput").innerHTML = " <select name='language'  id='language'> " + 
	                                               " <option id='0' value='0'>   Select Language </option> " +
	                                               " <option id='1' value='1'>   English & Spanish </option> " +
	                                               " <option id='14' value='14'>   English </option> " +
												   " <option id='2' value='2'>   Latin </option> " +
												   " <option id='3' value='3'>   Korean </option> " +
												   " <option id='4' value='4'>   Spanish </option> " +
												   " <option id='5' value='5'>   Malayalam </option> " +
												   " <option id='6' value='6'>   Polish </option> " +
												   " <option id='7' value='7'>   Chinese </option> " +
												   " <option id='8' value='8'>   Vietnamese </option> " +
												   " <option id='9' value='9'>   Ukranian </option> " +
												   " <option id='10' value='10'> Nigerian </option> " +
                                                   " </select>";
	 document.ListChurch.language.focus();
    }
	
	if (sID == "7")
	{
     document.getElementById("sInput").innerHTML = " <select name='rite'  id='rite'> " + 
	                                               " <option id='0' value='0'>   Select Rite </option> " +
	                                               " <option id='1' value='1'>   Syro-Malabar </option> " +
												   " <option id='2' value='2'>   Syro-Malankar </option> " +
												   " <option id='3' value='3'>   Byzantine Ruthenian </option> " +
												   " <option id='4' value='4'>   Byzantine Ukranian </option> " +
												   " <option id='5' value='5'>   Maronite </option> " +
												   " </select>";
	document.ListChurch.rite.focus();
    }	
}

String.prototype.trim = function () {
    return this.replace(/^\s*/, "").replace(/\s*$/, "");
}

function validateit()
 {
	 			   
   var strMassage  = ""; 
   var strZipcode  = ""; 
   var strKeyword  = ""; 
   var strZipcode  = "";
   var strLanguage = "";
   var strRite = "";
   var i = 0; 
   var iChecked = 0;
   
   for(i=3; i < 8 ; i++)
   {
     if (document.ListChurch.sType[i].checked)
	  {
	    iChecked = i;		
		// alert("option = " + document.ListChurch.sType[i].value);    return false;		
	  }	 	  
   }
   
     //  
    //  alert("option = " + iChecked);    return false;	
	   
      if (iChecked == 3)  //  Validate zipcode 
	   {  
	       strZipcode = (document.ListChurch.zipcode.value).trim();;	   
	       if(((strZipcode).length != 5)|(isNaN(strZipcode)))
		   {		       
		       strMassage = " Invalid zipcode";
		   }		    
	   }		
	      
	   if (iChecked == 4)  //  Validate keyword 
	   {  
	       strKeyword = (document.ListChurch.keyword.value).trim();
	       if((strKeyword).length == 0)
		   {
		       strMassage = " Invalid keyword";
		   }  
       }	
	   
	  // alert("option = " + iChecked);    return false;	
	   
	   if (iChecked == 6)  //  Validate Language
	   { 
	    strLanguage = document.ListChurch.language.value;		   
	   if(document.ListChurch.language.value == "0")
		   {
		       strMassage = " Invalid Language Selection";
		   } 			   
	   }		
	     
	  if (iChecked == 7) //  Validate Rite
	   { 
	    strRite = document.ListChurch.rite.value;
	    if(strRite == "0")
		   {
		       strMassage = " Invalid Rite Selection";
		   }				 	
	   }  	      
	  if (strMassage == "")  	     
	      { return true; }
	  else
	      {
		  alert("Input Error Detected - " + strMassage + "!");
		  return false;
		  }		   
}

function quicktest()
{
	alert("I had been clicked");
	return false;
	
}