function select_drop_down(val)
{	
	var dropdn = document.getElementById('vchNewSearch');
	var len = dropdn.length;
	for (i = 0; i < len; i++) {
		if (dropdn[i].value == val) {
			dropdn[i].selected=true;
			searchfunreload(val);
		}
	}
}

function searchfunreload(val)
{	
	// to reset
	//Effect.Fade("as_NEWvchFlashSearch");Effect.Fade("as_eduNEWvchSearch");Effect.Fade("as_NEWvchSearch");
	clearAutoSuggestDivs();
	if (val=='Professionals')
	{
		document.getElementById('New_Prof_search_box').style.display='';
		document.getElementById('New_search_field_title').innerHTML='Professional Category or Key Words';
	
		document.getElementById('New_education_search_box').style.display='none';
		document.getElementById('advsearch').innerHTML='Open Advanced Search <img src="images/down.gif" border="1">';
		document.getElementById('prof_flash_newsearch').style.display='';	
		document.getElementById('edu_newsearch').style.display='none';
		
		document.getElementById('New_Flash_search_box').style.display='none';
		document.getElementById('flash_newsearch').style.display='none';
		//document.getElementById('NEWvchSearch').value='Enter Keyword to Search';
	}
	else if (val=='Education')
	{
		document.getElementById('New_Prof_search_box').style.display='none';
		document.getElementById('New_search_field_title').innerHTML='Education Category or Key Words';
		document.getElementById('New_education_search_box').style.display='';
		document.getElementById('advsearch').innerHTML='Open Advanced Search <img src="images/down.gif" border="1">';
		document.getElementById('prof_flash_newsearch').style.display='none';	
		document.getElementById('edu_newsearch').style.display='';
	
		document.getElementById('New_Flash_search_box').style.display='none';
		document.getElementById('flash_newsearch').style.display='none';
		//document.getElementById('eduNEWvchSearch').value='Enter Keyword to Search';
	}
	else if (val=='Members')
	{
		document.getElementById('New_Prof_search_box').style.display='none';
		document.getElementById('New_search_field_title').innerHTML='Name, Industry or Key Words';
	
		document.getElementById('New_education_search_box').style.display='none';
		document.getElementById('advsearch').innerHTML='Open Advanced Search <img src="images/down.gif" border="1">';
		document.getElementById('prof_flash_newsearch').style.display='none';	
		document.getElementById('edu_newsearch').style.display='none';

		document.getElementById('New_Flash_search_box').style.display='';
		document.getElementById('flash_newsearch').style.display='';
		//document.getElementById('NEWvchFlashSearch').value='Enter Keyword to Search';
	}
	else 
	{
		document.getElementById('New_Prof_search_box').style.display='none';
		document.getElementById('New_search_field_title').innerHTML='Key Words';
		document.getElementById('New_education_search_box').style.display='none';
		document.getElementById('advsearch').innerHTML='&nbsp;';
		
		document.getElementById('New_Flash_search_box').style.display='none';
		document.getElementById('flash_newsearch').style.display='none';
	}
}

