﻿function search(){
		
			var _zip = document.getElementById("_zip");
			var _keyword = document.getElementById("_keyword");
			var _county = document.getElementById("_county");
			var _category = document.getElementById("_category");
//			var url = "http://search.networkforgood.org/results.aspx?state=NY&newsearch=true&source=NY&location=us";
			var url = "http://search.networkforgood.org/results.aspx?state=ny&newsearch=true&source=usafc&location=us";
//			
            if((_category.value != '' || _keyword.value != '') && (_zip.value != '' || _county.value != '')) {
            
			if(_category.value != ''){
				url += "&catid=" + _category.value;
			}
			if(_category.value == 'Senior' && _keyword.value == ''){
				url += "&tsfreetextentry=retired%20or%20senior%20or%20elderly%20or%20grandparent";
			}
			if(_keyword.value != ''){
				url += "&tsfreetextentry=" + _keyword.value;
			}
			if(_zip.value != ''){
				url += "&zipcode=" + _zip.value;
			}
			if(_county.value != ''){
				url += "&county=" + _county.value;
			}									
						
			window.location = url;
			//window.navigate(url);
			
			//onfocus="javascript:if(this.value == 'keyword'){this.select();}" onblur="javascript:if(this.value == ''){this.value = 'keyword';}"
			
            }
            else {
              alert('To perform a search, you must provide a zip code or a county AND a keyword or a service category.');
            }
		}
		
		function checkEnter(e){
            var characterCode
            if(e && e.which){ //if which property of event object is supported (NN4)
                e = e
                characterCode = e.which //character code is contained in NN4's which property
            }
            else{
                e = event
                characterCode = e.keyCode //character code is contained in IE's keyCode property
            }

            if(characterCode == 13){ //if generated character code is equal to ascii 13 (if enter key)
                search()
            }
            return true
        }