//// APEX Grandfather Objects -- by Ben Thum
var dashes = '------------------------------';

var comSep1 = "|";
var comSep2 = "~";
var comSep3 = "";
var comSep4 = "";

function apxFormItem(){
this.formNo = 0;
this.id = "";
this.fontSize = 10;
this.isBold = true;
this.fontFamily = "Arial";
this.border = "border:solid 1px gray";
this.hiliteColor = "#FF6633";
this.backgroundColor = "#FFFFFF";
this.checkedNos = new Array();

this.selWidth = "100%";

this.options = new Array();
this.values = new Array();

	
this.setFormNo =  formItem_setFormNo;	
this.setID =  formItem_setID;	
this.setWidth =  formItem_setWidth;	
this.setBorder = formItem_setBorder;
this.setArray = formItem_setArray;

this.setFontSize =  formItem_setFontSize;	
this.setFontSize =  formItem_setFontFamily;	
this.setFontSize =  formItem_setFontBold;	
this.setBackgroundColor = formItem_setBackgroundColor;
this.getID = formItem_getID;
this.getValue = formItem_getValue;
	
}

function formItem_setID(ix){
this.id = ix;	
}

function formItem_getID(){
return this.id;	
}

function formItem_setWidth(xSz){
// this.selWidth=xSz;
 document.forms[this.formNo][this.id].style.width=xSz;
	
}


function formItem_setFontSize(xFz){
 document.forms[this.formNo][this.id].style.fontSize=xFz;
}

function formItem_setFontFamily(xFz){
 document.forms[this.formNo][this.id].style.fontSize=xFz;
}


function formItem_setFontBold(xFz){
 document.forms[this.formNo][this.id].style.fontSize=xFz;
}


function formItem_setBorder(){
	
}

function formItem_setBackgroundColor(bCol){
document.forms[this.formNo][this.id].style.background=bCol;
//document.getElementById(this.id).style.background=bCol;

}


function formItem_getValue(){
var mDoc =document.forms[this.formNo].elements[this.id];
return mDoc.value;
// var ss = document.forms[fNo][xID].options[i].value;
	
	
}

function formItem_setFormNo(xx){
	this.formNo=xx;	
}

function formItem_setArray(myArray){
var i;
var s1;


this.options = new Array();
this.values = new Array();

for (i=0;i<myArray.length;i++){
	s1 = myArray[i].split(comSep1);
	this.options[i] = s1[1];
	this.values[i] = s1[0];
}




}

//////////// TEXT FIELD ////////////////

function apxTextField(){
	
	
this.popDialog = tf_popDialog;
	
}

function tf_popDialog(){
var ss;

ss  = '<input type="text" id="' + this.id + '" style="width:' + this.selWidth + ';' + this.border + ';';
if (this.isBold){ss += 'font-weight:bold;'};
ss += 'value="' + this.values[0] + '" >\n';
return ss;	
	
}



apxTextField.prototype = new apxFormItem();


/////////////// Radio Button
function apxRadioCheckBox(){
this.inactiveColor = "#444444";
this.checkType = "checkbox";
this.carriageReturn = "";	
this.backgroundColor = "#FFFFFF";
	
this.popDialog = rc_popDialog;
this.setChecked = rc_setChecked;	
this.getChecked = rc_getChecked;
this.setBackgroundColor = rc_setBackgroundColor;

}


function rc_popDialog(){
var i;
var s1;
var ss ="";
var xWidth;
var charWidth=9;
var isChecked;
var j;

this.checkType = this.checkType.toLowerCase();

for (i=0;i<this.options.length;i++){
	isChecked=false;
	for (j=0;j<this.checkedNos.length;j++){
			if (this.checkedNos[j]==this.values[i]){isChecked=true} else {if (this.checkType=="radio"){isChecked=false}};
		}
	ss += '<input type="' + this.checkType + '" id="' + this.id +  '_' + this.values[i] + '" name="' + this.id + '" ';
	ss += ' value="' + this.values[i] + '" ';
	if (isChecked){ ss += 'checked'};
	ss += ' onclick="rc_clicked(' + this.formNo + ',\'' + this.id + '\',\'' + this.values[i];
	ss += '\',\'' + this.inactiveColor + '\',\'' + this.values.join(comSep3) + '\',\'' + this.checkType + '\');">\n';
	ss += '<input type="text" value="' + this.options[i]	+ '" id="' + this.id + '_t_'  + this.values[i] + '" ';
	xWidth = charWidth * this.options[i].length;
    ss += 'style="border:none;width:' + xWidth + ';';
	if (isChecked){ss += 'font-weight:bold;color:#000000;'}
	else {ss += 'color:' + this.inactiveColor + ';'};
	ss += 'background:' + this.backgroundColor + ';" ><span id="' + this.id + '_f_' + this.values[i] + '" ';
	ss += ' style:visibility:none;" ></span>\n';
	ss +=  this.carriageReturn + '\n';
	
}

return ss;	
	
}


