if(!window.DOMInitialised)
{
	Event.onDOMReady(init_search_form);
}
else
{
	window.setTimeout(init_search_form, 1);
}

function init_search_form()
{
	Event.observe(window, 'resize', checkFormSize, false);
	Event.observe(window, 'load', checkFormSize, false);
	$('toggle_advanced').observe('click', toggleAdvancedOptions, false);
};

function checkFormSize(evt)
{
	var small = false;
	
	if(typeof window.innerWidth != 'undefined' && window.innerWidth < 1102)
	{
		small = true;
	}
	else if(typeof document.documentElement.clientWidth != 'undefined' && document.documentElement.clientWidth < 1102)
	{
		small = true;
	}
	
	if(small)
	{
		$('main').style.backgroundImage = 'none';
		$$('#main .right_col')[0].style.display = 'none';
		$('content').style.marginRight = '80px';
	}
	else
	{
		$('main').style.backgroundImage = '';
		$$('#main .right_col')[0].style.display = '';
		$('content').style.marginRight = '';
	}
};

function toggleAdvancedOptions(evt)
{
	if($F('show_advanced') == '1')
	{
		$('show_advanced').value = '0';
		
		$A(document.getElementsByClassName('advanced')).each(function (obj) { obj.removeClassName('show'); });
	}
	else
	{
		$('show_advanced').value = '1';
	
		$A(document.getElementsByClassName('advanced')).each(function (obj) { obj.addClassName('show'); });
	}
	
	Event.stop(evt);
};