function switchBackground(background)
{
	$('container').setStyle({
		backgroundImage: 'url(' + background + ')'
	});
}

function updateHousesFoundComplete() {
	objHousesFound = $('houses_found');
	objHousesFoundRatio = $('houses_found_ratio');
	
	ratio = parseFloat(objHousesFoundRatio.readAttribute('ratio'));
	rangeStart = objHousesFound.getWidth() / 2;
	rangeStop = 500 - objHousesFound.getWidth() / 2;
	pos = (rangeStop - rangeStart) * ratio;
	
	objHousesFoundPos = objHousesFound.positionedOffset();
	objHousesFound.setStyle({left: objHousesFoundPos[0] + 'px', right: 'auto'});
	new Effect.Move(objHousesFound, {x: pos, y: 0, mode: 'absolute'});
	
	new Effect.Pulsate($('houses_found_submit'), {from: 0.5, pulses: 4});
}

/**
 * Shows a loading element on top of another element
 */
function showLoading(parent, text) {
	var parent = $(parent);
	
	// Hide
	hideLoading(parent);

	// Create container text div
	var containerText = new Element('div', {'class': 'loadingText'});
	containerText.setAttribute('id', parent.id + '_loadingText');
	containerText.appendChild(document.createTextNode(text));
	containerText.hide();

	// Create container div
	var container = new Element('div', {'class': 'loading'});
	container.setAttribute('id', parent.id + '_loading');
	container.appendChild(containerText);
	container.hide();

	// Add container div
	container.className='loading';
	containerText.className='loadingText';
	parent.parentNode.appendChild(container);
	parent.parentNode.appendChild(containerText);
	
	// Position
	if(/*Prototype.Browser.IE && */parent.parentNode.nodeName.toLowerCase() == 'body') {
		// Fix for IE with Prototype
		container.style.top = '0';
		container.style.left = '0';
		container.style.height = (typeof(window.innerWidth) == 'number' ? window.innerWidth : document.documentElement.scrollHeight) + 'px';;
		container.style.width = '100%';
		
		containerText.style.top = (showLoadingYOffset() + (document.documentElement.clientHeight - containerText.getHeight()) / 2) + 'px';
		containerText.style.left = ((document.body.clientWidth - containerText.getWidth()) / 2) + 'px';
	} else {
		container.clonePosition(parent);
		containerText.clonePosition(parent, {'setWidth': false, 'setHeight': false, 'offsetLeft': (container.getWidth() - containerText.getWidth()) / 2, 'offsetTop': (Math.min(container.getHeight(), document.viewport.getHeight()) - containerText.getHeight()) / 2});
	}
	
	// Show
	container.show();
	containerText.show();
}

function showLoadingYOffset() {
	if( typeof( window.pageYOffset ) == 'number' ) {
		//Netscape compliant
		return window.pageYOffset;
	} else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
		// DOM compliant
		return document.body.scrollTop;
	} else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
		// IE6 standards compliant
		return document.documentElement.scrollTop;
	}
	return 0;
}

function hideLoading(parent) {
	var parent = $(parent);
	var container = $(parent.id + '_loading');
	var containerText = $(parent.id + '_loadingText');
	
	// Remove
	if(containerText !== null)
		containerText.remove();
	
	if(container !== null)
		container.remove();
}

/**
 * Hides/shows not_clean div for review
 */
function showNotClean(id)
{
	if (id == "Y")
	{
		$('not_clean').appear();
	}
	else
	{
		$('not_clean').fade();
	}
	return false;
}