// vim: set noet ft=javascript :
// Show and hide page elements according to session cookies
if (window.getCookie && window.$) {
	$('#top_nav').ready(function() {
			// check for cart data
			if (getCookie('purchase_id')) {
				$('#top-howto-link').hide();
				$('#top-cart-link').show();
			} else {
				$('#top-howto-link').show();
				$('#top-cart-link').hide();
			}
			// check for logged in user
			if (getCookie('user_id')) {
				$('#top-login-link').hide();
				$('#top-profile-link').show();
				$('#top-logout-link').show();
			} else {
				$('#top-login-link').show();
				$('#top-profile-link').hide();
				$('#top-logout-link').hide();
			}
			// check for affiliate
			if (getCookie('affiliate_alias')) {
				$('#affiliate_logo').show();
				$('#affiliate_logo_img').attr('src', '/images/affiliate/' + getCookie('affiliate_alias'));
			}
			if (getCookie('affiliate_home')) {
				$('.logo a').attr('href', unescape(getCookie('affiliate_home')));
				$('#top_nav .nav-home a').attr('href', unescape(getCookie('affiliate_home')));
				$('#affiliate_logo_url').attr('href', unescape(getCookie('affiliate_home')));
			}
			if (getCookie('affiliate_logo')) {
				$('#affiliate_logo_url').attr('href', unescape(getCookie('affiliate_logo')));
			}
		});
}


