/* GLOBAL VARIABLES */

ROOT_URL = ''; // should be at least '/' if site is at document root


/* FUNCTIONS */

$(document).ready(function() {
	/* plugin that handles the multi-level primary navigation */
	$('#primary-links').droppy({speed:200});
	
	/* hide the toggleable content */
	$('.toggle-content').hide();
	$('a.toggle-link').removeClass('opened');
	/* show/hide toggleable content when the icon is clicked */
	$('a.toggle-link').toggle(
		function(){
			$(this).addClass('opened').blur();
			$($(this).attr('href')).parent().addClass('opened');
			if($.browser.msie) {
				$($(this).attr('href')).show();
			} else {
				$($(this).attr('href')).slideDown();
			}
			return false;
		},
		function(){
			$(this).removeClass('opened').blur();
			$($(this).attr('href')).parent().removeClass('opened');
			if($.browser.msie) {
				$($(this).attr('href')).hide();
			} else {
				$($(this).attr('href')).slideUp();
			}
			return false;
		}
	);
	
	
	$('body.page-home #content-links-content > div[id^=content-]').css({'position': 'absolute', 'top': '0px'}).not(':first-child').hide();
	$('body.page-home #content-links-content').height($('#content-links-content > div:first').height()+'px');
	$('body.page-home #content-links li').click(function(){
		if(!$(this).hasClass('active')) {
			$('#content-links li').removeClass('active');
			$(this).addClass('active');
			
			//$('#content-links-content').height($($(this).attr('href')).height()+'px');
			$('#content-links-content').animate({height : $($(this).find('a').attr('href')).height()+'px'}, 250);
			$('#content-links-content > div[id^=content-]').hide();
			$($(this).find('a').attr('href')).fadeIn();
			// sIFR doesn't get applied to hidden elements, so do it as it's being shown.
			if($($(this).attr('href') + ' h2.sIFR-replaced').length == 0) {
				draw_sifr('h2');
			}
		}
		return false;
	});
	
	
	var default_search = $('#form-search input[type=text]').val('Enter search words here').val();
	$('#form-search input[type=text]').focus(function(){
		if($(this).val() == default_search) {
			$(this).val('');
		}
	});
	$('#form-search input[type=text]').blur(function(){
		if($(this).val() == '') {
			$(this).val(default_search);
		}
	});
});