var gAddOn="";

if(document.modifyForm){
gAddOn+='<select name="gOpt"><option value="" selected="1">None</option><option value="">--------------</option>'
for(d=0;d<groups.length;d++){
if(!groups[d][0].match(/EMPTY/i)){
gAddOn+='<option value="{g='+d+'}[br]">'+groups[d][0]+'</option>'
}
}
gAddOn+='</select>'
document.modifyForm.customtitle.parentNode.parentNode.parentNode.style.display="none"

var gDetect=document.modifyForm.customtitle.parentNode.parentNode.parentNode.parentNode;
gNewRow = gDetect.insertRow(1);
gNewRow.insertCell(0).innerHTML = '<font size=2>Secondary Group:</font>';
gNewRow.insertCell(1).innerHTML = gAddOn;
gNewRow.insertCell(2).innerHTML = '<font size=1>Select a secondary group to place this user into.</font>';
gNewRow.vAlign="top"
if(gCustom!="disable"){
gNewRow2 = gDetect.insertRow(2);
gNewRow2.insertCell(0).innerHTML = '<font size=2>Custom Title:</font>';
gNewRow2.insertCell(1).innerHTML = '<input type="text" size="35" name="faketitle" value="" maxlength="290"/>';
gNewRow2.insertCell(2).innerHTML = '<font size=1>To have a custom title displayed under this user\'s name, enter it in this box. UBBC tags are allowed.</font>';
gNewRow2.vAlign="top"
}else{
/*No Custom*/
}


var gMainGroup=document.modifyForm.membergroup.parentNode.parentNode
gMainGroup.previousSibling.innerHTML=gMainGroup.previousSibling.innerHTML.replace('Member','Main')
gMainGroup.nextSibling.innerHTML=gMainGroup.nextSibling.innerHTML.replace('member','main')
}

Form = document.modifyForm;
if(document.modifyForm && document.modifyForm.customtitle){
if(document.modifyForm) {
    document.modifyForm.onsubmit = function() {
        document.modifyForm.customtitle.value=document.modifyForm.gOpt.value+document.modifyForm.faketitle.value
    }
}
}

var gStar=new Array();
var gName=new Array();
var gGroup=new Array();
for(x=0;x<groups.length;x++){
if(groups[x][0]!="EMPTY HANDLER"){
gStar[x]=''
for(z=0;z<groups[x][1];z++){
gStar[x]+='<img src="'+groups[x][2]+'"/>'
}
gName[x]=groups[x][0]+'<br/>'
gGroup[x]=gName[x]+gStar[x]
}
}
var gTd=document.getElementsByTagName('td')
for(l=0;l<gTd.length;l++){
if(gTd[l].width=="20%" && gTd[l].className.match(/windowbg(|2)/i) && gTd[l].innerHTML.match(/\{g\=(\d+)\}/)){
var gReg=RegExp.$1
gTd[l].innerHTML=gTd[l].innerHTML.replace('{g='+gReg+'}',gGroup[gReg])
}
}


var option=document.getElementsByTagName('option')
if(document.modifyForm){
if(document.modifyForm.customtitle.value.match(/\{g\=(\d+)\}/)){
var gSetVal=RegExp.$1
for(k=0;k<option.length;k++){
if(option[k].value.match(gSetVal) && option[k].value.match(/\{g\=/)) {
option[k].selected="1"
}
}
customTitleVar=document.modifyForm.customtitle.value.split('}[br]')[1]
document.modifyForm.faketitle.value=customTitleVar
}else{
document.modifyForm.faketitle.value=document.modifyForm.customtitle.value
}
}