function slide_adv(id)
{
	if (document.getElementById(id).style.display=='')
	{
		document.getElementById('advsearch').innerHTML='Open Advanced Search <img src="images/down.gif" border="1">';
		
	}
	else
	{
		document.getElementById('advsearch').innerHTML='Close Advanced Search <img src="images/up.gif" border="1">';
	}
}
function newSearchReset(val)	// Professional Reset
{
	var theform= document.frmnewSearch;
	for(i=0;i<theform.elements.length;i++)
	{
	    if (val==1)	// Advance 1 search
	    {
		if(theform.elements[i].type  == 'select-multiple')
		{	
			theform.elements[i].selectedIndex = -1;
		}
		if(theform.elements[i].type  == 'select-one' && theform.elements[i].name!='vchNewSearch' &&  theform.elements[i].name!='intCountryID' && theform.elements[i].name!='intStateID' && theform.elements[i].name!='intCityID' && theform.elements[i].name!='miles')
		{	
			theform.elements[i].selectedIndex =0;
		}
		if(theform.elements[i].type == 'text')
		{	
			if(theform.elements[i].name!='vchCountryStateCityZip' && theform.elements[i].name!='vchState' && theform.elements[i].name!='vchCity' && theform.elements[i].name!='vchZipCode')
			theform.elements[i].value='';
			
			if(theform.elements[i].name!='vchSearch')
				theform.vchSearch.value='Enter Keyword to Search';
		}
		if(theform.elements[i].type == 'hidden' && theform.elements[i].name!='PintStateID_name' && theform.elements[i].name!='PintCityID_name')
		{
			theform.elements[i].value='';
		}
	    }	

	    if (val==2)	// Advance 2 search
	    {
		if(theform.elements[i].type  == 'select-one' && theform.elements[i].name!='vchNewSearch' &&  theform.elements[i].name!='intProfessionCategoryID' && theform.elements[i].name!='intProfessionID' && theform.elements[i].name!='NewvchGender')
		{	
			theform.elements[i].selectedIndex =0;
		}
		if(theform.elements[i].type == 'text')
		{	
			if(theform.elements[i].name!='vchSearch')
			theform.elements[i].value='';
			
			if(theform.elements[i].name=='vchCountryStateCityZip')
				theform.vchCountryStateCityZip.value='City,State or Zipcode';
		}
		if(theform.elements[i].type == 'hidden' && theform.elements[i].name!='intProfessionCategoryID_name' && theform.elements[i].name!='intProfessionID_name')
		{
			theform.elements[i].value='';
		}
	    }	

	}
	xajax_clear_search_sesson(xajax.getFormValues('frmnewSearch'));
	//theform.reset();
}

function newFlashSearchReset(val)	// Flash Member Reset
{
	var theform= document.frmnewSearch;
	for(i=0;i<theform.elements.length;i++)
	{
	    if (val==1)	// Advance 1 search
	    {
		if(theform.elements[i].type  == 'select-multiple')
		{	
			theform.elements[i].selectedIndex = -1;
		}
		if(theform.elements[i].type  == 'select-one' && theform.elements[i].name!='vchNewSearch' &&  theform.elements[i].name!='FintCountryID' && theform.elements[i].name!='FintStateID' && theform.elements[i].name!='FintCityID' && theform.elements[i].name!='Fmiles')
		{	
			theform.elements[i].selectedIndex =0;
		}
		if(theform.elements[i].type == 'text')
		{	
			if(theform.elements[i].name!='vchCountryStateCityZip' && theform.elements[i].name!='FvchState' && theform.elements[i].name!='FvchCity' && theform.elements[i].name!='FvchZipCode')
			theform.elements[i].value='';
			
			if(theform.elements[i].name=='vchFlashSearch')
				theform.elements[i].value='Enter Keyword to Search';
		}
		if(theform.elements[i].type == 'hidden' && theform.elements[i].name!='FintStateID_name' && theform.elements[i].name!='FintCityID_name')
		{
			theform.elements[i].value='';
		}
	    }	

	    if (val==2)	// Advance 2 search
	    {
		if(theform.elements[i].type  == 'select-one' && theform.elements[i].name!='vchNewSearch' &&  theform.elements[i].name!='intFlashCategoryID' && theform.elements[i].name!='FvchGender')
		{	
			theform.elements[i].selectedIndex =0;
		}
		if(theform.elements[i].type == 'text')
		{	
			if(theform.elements[i].name!='vchFlashSearch')
			theform.elements[i].value='';
			
			if(theform.elements[i].name=='vchCountryStateCityZip')
				theform.elements[i].value='City,State or Zipcode';
		}
		if(theform.elements[i].type == 'hidden' && theform.elements[i].name!='intFlashCategoryID_name')
		{
			theform.elements[i].value='';
		}
	    }	

	}
	//theform.reset();
	xajax_clear_search_sesson(xajax.getFormValues('frmnewSearch'));
}

