var realSimpleFaceliftImagesFolder = 'http://img.timeinc.net/realsimple/i/facelift/';

tii_callFunctionOnWindowLoad (function ()
{
	rs_focusSearchBox ();
});

function rs_focusSearchBox ()
{
	var search_box = document.getElementById ('search_box');
	if (search_box)
	{
		search_box.focus ();
	}
}

tii_callFunctionOnElementLoad ('top_searches_five_ideas', function ()
{
	var wait = setTimeout (function ()
	{
		rs_setTSFIWidget ();
	}, 10);
});

function rs_setTSFIWidget ()
{
	var top_searches = document.getElementById ('top_searches');
	var five_ideas = document.getElementById ('five_ideas');
	var top_searches_tab = document.getElementById ('top_searches_tab');
	var five_ideas_tab = document.getElementById ('five_ideas_tab');
	if (top_searches && five_ideas && top_searches_tab && five_ideas_tab)
	{
		tii_addEventHandler (top_searches_tab, 'click', function (event)
		{
			performSwitch (event, top_searches_tab);
		}, false);
		tii_addEventHandler (five_ideas_tab, 'click', function (event)
		{
			performSwitch (event, five_ideas_tab);
		}, false);
	}
	function performSwitch (event, tab)
	{
		if (tab.className == 'inactive')
		{
			var isTopSearchesTab = tab == top_searches_tab;
			var otherTab;
			var div;
			var otherDiv;
			if (isTopSearchesTab)
			{
				otherTab = five_ideas_tab;
				div = top_searches;
				otherDiv = five_ideas;
			}
			else
			{
				otherTab = top_searches_tab;
				div = five_ideas;
				otherDiv = top_searches;
			}
			tab.className = '';
			otherTab.className = 'inactive';
			div.className = '';
			otherDiv.className = 'inactive';
		}
		tii_stopDefaultAction (event);
	}
}