var addthis_config = {
	services_compact: 'facebook, twitter, google, favorites, email, print',
	ui_click: true
}

// Include google analytics onload
function load_ga(){var gaJsHost  = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");var s = document.createElement('script');s.src = gaJsHost + "google-analytics.com/ga.js";s.type = "text/javascript";document.getElementsByTagName("head")[0].appendChild(s);var i = 0;run_ga();
function run_ga(){if(typeof _gat == "object"){var pageTracker = _gat._getTracker(ga_key);pageTracker._initData();pageTracker._trackPageview();}else if(i < 20){i++;setTimeout(run_ga, 500);}};};
if(window.addEventListener){window.addEventListener("load", load_ga, false);}else if(window.attachEvent){window.attachEvent("onload", load_ga);} 

Shadowbox.init({
	animate: false,
	fadeDuration: 0.2
});

var agl = {
	init: function() {
		agl.init_uls();
		if(!aglcookie) {
			agl.set_state_triggers();
		}
		if($('.faqs').length > 0) {
			agl.init_faqs();
		}
	},
	set_state_triggers: function() {
		$('a.select-state').each(function(){
			$(this).bind('click', function(event){
				Shadowbox.open({
					content: '/state/?r=' + escape($(this).attr('href')),
					player: 'iframe',
					width:  260,
					height: 250
				});
				event.stopPropagation();
				return false;
			});
		});
	},
	init_faqs: function() {
		$('.faqs .faqs-content').each(function(){
			$(this).css('height', $(this).height() + 'px');
			$(this).hide();
		});
		$('.faqs .toggle').each(function(){
			$(this).bind('click', function(event){
				agl.toggle_faq($(this));
				event.stopPropagation();
				return false;
			});
		});
		if(document.location.hash) {
			this.toggle_faq($(document.location.hash).find('.toggle'));
		}
	},
	toggle_faq: function(link) {
		link.parents('.faqs-item').find('.faqs-content').slideToggle();
		link.parents('.faqs-item').toggleClass('open');
	},
	init_uls: function() {
		$('#page-content ul').each(function(){
			var list = $(this);
			var items = $(this).contents('li');
			var numa = 0;
			items.each(function(){
				if($(this).contents('a').length == 1) {
					numa++;
				}
			});
			if(numa > 0 && numa == items.length) {
				list.addClass('links');
			}
		});
	}
};

$(document).ready(function(){
	agl.init();
});


jQuery(document).ready(function($){
	
	// supersubs init
	$("ul.sf-menu").supersubs({ 
		minWidth:    12,   // minimum width of sub-menus in em units 
		maxWidth:    27,   // maximum width of sub-menus in em units 
		extraWidth:  1     // extra width can ensure lines don't sometimes turn over 
						   // due to slight rounding differences and font-family  
	 }).superfish({
		delay:       400,                            // one second delay on mouseout 
		animation:   {opacity:'show',height:'show'},  // fade-in and slide-down animation 
		speed:       'fast',                          // faster animation speed 
		autoArrows:  false,                           // disable generation of arrow mark-up 
		dropShadows: false                            // disable drop shadows 
	});
	
});


