/***********************************************
* Textarea Maxlength script- © Dynamic Drive (www.dynamicdrive.com)
* This notice must stay intact for legal use.
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/
/**/
function ismaxlength(obj){
	var mlength=parseInt(obj.attr("maxlength"));
	if (obj.val().length > mlength){
		obj.val(obj.val().substring(0,mlength));
	}
}

jQuery(document).ready(function(){
	/* mark as js-enabled */
	jQuery("body").addClass("js");
	
	/* create print page link */
	jQuery("#pageTools ul").append("<li id=\"pageToolsPrint\"><a href=\"javascript:window.print()\">Print</a></li>");

	/* Run the more complex functions */
	expandList();

	/*Expanding list - site map, org diagrams etc */
	function expandList(){
		var expandText = "<strong>(expand)</strong>"
		var closeText = "<strong>(close)</strong>"
		jQuery(".expandList li>ul").addClass("hide");
		jQuery(".expandList li").each( function(){
			var $this = jQuery(this);
			if($this.find("ul").length > 0){
				var expandTextAdditonal = "<em class=\"hide\">" + $this.text().split("\n")[0] + "</em>";
				$this.addClass("off").find("ul:first").before(" <a class=\"expand\" href=\"#\"><small>"+expandText+expandTextAdditonal+"</small><span></span></a>")
			}
		});
		
		jQuery(".expand").click(function(){
			var $this = jQuery(this);
			var expandTextAdditonal = "<em class=\"hide\">" + $this.parent().text().split("\n")[0] + "</em>";
			//if($this.text().indexOf(expandText)!=-1){
			if($this.parent().hasClass("off")){
				$this.parent().addClass("on").removeClass("off").find("ul:first").removeClass("hide");
				$this.find("small").html(closeText+expandTextAdditonal);
			} else {
				$this.parent().addClass("off").removeClass("on").find("ul:first").addClass("hide");
				$this.find("small").html(expandText+expandTextAdditonal);
			}
			return false;
		});
	};
	
	/* Limit on characters in sections of the Application Form */
/*
	 	$('#input_1_8').attr('maxlength', '9');
 		$('#input_1_8').keyup( function(){
			return ismaxlength($(this));
		});
	 	$('#input_1_9').attr('maxlength', '1350');
 		$('#input_1_9').keyup( function(){
			return ismaxlength($(this));
		});
	 	$('#input_1_11').attr('maxlength', '1350');
 		$('#input_1_11').keyup( function(){
			return ismaxlength($(this));
		});
	 	$('#input_1_12').attr('maxlength', '1500');
 		$('#input_1_12').keyup( function(){
			return ismaxlength($(this));
		});
	 	$('#input_1_13').attr('maxlength', '1350');
 		$('#input_1_13').keyup( function(){
			return ismaxlength($(this));
		});
*/
	 	jQuery('#input_1_18').attr('maxlength', '1350');
 		jQuery('#input_1_18').keyup( function(){
			return ismaxlength(jQuery(this));
		});
	 	jQuery('#input_1_17').attr('maxlength', '2000');
 		jQuery('#input_1_17').keyup( function(){
			return ismaxlength(jQuery(this));
		});
	 	jQuery('#input_1_16').attr('maxlength', '2000');
 		jQuery('#input_1_16').keyup( function(){
			return ismaxlength(jQuery(this));
		});
	 	jQuery('#input_1_14').attr('maxlength', '1350');
 		jQuery('#input_1_14').keyup( function(){
			return ismaxlength(jQuery(this));
		});
	 	jQuery('#input_1_13').attr('maxlength', '1000');
 		jQuery('#input_1_13').keyup( function(){
			return ismaxlength(jQuery(this));
		});
		
/*
input_1_13 1000
input_1_14 1350
input_1_16 2000
input_1_18 1350
input_1_17 2000
*/

});


