function showSearchSpinner() {
	document.getElementById('searchOpen').src =
		'/images/common/spinner_search.gif';
}

function hideSearchSpinner() {
	document.getElementById('searchOpen').src =
		'/images/common/icons/search_open.gif';
}

function initIEBugParam() {
	try {
		if (safeFromIEBug()) {
			return 'no_ie_bug=true';
		}
	} catch (e) {}

	return 'no_ie_bug=false';
}

function initAdvancedParams(type) {
	mode  = 'mode=' + type;
	iebug = initIEBugParam();

	return mode + '&' + iebug;
}

function initAdvanced(type) {
	new Ajax.Request('/apps/redlist/search/keywords/advanced', {asynchronous:true, evalScripts:true, parameters:initAdvancedParams(type) + '&authenticity_token=' + encodeURIComponent('Aif/VbG7B8P8Q3zcLEErPFankylKwWXHucIiN3Isu+A=')})
}

function initAdvancedTab(state) {
	id = state.bodyName;

	if (id == 'advKeywords') {
		new Ajax.Request('/apps/redlist/search/keywords/body', {asynchronous:true, evalScripts:true, method:'get', onLoaded:function(request){showAdvTabReady(state)}, parameters:'authenticity_token=' + encodeURIComponent('Aif/VbG7B8P8Q3zcLEErPFankylKwWXHucIiN3Isu+A=')})
	} else if (id == 'advTaxonomy') {
		new Ajax.Request('/apps/redlist/search/taxonomy/body', {asynchronous:true, evalScripts:true, method:'get', onLoaded:function(request){showAdvTabReady(state)}, parameters:'authenticity_token=' + encodeURIComponent('Aif/VbG7B8P8Q3zcLEErPFankylKwWXHucIiN3Isu+A=')})
	} else if (id == 'advLocation') {
		new Ajax.Request('/apps/redlist/search/location/body', {asynchronous:true, evalScripts:true, method:'get', onLoaded:function(request){showAdvTabReady(state)}, parameters:'authenticity_token=' + encodeURIComponent('Aif/VbG7B8P8Q3zcLEErPFankylKwWXHucIiN3Isu+A=')})
	} else if (id == 'advMap') {
		new Ajax.Request('/apps/redlist/search/map', {asynchronous:true, evalScripts:true, method:'get', onLoaded:function(request){showAdvTabReady(state)}, parameters:'authenticity_token=' + encodeURIComponent('Aif/VbG7B8P8Q3zcLEErPFankylKwWXHucIiN3Isu+A=')})
	} else if (id == 'advSystems') {
		new Ajax.Request('/apps/redlist/search/systems/body', {asynchronous:true, evalScripts:true, method:'get', onLoaded:function(request){showAdvTabReady(state)}, parameters:'authenticity_token=' + encodeURIComponent('Aif/VbG7B8P8Q3zcLEErPFankylKwWXHucIiN3Isu+A=')})
	} else if (id == 'advHabitats') {
		new Ajax.Request('/apps/redlist/search/habitats/body', {asynchronous:true, evalScripts:true, method:'get', onLoaded:function(request){showAdvTabReady(state)}, parameters:'authenticity_token=' + encodeURIComponent('Aif/VbG7B8P8Q3zcLEErPFankylKwWXHucIiN3Isu+A=')})
	} else if (id == 'advThreats') {
		new Ajax.Request('/apps/redlist/search/threats/body', {asynchronous:true, evalScripts:true, method:'get', onLoaded:function(request){showAdvTabReady(state)}, parameters:'authenticity_token=' + encodeURIComponent('Aif/VbG7B8P8Q3zcLEErPFankylKwWXHucIiN3Isu+A=')})
	} else if (id == 'advAssessment') {
		new Ajax.Request('/apps/redlist/search/assessment/body', {asynchronous:true, evalScripts:true, method:'get', onLoaded:function(request){showAdvTabReady(state)}, parameters:'authenticity_token=' + encodeURIComponent('Aif/VbG7B8P8Q3zcLEErPFankylKwWXHucIiN3Isu+A=')})
	} else if (id == 'advHistory') {
		new Ajax.Request('/apps/redlist/search/history/body', {asynchronous:true, evalScripts:true, method:'get', onLoaded:function(request){showAdvTabReady(state)}, parameters:'authenticity_token=' + encodeURIComponent('Aif/VbG7B8P8Q3zcLEErPFankylKwWXHucIiN3Isu+A=')})
	}
}

function refreshAdvancedTab(state) {
	id = state.bodyName;

	if (id == 'advKeywords') {
		new Ajax.Request('/apps/redlist/search/keywords/refresh', {asynchronous:true, evalScripts:true, method:'get', onLoaded:function(request){showAdvTabRefreshed(state)}, parameters:'authenticity_token=' + encodeURIComponent('Aif/VbG7B8P8Q3zcLEErPFankylKwWXHucIiN3Isu+A=')})
	} else if (id == 'advTaxonomy') {
		new Ajax.Request('/apps/redlist/search/taxonomy/refresh', {asynchronous:true, evalScripts:true, method:'get', onLoaded:function(request){showAdvTabRefreshed(state)}, parameters:'authenticity_token=' + encodeURIComponent('Aif/VbG7B8P8Q3zcLEErPFankylKwWXHucIiN3Isu+A=')})
	} else if (id == 'advLocation') {
		new Ajax.Request('/apps/redlist/search/location/refresh', {asynchronous:true, evalScripts:true, method:'get', onLoaded:function(request){showAdvTabRefreshed(state)}, parameters:'authenticity_token=' + encodeURIComponent('Aif/VbG7B8P8Q3zcLEErPFankylKwWXHucIiN3Isu+A=')})
	} else if (id == 'advMap') {
		new Ajax.Request('/apps/redlist/search/map', {asynchronous:true, evalScripts:true, method:'get', onLoaded:function(request){showAdvTabRefreshed(state)}, parameters:'authenticity_token=' + encodeURIComponent('Aif/VbG7B8P8Q3zcLEErPFankylKwWXHucIiN3Isu+A=')})
	} else if (id == 'advHabitats') {
		new Ajax.Request('/apps/redlist/search/habitats/refresh', {asynchronous:true, evalScripts:true, method:'get', onLoaded:function(request){showAdvTabRefreshed(state)}, parameters:'authenticity_token=' + encodeURIComponent('Aif/VbG7B8P8Q3zcLEErPFankylKwWXHucIiN3Isu+A=')})
	} else if (id == 'advThreats') {
		new Ajax.Request('/apps/redlist/search/threats/refresh', {asynchronous:true, evalScripts:true, method:'get', onLoaded:function(request){showAdvTabRefreshed(state)}, parameters:'authenticity_token=' + encodeURIComponent('Aif/VbG7B8P8Q3zcLEErPFankylKwWXHucIiN3Isu+A=')})
	} else if (id == 'advAssessment') {
		new Ajax.Request('/apps/redlist/search/assessment/refresh', {asynchronous:true, evalScripts:true, method:'get', onLoaded:function(request){showAdvTabRefreshed(state)}, parameters:'authenticity_token=' + encodeURIComponent('Aif/VbG7B8P8Q3zcLEErPFankylKwWXHucIiN3Isu+A=')})
	} else if (id == 'advHistory') {
		new Ajax.Request('/apps/redlist/search/history/refresh', {asynchronous:true, evalScripts:true, method:'get', onLoaded:function(request){showAdvTabRefreshed(state)}, parameters:'authenticity_token=' + encodeURIComponent('Aif/VbG7B8P8Q3zcLEErPFankylKwWXHucIiN3Isu+A=')})
	}
}