$(document).ready(
	function() {
	    initOptions();
		initSearchField();
		initMenus();
	}
);

/* attach click events to the "I would like to" list item anchors */
function initOptions() {
    $('#options .control').click(
        function() {
            var _this = $(this);
			// div.body is the expandable element
            var jBody = _this.parent().find('.body');

			// store a reference to the last active element
			// if it already exists, deactivate it, then update to reflect new element
            if( typeof window.__active == 'undefined' || window.__active == null ) {
            	window.__active = {
            		anchor: $('#options a.expanded'),
            		panel: $('#options div.expanded')
            	};
            }
            window.__active.anchor.removeClass('expanded');
            window.__active.panel.slideUp('fast').removeClass('expanded');

			// the active element was re-clicked - close it and set active to null
            if( window.__active.anchor.text() == _this.text() ) {
            	window.__active = null;
            } else {
            	_this.addClass('expanded');
            	jBody.slideDown('fast').addClass('expanded');
            	window.__active.anchor = _this;
            	window.__active.panel = jBody;
            }
            return false;
        }
    )
}

/* attach focus/blur events to search field */
function initSearchField() {
	$('#search-term').focus(
		function() {
			if( this.value == this.defaultValue ) {
				this.value = '';
			}
		}
	).blur(
    	function() {
    		if( this.value == '' ) {
    			this.value = this.defaultValue;
    		}
    	}
	)
}

/* apply a "hover" class to the list items as they're hovered over */
function initMenus() {
	$('#primary-nav li').hover(
		function() {
			$(this).addClass('hover');
		},
		function() {
			$(this).removeClass('hover');
		}
	);
}

function getBEntry($id){
	$.get("/php-includes/getfeatured.php",{curID: $id, ajax: 'true'}, function(data){
		document.getElementById('blog').innerHTML = data;
	})
}