function newEducationSearchReset(val)	// Education Reset
{
	var theform= document.frmnewSearch;
	for(i=0;i<theform.elements.length;i++)
	{
	    if (val==1)	// Advance 1 search
	    {
		if(theform.elements[i].type  == 'select-multiple')
		{	
			theform.elements[i].selectedIndex = -1;
		}
		if(theform.elements[i].type  == 'select-one' && theform.elements[i].name!='vchNewSearch' &&  theform.elements[i].name!='EintCountryID' && theform.elements[i].name!='EintStateID' && theform.elements[i].name!='EintCityID' && theform.elements[i].name!='Emiles')
		{	
			theform.elements[i].selectedIndex =0;
		}
		if(theform.elements[i].type == 'text')
		{	
			if(theform.elements[i].name!='vchCountryStateCityZip' && theform.elements[i].name!='EvchState' && theform.elements[i].name!='EvchCity' && theform.elements[i].name!='EvchZipCode')
			theform.elements[i].value='';
			
			if(theform.elements[i].name=='eduvchSearch')
				theform.elements[i].value='Enter Keyword to Search';
		}
		if(theform.elements[i].type == 'hidden' && theform.elements[i].name!='EintStateID_name' && theform.elements[i].name!='EintCityID_name')
		{
			theform.elements[i].value='';
		}
	    }	

	    if (val==2)	// Advance 2 search
	    {
		if(theform.elements[i].type  == 'select-one' && theform.elements[i].name!='vchNewSearch' &&  theform.elements[i].name!='intPrimaryFilterCategoryID' && theform.elements[i].name!='intPrimaryFilter')
		{	
			theform.elements[i].selectedIndex =0;
		}
		if(theform.elements[i].type == 'text')
		{	
			if(theform.elements[i].name!='eduvchSearch')
			theform.elements[i].value='';
			
			if(theform.elements[i].name=='vchCountryStateCityZip')
				theform.elements[i].value='City,State or Zipcode';
		}
		if(theform.elements[i].type == 'hidden' && theform.elements[i].name!='intPrimaryFilterCategoryID_name' && theform.elements[i].name!='intPrimaryFilter_name')
		{
			theform.elements[i].value='';
		}
	    }	

	}
	//theform.reset();
	xajax_clear_search_sesson(xajax.getFormValues('frmnewSearch'));
}

