function fsV(s){
	if(fSI(s)<0)return 0;
	var t=fSIT(s);
	return (t.search(/(Preference|\-\-|Countries)/)==-1 && t.length>1);}
var g_block=false;
function fV(f){
	var srt,srt2,strstate;
	strstate=fSIT(f.aw_State);
	var cbo=fID("aw_State"); 
	f.aw_City.value=fTW(f.aw_City.value);f.aw_Zip.value=fTW(f.aw_Zip.value);
	if(fSI(cbo)>=66 || (fSI(cbo)==1 && aw_d >0) || f.lcid.value!="en-us"){
		if(!fsV(f.aw_IsAgency) && !fsV(f.aw_CreationDate) && !fsV(f.aw_State) && !fsV(f.aw_Car) && !fsV(f.aw_Salary) && !fsV(f.aw_Shifts) && !fsV(f.aw_HrWrk) && !fsV(f.aw_Education) && !fsV(f.aw_Screened) && !fsV(f.aw_WorksWith) && !fsV(f.aw_ADLs) &&  !fsV(f.aw_IADLs) && !fsV(f.aw_OADLs) && fIE(f.aw_City.value) && fIE(f.aw_Zip.value)   && !fsV(f.aw_Days) && !fsV(f.aw_ReferencesAvailable) && fIE(f.aw_AgencyName.value) && fIE(f.aw_ScreenName.value) && fIE(f.aw_FirstName.value) && fIE(f.aw_LastName.value) && fIE(f.aw_Email.value) && fIE(f.aw_Phone.value) && fIE(f.aw_ONotes.value)  ){
			alert("Missing or invalid search parameters.\n\nSelect search parameters and try again.   \n\n");
			f.aw_City.focus();return false;}
		if(fSIT(f.aw_State).length > 4){
			if(!fsV(f.aw_State)){
				alert("Invalid country selection.\n\nSelect a country selection and try again.   \n\n");
				f.aw_State.focus();return false;}}
	}else{
		f.aw_County.value=fTW(f.aw_County.value); 
		if(!fsV(f.aw_IsAgency) && !fsV(f.aw_CreationDate ) && !fsV(f.aw_State) && !fsV(f.aw_Car) && !fsV(f.aw_Salary) && !fsV(f.aw_Shifts) && !fsV(f.aw_HrWrk) && !fsV(f.aw_Education) && !fsV(f.aw_Screened) && !fsV(f.aw_WorksWith) && !fsV(f.aw_ADLs) &&  !fsV(f.aw_IADLs) && !fsV(f.aw_OADLs) && fIE(f.aw_City.value) && fIE(f.aw_County.value) && fIE(f.aw_Zip.value)   && !fsV(f.aw_Days) && !fsV(f.aw_ReferencesAvailable) && fIE(f.aw_AgencyName.value) && fIE(f.aw_ScreenName.value) && fIE(f.aw_FirstName.value) && fIE(f.aw_LastName.value) && fIE(f.aw_Email.value) && fIE(f.aw_Phone.value) && fIE(f.aw_ONotes.value)  ){
			alert("Missing or invalid search parameters.\n\nSelect search parameters and try again.   \n\n");
			f.aw_City.focus();return false;}
		if(fSIT(f.aw_State).length >4){
			if(!fsV(f.aw_State)){
				alert("Invalid state selection.\n\nSelect a state and try again.   \n\n");
				f.aw_State.focus();return false;}}
		if(f.aw_Zip.value.search(/\w+/) !=-1){
			if(f.aw_Zip.value.length > 5 || f.aw_Zip.value.search(/[^0-9*]/) != -1 ){
				alert("Invalid zip code.\n\nType a 1-5 digit zip code and try again.   \n\nNote: Wildcard character(s) assumed if zip   \nis less than 5 digits.\n\n");
				f.aw_Zip.focus();
				return false;}}}
	var isdc=(fSIT(cbo).toLowerCase()=="district of columbia");
	if(isdc){
		if(fSIT(f.aw_Sort)=="County" || fSIT(f.aw_Sort)=="City"){
			as_OptSel("aw_Sort","Zip");}			
		if(fSIT(f.aw_Sort2)=="County" || fSIT(f.aw_Sort2)=="City"){
			if(fSIT(f.aw_Sort2)=="Zip")
				as_OptSel("aw_Sort2","Post Date");
			else
				as_OptSel("aw_Sort2","Zip");}			
		if(fSIT(f.aw_Sort)==fSIT(f.aw_Sort2)){
			if(fSIT(f.aw_Sort)=="Zip")
				as_OptSel("aw_Sort2","Post Date");
			else if(fSIT(f.aw_Sort)=="Post Date"){
				as_OptSel("aw_Sort2","Zip");}}}
	srt=fSIT(f.aw_Sort);srt2=fSIT(f.aw_Sort2);
	if(srt.length < 3 || srt2.length < 3){
		alert("Invalid sort option.\n\nOne or both sort options is missing.  \n\nSelect sort options and try again.   \n\n");
		f.aw_Sort.focus();return false;}
	if((strstate.length >3 && strstate !="District of Columbia") && srt=="State"){
		alert("Invalid first sort option.\n\nYou cannot sort by State when you have   \nnarrowed your search to a State.\n\nSelect a different sort option and try again.   \n\n");
		f.aw_Sort.focus();return false;}
	if((strstate.length >3 && strstate !="District of Columbia") && srt2=="State"){
		alert("Invalid second sort option.\n\nYou cannot sort by State when you have   \nnarrowed your search to a State.\n\nSelect a different sort option and try again.   \n\n");
		f.aw_Sort2.focus();return false;}
	if(strstate=="District of Columbia" && (srt=="City" || srt=="State" || srt=="County")){
		alert("Invalid first sort option.\n\nThe District of Columbia cannot be sorted   \nby city, state, or county.\n\nSelect a different sort option and try again.   \n\n");
		f.aw_Sort.focus();return false;}
	if(strstate=="District of Columbia" && (srt2=="City" || srt2=="State" || srt2=="County") ){
		alert("Invalid second sort option.\n\nThe District of Columbia cannot be sorted   \nby city, state, or county.\n\nSelect a different sort option and try again.   \n\n");
		f.aw_Sort2.focus();return false;}
	if(srt===srt2){
		alert("Invalid sort option.\n\nThe first and second sort options   \ncannot be the same.\n\nSelect different sort options and try again.   \n\n");
		f.aw_Sort.focus();return false;}
	if(!fsV(f.aw_ResultsPerPage)){
		alert("Invalid results per page selection.\n\nSelect the number of results to display per page  \nand try again.\n\n");
		f.aa_ResultsPerPage.focus();return false;}		
	return true;}
