$(function(){

/* --------------------------------------------------------- 
       PNG TRANSPARENCY FIX FOR IE6 
	 --------------------------------------------------------- */

$(document).pngFix();

/* ---------------------------------------------------------
        ADD ACTIVE CLASSES DEPENDING ON PAGE ID
		  
		  remove all class active
		  add class active for this page
		  if this page has a submenu
		  		add class active for parent
				copy title and clone submenu to sidemenu			
   --------------------------------------------------------- */

		var thislistitem = $('ul.tabs li.'+page);
		var hassubmenu = thislistitem.hasClass('subtab');
		
/* ---------------------------------------------------------
  		make LI active
	--------------------------------------------------------- */
 		thislistitem.addClass('active');
						

		if (hassubmenu) {
			var submenu = thislistitem.parent();
			var submenuhead =  submenu.parent().attr('rel'); 
/* ---------------------------------------------------------
        MAKE PARENT ACTIVE, if this is submenu
   --------------------------------------------------------- */
			submenu.parent().addClass('active');
/* ---------------------------------------------------------
        ADD SIDEMENU TITLE AS H3
   --------------------------------------------------------- */
		  $('<h3>').append(submenuhead).appendTo('#navsidebar');
 
/* ---------------------------------------------------------
        CLONE SUBMENU TO SIDEBAR
   --------------------------------------------------------- */
			submenu.clone().appendTo('#navsidebar');
/* ---------------------------------------------------------
        REMOVE subtabs CLASS ON SIDEBAR MENU
   --------------------------------------------------------- */
 			$('#navsidebar ul').removeClass('subtabs').addClass('submenu');
		}
/* ---------------------------------------------------------
        SET WRAPPER CLASS
   --------------------------------------------------------- */
 		$('#wrapper').addClass((hassubmenu)?'twocolumns':'onecolumn');
		if ( page=='home') { $('#wrapper').addClass('homepage')};
			
/* ---------------------------------------------------------
        ADD RANDOM COMMENT
   --------------------------------------------------------- */
		$('#whyigive').load('quotes.html #quotelist ul', function(){
				var qs = $('#whyigive li');
				var nq = qs.length;
				var rnd = Math.floor(Math.random()*nq);
				qs.hide();
				qs.eq(rnd).show();
		});			
/*				
	 ---------------------------------------------------------
        POPUPS
   --------------------------------------------------------- 
*/ 		  
		$('a.popup').click(function(){ 
					window.open(this.href, 
						'_blank',
						'menubar=yes,scrollbars=yes,resizable=yes,width=960,height=680');
					return false;
				});
		$('a.popupSmall').click(function(){ 
					window.open(this.href, 
								'_blank',
								'menubar=yes,scrollbars=yes,resizable=yes,width=600,height=280');
					return false;
				});
		$('a.popupVideo').click(function(){ 
					window.open(this.href, 
								'_blank',
								'menubar=yes,scrollbars=yes,resizable=yes,width=650,height=500');
					return false;
				});
		$('a.popupForm').click(function(){ 
					window.open(this.href, 
								'_blank',
								'menubar=yes,scrollbars=yes,resizable=yes,width=700,height=450');
					return false;
				});
		
/*				
	 ---------------------------------------------------------
        SHOW QUOTE ACCORDION LIKE BEHAVIOR
   --------------------------------------------------------- 
*/

	$('li.showquote a ').click(function(){			
			$(this).siblings().toggleClass('hide');
			return false;
			});

/*				
	 ---------------------------------------------------------
        HIGHLIGHT WHEN BOTTOM HOMEPAGE PANELS HOVERED OVER
   --------------------------------------------------------- 
*/

    $('#homepagebottom div.imagemodule').hover(
				function(){ $(this).css('opacity', .8).toggleClass('highlit')},
				function(){ $(this).css('opacity', 1).toggleClass('highlit')});
	
/*				
	 ---------------------------------------------------------
        AMEND DETAILS IN FOOTER - 
		THIS SAVES UPDATING ALL PAGES WITH TEMPLATE
		AND POSSIBLY DISTURBING THE ADOBE ICE SETTINGS
   --------------------------------------------------------- 


    $('#footer').html('<div id="footer">Church of the Pioneers Foundation&nbsp;&nbsp;|&nbsp;&nbsp;Phone (650) 324-1365&nbsp;&nbsp;|&nbsp;&nbsp;Email <a href="mailto:contact@churchofthepioneers.org">contact@churchofthepioneers.org</a></div>');*/

});



