// Custom jQuery interaction layer for WardOnTheWeb.com by Stephen Ward
$(document).ready(function(){

	// Toggle search prompt
	$search_box = $('#s');
	$search_box.focus(function(){
		if ($search_box.val() == 'search this site...')
			$search_box.val('');
	});
	$search_box.blur(function(){
		if ($search_box.val() == '')
		  	$search_box.val('search this site...');
	});
	
	// Set default menu states	
	expanded = $('#r_sidebar li > h2').not('.widget_links > h2').not('.widget_archive > h2').not('.widget_text > h2');
	expanded.css('cursor', 'pointer');
	jQuery.each(expanded, function(){
		$(this).text('- ' + $(this).text());
	});
	collapsed = $('.widget_links > h2').add('.widget_archive > h2');
	collapsed.css('cursor', 'pointer').next('ul').css('display', 'none');
	jQuery.each(collapsed, function(){
		$(this).text('+ ' + $(this).text());
	});
	
	// Switch menu states when the menu headers are clicked
	$('#r_sidebar li > h2').click(function(){
		menu_header = $(this);
		menu_header.next('ul').slideToggle('normal');
		menu_header.next('div').slideToggle('normal');
		if (menu_header.text().substring(0, 2) == '+ ')
			menu_header.text('- ' + menu_header.text().substring(2));
		else if (menu_header.text().substring(0, 2) == '- ')
			menu_header.text('+ ' + menu_header.text().substring(2));
	});
	
	// Highlight portfolio items
	$('.portfolio-item').hover(
		function(){
			$(this).css('border', '1px solid #027CEE');
		},
		function(){
			$(this).css('border', '1px solid #C0C0C0');
		}	
	);

});