// this file REQUIRES that the SACK AJAX file BE INCLUDED BEFORE IT IN THE LOAD LIST window.onload=init; var member_search_ajax; var timerID = null; var timerOn = false; var timecount = 2000; // Change this to the time delay that you desire var what = null; var newbrowser = true; var check = false; function init() { if (document.getElementById('member_search_textbox') && document.getElementById('member_search_dropdown')) { member_search_ajax=new sack(); var searchTextBox=document.getElementById('member_search_textbox'); var searchDropBox=document.getElementById('member_search_dropdown'); searchDropBox.style.width=getStyle('member_search_textbox','width'); var position=new Array(); position=getTopLeft('member_search_textbox'); //alert("position left:" + position[1] + " top:" + position[0]); searchDropBox.style.left=position[1] + "px"; //var newtop=position[0]+parseFloat(searchTextBox.style.height.substring(0,2)); var newtop=position[0]+23; //alert(searchTextBox.style.height.substring(0,2)); //alert(newtop); searchDropBox.style.top=newtop + "px"; } // set up for hiding/showing the search box if (document.layers) { layerRef="document.layers"; styleSwitch=""; visibleVar="show"; screenSize = window.innerWidth; what ="ns4"; } else if(document.all) { layerRef="document.all"; styleSwitch=".style"; visibleVar="visible"; screenSize = document.body.clientWidth + 18; what ="ie4"; } else if(document.getElementById) { layerRef="document.getElementByID"; styleSwitch=".style"; visibleVar="visible"; what="dom1"; } else { what="none"; newbrowser = false; } check = true; } var xmlHttp=false; function getAttrPixValue(e,a){ var px=0; if(window.getComputedStyle){ var css,sty=window.getComputedStyle(e,''); if(sty&&sty.getPropertyCSSValue){ css=sty.getPropertyCSSValue(a); if((css)&&css.primitiveType<=18){try{px=css.getFloatValue(5)|0;}catch(e){};} } } return px; } function getTopLeft(sID){ var o=document.getElementById(sID); if(o==null){return [0,0];} var top=o.offsetTop,left=o.offsetLeft; o=o.offsetParent; while(o){ if(document.all){ if(o.offsetParent){ if(o.scrollTop)top-=o.scrollTop; if(o.scrollLeft)left-=o.scrollLeft; } }else{ if(o.scrollTop)top-=o.scrollTop; if(o.scrollLeft)left-=o.scrollLeft; // Mozilla bug if((o.tagName=='DIV')||(o.tagName=='TABLE' && navigator.vendor!=undefined)) top+=getAttrPixValue(o,'border-top-width')|0,left+=getAttrPixValue(o,'border-left-width')|0; } top+=o.offsetTop; left+=o.offsetLeft; o=o.offsetParent; } if(navigator.userAgent.indexOf('Mac')!=-1 && typeof(document.body.leftMargin)!='undefined'){ left+=document.body.leftMargin,top+=document.body.topMargin; // working? } return [top,left]; } // -------------------------------------------------------------------------------------------------------------------------------- function getStyle(el,styleProp) { var x = document.getElementById(el); if (x.currentStyle) var y = x.currentStyle[styleProp]; else if (window.getComputedStyle) var y = document.defaultView.getComputedStyle(x,null).getPropertyValue(styleProp); return y; } // -------------------------------------------------------------------------------------------------------------------------------- function startTime() { if (timerOn == false) { timerID=setTimeout( "hideLayer('member_search_dropdown')" , timecount); timerOn = true; } } // -------------------------------------------------------------------------------------------------------------------------------- function stopTime() { if (timerOn) { clearTimeout(timerID); timerID = null; timerOn = false; } } // -------------------------------------------------------------------------------------------------------------------------------- function cursor_wait() { document.body.style.cursor = 'wait'; } // -------------------------------------------------------------------------------------------------------------------------------- function cursor_clear() { document.body.style.cursor = 'default'; } // -------------------------------------------------------------------------------------------------------------------------------- // Toggles the layer visibility on function showLayer(layerName) { if(check) { if (what =="none") { return; } else if (what == "dom1") { document.getElementById(layerName).style.visibility="visible"; } else { eval(layerRef+'["'+layerName+'"]'+styleSwitch+'.visibility="visible"'); } } else { return; } } // -------------------------------------------------------------------------------------------------------------------------------- // Toggles the layer visibility off function hideLayer(layerName) { if(check) { if (what =="none") { return; } else if (what == "dom1") { document.getElementById(layerName).style.visibility="hidden"; } else { eval(layerRef+'["'+layerName+'"]'+styleSwitch+'.visibility="hidden"'); } } else { return; } } // -------------------------------------------------------------------------------------------------------------------------------- //because every change function on this page references the same section of the page, we can use the same function // to change the actual html goodies. function stateChanged() { cursor_clear(); if (member_search_ajax.response != "notext") { showLayer('member_search_dropdown'); } else { hideLayer('member_search_dropdown'); } } function ajaxError() { alert("There was an error retrieving the list of search results. Please try again"); } // -------------------------------------------------------------------------------------------------------------------------------- // works every time the text box is changed function updateSearch() { // the php page uses "if(isset())" to check for the various operations var searchtext=document.getElementById('member_search_textbox').value; member_search_ajax.setVar("search",searchtext); member_search_ajax.requestFile='http://n4a.solacedev.com/tools/member_search_dropdown/bin/member_search_response.php'; member_search_ajax.element='member_search_dropdown'; member_search_ajax.method="GET"; member_search_ajax.onLoading=cursor_wait; member_search_ajax.onCompletion=stateChanged; member_search_ajax.onError=ajaxError; member_search_ajax.runAJAX(); }