function GoBack()
{ 
  //alert(sPassAlong);
  window.location = "pick_shelter.asp?" + sPassAlong ;
}

function Init()
{
//  alert(document.frmSearch.ColorGroup[0].checked) ;

  if (document.frmSearch.AnimalAge[0].checked) 
    NoteChoice("age","younger");  
  else if (document.frmSearch.AnimalAge[1].checked) 
    NoteChoice("age","older");  
  else
    NoteChoice("age","");	

  if (document.frmSearch.AnimalGender[0].checked)	
    NoteChoice("Gender","male");  
  else if (document.frmSearch.AnimalGender[1].checked)	
    NoteChoice("Gender","female");  
  else
    NoteChoice("Gender","");  	

  if (document.frmSearch.AnimalSize[0].checked)	
    NoteChoice("size","small");
  else if (document.frmSearch.AnimalSize[1].checked)	
    NoteChoice("size","medium");
  else if (document.frmSearch.AnimalSize[2].checked)	
    NoteChoice("size","large");
  else	
    NoteChoice("size","");

  if (document.frmSearch.AnimalType[0].checked)	
    NoteChoice("type","dog");
  else if (document.frmSearch.AnimalType[1].checked)	
    NoteChoice("type","cat");
  else if (document.frmSearch.AnimalType[2].checked)	
    NoteChoice("type","other");
  else
    NoteChoice("type","");	
	
  if (document.frmSearch.ColorGroup[0].checked)	
    NoteChoice("color","black");
  else if (document.frmSearch.ColorGroup[1].checked)	
    NoteChoice("color","brown");
  else if (document.frmSearch.ColorGroup[2].checked)	
    NoteChoice("color","white");	
  else if (document.frmSearch.ColorGroup[3].checked)	
    NoteChoice("color","other");	
  else
    NoteChoice("color","");	
}

function NoteChoice(sAttribute,sValue)
{
  //alert("NoteChoice: " + sAttribute + " = " + sValue) ;
  switch (sAttribute)
  {
    case "type":
	 sType = sValue ;
	 break ;
	 
	case "Gender": 
     sGender = sValue ;
	 break ;
	 
	case "size": 
     sSize = sValue ;
	 break ;
	 
    case "age":	 
     sAge = sValue ;
	 break ;
	 
	case "color": 
     sColorGroup = sValue ;
	 break ;
	 
	case "breed": 
     sBreedGroup = sValue ;
	 break ;
	 
	default:
	 break ; 
  } // end: select

  PlaySound("SearchSound", "Sounds/frog.wav") ;
}
	
function CheckForm()
{
  var sWhere = new String() ; 
  sWhere = "" ;
  var bGotOne ;
  bGotOne = false ;

  // ================
  // animal_type
  // ================
  if (sType != "")
  {
    bGotOne = true ;
	switch(sType)
	{
	  case "dog":
	    sWhere += "type_DOG" ;
		break ;
	  case "cat":
        sWhere += "type_CAT" ;	  
		break ;	  
	  case "other":
		sWhere += "type_OO" ;
		break ;
	  default:
	    break ;
			
	} // end: switch
  }

  // ================
  // Gender
  // ================  
  if (sGender != "")
  {
    if (bGotOne)
	  sWhere += "," ; // " AND " ;
	else  
      bGotOne = true ;  

	switch(sGender)
	{
	  case "male":
		sWhere += "gender_m" ; // "(Gender = 'M' OR Gender = 'N' OR Gender is null)"	;  
	    break ;
	  case "female":
		sWhere += "gender_f" ; // "(Gender = 'F' OR Gender = 'S' OR Gender is null)"	;  
	    break ;	  
	  default:
	    break ;	  		  
	} // end: switch	  
  }
  
  // ================  
  // size
  // ================      
  if (sSize != "")
  {
    if (bGotOne)
	  sWhere += "," ;
	else  
      bGotOne = true ;  

	switch(sSize)
	{
	  case "small":
	    sWhere += "size_s" ;
	    break ;
	  case "medium":
	    sWhere += "size_m" ;
	    break ;	  
	  case "large":
	    sWhere += "size_l" ;
	    break ;
	  default:
	    break ;	  		  
	} // end: switch	  
  }

  // ================  
  // age
  // ================      
  if (sAge != "")
  {
      if (bGotOne)
	  sWhere += "," ;
	else  
      bGotOne = true ;  

	switch(sAge)
	{
	  case "younger":
	    sWhere += "age_y" ; // "(dateadd(year,1,dob) >= getdate())" ;
	    break ;
	  case "older":
	    sWhere += "age_o" ; // "(dateadd(year,1,dob) < getdate())" ;
	    break ;	  
	  default:
	    break ;	  		  
	} // end: switch	  
  }

  // ================  
  // color group
  // ================      
  if (sColorGroup != "")
  {
      if (bGotOne)
	  sWhere += "," ;
	else  
      bGotOne = true ;  

	switch(sColorGroup)
	{
	  case "black":
	    sWhere += "color_b" ; // "color_group = 'B'" ;
		break ;
	  case "brown":
	    sWhere += "color_br" ; // "color_group = 'BR'" ;
	    break ;	  
	  case "white":
	    sWhere += "color_w" ; // "color_group = 'W'" ;
	    break ;
	  case "other":
	    sWhere += "color_oo" ; // "color_group = 'OO'" ;
	    break ;		
	  default:
	    break ;	  		  
	} // end: switch	  
  }

  // ================  
  // breed group
  // ================      
  if (sBreedGroup != "")
  {
    if (bGotOne)
	  sWhere += "," ;
	else  
      bGotOne = true ;  
	  
    sWhere += "color_group = '" + sBreedGroup + "'" ;
  }

  if (!bGotOne)
   window.alert("You must choose at least one descriptive feature")
  else
  {
    //var s = new String;

    //s = sWhere + sSearchType ;
    //s = CleanQueryString(s) ;
//alert(sPassAlong + "&WHERE=" + sWhere + "&PAGE=1") ;
    //window.location = "results.asp?WHERE=" +  s ;
    //alert(CleanQueryString("?WHERE=" + sWhere + "&PAGE=1&" + sPassAlong  ) );
    window.location = "results.asp?" +  CleanQueryString("WHERE=" + sWhere + "&PAGE=1&" + sPassAlong  ) ;
  }

} // end function

