//DHTML COMBOBOX jamesgeraldgayoiloilophilippines2007 //cb global vars //defaults :cbAutoExpand=false;cbLimitToList=false;cbMatchOnAnyPart=true; // cbHighLightMatch=false;cbAddToList=false; var jvArray,txtList; var cbIgnoreKeyDown=false; var cbOldTextValue=''; var cbTextControl; var cbHighlightedItem; var limitedText=''; var cbListBox,cbListBoxBckgrnd,cbButton; var justhide=false; function cbActivate(e){ var elem=(document.getElementById && !document.all) ? (e.target):(window.event.srcElement); if (!elem.getAttribute("cbData")){alert("No data parameter passed.");return;} if (document.getElementById("cbBox")==null){ document.body.insertAdjacentHTML ("beforeEnd","
"); document.body.insertAdjacentHTML ("beforeEnd",""); document.body.insertAdjacentHTML ("beforeEnd","
")
if (document.getElementById && !document.all){document.getElementById("cbBoxbckgrnd").style.MozOpacity =.95;}
else{document.getElementById("cbBoxbckgrnd").style.filter="Alpha(Opacity=95)";}}
if ((cbTextControl==undefined) || (cbTextControl!=elem)) {cbTextControl=elem;cbOldTextValue=elem.value;
jvArray=eval(elem.getAttribute("cbData") );jvArray=jvArray.sort();txtList=jvArray.join("|");
cbListBox=document.getElementById("cbBox");cbListBoxBckgrnd=document.getElementById("cbBoxbckgrnd");
cbButton=document.getElementById("cbDrpDwnBttn");
cbListBox.style.display="none"; cbListBoxBckgrnd.style.display="none";cbButton.style.display="none"
var pT,pL,vparent;pT=0;pL=0;vparent=elem.parentNode;
while (vparent!=null && vparent.tagName!="BODY"){if (vparent.tagName!="FORM"){pT=pT+vparent.offsetTop;pL=pL+vparent.offsetLeft;}vparent=vparent.parentNode;}
cbListBox.style.top=(elem.offsetTop+elem.offsetHeight+pT-0)+'px';
cbListBox.style.left=(elem.offsetLeft+pL+1)+'px';
var w=(document.getElementById && !document.all) ? elem.offsetWidth-2 :elem.offsetWidth;
cbListBox.style.width=(w+16 )+'px';cbListBoxBckgrnd.style.top=cbListBox.style.top;
cbListBoxBckgrnd.style.left=cbListBox.style.left;cbListBoxBckgrnd.style.width=cbListBox.style.width;
cbButton.style.left=elem.offsetLeft+pL+elem.offsetWidth-0;cbButton.style.top=parseInt(cbListBox.style.top)-18;//elem.offsetHeight;
cbListBox.onmouseover=cbonMouseOver;cbListBox.onmouseout=cbonMouseOut;cbListBox.onclick=cbonMouseClick;
elem.onkeypress=cbonKeyPress;elem.onkeydown=cbonKeyDown;elem.onkeyup=cbonKeyUp;cbUpdateListBox(e);document.body.onclick=documentclick;}
else{if (justhide==true){justhide=false;}else{cbUpdateListBox(e);}}
}
function documentclick(e){
var elem=(document.getElementById && !document.all) ? (e.target):(window.event.srcElement);
if (elem==cbTextControl){return}cbHide();cbDoesValueExist();
}
function cbonKeyDown(e){var elem=(document.getElementById && !document.all) ? (e.target):(window.event.srcElement);
var keyc=(document.getElementById && !document.all) ? (e.keyCode):(window.event.keyCode);if (keyc==8){if (elem.value.length>0) {cbIgnoreKeyDown=true;}return;}
if (keyc==13){cbonEnter(e);return};if (keyc==46){return;}//DELETE
if (keyc==9){if (document.getElementById && !document.all){e.preventDefault();}cbonEnter(e);return}
if (keyc==38 && cbListBox.childNodes.length>0 ){
if (cbHighlightedItem==null ){cbHighlightItem(e,cbListBox.childNodes[0])}
else{if (cbHighlightedItem==cbListBox.firstChild){return;}cbHighlightItem(e,cbHighlightedItem.previousSibling.previousSibling)};return;}
if (keyc==40 && cbListBox.childNodes.length>0 ){
if (cbHighlightedItem==null ){cbHighlightItem(e,cbListBox.childNodes[0])}
else{if (cbHighlightedItem==cbListBox.lastChild){return;}cbHighlightItem(e,cbHighlightedItem.nextSibling.nextSibling)};return;}
}
function cbonKeyUp(e){
var keyc=(document.getElementById && !document.all) ? (e.keyCode):(window.event.keyCode);
var elem=(document.getElementById && !document.all) ? (e.target):(window.event.srcElement);
if (cbIgnoreKeyDown==false){return;}
var elem=(document.getElementById && !document.all) ? (e.target):(window.event.srcElement);
cbUpdateListBox(e);
if ( cbListBox.childNodes.length==0){return;}
if (document.getElementById && !document.all){var afText=cbListBox.childNodes[0].innerHTML;}
else{var afText=cbListBox.childNodes(0).innerText;}
if (afText.toLowerCase().indexOf(elem.value.toLowerCase())!=0){cbHighlightItem(e);return;}
else{cbIgnoreKeyDown=false }
}
function cbonKeyPress(e){
var elem=(document.getElementById && !document.all) ? (e.target):(window.event.srcElement);
var keyc=(document.getElementById && !document.all) ? (e.charCode):(window.event.keyCode);
if (keyc==0 || keyc==13){return;}//darn Mozilla; i never knew this;gave me a hard time why updn arrow routine won't work
if (keyc==27){elem.value=cbOldTextValue;cbIgnoreKeyDown=true;return;}
if (cbIgnoreKeyDown==true){return}
if (typeof elem.createTextRange!="undefined"){
var txt1=elem.createTextRange();var txt2=document.selection.createRange();var txt2txt=txt2.text;
if (txt1.text.toLowerCase().substr(txt1.text.length-txt2txt.length)==txt2txt.toLowerCase() && txt2txt.length>0){
}else{txt2.moveToPoint(window.event.x, window.event.y);txt2.expand("character");if (txt2.text.length>0){return;};}
window.event.returnValue=false;
elem.value=elem.value.substr(0,(elem.value.length-txt2txt.length))+String.fromCharCode(keyc);cbUpdateListBox(e);//
var xtxtrange=elem.createTextRange();xtxtrange.moveStart("character",elem.value.length);xtxtrange.select() ;
if (cbListBox.childNodes.length==0){return;}cbHighlightItem();
var afText=cbListBox.childNodes[0].innerText;
if (afText.toLowerCase().indexOf(elem.value.toLowerCase())!=0){return;}
if (!elem.getAttribute("cbAutoExpand")){return;}else{if (elem.getAttribute("cbAutoExpand")==false){return;}}
var subtext=elem.value;elem.value=afText;var txtrange=elem.createTextRange();
txtrange.moveStart("character",subtext.length);txtrange.select();
}
else{//darn mozilla;never thought it to be simpler(just this)
var txt2=window.getSelection(); var txt2txt=txt2.toString();
if (elem.selectionStart!=elem.value.length){
if (((elem.selectionEnd-elem.selectionStart)+elem.selectionStart)!=elem.value.length){return;}}
var thechar=String.fromCharCode(keyc);var re=thechar.match(/[ \s\u00C0-\u00FFA-Za-z0-9,'\-]/i);
if (re==null){}else{e.preventDefault();elem.value=elem.value.substr(0,(elem.value.length-(elem.selectionEnd-elem.selectionStart)))+String.fromCharCode(keyc);}
cbUpdateListBox(e);if (cbListBox.childNodes.length==0){return;}cbHighlightItem();
var afText=cbListBox.childNodes[0].innerHTML;
if (afText.toLowerCase().indexOf(elem.value.toLowerCase())!=0){return;}
if (!elem.getAttribute("cbAutoExpand")){return;}else{if (elem.getAttribute("cbAutoExpand")==false){return;}}
var subtext=elem.value;elem.value=afText;elem.Select;elem.selectionStart=subtext.length;
}
}
function cbLimitChoice(theList,thefilter){cbHighlightedItem=null;
var xtheList=theList.replace(/\,/g,"===");//so that a comma stays a comma
xjarray=jsfilter(xtheList,thefilter);
if (xjarray==null){limitedText='';return ''}
if (xjarray.length>300){xjarray=xjarray.slice(0,300);}
xjarray=xjarray.toString();xjarray=xjarray.replace(/\|/ig,"");limitedText=xjarray;xjarray=xjarray.replace(/,/g,'