function newTopSearch(theform,btnclick)
{
	var theform= document.frmnewSearch;
	
	for(i=0;i<theform.elements.length;i++)
	{
		if (btnclick==1)
		{
			if(theform.elements[i].type  == 'select-multiple')
			{	
				theform.elements[i].selectedIndex = -1;
			}
			if(theform.elements[i].type  == 'select-one' && theform.elements[i].name !='vchNewSearch')
			{	
				theform.elements[i].selectedIndex =0;
			}
			if(theform.elements[i].type == 'text' && theform.elements[i].name!='vchSearch' && theform.elements[i].name!='vchFlashSearch' && theform.elements[i].name!='eduvchSearch' &&  theform.elements[i].name!='vchCountryStateCityZip')
			{
				theform.elements[i].value="";
			}
		}
		if (btnclick==2)
		{
			if(theform.elements[i].name=='vchCountryStateCityZip')
				theform.elements[i].value ='City,State or Zipcode';
		}
		if (btnclick==3)
		{
			if(theform.elements[i].name=='vchCountryStateCityZip')
				theform.elements[i].value ='City,State or Zipcode';
		}
	}
	

	if (theform.vchNewSearch.value=='Professionals') {
		theform.vchFlashSearch.value="Enter Keyword to Search";
		theform.eduvchSearch.value ="Enter Keyword to Search";
	} else if (theform.vchNewSearch.value=='Members') {
		theform.vchSearch.value="Enter Keyword to Search";
		theform.eduvchSearch.value ="Enter Keyword to Search";
	} else if (theform.vchNewSearch.value=='Education') {
		theform.vchSearch.value="Enter Keyword to Search";
		theform.vchFlashSearch.value ="Enter Keyword to Search";
	}
	
		if (theform.vchNewSearch.value=='Professionals')
		{
			var first_name = theform.intProfessionID_name.value;
			var second_name = theform.intProfessionCategoryID_name.value;

			var location_city = theform.PintCityID_name.value;
			var location_state = theform.PintStateID_name.value; 
		}
		else if (theform.vchNewSearch.value=='Members')
		{
			var first_name = theform.intFlashCategoryID_name.value;
			var second_name = "";

			var location_city = theform.FintCityID_name.value;
			var location_state = theform.FintStateID_name.value; 
		}
		else if (theform.vchNewSearch.value=='Education')
		{
			var first_name = theform.intPrimaryFilter_name.value;
			var second_name = theform.intPrimaryFilterCategoryID_name.value;

			var location_city = theform.EintCityID_name.value;
			var location_state = theform.EintStateID_name.value; 
		}

		if ((btnclick==2) || (btnclick==3))
		{
			///////// Top Search Bar - PreSet
			var setSearchFeild='';
			if(first_name!='') {
				setSearchFeild =first_name;
			} 
			if(second_name!='') {
				if (setSearchFeild!='') setSearchFeild=setSearchFeild+', ';	
				setSearchFeild =setSearchFeild+second_name; 
			}
			if (setSearchFeild!='')
			{
				if (theform.vchNewSearch.value=='Professionals')
					theform.vchSearch.value=setSearchFeild;
				else if (theform.vchNewSearch.value=='Members')
					theform.vchFlashSearch.value=setSearchFeild;
				else if (theform.vchNewSearch.value=='Education')
					theform.eduvchSearch.value=setSearchFeild;
			}

			///////// Top Location bar  - PreSet
			var setLocationFeild='';
			if(location_city!='') {
				setLocationFeild =location_city;
			} 
			if(location_state!='') {
				if (setLocationFeild!='') setLocationFeild=setLocationFeild+', ';	
				setLocationFeild =setLocationFeild+location_state; 
			} 
			if (setLocationFeild!='')
			{
				theform.vchCountryStateCityZip.value=setLocationFeild;
			}
		}
		
	theform.target="_parent";
	if (theform.vchNewSearch.value=='Professionals')
	{
		theform.action="/professional/search.htm";
		document.frmnewSearch.vchFlashSearch.value='';
		document.frmnewSearch.eduvchSearch.value='';
	}
	else if (theform.vchNewSearch.value=='Education')
	{
		theform.action="/library/search.htm";
		document.frmnewSearch.vchFlashSearch.value='';
		document.frmnewSearch.vchSearch.value='';
	}
	else if (theform.vchNewSearch.value=='Members')
	{
		theform.action="/flash/search.htm";
		document.frmnewSearch.vchSearch.value='';
		document.frmnewSearch.eduvchSearch.value='';
	}

	theform.onsubmit="return true";
	theform.submit();
}

function checkautoSuggestDiv(e)
{
	var t=typeof(e);
	if (t == "undefined")
		return 0;
	else if (t == "string")
	{
		var re = document.getElementById( e );
		if (!re)
			return 0;
		else if (typeof(re.appendChild) != "undefined" )
			return re;
		else
			return 0;
	}
	else if (typeof(e.appendChild) != "undefined")
		return e;
	else
		return 0;
}

function clearAutoSuggestDivs()
{
	var p_sug = checkautoSuggestDiv("as_NEWvchSearch");
	if (p_sug) {	removeElemSearch("as_NEWvchSearch"); }

	var m_sug = checkautoSuggestDiv("as_eduNEWvchSearch");
	if (m_sug) {	removeElemSearch("as_eduNEWvchSearch"); }
	
	var e_sug = checkautoSuggestDiv("as_NEWvchFlashSearch");
	if (e_sug) {	removeElemSearch("as_NEWvchFlashSearch"); }
		
	var l_sug = checkautoSuggestDiv("as_vchCountryStateCityZip");
	if (l_sug) {	removeElemSearch("as_vchCountryStateCityZip");}
}

function removeElemSearch(ele)
{
	var e = checkautoSuggestDiv(ele);
	
	if (!e)
		return 0;
	else if (e.parentNode.removeChild(e))
		return true;
	else
		return 0;
}
