// generic xmlhttp object function function getHTTPObject() { var http; if (window.XMLHttpRequest) { // Mozilla, Safari,... http = new XMLHttpRequest(); }else if(window.ActiveXObject) { // IE try { http = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { http = new ActiveXObject("Microsoft.XMLHTTP"); }catch(e2) { } } }else { ajdisabled = 1; /* disable this because this user has an ancient browsers */ /* alert("failed to creat the http object");*/ } return http; } var update_interval =8; // number of seconds between updates var ajdisabled = 0; // disables ajax functionality var banners = null; // this will hold all the banners var current_banner = 0; // this will always be the current banner, default to 0 // should be no need to edit any vars below this line var stats_age = 0; var banner_update_interval = 120; // duration between updates of actual banner data var banner_last_update = 0; // dont change this default val var url = "http://www.stignace.org/banner.js"; var doing_query = 0; var Seconds = 0; var Minutes = 0; var Hours = 0; var TT = ''; var TimerOn = false; var totalSeconds = 0; var next_update =0; var http = getHTTPObject(); // We create the HTTP Object function do_query() { doing_query = 1; //alert("doing query, lastupdate" + banner_last_update); http.open("GET",url,true); http.onreadystatechange = function() { if(http.readyState == 4) { var results = http.responseText; stats_age = 0; doing_query =0; // done with the query; // propigate the banners array banners = results.split('|'); } return true; } http.send(null); } function update_banner() { // here we need to select a random banner to display max = banners.length; // number of elements in the banner array mykey = Math.floor(Math.random()*max); if(mykey == current_banner) { // if we are the same as the current one, try again mykey = Math.floor(Math.random()*max); } //alert(banners[mykey]); document.getElementById('banner_area').innerHTML = banners[mykey]; // populate the banner area } function BannerRotateTimer() { // this updates the banner content, not the banners themselves /* banner_last_update++; if(banner_last_update == banner_update_interval && doing_query!=1) { do_query(); banner_last_update = 0; } */ // end of banner content update if( ++Seconds > 59 ) { Minutes++; Seconds = 0; if(Minutes > 59) { Hours++; Minutes = 0; } } if( ++stats_age > update_interval && doing_query!=1 ) { update_banner(); stats_age=0; } Seconds = (Seconds<10 ? '0' : '') + Seconds; ++totalSeconds; if(doing_query) { stats_age = 0; next_update = 'In Progress'; } TT = setTimeout("BannerRotateTimer()", 1000); } function ToggleTimer() { if( !TimerOn ) { TT = setTimeout("BannerRotateTimer()", 1000); TimerOn = true; }else { TT = clearTimeout( TT ); TimerOn = false; } } if(ajdisabled==0) { do_query(); ToggleTimer(); }