function hideCrumbs(type)
{
	hideShowLayer('quickCrumbResults','HIDE');
	hideShowLayer('serviceCrumbResults','HIDE');
	hideShowLayer('keywordCrumbResults','HIDE');
	hideShowLayer('servFocusCrumbResults','HIDE');
	hideShowLayer('providerCrumbResults','HIDE');
	hideShowLayer('healthCrumbResults','HIDE');
	hideShowLayer('pracFocusCrumbResults','HIDE');
	
	hideShowLayer(type + 'CrumbResults','SHOW');
}
function servfocusSearchOption(type)
{
	document.servfocusForm.rn.value = GetCookie('ISS_SUBURB');
	SetCookie('ISS_SEARCH', type, null, '/');
	focus_onLoad();
	// Reset options (e.g. when going 'back' in browser)
	var e = document.getElementById('ServFocus1');
	e.selectedIndex = 0;
	e.focus();
	
}

function keywordSearchOption(type)
{
	document.keywordForm.rn.value = GetCookie('ISS_SUBURB');
	SetCookie('ISS_SEARCH', type, null, '/');
	setwidth("keyword_search", getwidth("keyword_list"));
	document.keywordForm.keyword_list.focus();
}

function healthSearchOption(type)
{
        document.pract_search_form.rn.value = GetCookie('ISS_SUBURB');
	SetCookie('ISS_SEARCH', type, null, '/');
	document.pract_search_form.agency.focus();
}

function pracfocusSearchOption(type)
{
        document.practFocusForm.rn.value = GetCookie('ISS_SUBURB');
	SetCookie('ISS_SEARCH', type, null, '/');
	pract_onLoad();
	// Reset options (e.g. when going 'back' in browser)
	var e = document.getElementById('PractFocus1');
	e.selectedIndex = 0;
	e.focus();
	document.getElementById('PractFocusGender').selectedIndex = 0;
	document.getElementById('PractFocusLanguage').selectedIndex = 0;
}

function serviceSearchOption(type)
{
        document.service_input.rn.value = GetCookie('ISS_SUBURB');
	SetCookie('ISS_SEARCH', type, null, '/');
	document.service_input.sname.focus();
}

function quickSearchOption(type)
{
  SetCookie('ISS_SEARCH', type, null, '/');
  document.quickForm.text.focus();
	var args = getArgs();
	var suburb;
  if ((GetCookie('ISS_SUBURB') == 'undefined') || (args.suburb))
	{
			if (args.suburb) 
			   suburb = args.suburb;
			if (suburb != '')
			{
			   document.quickForm.rn.value = suburb;
			   SetCookie('ISS_SUBURB',suburb, null, '/');
			}																
	}
	else
	    document.quickForm.rn.value = GetCookie('ISS_SUBURB');
}
																										 
function providerSearchOption(type)
{
        document.agency_input.rn.value = GetCookie('ISS_SUBURB');
	SetCookie('ISS_SEARCH', type, null, '/');
	document.agency_input.agency.focus();
}

function hideShowServiceFocusTip(doWhat)
{

        if (doWhat == 'SHOW')
        {
                hideShowField('ServFocus1_Layer','HIDE')
                hideShowField('ServFocus2_Layer','HIDE')
                hideShowField('ServFocus3_Layer','HIDE')
                hideShowField('ServGender','HIDE')
                hideShowTip('servfocus_tip','SHOW')
        }
        else
        {
                hideShowField('ServFocus1_Layer','SHOW')
                hideShowField('ServFocus2_Layer','SHOW')
                hideShowField('ServFocus3_Layer','SHOW')
                hideShowField('ServGender','SHOW')
                hideShowTip('servfocus_tip','HIDE')
        }
}

function hideShowPractFocusTip(doWhat)
{

  if (doWhat == 'SHOW')
  {
    hideShowField('PractFocus1_Layer','HIDE')
    hideShowField('PractFocus2_Layer','HIDE')
    hideShowField('PractGender','HIDE')
    hideShowField('PractLanguage','HIDE')
    hideShowTip('practFocus_tip','SHOW')
  }
  else
  {
    hideShowField('PractFocus1_Layer','SHOW')
    hideShowField('PractFocus2_Layer','SHOW')
    hideShowField('PractGender','SHOW')
    hideShowField('PractLanguage','SHOW')
    hideShowTip('practFocus_tip','HIDE')
  }
}

//////////////////////////////////////////////////////////////////////

