/************************************************************************
 globalUtilities.js
 jpl 4/16/08
 
	Suite of global JavaScript functions specific to rent-a-brit.
	
	void			swapSections(oldSection, newSection)
	
************************************************************************/
	
	function swapSections(oldSection, newSection) {
		
		oldSection = $(oldSection);
		newSection = $(newSection);
		
		oldSection.effect('opacity').start(1,0).chain(function() {
			newSection.style.visibility = 'hidden';
			oldSection.style.display = 'none';
			newSection.style.display = '';
			newSection.effect('opacity').start(0, 1);
		});
	}
	
	function disableForm(theForm) {
		theForm.getFormElements().each( function(theElement) {
			theElement.disabled = true;
		});
	}
	
	
var Effect = {};

Element.getInlineOpacity = function(element){
  return $(element).getStyle('opacity');
}
	
Effect.Appear = function(element) {
	element = $(element);
	if(!element)
		return;
	
	var oldOpacity = Element.getInlineOpacity(element);
	$(element).effect('opacity').start(oldOpacity, 1).chain(function() {
		element.style.display = 'block';
		element.setStyle('opacity', oldOpacity);
	});
}

Effect.Fade = function(element) {
	
	element = $(element);
	if(!element)
		return;
	
	var oldOpacity = Element.getInlineOpacity(element);
	$(element).effect('opacity').start(oldOpacity, 0).chain(function() {
		element.style.display = 'none';
		element.setStyle('opacity', oldOpacity);
	});
  
}
