$(document).ready(function() {
	if($().cycle && $('#home_slideshow').length != 0) {
		$('#home_slideshow').cycle({
			fx: 'fade',
			speed: 500,
			timeout: 8000,
			pager: '#home_slideshow_pager'
		});
	}

	//cernter the nav
	var Margin = (960 - $('#primary_nav ul.nav1').width())/2
	$('#primary_nav ul.nav1').css('margin-left', Margin);
	
	
	//Login Panel
	if($('body').hasClass('ie7' , 'ie6') ){
		$('#login_panel_wrapper').remove();
		}else{
		$("#open").click(function(e){
			e.preventDefault();
			
			$("div#login_panel").slideDown("slow");
			$('#login_panel_wrapper .tab').toggleClass('tab_opened');
		});	
		
		$("#close").click(function(e){
			e.preventDefault();
			
			$("div#login_panel").slideUp("slow" , function(){
				$('#login_panel_wrapper .tab').toggleClass('tab_opened');
			});
				
		});		
		
		// Switch buttons from "Log In | Register" to "Close Panel" on click
		$("#toggle a").click(function (e) {
			e.preventDefault();
			$("#toggle a").toggle();
		});		
 	}



	//accordion
	$('.acc_trigger a[id^="mpip"]').css({
	    'background':'none',
	    'display':'inline'
	});
	
	$('#supporters h3:eq(1)').addClass('second').next('div').addClass('second');
	$('#supporters h3:eq(2)').addClass('third').next('div').addClass('third');
	$('#supporters h3:eq(3)').addClass('fourth').next('div').addClass('fourth');
	
	$('.acc_container').hide();
	$('.acc_trigger:first').addClass('active').next().show();
	
	$('.acc_trigger').click(function(){
		if( $(this).next().is(':hidden') ) { 
	    	$('.acc_trigger').removeClass('active').next().slideUp(); 
	    	$(this).toggleClass('active').next().slideDown();}
	    return false; 
	});
	

	/* tweet */
 	if($("#twit_feed").length > 0){    
 		$("#twit_feed").tweet({
        username: "JLGNF",
        count: 3,
        template: "{text}{time}",
        loading_text: "loading tweets..."
      });
	}
	
	//removes the subnav if it isn't present
	if ($("#subnav ul li.on").children("ul").length == 0) {
	    $("#subnav_area").remove();
	}
	
	//changes the page width on pages w/o a subnav area
	if ($("#subnav_area").children().size() == 0) {					
	    $("#main_content").css({
			"width": "auto",
	    	"float": "none"
	    });
	}

});

