/***************************************/	
/***************************************
init.js is a javascript driver for the site.
Jquery is a framework implemented. To learn more 
about jquery visit jquery.com. 
To keep content pages clean this code is included 
in the header of each file.
****************************************/	
	$j(document).ready(function(){		
		 //menu animation
		$j(".sf-menu li ul").each(function(){
			var subMenu = $j(this).html();
			if (subMenu.length < 39) {$j(this).remove(); }
		});

		
		$j(".sf-menu li:last-child a, .sf-menu ul li:last-child, .sub-menu li:last-child a, .sub-menu ul li:last-child").css({
			"border-right":"none", 
			"border-bottom":"none"
		});

		//$j("ul.sf-menu").superfish({delay:0}); 	
		
		//add this username goes here
		var addthis_pub="Your username";
		
		// Reset font size on the page
		var originalFontSize = $j('html').css('font-size');

		// Increase Font Size
		$j("#font_select_med").click(function(){
			var currentFontSize = $j('html').css('font-size');
			var currentFontSizeNum = parseFloat(currentFontSize, 10);
			var newFontSize = currentFontSizeNum*1.1;
			if (newFontSize < 20) {
			$j('div.left p, div.right p').animate({'font-size': newFontSize},  600);
			}
		return false;
		});

		// Increase Font Size more
		$j("#font_select_large").click(function(){
			var currentFontSize = $j('html').css('font-size');
			var currentFontSizeNum = parseFloat(currentFontSize, 10);
			var newFontSize = currentFontSizeNum*1.2;
			if (newFontSize < 20) {
			$j('div.left p, div.right p').animate({'font-size': newFontSize}, 600 );
			}
		return false;
		});

		// Decrease Font Size
		$j("#font_select").click(function(){
			$j('div.left p, div.right p').animate({'font-size': originalFontSize}, 600);
		});


		// slide show
		$j(".carousel").cycle({
			fx: 'fade' ,
			timeout: 8000,
			cleartypeNoBg: true,
			next: '.pager a.next',
			prev: '.pager a.prev',
			pager:  '.controls' ,
			pagerAnchorBuilder: function(index, el) {
				//get current url value
				var sMoreUrl = $j(el).find('.slideImg').attr('alt');
				//alert(sMoreUrl);
				//on click read-more
				$j('button.read-more').click(function(){
					//window.open(sMoreUrl ,'_self');
				});
				return '<a href="#" class="bull">&bull;</a>'; 
			},
			
			//function to create a link on click
			pagerClick: function(zeroBasedSlideIndex, slideElement){
				var sGetUrlClick = $j(slideElement).find('.slideImg').attr('alt');
				$j('button.read-more').click(function(){
					window.open(sGetUrlClick ,'_self');
				});
			},
			
			//function to create a link
			before: function(currSlideElement, nextSlideElement, options, forwardFlag){
				//get current url value
				var sAltUrl = $j(nextSlideElement).find('.slideImg').attr('alt');
				//on click read-more
				$j('button.read-more').click(function(){
					window.open(sAltUrl ,'_self');
				});
			}
		});
		
		
		//pause the show
		$j('#resumeButton').hide();
		$j('#pauseButton').show();
		$j('#pauseButton').click(function() {		
			$j('.carousel').cycle('pause');
			$j('#resumeButton').show();
			$j(this).hide();
			
		});

		//resume the show		
		$j('#resumeButton').click(function() {		
			$j('.carousel').cycle('resume');
			$j('#pauseButton').show();
			$j(this).hide();
		});

		//rollover effect get involved buttons
		$j('button.advocate, button.donate, button.participate').hover(function(){
			$j(this).animate({opacity:0.8},200);
		},
		 function(){
			$j(this).animate({opacity:1.0},200)
		 });
	
		//getInvolved page style
		$j('ul.involve li:odd').css('border-right','0');
	
	
	
	
	//checkboxes fix ie
		$j('input.checkbox').click( function() {
		$j('input.checkbox').attr('checked', '');
			$j(this).attr('checked', 'checked');
		});
		
		$j('input.cc').click( function() {
		$j('input.cc').attr('checked', '');
			$j(this).attr('checked', 'checked');
		});
	
	
	//popup box verification
	$j('p.explain').hover(function(){
		var expainBox = '<div id="expBox"><p>The Verification Code is a three-digit number on the back  of your credit card.</p></div>';
		$j('div.mainDonateRight').append(expainBox);
	}, function(){
		$j('#expBox').remove();
	})
	
		//label plugin
		//$j.fn.formLables();
	});
	
	