function rc_setBackgroundColor(bCol){
var i;
var s1;
for (i=0;i<this.values.length;i++){
	s1 = this.id + '_f_' + this.values[i];
	// document.forms[this.formNo][s1].style.background = bCol;
}	
	
	
	
}

function rc_getChecked(){
var i;
var s1;
var ss = "";

for (i=0;i<this.options.length;i++){
	
	s1 = this.id + '_' + this.values[i];
	if (document.forms[this.formNo].elements[s1].checked){
		if (ss==""){ss=this.values[i]} else {ss += comSep2 + this.values[i]};
	}
	
}
	
return ss.split(comSep2);	
	
	
}


function rc_setChecked(){
var i;
var s1;

for (i=0;i<this.checkedNos.length;i++){
	
	s1 = this.id +  '_' + this.checkedNos[i];
	document.forms[this.formNo].elements[s1].checked = true;
	
}	
		
}

function rc_clicked(xFno,xID,xVal,xGray,xValues,xType){
// alert(xFno + "\n" + xID + "\n" + xNo + "\n" + xGray);	
var i;
var s1;
var s2;
var y;
if (xType=="radio"){
	s1 = xValues.split(comSep3);
	for (i=0;i<s1.length;i++){
		s2 = xID + '_t_' + s1[i];
		y = document.forms[xFno].elements[s2];
		y.style.fontWeight="normal";
		y.style.color=xGray;
	}
}


s1 = xID + '_' + xVal;
x = document.forms[xFno].elements[s1];
s2 = xID + '_t_' + xVal;
y = document.forms[xFno].elements[s2];
if (x.checked){
		y.style.fontWeight = "bold";
		y.style.color = "#000000";
	}
	else {
		y.style.fontWeight = "normal";
		y.style.color = xGray;	
	}

rc_FollowUp(xFno,xID,xVal);	
	
}


apxRadioCheckBox.prototype = new apxFormItem();

function rc_FollowUp(xFno,xID,xVal){
// alert(xFno + '\n' + xID + '\n' + xVal);	
	
}



/////////// MENU OBJECT /////////////
function apxPopMenu(){
	
this.popDialog = menu_popDialog;	
	
}

function menu_popDialog(){
	
var ss;
var i;
var s1;
var s2;
var isChecked;
var j;

ss  = '<table width="' + this.selWidth + '" border="0" class="txt' + this.fontSize + '" ';
ss += ' bgcolor="' + this.backgroundColor + '">\n';
// ss += 'onmouseover="holdTip();">\n';
for (i=0;i<this.options.length;i++){
	ss += '<tr valign="top" >\n';
	ss += '<td onmouseover="menu_hilite(\'' + this.id + '\',\'' + this.values[i];
	ss += '\',\'' + this.hiliteColor + '\');" ';
	ss += 'onmouseout="menu_hilite(\'' + this.id + '\',\'' + this.values[i];
	ss += '\',\'' + this.backgroundColor + '\');" ';
	ss += 'id="' + this.id + '_' + this.values[i] + '" ';
	ss += 'onclick="pop_clickedMenu(\'' + this.id + '\',\'' + this.values[i] + '\');" '
	ss += '>\n';
	isChecked=false;
	for (j=0;j<this.checkedNos.length;j++){
		if (this.checkedNos[j]==this.values[i]){isChecked=true;break;};
	}
	s2 = this.options[i];
	if (isChecked){ s2 = '<b><font color="#000000">' + s2 + '</font></b>'} else {s2 = ' &nbsp; ' + s2};
	
	ss += s2;
	ss += '</td>\n';
	ss += '</tr>\n';
}

ss += '</table>\n';

return ss;	
	
}


function menu_hilite(bID,bVal,bCol){
var s1 = bID + '_' + bVal;
x = document.getElementById(s1);
x.style.background=bCol;
	
}



apxPopMenu.prototype = new apxFormItem();




function pop_clickedMenu(bID,bVal){
	
// alert(bID + "\n" + bVal);	
	
}
