<%@ include file="inc_header.jsp"%>

<c:set var="minifiedSuffix" value="" />
<c:if test="${useMinifiedDependencies}">
	<c:set var="minifiedSuffix" value=".min" />
</c:if>

<link rel="stylesheet" type="text/css" href="css/dataTables.jqueryui${minifiedSuffix}.css" />
<link rel="stylesheet" type="text/css" href="css/jquery-ui.css" />
<link rel="stylesheet" type="text/css" href="css/select.jqueryui${minifiedSuffix}.css" />
<link rel="stylesheet" type="text/css" href="css/styles.css">
<link rel="stylesheet" type="text/css" href="css/footerNew.css">
<link rel="stylesheet" type="text/css" href="css/menustyle.css">
<link rel="stylesheet" type="text/css" href="css/error.css">

<script type="text/javascript" src="js/jquery-1.12.3${minifiedSuffix}.js"></script>
<script type="text/javascript" src="js/jquery-ui${minifiedSuffix}.js"></script>
<script type="text/javascript" src="js/jquery.dataTables${minifiedSuffix}.js"></script>
<script type="text/javascript" src="js/dataTables.jqueryui${minifiedSuffix}.js"></script>
<script type="text/javascript" src="js/dataTables.select${minifiedSuffix}.js"></script>
<script type="text/javascript" src="js/jquery-accessibleMegaMenu.js"></script>
<script type="text/javascript" src="js/expandPanel.js"></script>
<script type="text/javascript" src="js/jquery.topzindex.js"></script>
<script type="text/javascript" src="js/ccht.js"></script>
<script type="text/javascript" src="js/cchtmenu.js"></script>

<%@ include file="inc_attentionDialog.jsp"%>
<%@ include file="inc_confirmationDialog.jsp" %>
<%@ include file="inc_spinner.jsp"%>

<script type="text/javascript">
	$(function() {
		$("a.buttonAnchor, .submitAnchor, button").button()
	})


	function commonAjaxErrorHandler(jqXHR, textStatus, errorThrown) {
		var errorText = errorThrown
		var details = null
		if (jqXHR.status == 404 || jqXHR.status == 0) {
			errorText = 'The server is offline or could not be contacted.'
		} else if (jqXHR.status == 403) {
			errorText = 'Your request was denied, possibly due to a session timeout or server restart. Please logout and login again.'
		} else if (jqXHR.responseJSON) {
			var ar = jqXHR.responseJSON.ajaxResult
			if (ar) {
				errorText = ar.statusMessage
				details = ar.statusDetails
			}
		} else if (jqXHR.responseText) {
			details = jqXHR.responseText
		}

		if (errorText == null)
			errorText = 'Unknown error'

		displayAttentionDialog(errorText, details, 'Error')
	}

	function doubleClickSafeguard(jqueryObjToDisable, timeout,
			timeoutExpiredCallback) {
		jqueryObjToDisable.button("option", "disabled", true)
		var finalTimeout = timeout ? timeout : 3000
		setTimeout(function() {
			jqueryObjToDisable.button("option", "disabled", false)
		}, finalTimeout)
		if (timeoutExpiredCallback) {
			setTimeout(timeoutExpiredCallback, finalTimeout)
		}
	}
	
	function escapeHTML(theVal) {
		if (theVal == null) return null
		theVal = $('<div />').text(theVal).html()
		theVal = theVal.replace(/\"/g,"&quot;")
		theVal = theVal.replace(/\'/g,"&#39;")
		return theVal
	}
	
	function validateDate(date) {
		// validate date format mm/dd/yyyy
		var dateCheck = /^([0][1-9]|[1][0-2])\/([0][1-9]|[1-2]\d|[3][0-1])\/([2][01]|[1][6-9])\d{2}(\s([0]\d|[1]\d|[2][0-3])(\:[0-5]\d){1,2})*\s*$/
		return dateCheck.test(date);
	}
	
	function isNormalInteger(str) {
	    var n = ~~Number(str);
	    return String(n) === str && n >= 0;
	}
	
	function isValidDayOfMonthNum(str) {
		if (!isNormalInteger(str)) return false
		var n = ~~Number(str)
		return n > 0 && n <= 31
	}
	
	 // Get all textareas that have a "maxlength" property.
    $('textarea[maxlength]').each(function() {
        var $textarea = $(this)
        var maxlength = $textarea.attr('maxlength')
        var val = $textarea.val()
        $textarea.val(val.slice(0, maxlength))
        $textarea.bind('keyup', function() {
        	// On IE 9 and earlier, calling slice or substring on text area
			// content causes the cursor to jump to the end
        	// of the text area content. If the slice is called on each
			// keyup event , it will be impossible to enter text in the
			// middle
        	// of existing text in a text area. Fixing this by calling slice
			// only when the text area content length is exceeding the max
			// Length.
        	if($textarea.val().length > maxlength){
           		 $textarea.val($textarea.val().slice(0, maxlength));
        	}
        })
    })
</script>



