var __global_options_data;

// ------------------------------
// Bookmark functions
// ------------------------------

function iebookmark(url, title)
{
	window.external.AddFavorite(url, title);
}

function ffbookmark()
{
	var ff = document.getElementById('fffav');
	ff.innerHTML = '<p>Type CTRL+D On Your Keyboard To Bookmark Us in FireFox</p>';
}

// --------------------------
// Search Functions
// --------------------------

function clearSearch()
{
	searchQuery = '';
	document.getElementById("NCSearchControlForm").q.value = '';
}

function focusSearch()
{
	document.getElementById("NCSearchControlForm").q.focus();
}

function search(query)
{
	var options = document.getElementById('options');
	options.innerHTML = '<p>Return to <a href="javascript:hideSearchResults();">Gallery Index</a></p>';

	showSearchResults();
	SearchControl.execute(query);
}

function hideSearchResults()
{
	document.getElementById('options').innerHTML = __global_options_data;
	document.getElementById("NCSearchResults").style.display = 'none';
	document.getElementById("thumbs").style.display = 'block';
}

function showSearchResults()
{
	// deSelectNavItems();

	document.getElementById("NCSearchResults").style.display = 'block';
	document.getElementById("thumbs").style.display = 'none';
}

function onLoad(niche)
{
	if(window.external) {
		var ve = window.external;
		if(typeof(ve.AddFavorite) != 'undefined') {
			document.getElementById('iefav').style.display = 'block';
		}
	}

	if(navigator.userAgent.indexOf('Firefox') != -1) {
		document.getElementById('fffav').style.display = 'block';
	}

	var searcher = new Searcher();
	SearchControl = new SearchControl('javascript:search(document.getElementById(\'NCSearchControlForm\').q.value);', true, 25);

	if(niche) {
		searcher.niche = niche;
	}

	SearchControl.addSearcher(searcher);
	SearchControl.draw(document.getElementById('SearchControl'));

	document.getElementById('NCSearchResults').style.display = 'none';

	__global_options_data = document.getElementById('options').innerHTML;
}
