//  remember mootools is also loaded
/*  HELPER FUNCTIONS FOR THE DONATION FORM
--------------------------------------- */

function clear_other() {
	document.getElementById('other_donation').value = '';
	document.getElementById('other_donation').style.backgroundColor = "#ccc";
}
function set_other() {
	document.getElementById('other_donation').value = '';
	document.getElementById('other_donation').style.backgroundColor = "#fff";
	document.getElementById('other_donation').disabled=false;
	document.getElementById('other_checkbox').checked=true;
	document.getElementById('other_donation').focus();
}

jQuery(function(){
(function($) { // allows us to use the dollar symbol without conflicting with mootools
/*  CYCLE THE BANNER IMAGES
--------------------------------------- */
$('#banner p').cycle({
		fx: 'fade', // choose your transition type, ex: fade, scrollUp, shuffle, etc...
		timeout:5000
	});


/*  SHOW THE COLOR PICKER
--------------------------------------- */

$('#color').bind('colorpicked', function  () {
	$('html, body, #wrapper').css('background-color', $(this).val());
  });


	
/* REMOVE UNWANTED MENU ITEMS FROM THE SIDE MENU
--------------------------------------------------------------------------- */

/* code to be provided, meanwhile we will use css to hide all but the active elements */
	
	// system message - taken from german american school
 $("#system-message").css('display', 'none').fadeIn();
 setTimeout( function() { $("#system-message").fadeOut(); }, 3000);

/* FIX UP FACEBOOK FEED
--------------------------------------------------------------------------- */

// use the divs for each item to construct the links etc.
$(".facebookfeed li").each(function(){
var $this          = $(this);
var $description   = $this.find('.newsfeed_item_description');
var descriptiontext= $this.find('.newsfeed_item_description').text();
var $link          = $this.find('.newsfeed_item_link');
var linktext       = $this.find('.newsfeed_item_link').text();
var $title         = $this.find('.newsfeed_item_title');
var titletext      = $this.find('.newsfeed_item_title').text();
var descriptioncurt= descriptiontext.split(" ").slice(0,6).join(' ')+' ...'; 
$title.html( '<a href="'+linktext+'" target="_blank">'+descriptioncurt+'</a>' );
$description.hide();
$link.hide();
});

// when title clicked show the description.
$(".facebookfeed li .newsfeed_item_title a").click(function(event){
$(this).parent().parent().find('.newsfeed_item_description').toggle(400);  event.preventDefault(); 
});	

// make sure description links go to new windows.
$(".facebookfeed li .newsfeed_item_description a").attr('target','_blank');

/* ADD CLEARFIX TO ITEMS IN BLOG ENTRIES
--------------------------------------------------------------------------- */
$(".blog .item").addClass('clearfix');

/* CHANGE WORDING OF 'MORE ARTICLES'
--------------------------------------------------------------------------- */
$(".morearticles h3").html('Previously Published Articles...');

/* end of Jquery initialization
--------------------------------------------------------------------------- */


})(jQuery); 
}); // end of Jquery domready work

window.onload= function(){
// make all home page teaser articles the same height 
// this has to be done onload because otherwise heights are not yet calculated
var maxh = 0;
jQuery('.joomla.homepage .teaserarticles .item').each( function(){
var h = jQuery(this).height();
if (h>maxh) { maxh = h;};
});
jQuery('.joomla.homepage .teaserarticles .item').height(maxh);
};

/*         M O O T O O L S    I N I T I A L I Z E

SET UP TO ALLOW MODAL WINDOW POPUpS 
-----------------------------------------------------------*/
window.addEvent('domready', function(){ 
	var JTooltips = new Tips($$('.hasTip'), { maxTitleChars: 50, fixed: 'false'}); 
});

window.addEvent('domready', function() {
	SqueezeBox.initialize({});
	$$('a.modal').each(function(el) {
		el.addEvent('click', function(e) {
			new Event(e).stop();
			SqueezeBox.fromElement(el);
		}); 
	}); 
}); 

	

	




