// CCCC Initialize jQuery JavaScript Document
$(document).ready(function(){
		
		$('a[rel="external"]').click( function() {
			window.open( $(this).attr('href') );
			return false;
    	});	
		
		$('.btn-slide').click(function(event) {
				$('#panel').fadeIn("slow");
            },
            function () {} // Because the hover method has a mouseout state we need to define too
        );
		
		$('img#print_icon').click( function() {
			window.print();
    	});	
		
		$('img#firstStepButtonIMG').hoverIntent(function() {
			$(this).attr("src","/images/firstStepButton_on-spanish.gif");
				}, function() {
			$(this).attr("src","/images/firstStepButton-spanish.gif");
		});
		
		$('img#btn_submitStory').hoverIntent(function() {
			$(this).attr("src","/images/btn_submitStory_on.jpg");
				}, function() {
			$(this).attr("src","/images/btn_submitStory.jpg");
		});
		
		//Dropdown/hover for menu
		$('#cssdropdown li.headlink').hoverIntent(
			function() { $('ul', this).fadeIn("slow"); },
			function() { $('ul', this).fadeOut("slow"); }
		);
		
		$('#cssdropdown li.headlink ul li').hoverIntent(function() {
			$(this).addClass('hover');
		}, function() {
			$(this).removeClass('hover');
		});
				
		$('img#aboutUsLink').hoverIntent(function() {
			$(this).attr("src","/images/aboutUs-nosotros-btn-over.gif");
				}, function() {
			$(this).attr("src","/images/aboutUs-nosotros-btn.gif");
		});
		
		$('ul.aboutUs-subLink li.page_item').hoverIntent(function() {
			$('img#aboutUsLink').attr("src","/images/aboutUs-nosotros-btn-over.gif");
				}, function() {
			$('img#aboutUsLink').attr("src","/images/aboutUs-nosotros-btn.gif");
		});

		$('img#teachingsLink').hoverIntent(function() {
			$(this).attr("src","/images/catholicTeachings-EnsenanzasCatolicas-btn-over.gif");
				}, function() {
			$(this).attr("src","/images/catholicTeachings-EnsenanzasCatolicas-btn.gif");
		});
		
		$('ul.teachings-subLink li.page_item').hoverIntent(function() {
			$('img#teachingsLink').attr("src","/images/catholicTeachings-EnsenanzasCatolicas-btn-over.gif");
				}, function() {
			$('img#teachingsLink').attr("src","/images/catholicTeachings-EnsenanzasCatolicas-btn.gif");
		});

		$('img#pledgeLink').hoverIntent(function() {
			$(this).attr("src","/images/thePledge-LaPromesa-btn-over.gif");
				}, function() {
			$(this).attr("src","/images/thePledge-LaPromesa-btn.gif");
		});
		
		$('ul.thePledge-subLink li.page_item').hoverIntent(function() {
			$('img#pledgeLink').attr("src","/images/thePledge-LaPromesa-btn-over.gif");
				}, function() {
			$('img#pledgeLink').attr("src","/images/thePledge-LaPromesa-btn.gif");
		});

		$('img#storiesLink').hoverIntent(function() {
			$(this).attr("src","/images/realStoriesHistoriasVeridicas-btn-over.gif");
				}, function() {
			$(this).attr("src","/images/realStoriesHistoriasVeridicas-btn.gif");
		});
		
		$('ul.stories-subLink li.page_item').hoverIntent(function() {
			$('img#storiesLink').attr("src","/images/realStoriesHistoriasVeridicas-btn-over.gif");
				}, function() {
			$('img#storiesLink').attr("src","/images/realStoriesHistoriasVeridicas-btn.gif");
		});

		$('img#newsLink').hoverIntent(function() {
			$(this).attr("src","/images/news-Notocias-btn-over.gif");
				}, function() {
			$(this).attr("src","/images/news-Notocias-btn.gif");
		});
		
		$('ul.news-subLink li.page_item').hoverIntent(function() {
			$('img#newsLink').attr("src","/images/news-Notocias-btn-over.gif");
				}, function() {
			$('img#newsLink').attr("src","/images/news-Notocias-btn.gif");
		});

		$('img#resourcesLink').hoverIntent(function() {
			$(this).attr("src","/images/resources-Recursos-btn-over.gif");
				}, function() {
			$(this).attr("src","/images/resources-Recursos-btn.gif");
		});
		
		$('ul.resources-subLink li.page_item').hoverIntent(function() {
			$('img#resourcesLink').attr("src","/images/resources-Recursos-btn-over.gif");
				}, function() {
			$('img#resourcesLink').attr("src","/images/resources-Recursos-btn.gif");
		});

		$('img#coalitionLink').hoverIntent(function() {
			$(this).attr("src","/images/coalitionMembers-MiembrosDeLaCoalicion-btn-over.gif");
				}, function() {
			$(this).attr("src","/images/coalitionMembers-MiembrosDeLaCoalicion-btn.gif");
		});
		
		$('ul.coalition-subLink li.page_item').hoverIntent(function() {
			$('img#coalitionLink').attr("src","/images/coalitionMembers-MiembrosDeLaCoalicion-btn-over.gif");
				}, function() {
			$('img#coalitionLink').attr("src","/images/coalitionMembers-MiembrosDeLaCoalicion-btn.gif");
		});
		//Dropdown/hover for menu - end
		
		// Hide all pledge descriptions except the first one and hide pledge form
        $('#pledgeRolloverMessages div').hide().filter(':first').show();
		$('#takePledge-home').hide();
		// Hide all pledge descriptions except the first one and hide pledge form

		$('#firstStepButton img, #homePledgeHeaderIMG').click(function () {
			$('#takePledge-home').fadeIn("slow");
            },
            function () {} // Because the hover method has a mouseout state we need to define too
        );
		
		$('#takePledge-home img.closeBTN').click(function () {
			$('#takePledge-home').fadeOut("slow");
            },
            function () {} // Because the hover method has a mouseout state we need to define too
        );
		
		$('#prayButton').click(function () {
			$('#pray').fadeIn("slow");
			$('#learn').hide();
			$('#assess').hide();
			$('#act').hide();
			$('#advocate').hide();
			
			return false;
		});
				
		$('img#prayButton').hoverIntent(function() {
			$(this).attr("src","/images/rezar-over.gif");
			$('#pray').fadeIn("slow");
			$('#learn').hide();
			$('#assess').hide();
			$('#act').hide();
			$('#advocate').hide();
			
			return false;
			
				}, function() {
			$(this).attr("src","/images/rezar.gif");
		});
		
		$('#learnButton').click(function () {
			$('#learn').fadeIn("slow");
			$('#pray').hide();
			$('#assess').hide();
			$('#act').hide();
			$('#advocate').hide();
			
			return false;
		});

		$('img#learnButton').hoverIntent(function() {
			$(this).attr("src","/images/aprender-over.gif");
			$('#learn').fadeIn("slow");
			$('#pray').hide();
			$('#assess').hide();
			$('#act').hide();
			$('#advocate').hide();
			
			return false;
				}, function() {
			$(this).attr("src","/images/aprender.gif");
		});
		
		$('#assessButton').click(function () {
			$('#assess').fadeIn("slow");
			$('#pray').hide();
			$('#learn').hide();
			$('#act').hide();
			$('#advocate').hide();
			
			return false;
		});
		
		$('img#assessButton').hoverIntent(function() {
			$(this).attr("src","/images/evaluar-over.gif");
			$('#assess').fadeIn("slow");
			$('#pray').hide();
			$('#learn').hide();
			$('#act').hide();
			$('#advocate').hide();
			
			return false;
				}, function() {
			$(this).attr("src","/images/evaluar.gif");
		});
		
		$('#actButton').click(function () {
			$('#act').fadeIn("slow");
			$('#pray').hide();
			$('#learn').hide();
			$('#assess').hide();
			$('#advocate').hide();
			
			return false;
		});
		
		$('img#actButton').hoverIntent(function() {
			$(this).attr("src","/images/actuar-over.gif");
			$('#act').fadeIn("slow");
			$('#pray').hide();
			$('#learn').hide();
			$('#assess').hide();
			$('#advocate').hide();
			
			return false;
				}, function() {
			$(this).attr("src","/images/actuar.gif");
		});
		
		$('#advocateButton').click(function () {
			$('#advocate').fadeIn("slow");
			$('#pray').hide();
			$('#learn').hide();
			$('#assess').hide();
			$('#act').hide();
			
			return false;
		});
		
		$('img#advocateButton').hoverIntent(function() {
			$(this).attr("src","/images/defender-over.gif");
			$('#advocate').fadeIn("slow");
			$('#pray').hide();
			$('#learn').hide();
			$('#assess').hide();
			$('#act').hide();
			
			return false;
				}, function() {
			$(this).attr("src","/images/defender.gif");
		});

		$('img#twitterBTN').hoverIntent(function() {
			$(this).attr("src","/images/socialIcons_t_on.jpg");
				}, function() {
			$(this).attr("src","/images/socialIcons_t.jpg");
		});

		$('img#facebookBTN').hoverIntent(function() {
			$(this).attr("src","/images/socialIcons_f_on.jpg");
				}, function() {
			$(this).attr("src","/images/socialIcons_f.jpg");
		});
		
		$('img#signupIMG').hoverIntent(function() {
			$(this).attr("src","/images/eNews_on-spanish.png");
				}, function() {
			$(this).attr("src","/images/eNews-spanish.png");
		});
		
		$('img#pledgeBTN').hoverIntent(function() {
			$(this).attr("src","/images/btn_pledgeNow_on.jpg");
				}, function() {
			$(this).attr("src","/images/btn_pledgeNow.jpg");
		});
		
		$('#firstpane p.menu_head, #firstpane p.menu_head_first').hover(function() {
				$(this).addClass('mhover');
			}, function() {
				$(this).removeClass('mhover');
		});
		
		//slides the element with class "menu_body" when paragraph with class "menu_head" is clicked
		$("#firstpane p.menu_head, #firstpane p.menu_head_first").click(function()
		{
			$(this).next("div.menu_body, div.menu_body_active").slideToggle(300).siblings("div.menu_body, div.menu_body_active").slideUp("slow");
			$(this).siblings();
		});
		
});	