function ClearFields(fl){
	if(!confirm("Reset advanced assistant wanted\nsearch session?\n\n"))return (fl)?void(0):false;
	document.location.href='advsearchw.php?cmd=new';return true;}
function fSubmit(fl){
	if(g_block)return (fl)?void(0):false;
	var frm=fID('frmmain');
	if(fV(frm)){
		g_block=true;
		var a=new Array("City","Zip","County","ScreenName","FirstName","LastName","Email","Phone","AgencyName","ONotes"),e;
		for(var i=0;i<a.length;i++){
			e=fID("aw_"+a[i]);
			if(e){
				if(!fIE(e.value)){
					if(window.frames["aw_"+a[i]+"_frame"].ih_fLAU){
						window.frames["aw_"+a[i]+"_frame"].ih_fLAU(new Array(e.value,"all"));}}}}
		frm.submit();g_block=false;return void(0);
		g_block=false;	return true;}
	return (fl)?void(0):false;}
function as_OptRename(id,f,t){
	var cbo=fID(id); 
	for(var i=0;i<cbo.options.length;i++){if(cbo.options[i].text==f){cbo.options[i].text=t;}}
	return 1;}
function as_OptRemove(id,t){
	var cbo=fID(id);for(var i=0;i<cbo.options.length;i++){if(cbo.options[i].text==t){cbo.remove(i);break;}}
	return 1;}
