var _____WB$wombat$assign$function_____ = function(name) {return (self._wb_wombat && self._wb_wombat.local_init && self._wb_wombat.local_init(name)) || self[name]; }; if (!self.__WB_pmw) { self.__WB_pmw = function(obj) { this.__WB_source = obj; return this; } } { let window = _____WB$wombat$assign$function_____("window"); let self = _____WB$wombat$assign$function_____("self"); let document = _____WB$wombat$assign$function_____("document"); let location = _____WB$wombat$assign$function_____("location"); let top = _____WB$wombat$assign$function_____("top"); let parent = _____WB$wombat$assign$function_____("parent"); let frames = _____WB$wombat$assign$function_____("frames"); let opener = _____WB$wombat$assign$function_____("opener"); //useful conversions var mi2km = 1.60934; var mi2m = 1609.34; var km2ft = 3280.84; var m2ft = 3.28084; var ft2m = 0.3048; var ft2km = 0.0003048; var ft2mi = 0.000189394; var m2mi = 0.000621371; var mi2ft = 5280; var km2mi = 0.621371; var rad2deg = 180/Math.PI; var deg2rad = Math.PI/180; function colorStep(step,max,theColorBegin,theColorEnd,overStep,overStep2x) { if(step>max) { if(step>=max*2) { if(overStep2x!=undefined) { return overStep2x; } else { return theColorEnd; } } else { if(overStep!=undefined) { return overStep; } else { return theColorEnd; } } } else if(step<=0) { return theColorBegin; } else { theColorBegin = parseInt(theColorBegin,16); theColorEnd = parseInt(theColorEnd,16); theR0 = (theColorBegin & 0xff0000) >> 16; theG0 = (theColorBegin & 0x00ff00) >> 8; theB0 = (theColorBegin & 0x0000ff) >> 0; theR1 = (theColorEnd & 0xff0000) >> 16; theG1 = (theColorEnd & 0x00ff00) >> 8; theB1 = (theColorEnd & 0x0000ff) >> 0; theR = interpolate(theR0, theR1, step, max); theG = interpolate(theG0, theG1, step, max); theB = interpolate(theB0, theB1, step, max); theVal = ((( theR << 8 ) | theG ) << 8 ) | theB; return (theVal.toString(16)); } } // return the interpolated value between pBegin and pEnd function interpolate(pBegin, pEnd, pStep, pMax) { if (pBegin < pEnd) { return ((pEnd - pBegin) * (pStep / pMax)) + pBegin; } else { return ((pBegin - pEnd) * (1 - (pStep / pMax))) + pEnd; } } function blend_colors(foreground,background,alpha) { var r1 = parseInt(foreground.substring(0,2),16); var g1 = parseInt(foreground.substring(2,4),16); var b1 = parseInt(foreground.substring(4,6),16); var r2 = parseInt(background.substring(0,2),16); var g2 = parseInt(background.substring(2,4),16); var b2 = parseInt(background.substring(4,6),16); var r3 = Math.round(alpha * r1 + (1 - alpha) * r2); var g3 = Math.round(alpha * g1 + (1 - alpha) * g2); var b3 = Math.round(alpha * b1 + (1 - alpha) * b2); if(r3>255) r3=255; if(g3>255) g3=255; if(b3>255) b3=255; var rr3 = r3.toString(16); var gg3 = g3.toString(16); var bb3 = b3.toString(16); if(rr3.length==1) rr3="0"+rr3; if(gg3.length==1) gg3="0"+gg3; if(bb3.length==1) bb3="0"+bb3; return rr3+gg3+bb3; } // 'improve' Math.round() to support a second argument var _round = Math.round; Math.round = function(number, decimals /* optional, default 0 */) { if (arguments.length == 1) return _round(number); var multiplier = Math.pow(10, decimals); return _round(number * multiplier) / multiplier; } function rgb(red, green, blue) { var decColor =0x1000000+ Math.round(blue) + 0x100 * Math.round(green) + 0x10000 *Math.round(red) ; return '#'+decColor.toString(16).substr(1); } function addCommas(nStr) { nStr += ''; x = nStr.split('.'); x1 = x[0]; x2 = x.length > 1 ? '.' + x[1] : ''; var rgx = /(\d+)(\d{3})/; while (rgx.test(x1)) { x1 = x1.replace(rgx, '$1' + ',' + '$2'); } return x1 + x2; } function isArray(theVar) { if(Object.prototype.toString.call( theVar ) === '[object Array]' ) { return true; } else { return false; } } function inArray(needle, haystack, convert) { var length = haystack.length; for(var i = 0; i < length; i++) { if(convert==undefined) { if(haystack[i] == needle) return true; } else { switch(convert) { case "string": if(String(haystack[i])==String(needle)) return true; break; case "float": if(parseFloat(haystack[i])==parseFloat(needle)) return true; break; case "int": if(parseInt(haystack[i])==parseInt(needle)) return true; break; default: if(haystack[i] == needle) return true; break; } } } return false; } function arraysEqual(array1,array2) { if(!array1||!array2) return false; if(array1.length!=array2.length) return false; for (var i = 0; i < array1.length; i++) { // Check if we have nested arrays if (isArray(array1[i]) && isArray(array2[i])) { if(!arraysEqual(array1[i],array2[i])) return false; } else if (array1[i] != array2[i]) { return false; } } return true; } //parses URL vars for permalink variables -- works for arrays, too //permalink parameters can be in any order but if they don't have indices explicitly listed, they MUST have kt be the parameter that separates each det function getUrlVars(url) { var vars = []; var hash; if(!url) { var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&'); } else { var hashes = url.split('&'); } var last_indx; for(var i = 0; i < hashes.length; i++) { hash = hashes[i].split('='); if(hash[0]) { if((hash[0].indexOf("[")!==-1)&&(hash[0].indexOf("]")!==-1)) { var arr_name = hash[0].substring(0,hash[0].indexOf("[")); var arr_indx = hash[0].substring(hash[0].indexOf("[")+1,hash[0].indexOf("]")); if(arr_indx=="") { if(arr_name=="kt") { if(last_indx!=undefined) { arr_indx = last_indx+1; } else { arr_indx = 0; } } else { arr_indx = last_indx; } } else { arr_indx = parseInt(arr_indx); } var arr = []; if(!vars[arr_name]) { //vars.push(arr_name); arr[arr_indx] = hash[1]; vars[arr_name] = arr; } else { vars[arr_name][arr_indx] = hash[1]; } last_indx = parseInt(arr_indx); } else { //vars.push(hash[0]); vars[hash[0]] = hash[1]; } } } return vars; } function colorStep(step,max,theColorBegin,theColorEnd,overStep,overStep2x) { if(step>max) { if(step>=max*2) { if(overStep2x!=undefined) { return overStep2x; } else { return theColorEnd; } } else { if(overStep!=undefined) { return overStep; } else { return theColorEnd; } } } else if(step<=0) { return theColorBegin; } else { theColorBegin = parseInt(theColorBegin,16); theColorEnd = parseInt(theColorEnd,16); theR0 = (theColorBegin & 0xff0000) >> 16; theG0 = (theColorBegin & 0x00ff00) >> 8; theB0 = (theColorBegin & 0x0000ff) >> 0; theR1 = (theColorEnd & 0xff0000) >> 16; theG1 = (theColorEnd & 0x00ff00) >> 8; theB1 = (theColorEnd & 0x0000ff) >> 0; theR = interpolate(theR0, theR1, step, max); theG = interpolate(theG0, theG1, step, max); theB = interpolate(theB0, theB1, step, max); theVal = ((( theR << 8 ) | theG ) << 8 ) | theB; return (theVal.toString(16)); } } // return the interpolated value between pBegin and pEnd function interpolate(pBegin, pEnd, pStep, pMax) { if (pBegin < pEnd) { return ((pEnd - pBegin) * (pStep / pMax)) + pBegin; } else { return ((pBegin - pEnd) * (1 - (pStep / pMax))) + pEnd; } } function clone(obj) { if (null == obj || "object" != typeof obj) return obj; var copy = obj.constructor(); for (var attr in obj) { if (obj.hasOwnProperty(attr)) copy[attr] = obj[attr]; } return copy; } function isEmptyArray(arr) { if(!isArray(arr)) return false; if(arr.length!=1) return false; if(arr[0]=="") { return true; } else { return false; } } //verbose translation of kt depending on units function ktOrMt(kt,shortform = false,comma = false,pluralize=false) { var yield; var unit; if(kt>=1000) { yield = kt/1000; unit = (shortform?"Mt":"megaton"); } else if (kt<1) { yield = kt*1000; unit = (shortform?"t":"ton"); } else { yield = kt; unit = (shortform?"kt":"kiloton"); } if(yield!=1 && pluralize==true && shortform == false) { unit+="s"; } if(comma) yield = addCommas(yield); return yield+" "+unit; } //simple linear interpolation -- returns x3 for a given y3 function lerp(x1,y1,x2,y2,y3) { return ((y2-y3) * x1 + (y3-y1) * x2)/(y2-y1); } var modal_end_function = ""; function query_modal(header="",contents="",buttons=[],end_function="") { $("#modal_header").toggle(header?true:false); $("#modal_header").html(header); $("#modal_text").toggle(contents?true:false); $("#modal_text").html(contents); $("#modal_buttons").toggle(buttons.length?true:false); var b = ""; if(buttons.length) { for(var i in buttons) { b+="