function LeftPad(number, length) {var str = '' + number;while (str.length < length) {str = '0' + str;}return str;}function PrepDate(dateIn, direction) {sortDate = (direction=="asc") ? "Dec 31, 2099" : "Dec 31, 1900";dateIn = (dateIn.match(/^\&nbsp\;/)) ? dateIn.replace(/\&nbsp\;/gi, sortDate) : dateIn.replace(/\&nbsp\;/gi, "" );dateIn = new Date(dateIn);return String(dateIn.getFullYear()) + LeftPad(dateIn.getMonth()+1,2) + LeftPad(dateIn.getDate(),2);}function PrepText(textIn, direction) {sortText = (direction=="asc") ? "ZZZZZ" : "AAAAA";textIn = (textIn.match(/^\&nbsp\;/)) ? textIn.replace(/\&nbsp\;/gi, sortText) : textIn.replace(/\&nbsp\;/gi, "" );return String(textIn);}function PrepNumber(numberIn, direction) {sortNumber = (direction=="asc") ? "99999" : "00000";numberIn = (numberIn.match(/^\&nbsp\;/)) ? numberIn.replace(/\&nbsp\;/gi, sortNumber) : numberIn.replace(/\&nbsp\;/gi, "" );numberIn = (numberIn.match(/\+$/)) ? LeftPad(numberIn, 6) : LeftPad(numberIn, 5);return String(numberIn);}function PrepToughness(toughnessIn, direction) {sortToughness = (direction=="asc") ? "99999" : "00000";toughnessIn = (toughnessIn.match(/^Hard \+/)) ? "66666" : (toughnessIn.match(/^Hard/)) ? "55555" : (toughnessIn.match(/^Moderate \+/)) ? "44444" : (toughnessIn.match(/^Moderate/)) ? "33333" : (toughnessIn.match(/^Easier/)) ? "22222" : sortToughness;return String(toughnessIn);}function PrepExposure(exposureIn, direction) {sortExposure = (direction=="asc") ? "99999" : "00000";exposureIn = (exposureIn.match(/^Extreme/)) ? "66666" : (exposureIn.match(/^High/)) ? "55555" : (exposureIn.match(/^Moderate/)) ? "44444" : (exposureIn.match(/^Mild/)) ? "33333" : sortExposure;return String(exposureIn);}jQuery.fn.dataTableExt.oSort['date-asc']  = function(a,b) {var x = PrepDate(a, "asc");var y = PrepDate(b, "asc");return ((x < y) ? -1 : ((x > y) ?  1 : 0));};jQuery.fn.dataTableExt.oSort['date-desc']  = function(a,b) {var x = PrepDate(a, "desc");var y = PrepDate(b, "desc");return ((x < y) ?  1 : ((x > y) ? -1 : 0));};jQuery.fn.dataTableExt.oSort['number-asc']  = function(a,b) {var x = PrepNumber(a, "asc");var y = PrepNumber(b, "asc");return ((x < y) ? -1 : ((x > y) ?  1 : 0));};jQuery.fn.dataTableExt.oSort['number-desc']  = function(a,b) {var x = PrepNumber(a, "desc");var y = PrepNumber(b, "desc");return ((x < y) ?  1 : ((x > y) ? -1 : 0));};jQuery.fn.dataTableExt.oSort['text-asc']  = function(a,b) {var x = PrepText(a, "asc");var y = PrepText(b, "asc");return ((x < y) ? -1 : ((x > y) ?  1 : 0));};jQuery.fn.dataTableExt.oSort['text-desc']  = function(a,b) {var x = PrepText(a, "desc");var y = PrepText(b, "desc");return ((x < y) ?  1 : ((x > y) ? -1 : 0));};jQuery.fn.dataTableExt.oSort['toughness-asc']  = function(a,b) {var x = PrepToughness(a, "asc");var y = PrepToughness(b, "asc");return ((x < y) ? -1 : ((x > y) ?  1 : 0));};jQuery.fn.dataTableExt.oSort['toughness-desc']  = function(a,b) {var x = PrepToughness(a, "desc");var y = PrepToughness(b, "desc");return ((x < y) ?  1 : ((x > y) ? -1 : 0));};jQuery.fn.dataTableExt.oSort['exposure-asc']  = function(a,b) {var x = PrepExposure(a, "asc");var y = PrepExposure(b, "asc");return ((x < y) ? -1 : ((x > y) ?  1 : 0));};jQuery.fn.dataTableExt.oSort['exposure-desc']  = function(a,b) {var x = PrepExposure(a, "desc");var y = PrepExposure(b, "desc");return ((x < y) ?  1 : ((x > y) ? -1 : 0));};
