/************************************************************************
 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.Fade = function(element) {
	
	element = $(element);
	if(!element)
		return;
	
	var oldOpacity = Element.getInlineOpacity(element);
	$(element).effect('opacity').start(1, 0).chain(function() {
		element.style.display = 'none';
		element.setStyle('opacity', oldOpacity);
	});
}

Effect.Appear = function(element) {
	
	element = $(element);
	if(!element)
		return;
	
	var oldOpacity = Element.getInlineOpacity(element);
	element.setStyle('opacity', 0);
	element.style.display = 'block';
	$(element).effect('opacity').start(0, 1).chain(function() {
		element.setStyle('opacity', oldOpacity);
	});
}

function createBookmark() {
	
	title = "The Playground Creative"; 
	url = "http://www.playgroundcreative.com";
	
	if (window.sidebar) // firefox
		window.sidebar.addPanel(title, url, "");
	else if(document.all) // ie
		window.external.AddFavorite(url, title);
	else if(window.opera && window.print) { // opera
		var elem = document.createElement('a');
		elem.setAttribute('href',url);
		elem.setAttribute('title',title);
		elem.setAttribute('rel','sidebar');
		elem.click();
	}
}
