
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* 
 *
 *	====================================		
 *     JQUERY TOOLBOX LIBRARY
 *	====================================		
 *
 *		This is a library of common & useful jquery functions that can be easily used in your website.
 *		
 *					....And how!
 *
 *
 *		Insert the following code at the bottom of your page but before the closing body tab ( </body> )
 *	
 *		<script type="text/javascript">
 *			$(document).ready(function() {
 *
 *				// *** CALL FUNCIONS HERE
 *
 *			});
 * 	 	</script>
 *
 *					....But wait! there's more!....
 * 
 *
 *		FUNCTIONS
 *	====================================	
 *	
 *		1) input_box_text(str, inputBoxClass)
 *		2) new_window(href_class)
 *		3) print(any_element_class)
 *		4) confirm_box(message, href_class)
 */
	
	
// ------------------------------------------
	
	function input_box_text(str, input_box_class) {
		/*  #1
		 *	Author:		Michael "Face disgusts me" Dowling	 	  
		 *	Date: 
		 *	Purpose: 	Sets the default in a input box . eg, 'search...' in a search box
		 *				It also clears the box when the user clicks in it ...H0t!
		 *	Params: 	str: 			The text to display  
		 *				input_box_class: 	The class of the input box
		 *	Example: 	
		 *		HTML code: 	 	<input type="text" class="search_field" value="keyword (s)" />	   	   	
		 *		Function call: 	input_box_text('keyword (s)', 'search_field');	
		 *
		 */
		$('.'+input_box_class).focus(function () {
		    var text = $(this).val();
		    if (text == str) {
		        $(this).val('');
		    }
		});

		$('.'+input_box_class).blur(function () {
		    var text = $(this).val();
		    if (text == '') {
		        $(this).val(str);
		    }
		});
	}


// ------------------------------------------

	function new_window(href_class) {
		/*	#2
		 *	Author:		Michael Dowling	 	  
		 *	Date: 
		 *	Purpose: 	Opens a page in a new window... the validating way
		 *	Params: 	href_class: 	The href class of the link you want to open in a new window   			  
		 *	Example: 	
		 *		HTML code: 	   <a href="www.oberto.co.nz" class="new_window">link</a>	
		 *		Function call: new_window('new_window');		
		 *
		 */
		$(document).ready(function() {
			$('.'+href_class).click(function() {
				window.open($(this).attr('href'));
				return false;
			});	
		});	
	}

// ------------------------------------------

	function print(any_element_class) {
		/*	#3			
		 *	Author:		Michael Dowling	 	  
		 *	Date: 
		 *	Purpose: 	Prints the page when the element is clicked on.
		 *	Params: 	any_element_class: 	The class if the div you want to print   			  
		 *	Example: 	
		 */
		$(document).ready(function() {	
			$('.'+any_element_class).click(function() {
				window.print();
			});	
		});
	}	
	
// ------------------------------------------

	function confirm_box(message, href_class) {
		/*	#4
		 *	Author: 	Jarrod Oberto
		 *	Date: 		
		 *	Purpose: 	Confirmation box
		 *	Params: 	message: 	Message to display on box
		 *				hrefClass: 	The href class of the link you want to open in a new window   			  
		 *	Example: 	
		 *		HTML code: 	   <a href="http://www.oberto.co.nz" class="confirm">link</a>	
		 *		Function call: confirm_box('Are you sure your want to open in a new window', 'confirm');		
		 *
		 */
		$('.'+href_class).click(function(){
			var answer = confirm(message);
		  	return answer // answer is a boolean
		});
	}
	
	function auto_select(id) {
		$('#'+id).focus();
	}
<!-- 
 -->