function Hello() { } //////////////////// // // // Extensions // // // //////////////////// Math.rand = function ( a, b ) { if( a && !b ) return Math.floor( Math.random() * a ); if( a > b ) return Math.floor( Math.random() * ( a - b )) + b; if( b > a ) return Math.floor( Math.random() * ( b - a )) + a; return a; }; String.prototype.isNumeric = function () { var list = "0123456789."; var flag = true; var snip = null; for( var i = 0; i < this.length && flag == true; i++ ) { snip = this.charAt( i ); if( list.indexOf( snip ) == -1 ) flag = false; }; return flag; }; ////////////////// // // // Routines // // // ////////////////// function validate( url, zip ) { if( !url ) url = "www.nytimes.com"; if( url == "google.com" || url == "http://google.com" ) url = "www.google.com"; if( url.indexOf( "http://" ) == -1 ) url = "http://" + url; // the following didn't take into account internationl ID's //if( zip.length != 5 || !zip.isNumeric() ) zip = null; var valid = new Array(); valid["url"] = url; valid["zip"] = escape( zip ); return valid; }; function update() { var url = document.getElementById( "url" ).value; var zip = document.getElementById( "zip" ).value; var valid = validate( url, zip ); url = valid["url"]; zip = valid["zip"]; if( !zip ) zip = "10002"; var htm = ""; //document.getElementById( "code" ).value = htm; var esc = "<script type='text/javascript' src='http://stewdio.org/windmaker/windmaker.js"; esc += "?zip="+ zip; esc += "'></script>"; document.getElementById( "code" ).innerHTML = esc; var add = "javascript:void(document.location='http://stewdio.org/windmaker/windmaker.html"; add += "?zip="+ zip; add += "&url='+escape(document.location.href))"; document.getElementById( "bookmarklet" ).href = add; }; function launch() { var url = document.getElementById( "url" ).value; var zip = document.getElementById( "zip" ).value; var valid = validate( url, zip ); url = valid["url"]; zip = valid["zip"]; var make = "http://stewdio.org/windmaker/windmaker.html?"; if( zip ) make += "zip="+ zip +"&"; if( url ) make += "url="+ escape( url ); //var pwin = window.open( make, "WindMaker" ); //pwin.focus (); document.location.href = make; }; function show( id ) { var el = document.getElementById( id ); el.style.display = "block"; var tab = document.getElementById( id + "_tab" ); tab.className = "selected"; }; function hide( id ) { var el = document.getElementById( id ); el.style.display = "none"; var tab = document.getElementById( id + "_tab" ); tab.className = ""; }; function hideAll() { hide( "about" ); hide( "steal" ); hide( "book" ); hide( "inter" ); }; function switchTo( id ) { hideAll(); show( id ); }; function reset() { hideAll(); document.getElementById( "url" ).value = "www.nytimes.com"; document.getElementById( "zip" ).value = "10002"; update(); };