/*<![CDATA[*/
$(function(){ 
	
	/* ************************************************************* 
	 *                                         SIMPLE SEARCH
	 ************************************************************** */
	$('#search_widget_button').hover(function() {
			$(this).css({background: "url(/assets/templates/site_tpl/images/search_up.gif)"});
			$('#search_widget_box').css({border:"1px solid #ec3200"});
		},function() {	
			$(this).css({background: "url(/assets/templates/site_tpl/images/search.gif)"})
			$('#search_widget_box').css({border:"1px solid #ccc"});
	});

	$('#search_widget_box').hover(function() {
			$(this).css({background:"whitesmoke",color:"black"});
		},function() {	
			$(this).css({background:"#fff",color:"#cccccc"});
	});
	$('#search_widget_box').click(function() {
			$(this).css({background:"white",border:"1px solid #ec3200"});
		},function() {	
			$(this).css({background:"white",border:"1px solid #ccc"});
	});
	
	$('#search_widget_box').blur(function() {
		$(this).css({border:"1px solid #ccc",background:"#fff"});
		if (this.value == '') {
			this.value = this.defaultValue;  
		}
	});
	
	$('#search_widget_box').focus(function() {
		if (this.value == this.defaultValue) {
			this.value = '';  
		}
		if (this.value != this.defaultValue) {
			this.select();  
		}
	});

	/* ************************************************************* 
	 *                                      CASE HISTORY FILTER
	 ************************************************************** */
	/* remove the initial instructions from the box */
	$('#inline_chfilter').focus(function() {
		if (this.value == this.defaultValue) {
			this.value = '';  
		}
		if (this.value != this.defaultValue) {
			this.select();  
		}
	});
	
	$('#inline_chfilter').blur(function() {
		if (this.value == '') {
			this.value = this.defaultValue;  
		}
	});
	
	/* filter the results */
	$('#inline_chfilter').keyup(function() {
		var filter = $(this).val(), count = 0;
		$('h3.leadline a').each(function() {
			if ($(this).text().search(new RegExp(filter, "i")) < 0) {
				$(this).parent().parent().parent().fadeOut('fast');
			} else {
				$(this).parent().parent().parent().fadeIn('fast');
				count++;
			}
		});
		$("#filter_count").text(count);
	});


	/* ************************************************************* 
	 *                                      PERSON FILTER
	 ************************************************************** */
	/* remove the initial instructions from the box */
	$('#inline_personfilter').focus(function() {
		if (this.value == this.defaultValue) {
			this.value = '';  
		}
		if (this.value != this.defaultValue) {
			this.select();  
		}
	});

	$('#inline_personfilter').blur(function() {
		if (this.value == '') {
			this.value = this.defaultValue;  
		}
	});
	
	/* filter the results */
	$('#inline_personfilter').keyup(function() {
		var filter = $(this).val(), count = 0;
		$('div.staffcard a').each(function() {
			if ($(this).text().search(new RegExp(filter, "i")) < 0) {
				$(this).parent().parent().fadeOut('fast');
			} else {
				$(this).parent().parent().fadeIn('fast');
				count++;
			}
		});
		$("#personfilter_count").text(count);
	});

	
	/* ************************************************************* 
	 *                                     SEARCH APP
	 ************************************************************** */
	$('#searchappbutton').hover(function() {
			$(this).css({background:"red",border:"1px solid red"});
			$('#searchappbox').css({border:"1px solid #fed100"});
		},function() {	
			$(this).css({background:"#fff",border:"1px solid #ccc"})
			$('#searchappbox').css({border:"1px solid #ccc"});
	});

	$('#searchappbox').hover(function() {
			$(this).css({background:"whitesmoke"});
		},function() {	
			$(this).css({background:"#fff"});
	});
	
	$('#searchappbox').blur(function() {
		$(this).css({border:"1px solid #aaa",background:"#fff"});
	});
	
	$('#searchappbox').focus(function() {
		$(this).css({border:"1px solid #aaa",color:"#333",background:"red"});
		if (this.value == this.defaultValue) {
			this.value = '';  
		}
		if (this.value != this.defaultValue) {
			this.select();  
		}
	});

});
/*]]>*/
