$(document).ready(function(){

	// Header Cart Tweaking
	var cartItems = $(".cartSummaryItem").html();
	
	if (cartItems != null){
		cartItems = cartItems.substring(0,cartItems.indexOf(" "));
		
		var cartLink = $(".cartSummaryLink").attr('href');
		
		$("#catCartSummary").hide();
		
		$("#headerCart").prepend("<a href='"+cartLink+"'>My Cart ("+cartItems+") <img src='/images/eCommerce/cart.gif' alt='Cart' width='16' height='13' /> <span>Checkout</span></a>");
	}

	// eCommerce menu highlighting
	var eCommerceSection = $(".breadcrumbs").html();

	if (eCommerceSection != null){
		if (eCommerceSection.indexOf('>Pay') != -1){
			$("#navigationDownloadsPay").addClass("active");
		}else if(eCommerceSection.indexOf('>Free') != -1){
			$("#navigationDownloadsFree").addClass("active");
		}else{
			//alert('none');
		}
	}

	// Navigation Menu Selector
	switch(navigation){
		case "home":
			$("#navigationHome").addClass("active");
			break;
		case "counselors":
			$("#navigationCounselors").addClass("active");
			$("#navigationMain").addClass("navigationMainCounselors");
			$("#navigationNew").addClass("navigationMainCounselors");
			$("#subNavigationCounselors").show();
			break;
		case "services":
			$("#navigationServices").addClass("active");
			break;
		case "testimonials":
			$("#navigationTestimonials").addClass("active");
			break;
		case "about-us":
			$("#navigationAboutUs").addClass("active");
			break;
		case "blog":
			$("#navigationBlog").addClass("active");
			break;
		case "events":
			$("#navigationEvents").addClass("active");
			$("#navigationMain").addClass("navigationMainEvents");
			$("#navigationNew").addClass("navigationMainEvents");
			$("#subNavigationEvents").show();
			break;
		case "employment":
			$("#navigationEmployment").addClass("active");
			break;
		case "contact":
			$("#navigationContact").addClass("active");
			break;
		case "onlineCounseling":
			if (subNavigation == ""){
				$("#navigationOnlineCounseling").addClass("active");
			}
			$("#subNavigationOnlineCounseling").show();
			$("#navigationMain").addClass("navigationMainOnlineCounseling");
			break;
		case "subscribe":
			$("#navigationSubscribe").addClass("active");
			break;
		case "videos":
			$("#navigationVideos").addClass("active");
			break;
		case "downloads":
			$("#navigationDownloads").addClass("active");
			break;
		case "downloads-free":
			$("#navigationDownloadsFree").addClass("active");
			break;
		case "downloads-pay":
			$("#navigationDownloadsPay").addClass("active");
			break;
		case "online_services":
			$("#navigationOnlineServices").addClass("active");
			break;
	}
	
	// Sub-Navigation Selector
	if (subNavigation){
		switch(navigation){
			case "counselors":
				switch(subNavigation){
					case "irvine":
						$("#subNavigationCounselorsIrvine").addClass("active");
						break;
					case "north-white-plains":
						$("#subNavigationCounselorsNorthWhitePlains").addClass("active");
						break;
					case "chatham":
						$("#subNavigationCounselorsChatham").addClass("active");
						break;
					case "bellevue":
						$("#subNavigationCounselorsBellevue").addClass("active");
						break;
				}
				break;
			case "onlineCounseling":
				//$("#subNavigationCounselors").show();
				switch(subNavigation){
					case "freshmen":
						$("#navigationFreshmen").addClass("active");
						break;
					case "juniors":
						$("#navigationJuniors").addClass("active");
						break;
					case "seniors":
						$("#navigationSeniors").addClass("active");
						break;
					case "sophomores":
						$("#navigationSophomores").addClass("active");
						break;
				}
				break;
			case "events":
				switch(subNavigation){
					case "irvine":
						$("#subNavigationEventsIrvine").addClass("active");
						break;
					case "north-white-plains":
						$("#subNavigationEventsNorthWhitePlains").addClass("active");
						break;
					case "chatham":
						$("#subNavigationEventsChatham").addClass("active");
						break;
					case "bellevue":
						$("#subNavigationEventsBellevue").addClass("active");
						break;
				}
				break;
		}	
	}
	
	// Buttons
	$(".button").mouseover(function(){
		$(this).css("background","url('/images/global/buttons/middle-over.png') repeat-x top left");
		$(this).children(".buttonLeft").attr("src","/images/global/buttons/left-over.png");
		$(this).children(".buttonRight").attr("src","/images/global/buttons/right-over.png");
	});
	
	$(".button").mouseout(function(){
		$(this).css("background","url('/images/global/buttons/middle.png') repeat-x top left");
		$(this).children(".buttonLeft").attr("src","/images/global/buttons/left.png");
		$(this).children(".buttonRight").attr("src","/images/global/buttons/right.png");
	});
	
	$("#footerContent #e2ma_signup_form_button_row").append('<input type="image" src="/images/global/footer/leaf.jpg" style="vertical-align: top" />');
		
});	

(function(){ 
  var checkoutTracking = function(){
  if (typeof ValidateCart !== 'function'){ 
    return;
  }
 var _validateCart = ValidateCart;
 ValidateCart = function(){
  var 
  link = document.getElementById('catshopbuy'),
  res = _validateCart.apply(this, arguments);
  if (res === true) {
  	_gaq.push(['_link', link.href]); 
  } 
  return false;
  };
 };
  
  checkoutTracking(); 
  })();
  
  $('.googleCrossDomainTracking').live('click', function(e) { _gaq.push(['_link', $(this).attr('href')]); return false; });

/*


   var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-7293942-1']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();
  
  
*/

