if ("undefined" != typeof jQuery) { $(document).ready(function () { if (jQuery().validate) { $.validator.addMethod("US_DateFormat", function (value, element) { // return value.match(/^dd?-dd?-dd$/); return value.match(/^\d{2}\/\d{2}\/\d{4}$/); }, "Please enter a date in the format dd/mm/yyyy." ); } }); } function convertDate(inputFormat) { function pad(s) { return (s < 10) ? '0' + s : s; } var d = new Date(inputFormat); return [pad(d.getDate()), pad(d.getMonth() + 1), d.getFullYear()].join('/'); } if (typeof String.prototype.startsWith != 'function') { String.prototype.startsWith = function (str) { return this.indexOf(str) === 0; }; } if (typeof String.prototype.endsWith != 'function') { String.prototype.endsWith = function (str) { return this.slice(-str.length) == str; }; } function setCookie(cname, cvalue, exdays) { var d = new Date(); d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000)); var expires = "expires=" + d.toUTCString(); document.cookie = cname + "=" + cvalue + "; " + expires; } function getCookie(cname) { var name = cname + "="; var ca = document.cookie.split(';'); for (var i = 0; i < ca.length; i++) { var c = ca[i]; while (c.charAt(0) == ' ') c = c.substring(1); if (c.indexOf(name) == 0) return c.substring(name.length, c.length); } return ""; } function setPage() { hrefString = document.location.href ? document.location.href : document.location; if (hrefString.endsWith("#")) { hrefString = hrefString.replace("#",""); } //if (hrefString.endsWith("/")) { // hrefString = hrefString + "Default.aspx"; //} //else if (!hrefString.endsWith(".aspx")) { // hrefString = hrefString + ".aspx"; //} if (document.getElementById("side_menu") != null) { //alert("In set page: " + hrefString); //setActiveMenu(document.getElementById("side_menu").getElementsByTagName("a"), extractPageName(hrefString)); setActiveMenu(document.getElementById("side_menu").getElementsByTagName("a"), hrefString); } } function setActiveMenu(arr, crtPage) { for (var i = 0; i < arr.length; i++) { //alert("In setActiveMenu: " + arr[i].href + ", " + crtPage); if (extractPageName(arr[i].href) == crtPage) { //alert("Match found: " + arr[i].href + ", " + crtPage); if (arr[i].parentNode.tagName == "LI" ) { arr[i].parentNode.className = "active"; } if (arr[i].parentNode.parentNode.parentNode.tagName == "LI" ) { arr[i].parentNode.parentNode.parentNode.className = "active"; } if (arr[i].parentNode.parentNode.parentNode.parentNode.parentNode.tagName == "LI") { arr[i].parentNode.parentNode.parentNode.parentNode.parentNode.className = "active"; } } else { if (arr[i].parentNode.tagName == "LI") { arr[i].parentNode.className = ""; } } } } function extractPageName(hrefString) { //var arr = hrefString.split('/'); //return (arr.length < 2) ? hrefString : arr[arr.length-2].toLowerCase() + arr[arr.length-1].toLowerCase(); return hrefString; //.pathname.match(/[^\/]+$/)[0];//.replace("#", ""); } function getPageName() { return document.location.pathname.match(/[^\/]+$/)[0]; } function getParameterByName(name, url) { if (!url) url = window.location.href; name = name.replace(/[\[\]]/g, "\\$&"); var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"), results = regex.exec(url); if (!results) return null; if (!results[2]) return ''; return decodeURIComponent(results[2].replace(/\+/g, " ")); } function escapeHtml(text) { // May need to add the following ~!*()' var map = { '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }; return text.replace(/[&<>"']/g, function (m) { return map[m]; }); } function getQueryString(search) { var queries = {}; $.each(document.location.search.substr(1).split('&'), function (c, q) { var i = q.split('='); if (i[1] != undefined) { queries[i[0].toString()] = i[1].toString(); } }); return queries[search]; }