//////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// var http; var fade_tick = 50; var fade_max = 600; var fader = new Array(); var shade_tick = 20; var shade_max = 600; var shader = new Array(); // make sure init handler array is defined document.initialize = new Array(); // global config vars var login = 1; var pref_locked = 0; var pref_confirm = 1; var pref_animate = 1; //////////////////////////////////////////////////////////////////////////////// // F U N C T I O N S /////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// //// run all registered initialization routines function init() { while (handler = document.initialize.shift()) { if (handler.init) { handler.init(); } else { handler(); } } } //////////////////////////////////////////////////////////////////////////////// //// open new window of specified size function openwin(url, name, width, height) { window.open(url, name, ('titlebar=yes,scrollbars=yes,resizable=yes,toolbar=yes,menubar=yes,location=yes,width=' + width + ',height=' + height)); return false; } //////////////////////////////////////////////////////////////////////////////// //// open non-resizable window of specified size function openwin2(url, name, width, height) { window.open(url, name, ('titlebar=no,scrollbars=no,resizable=no,width=' + width + ',height=' + height)); return false; } //////////////////////////////////////////////////////////////////////////////// //// open Britannica window function openbrit(url, type) { var query, mode; if (type == 'search') { // search type query = document.getElementById('brit_query').value; mode = document.getElementById('brit_mode').value; url += ('&ct=' + mode + '&query=' + query); } else { // atlas type mode = document.getElementById('brit_atlas').value; url += ('&mode=atlas&query=' + mode); } openwin(url, 'britannica', 800, 600); return false; } //////////////////////////////////////////////////////////////////////////////// //// open map window function openmap() { var address = document.getElementById('map_address').value; var city = document.getElementById('map_city').value; var state = document.getElementById('map_state').value; var zip = document.getElementById('map_zip').value; var search = new String(); // build search string search += address; if (zip.length) { if (search.length) { search += ', '; } search += zip; } else if (city.length) { if (search.length) { search += ', '; } search += (city + ', ' + state); } window.open(('http://maps.google.com?q=' + search), ('map_' + Math.floor(Math.random() * 10000)), 'scrollbars=yes,resizable=yes,width=700,height=600'); return false; } //////////////////////////////////////////////////////////////////////////////// //// switch search logo function searchmode() { var mode = document.getElementById('searchselect').value; var logo = document.getElementById('searchlogo'); if (mode == 1) { logo.src = 'http://www.google.com/logos/Logo_25wht.gif'; } else { logo.src = 'img/blank.gif'; } } //////////////////////////////////////////////////////////////////////////////// //// attempts to set bookmark function bookmark() { if (window.external) { window.external.AddFavorite("http://portal.tds.net", "TDS"); } else { alert("To bookmark this page, click okay, "+ "then hold down control and press D"); } return(false); } //////////////////////////////////////////////////////////////////////////////// //// attempts to set as homepage function set_homepage(link) { if (window.external) { link.style.behavior='url(#default#homepage)'; link.setHomePage(link.href); } else { alert("To set this page to be your homepage, drag this link onto your "+ "browser's 'Home' button."); } return(false); } //////////////////////////////////////////////////////////////////////////////// //// checks and tries to fix users login domain function ck_login(txtfld) { var login = txtfld.value; var user = null; var domain = null; if (txtfld.value == "") { alert('Please enter your username.'); return(false); } login = txtfld.value.split("@", 2); user = login[0]; domain = login[1]; // no domain, use tds.net if (!domain) { txtfld.value = user+"@tds.net"; return(true); } // mangle if needed if (domain.match(/itis.com/gi) ) { domain = "chorus.net"; } else if (domain.match(/mid-plains.com/gi) ) { domain = "chorus.net"; } else if (domain.match(/mid-plains.net/gi) ) { domain = "chorus.net"; } else if (domain.match(/pcii.net/gi) ) { domain = "chorus.net"; } else if (domain.match(/brodnet.net/gi) ) { domain = "wekz.net"; } else if (domain.match(/ckhnet.com/gi) ) { domain = "wekz.net"; } else if (domain.match(/tdsnet.com/gi) ) { domain = "tds.net"; } else if (domain.match(/conknet.com/gi) ) { domain = "mcttelecom.com"; } txtfld.value = user+"@"+domain; return(true); } //////////////////////////////////////////////////////////////////////////////// //// submit layout customization update function sync(op, id, args, cb) { if (args == undefined) { args = ""; } if (!http) { try { http = new XMLHttpRequest(); send = function() { http.send(null) }; } catch (e) { try { http = new ActiveXObject("Msxml2.XMLHTTP"); send = function() { http.send() }; } catch (e) { try { http = new ActiveXObject("Microsoft.XMLHTTP"); send = function() { http.send() }; } catch (e) { // give up return; } } } } if (cb) { http.onreadystatechange = function() { cb(http); } } http.open('GET', ('/sync.php?op=' + op + '&id=' + id + args), true); send(); } //////////////////////////////////////////////////////////////////////////////// // swap two boxes posistions function swap(a, b) { c = b.cloneNode(true) a.parentNode.replaceChild(c, a); b.parentNode.replaceChild(a, b); c.parentNode.replaceChild(b, c); } //////////////////////////////////////////////////////////////////////////////// //// get height of child // FIXME function childheight(ele) { ele = ele.firstChild; /* while(ele.offsetHeight == undefined) ele = ele.nextSibling; */ h = (ele.offsetHeight != undefined) ? ele.offsetHeight : 0; //alert("childheight returning "+h); // return(h); //alert("starting with "+h); while((ele = ele.nextSibling)) { if(ele.offsetHeight != undefined) { if(ele.nodeType == 1) h = ele.offsetTop + ele.offsetHeight; // h += ele.offsetHeight; //alert("adding "+ele.nodeType+":"+ele.tagName+"("+ele.nodeValue+"): "+ele.offsetHeight+" ("+ele.offsetTop+")"); } } return(h); } //////////////////////////////////////////////////////////////////////////////// //// changes a box to absolute positioning and keeps it's current size function posabs(box) { h = box.offsetHeight; w = box.offsetWidth; box.style.position = "absolute"; box.style.width = w+'px'; box.style.height = h+'px'; } var yesfunc; //////////////////////////////////////////////////////////////////////////////// //// gets the current window size and scroll offset function winsize() { var ret = new Array(); // get page size if (self.innerHeight) { ret.x = self.innerWidth; ret.y = self.innerHeight; } else if (document.documentElement && document.documentElement.clientHeight) { ret.x = document.documentElement.clientWidth; ret.y = document.documentElement.clientHeight; } else if (document.body) { ret.x = document.body.clientWidth; ret.y = document.body.clientHeight; } // get offset if (self.pageYOffset) { ret.offx = self.pageXOffset; ret.offy = self.pageYOffset; } else if (document.documentElement && document.documentElement.scrollTop) { ret.offx = document.documentElement.scrollLeft; ret.offy = document.documentElement.scrollTop; } else if (document.body) { ret.offx = document.body.scrollLeft; ret.offy = document.body.scrollTop; } return(ret); } //////////////////////////////////////////////////////////////////////////////// //// brings up the alert box function showalert() { var box = document.getElementById('alertbox'); var win = winsize(); // center and show box box.style.left = ((win.x - box.offsetWidth >> 1) + win.offx) + "px"; box.style.top = ((win.y - box.offsetHeight >> 1) + win.offy) + "px"; box.style.visibility = "visible"; } //////////////////////////////////////////////////////////////////////////////// //// calls the confirm yes func and then closes the box function alert_ok() { var box = document.getElementById('alertbox'); box.style.visibility = "hidden"; box.style.left = "-500px"; box.style.top = "-500px"; } //////////////////////////////////////////////////////////////////////////////// //// brings up the confirm box function rmconfirm(yf) { var box = document.getElementById('confirmbox'); var win = winsize(); yesfunc = yf; // center and show box box.style.left = ((win.x - box.offsetWidth >> 1) + win.offx) + "px"; box.style.top = ((win.y - box.offsetHeight >> 1) + win.offy) + "px"; box.style.visibility = "visible"; } //////////////////////////////////////////////////////////////////////////////// //// calls the confirm yes func and then closes the box function confirm_yes() { if(typeof(yesfunc) == 'function') yesfunc(); confirm_no(); } //////////////////////////////////////////////////////////////////////////////// //// closes the confirm box function confirm_no() { var box = document.getElementById('confirmbox'); box.style.visibility = "hidden"; box.style.left = "-500px"; box.style.top = "-500px"; } //////////////////////////////////////////////////////////////////////////////// //// locks the layout function locklayout() { txt = (pref_locked ^= 1) ? 'unlock layout' : 'lock layout'; // find all the links and update to toggled command span = document.getElementsByTagName('span'); for (i = 0; i < span.length; i++) { if (span[i].className == 'locklayout') { alert(span[i]); span[i].replaceChild(document.createTextNode(txt), span[i].firstChild); } } sync(8, 1); } //////////////////////////////////////////////////////////////////////////////// //// gives a visual warning that the display is locked // FIXME function trylocked() { span = document.getElementsByTagName('span'); for (i = 0; i < span.length; i++) { if (span[i].className == 'locklayout') { span[i].style.fontWeight = 'bold'; } } } //////////////////////////////////////////////////////////////////////////////// //// B O X F U N C T I O N S ////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// //// remove a box function box_rm(id) { var box = document.getElementById('b'+id); // just remove box if it is already fading if (fader[id]) { fader[id].kill(); return(false); } // initialize fader object fader[id] = new Object(); fader[id].id = id; fader[id].box = box; fader[id].kill = kill; fader[id].start = (new Date()).getTime(); // just remove if animation is turned off if(!pref_animate) { fader[id].kill(); return(true); } // determine fader to use if (typeof(box.style.opacity) != 'undefined') { // use Mozilla fader fader[id].step = ((100 / (fade_max / fade_tick)) / 100); fader[id].total = 1; box.style.opacity = 1; fader[id].fade = fade_moz; } else if (typeof(box.style.filter) != 'undefined') { // use Internet Explorer fader fader[id].step = (100 / (fade_max / fade_tick)); fader[id].total = 100; box.style.zoom = '100%'; box.style.filter = 'alpha(opacity=100)'; fader[id].fade = fade_ie; } else { // unable top fade -- just remove fader[id].kill(); return(true); } // start fading fader[id].alrm = window.setInterval(('fader[' + id + '].fade()'), fade_tick); return(true); ////////////////////////////////////////////////// //// make box fade out in mozilla function fade_moz() { if ((new Date()).getTime() - this.start > fade_max || (this.total -= this.step) < 0) { this.kill(); return; } this.box.style.opacity = this.total; } ////////////////////////////////////////////////// //// make box fade out in ie function fade_ie() { if ((new Date()).getTime() - this.start > fade_max || (this.total -= this.step) < 0) { this.kill(); return; } this.box.filters.alpha.opacity = this.total; } ////////////////////////////////////////////////// //// actually remove a box function kill() { if (this.alrm) { window.clearInterval(this.alrm); } this.box.parentNode.removeChild(this.box); fader[this.id] = undefined; // remove box from arrays box = _b[this.id]; _c[box.c][box.i] = undefined; _b[this.id] = undefined; } ////////////////////////////////////////////////// } //////////////////////////////////////////////////////////////////////////////// //// shade a box function box_shade(id) { box = document.getElementById('c'+id); // skip animation it's clicked again if (shader[id]) { shader[id].shade(); return(true); } // just shade if animation is turned off if (!pref_animate) { if (box.style.visibility != "hidden") { box.style.visibility = "hidden"; box.style.position = "absolute"; } else { box.style.visibility = "visible"; box.style.position = "static"; } return(true); } // initialize shader object shader[id] = new Object(); shader[id].id = id; shader[id].box = box; shader[id].start = (new Date()).getTime(); // opening if (box.style.visibility == "hidden") { shader[id].shade = _unshade; shader[id].total = 0; shader[id].target = childheight(this.box); // set height to height of child shader[id].step = Math.round((shader[id].target / (fade_max / fade_tick))); // set to show unshade, set height in case it was loaded minimized box.style.height = shader[id].total + "px"; box.style.visibility = "visible"; box.style.position = "static"; // closing } else { shader[id].shade = _shade; shader[id].total = box.offsetHeight; shader[id].target = 0; shader[id].step = -Math.round((shader[id].total / (fade_max / fade_tick))); } box.style.overflow = 'hidden'; shader[id].animate = animate; shader[id].alrm = window.setInterval(('shader[' + id + '].animate()'), shade_tick); return(true); ////////////////////////////////////////////////// //// animate the shading function animate() { this.total += this.step; // force shade if time is out, or if there is less than 1 step left if ((new Date()).getTime() - this.start > shade_max || Math.abs(this.target - this.total) < Math.abs(this.step)) { //alert("force shade\n" +"target :"+this.target + " at:"+this.total + " stepping:"+this.step +" = "+ Math.abs(this.target - this.total) + " < " + Math.abs(this.step)); this.shade(); return; } // this.total += this.step; //alert("total: "+this.total+"; target: "+this.target); this.box.style.height = this.total + "px"; } ////////////////////////////////////////////////// //// shade box fully function _shade() { if (this.alrm) { window.clearInterval(this.alrm); } shader[this.id] = undefined; this.box.style.visibility = "hidden"; this.box.style.position = "absolute"; } ////////////////////////////////////////////////// //// unshade box fully function _unshade() { if (this.alrm) { window.clearInterval(this.alrm); } shader[this.id] = undefined; this.box.style.visibility = "visible"; this.box.style.position = "static"; this.box.style.height = "auto"; } } //////////////////////////////////////////////////////////////////////////////// //// move a box up function box_up(id) { box = _b[id]; // check bounds if(!(did = _c[box.c][box.i - 1])) { alert('Box cannot be moved any farther.'); return(false); } dbox = _b[did]; if(dbox.p <= 0) return(false); /* swap posistions */ tmp = box.p; box.p = dbox.p; dbox.p = tmp; /* swap colidx */ tmp = box.i; box.i = dbox.i; dbox.i = tmp; /* set col array */ _c[box.c][box.i] = id; _c[box.c][dbox.i] = did; a = document.getElementById('b'+id); b = document.getElementById('b'+did); swap(a, b); return(true); } //////////////////////////////////////////////////////////////////////////////// //// move a box down function box_down(id) { box = _b[id]; // check bounds if(!(did = _c[box.c][box.i + 1])) { alert('Box cannot be moved any farther.'); return(false); } dbox = _b[did]; if(dbox.p <= 0) { return(false); } /* swap posistions */ tmp = box.p; box.p = dbox.p; dbox.p = tmp; /* swap colidx */ tmp = box.i; box.i = dbox.i; dbox.i = tmp; /* set col array */ _c[box.c][box.i] = id; _c[box.c][dbox.i] = did; a = document.getElementById('b'+id); b = document.getElementById('b'+did); swap(a, b); return(true); } //////////////////////////////////////////////////////////////////////////////// //// U I O P S //////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// //// function rm(id, cfrm) { // check if logged in if (!login) { showalert(); return; } // check if layout is locked if (pref_locked) { trylocked(); return; } // check for confirm if (pref_confirm && !cfrm) { return(rmconfirm(function() {rm(id, 1);})); } if (box_rm(id)) { sync(6, id); } } //////////////////////////////////////////////////////////////////////////////// //// function shade(id) { var box = document.getElementById('c'+id); // check if logged in if (!login) { showalert(); return; } if (box.style.visibility != "hidden") { if (theme_shade) { theme_shade(id); } op = 1; } else { if (theme_unshade) { theme_unshade(id); } op = 2; } if (box_shade(id)) { sync(op, id); } } //////////////////////////////////////////////////////////////////////////////// //// function up(id) { // check if logged in if (!login) { showalert(); return; } // check if layout is locked if (pref_locked) { alert('Layout is locked. Click "unlock" to unlock it.'); trylocked(); return; } if (box_up(id)) { sync(3, id); } } //////////////////////////////////////////////////////////////////////////////// //// function down(id) { // check if logged in if (!login) { showalert(); return; } // check if layout is locked if (pref_locked) { trylocked(); return; } if (box_down(id)) { sync(4, id); } } //////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////