function getOffers(l,t,b)
{
	new Ajax.Request('get-offers.php',{
		method: 'post', 
		parameters: {
			'location': l,
			'type': t,
			'brand': b
		},
		onSuccess: function(transport){
			$('popup').update(transport.responseText);
			hideBoxes('loc','type','brand');
		},
		onFailure: function(transport){
			$('popup').update('There are no offers that match your search criteria');
		},
		onLoading: function(transport){
			$('popup_wrapper').show();
			//$('home-maplink').hide();
			$('popup').update('Loading...');
		}
	});
	
}

function hideBoxes(id1,id2,id3){
	$(id1).hide();
	$(id2).hide();
	$(id3).hide();
}

function showBoxes(id1,id2,id3){
	$(id1).show();
	$(id2).show();
	$(id3).show();
}

function openPopup()
{
	$('bot-shadow').hide();
	$('footer').hide();
	$('footer-pop-up').show();
	//$('home-maplink').hide();
	$$('body').each(function(e){
		e.setStyle({'backgroundImage':"url('assets/extended_bg.gif')", 'backgroundRepeat':'repeat-y', 'backgroundPosition':'top center'})
	});
}

function closePopup()
{
	$('bot-shadow').show();
	$('footer').show();
	$('footer-pop-up').hide();
	//$('home-maplink').show();
	document.forms.searcharea.reset();
	$$('body').each(function(e){
		e.setStyle({'backgroundImage':"", 'backgroundRepeat':'repeat-y', 'backgroundPosition':'top center'})
	});
}
function preload() {
  if (!document.images) return;
  var ar = new Array();
  var arguments = preload.arguments;
  for (var i = 0; i < arguments.length; i++) {
    ar[i] = new Image();
    ar[i].src = arguments[i];
  }
}

function whichChosen(varId){
	if ($(varId).value.blank())
	{
		$('type').disabled = false;
		$('brand').disabled = false;
		$('loc').disabled = false;
	} else {
		$('type').disabled = true;
		$('brand').disabled = true;
		$('loc').disabled = true;
		$(varId).disabled = false;
	}
}
function clearDisabled(){
		$('type').enable();
		$('brand').enable();		
		$('loc').enable();			
}