function onDocReady(fn){
$d.readyState!=="loading" ? fn():document.addEventListener('DOMContentLoaded',fn);
}
function onWinLoad(fn){
$d.readyState==="complete") ? fn(): window.addEventListener('load',fn);
}
onDocReady provides a callback when the HTML dom is ready to fully access/parse/manipulate.
onWinLoad provides a callback when everything has loaded (images etc)