/* Author: Ryan Davis */

$(document).ready(function(){
	// Add last-child class to navbar & drop menus
	$('ul#navbar').children('li:last').addClass('last-1st-level');
	$('div#banner-and-nav ul#navbar li ul').find('li:last').addClass('last-2nd-level');
	
	// Add class to right-most drop menus
	$('ul#navbar > li:gt(4)').children('ul').addClass('drop-menu-align-right');
	
	//Slide down drop menus
	$('div#banner-and-nav ul#navbar li').hover(
		function(){
		$(this).children('ul').stop(true, true).slideDown(200);
		},function(){
		$(this).children('ul').stop(true, true).slideUp(200);
		}
	);

	   // BEGIN redirect all outbound links through tracker page
	   $("a").click(function(){ 

	      // if it's a full URL...
	      if ($(this).attr("href").indexOf("http")==0) {

	         // if it doesn't go to our site
	         if (!/^http(s){0,1}(.){0,3}(www){0,3}(\.){0,1}abundancellc\.com/.test($(this).attr("href"))){

	            // send it through the linkout page
	            $(this).attr("href","/outbound.php?p=" + $(this).attr("href"))

	         }
	      } 
	   });
	   // END redirect all outbound links through tracker page
	
});

//Send to a friend contact form
function showFriendForm(){
	$('#blackout').fadeIn(400);
	$('#send-to-a-friend-wrapper').fadeIn(400);
	return false;
};

function hideFriendForm(){
	$('#blackout').fadeOut(400);
	$('#send-to-a-friend-wrapper').fadeOut(400);
	return false;
};
