var whitespace = " \t\n\r";
			//begin whitespace function :
		function isWhitespace(space) {
		   var i;
   	   // Search through string's characters one by one
	   	// until we find a non-whitespace character.
		   // When we do, return false; if we don't, return true.
   		for (i = 0; i < space.length; i++){   
	       // Check that current character isn't whitespace.
			 // use -1 use as "false" condition of non character, which means it 
			 // it contains character, therefore return false
	         var current = space.charAt(i);
   	      if (whitespace.indexOf(current) == -1) return false;
      	}
	      // All characters are whitespace.
   	   return true;
      }
			
		 function check(fields){
		 
			var shd = "no" //default setting for HEALTH DISTRICT
			var scod= "no" //default setting for CODE
			var sspa = "no" //default setting for SPA
			
			//loop through to check if the user select at least one criteria for health district
			for (i=0; i<fields.selhd.options.length; i++){
				if (fields.selhd.options[i].selected && fields.selhd.options[i].value !=""){
					shd = "yes"							
					break;					
				}				
			 }	
			//loop through to check if the user select at least one criteria for code			
			for (i=0; i<fields.selcod.options.length; i++){
				if (fields.selcod.options[i].selected && fields.selcod.options[i].value !=""){
					scod = "yes"						
					break;					
				}				
			 }	
			//loop through to check if the user select at least one criteria for SPA			
			for (i=0; i<fields.selspa.options.length; i++){
				if (fields.selspa.options[i].selected && fields.selspa.options[i].value !=""){
					sspa = "yes"						
					break;					
				}				
			 }	
			
			// CLIENT validation : need to select or enter at least one criteria
			if ((shd == "no") && (scod == "no")&&
				(isWhitespace(fields.selcity.value)) && (sspa == "no")&&
				(isWhitespace(fields.selzip.value))&& (isWhitespace(fields.selname.value))&&
				(isWhitespace(fields.selcen.value)))
			
			    {  
				alert("You need to select or enter at least one search criteria .");
				return false;		
			}
		}
		
		
		function PrintIns(printlist) {
		GroupWindow = window.open('phnprintrpt.cfm?'+printlist, 'GroupWin', 
		'toolbar=yes,location=no,menubar=yes,scrollbars=yes,width=700,height=400')
	}
	//this function use to open a new window for code definition
	function code() {
		codewin = window.open('/phn/cpd_orgcode.htm', 'codewin', 
		'toolbar=yes,location=no,menubar=yes,scrollbars=yes,width=600,height=400')
		codewin.focus()
	}
	//this function use to open a new window for health district definition
	function hd() {
		hdwin = window.open('/phn/cpd_hd.htm', 'hdwin', 
		'toolbar=yes,location=no,menubar=yes,scrollbars=yes,width=600,height=400')
		hdwin.focus()
	}