function showSearchHelp()
{
		var search = GetCookie('ISS_SEARCH');

	if (search == '' || search == 'Quick Search')
	{
		spawnwindow('http://www.serviceseeker.com.au/help/quicksearch_help.htm');
	}
	else if (search == 'Service Focus')
	{
		spawnwindow('http://www.serviceseeker.com.au/help/service_focus_help.htm');
	}
	else if (search == 'Service Provider')
	{
		spawnwindow('http://www.serviceseeker.com.au/help/provider_help.htm');
	}
	else if (search == 'Service Name')
	{
		spawnwindow('http://www.serviceseeker.com.au/help/service_name_help.htm');
	}
	else if (search == 'Keyword')
	{
		spawnwindow('http://www.serviceseeker.com.au/help/keyword_help.htm');
	}
	else if (search == 'Health Practitioner')
	{
		spawnwindow('http://www.serviceseeker.com.au/help/prac_name_help.htm');
	}
	else if (search == 'Practitioner Focus')
	{
		spawnwindow('http://www.serviceseeker.com.au/help/prac_focus_help.htm');
	}
}

function hideVacancy()
{
	if(document.getElementById('VIC').style.display == 'none')
	{
		var divs = getElementsByClassName("vacancyLink", "div");
		for (var i = 0; i < divs.length; i++) {
			divs[i].style.display = 'none';
		}
		divs = getElementsByClassName("vacancyGroup", "td");
		for (var i = 0; i < divs.length; i++) {
			divs[i].style.border_right = '0px';
			divs[i].style.border_top = '0px';
		}
	}
	else
	{
		var divs = getElementsByClassName("vacancyLink", "div");
		for (var i = 0; i < divs.length; i++) {
			divs[i].style.display = 'block';
		}
	}
		
}

function hideShowServiceKeywordTip(doWhat)
{
        if (doWhat == 'SHOW')
        {
                hideShowField('keywordList','HIDE');
                hideShowTip('keyword_tip','SHOW');
        }
        else
        {
                hideShowField('keywordList','SHOW');
                hideShowTip('keyword_tip','HIDE');
        }
}

function hideShowOptions(hide)
{
	var shown = getElementsByClassName("searchOptions", "div");
	var hidden = getElementsByClassName("showOptions", "div");
	
	for (var i = 0; i < shown.length; i++) {
		if (shown[i].style.display == 'block' || hide == 'HIDE')
		{
			shown[i].style.display = 'none';
			hidden[i].style.display = 'block';
		}
		else
		{
			shown[i].style.display = 'block';
			hidden[i].style.display = 'none';
		}
	}
}

function setTargetGroup()
{
	var elems = getElementsByClassName('targetGroupOption', 'div', document.quickForm);
	for (var i = 0; i < elems.length; i++) {
		elems[i].style.display = 'block';
	}

	var elems = getElementsByClassName('targetGroupOption', 'div', document.keywordForm);
	for (var i = 0; i < elems.length; i++) {
		elems[i].style.display = 'block';
	}
}

function setHeadingResults(type) {
	var e = document.getElementById('typeHeading');
	switch (type) {
	case 'quick':
		e.innerHTML = 'Quick Search  Results';
		break;
	case 'provider':
		e.innerHTML = 'Service Provider Search Results';
		break;
	case 'servFocus':
		e.innerHTML = 'Service Focus Search Results';
		break;
	case 'keyword':
		e.innerHTML = 'Service Keyword Search Results';
		break;
	case 'service':
		e.innerHTML = 'Service Name Search Results';
		break;
	case 'health':
		e.innerHTML = 'Health Practitioner Name Search Results';
		break;
	case 'pracFocus':
		e.innerHTML = 'Health Practitioner Focus Search Results';
		break;
	}
}

//
// Change to a particular state
//
function setState(state, leaveSuburb)
{
	state = state.toUpperCase();

	if (!leaveSuburb) {
		// Set suburb to blank
		changeAllSuburbs('');
		SetCookie('ISS_SUBURB', '');
	}
	
	//
	// Save our chosen State
	//
	var one_year = new Date();
	one_year.setDate(one_year.getDate() + 365);
	SetCookie('ISS_STATE', state, one_year);

	//
	// Record our chosen state in all forms
	//
	for (var i = 0; i < document.forms.length; ++i) {
		if (document.forms[i].state) {
			document.forms[i].state.value = state;
		}
	}
	hideVacancy();
}