function as_OptAdd(id,t){
	var cbo=fID(id);
	for(var i=0;i<cbo.options.length;i++){if(cbo.options[i].text==t){return 1;}}
	var n=fCE("OPTION");n.text=t;
	if(g_b=='ms')
		cbo.add(n);
	else
		cbo.add(n,null);return 1;}
function as_OptSel(id,t){
	var cbo=fID(id);for(var i=0;i<cbo.options.length;i++){if(cbo.options[i].text==t){cbo.options[i].selected=true;break;}}
	return 1;}
function as_View(p){
	var cbo=fID(p+"State"),a,isdc=0; 
	if(fSI(cbo)>=66 || (fSI(cbo)==1 && aw_d >0)){
		a=((g_b=="ms")?"block":"table-row");
		a=new Array("none","block","none","block","none","Zip","Postal Code",a);
		as_OptRemove(p+"Sort","County");as_OptRemove(p+"Sort2","County");a[8]="none";
	}else{
		isdc=(fSIT(cbo).toLowerCase()=="district of columbia");
		if(isdc){
			a="none";
		}else{
			a=((g_b=="ms")?"block":"table-row");}
		a=new Array("block","none","block","none","block","Postal Code","Zip",a);
		a[8]=a[7];as_OptAdd(p+"Sort","County");as_OptAdd(p+"Sort2","County");}
	fIS(p+"CityTD").display=a[7];fIS(p+"CountyTD").display=a[8];fIS(p+"StateLabel").display=a[0];
	fIS(p+"StateLabelCountry").display=a[1];fIS(p+"ZipLabel").display=a[2];
	fIS(p+"ZipLabelCountry").display=a[3];
	if(a[3]=="block"){
		fID(p+"Zip").title=fID(p+"ZipLabelCountry").title; 
	}else{
		fID(p+"Zip").title=fID(p+"ZipLabel").title;}
	fIS(p+"CountyLabel").display=a[4];
	as_OptRename(p+"Sort",a[5],a[6]);as_OptRename(p+"Sort2",a[5],a[6]);
	var s=fSIT(cbo);
	if(s.search(/\w+/)==-1){
		as_OptAdd(p+"Sort","State");as_OptAdd(p+"Sort2","State");
	}else{
		as_OptRemove(p+"Sort","State");as_OptRemove(p+"Sort2","State");}
	if(fSIT(fID(p+"Sort")).length<3){as_OptSel(p+"Sort","City");}if(fSIT(fID(p+"Sort2")).length<3){as_OptSel(p+"Sort2","City");}
	if(a[7]!="none"){
		h_fHP(p+"City");
	}else{
		h_fHG2(p+"City_");}
	h_fHP(p+"Zip");
	if(a[8]!="none"){
		h_fHP(p+"County");
	}else{
		h_fHG2(p+"County_");}
	return 1;
}
function as_Viewf(p){
	var cbo=fID(p+"State"),s=fSIT(cbo);
	if(s.search(/\w+/)==-1){
		as_OptAdd(p+"Sort","Country");as_OptRemove(p+"Sort","State");as_OptAdd(p+"Sort2","Country");as_OptRemove(p+"Sort2","State");
	}else{
		as_OptRemove(p+"Sort","Country");as_OptRemove(p+"Sort2","Country");}
	cbo=fID(p+"Sort");
	if(s=="United States"){
		as_OptAdd(p+"Sort","State");as_OptAdd(p+"Sort2","State");
		if(fSIT(cbo).length < 3){as_OptSel(p+"Sort","State");}
		if(fSIT(fID(p+"Sort2")).length < 3){as_OptSel(p+"Sort2","State");}
	}else{
		as_OptRemove(p+"Sort","State");as_OptRemove(p+"Sort2","State");
		if(fSIT(cbo).length < 3){as_OptSel(p+"Sort","City");}
		if(fSIT(fID(p+"Sort2")).length < 3){as_OptSel(p+"Sort2","City");}}
	return 1;}
function as_Clear(e){
	e=fID(e).selectedIndex=-1;
	return 1;}
function as_ViewA(p){
	var cbo=fID(p+'IsAgency');
	var e=fIS(p+'AgencyNameTD');
	if(fSIT(cbo)=='Individuals Only'){
		e.display='none';
	}else{
		e.display='block';
	}

}