/*
File: jquery.config.js
Copyright: (c) 2011 Brand Rich Media
Author: Brandon Neil Richards
Author URI: http://www.brandrichmedia.com/
*/
// callback functions

$(function() 
{
		
		// overlays
		$("#team a[rel],#galleries a[rel], #media-port-tabs a[rel]").overlay(
			{
				mask: '#000', 
				top: 'center',
				close: '#close'
			});
		
		var tabContainers = $('#testimony, #submit');
		// on click show tab
				$('#tab-containers a').click(function () {
				        tabContainers.hide().filter(this.hash).show();
				        $('#tab-containers a').removeClass('selected');
				        $(this).addClass('selected');
				        return false;
				    }).filter(':first').click();

		$('#donate').submit(function() {
         $('input[type=submit]').attr('value','Processing').attr('disabled', 'disabled');
      	});
		
		// media
		$('.show-body').hide();
		$('#show-more').click(function() {
  			$('.show-body').slideDown('slow',function()
  			{
  				$('.show-summary').hide();
  				$('#show-more').parent().fadeOut('slow');
  			});
  			return false;
		});
		
		//upcoming trips show/hide
		$('.hidden,.trip-button').hide();
		$(".trip").hover(
		  function () {
		    $(this).find(".hidden").slideToggle(400);
		    $(this).find(".trip-button").fadeToggle("slow", "linear");
		  }, 
		  function () {
		  	$(this).find('.hidden').slideToggle(400);
		  	$(this).find(".trip-button").fadeToggle("slow", "linear");
		  }
		);
		
		// dropdowns
		$('.dropdown').each(function () {
				$(this).parent().eq(0).hover(function () {
					$('.dropdown:eq(0)', this).slideDown('fast');
				}, function () {
					$('.dropdown:eq(0)', this).slideUp('fast');
				});
		});
		
		// jquery.cycle.min.js
		$('#main-container .slides').cycle({
			fx:     'fade', 
	    	timeout: 5000,
	 		pause: 1,
	 		pager: '#slide-toggle ul',
	 		pagerAnchorBuilder: function(idx, slide) { 
	 		        return '<li><a href="#" class="item"></a></li>';}
		});
		
		$('.quote-media').cycle({
			fx:	'scrollDown',
			timeout: 7500
		});
		
		
		// remove input text
		$('.rmv').click(function() {
			if (this.value == this.defaultValue) {
				this.value = '';
			}
		});
		
		$('.rmv').blur(function() {
			if (this.value == '') {
				this.value = this.defaultValue;
			}
		});
		
		//open windows without embedding target="_blank"				
		$('a[rel="external"]').each(function() {
			$(this).attr('target', '_blank');
		});		
		
		$(".recent-article").click(function(){
		      window.location = $(this).children().find(".thehref").attr("href")
		   });
		
		//toggle archives
		$("#2007, #2008, #2009,#2010").siblings().hide();
		//toggle the componenet
		$("#2007, #2008, #2009, #2010").click(function()
		{
			$(this).siblings().slideToggle(600);
		});

		//add hand icon to event selectors
		$('.recent-article').hover(function() 
		{
			$(this).addClass('hand');
		}, function() {
			$(this).removeClass('hand');
		});
		

});
