Slightly improved graemlins_select.js

Code

gpath='/ubbthreads/images/graemlins/';
d='';


skip = new Array();

for(f=0;f<document.replier.instant.length;f++){skip[document.replier.instant[f].src.split('.gif')[0].split(gpath)[1]]='omit';}


grandom=dl[Math.round(Math.random()*dl.length)];
if (skip[grandom] == 'omit'){grandom = 'wave';}
current=grandom;

d+='<table cellpadding="0" cellspacing="0"><tr><td><br /><br /><br /><select class="formboxes" name="egselect" onchange="ShowSmiley(this.options[this.selectedIndex].value);">\n';
d+='<option selected value="'+grandom+'"> Extra Graemlins\n';

for(i=0;i<dl.length;i++){
     if (skip[dl[i]] == 'omit') {d+='';}
     else {d+='<option value="'+dl[i]+'"> :'+dl[i]+':\n';}
}

d+='</select>  <b>>></b> <br /><br /><br />\n';

d+='</td><td><img id="egimg" src="'+gpath+grandom+'.gif" style="cursor:pointer; cursor:hand;" onclick="AddIt(current)" alt=":'+grandom+':" title=":'+grandom+':" /></td></tr></table>\n';


document.write(d);

document.replier.egselect.options[0].selected = "true";

function ShowSmiley(i){

document.getElementById('egimg').src=gpath+i+'.gif';
document.getElementById('egimg').alt=':'+i+':';
document.getElementById('egimg').title=':'+i+':';
current=i;
}

function AddIt(sm){
insertAtCaret(document.replier.Body, ' :'+sm+':');
document.replier.Body.focus();
}