


// create a new Html tag object
function newHtmlObject(tagName, id, className) {
  var oElement = document.createElement(tagName)
  if (id) oElement.id = oElement.name = id;
  if (className) oElement.className = className;
  return oElement;
}

// create a new html input object
function newInput(id, title, type, className) {
	var oInput = newHtmlObject("INPUT", id, className);
	if (title != '') oInput.title = title;
	oInput.type = type;			
	if (className != '' && type != 'hidden') oInput.className = className;													
	return oInput;
}

// crete a new Html input of type text/hidden
function newInputText(id, isVisible, value, size, title, className, onchange) {
  var oInputText = newInput(id, title, (isVisible)?'Text':'hidden', className);
  oInputText.value = value;
  if (isVisible) {
    oInputText.size = size;
    oInputText.onchange = onchange;
  }
  return oInputText;
}

// create a new Html input of image type
function newInputImage(id, src, title, onclick) {
	var inputImage = newInput(id, title, "image", '');			
	inputImage.src = src;		
	inputImage.style.backgroundColor = 'transparent';	
	inputImage.style.border = 0;
	inputImage.onclick = onclick;
	return inputImage		
}

// create a new html input of type button
function newInputButton(type, id, value, className, onclick) {
  var oInputButton = newInput(id, '', type);
  oInputButton.value = value;
  oInputButton.onclick = onclick;
  return oInputButton;
}

// create a new Hbcp style dialog table
function newHbcpTable(bgColor, id, className, title, close) {
	var oTable = newHtmlObject("table", id, className );
	oTable.bgColor= bgColor
	oTable.cellPadding=2;
	oTable.cellSpacing=0;
	var rowCount = 0;
	var oNewRow = oTable.insertRow(rowCount++);
	var oNewCell;
	if (title) {						
		oNewCell = oNewRow.insertCell(0);
		oNewCell.align='left';						
		oNewCell.bgColor = bgColor;
		oNewCell.innerHTML = title;
		oTable.titleCell = oNewCell;
		
		oNewCell = oNewRow.insertCell(1);
		oNewCell.width='1';
		oNewCell.align='right';
		oNewCell.vAlign='top';
		oNewCell.bgColor = bgColor;
		oNewCell.appendChild(newInputImage('', 'images/delete.gif', 'Close this window', close));
		oTable.closeCell = oNewCell;	
		
		oNewRow = oTable.insertRow(rowCount++);												
	}						
	oNewRow = oTable.insertRow(rowCount++)
	oNewCell = oNewRow.insertCell(0);
	oNewCell.align="left";
	oNewCell.colSpan=2;
	oTable.content = oNewCell
  	
	return oTable;
}

// open a fresh browser with a target name or give focus if already open
function linkBrowser(toHref, windowName) {
	windowprops = "height=540,width=740,location=0,resizable=1,scrollbars=1,status=0,titlebar=1,toolbar=0,z-lock=0";
	info = window.open(toHref, windowName, windowprops);					
	if (info.opener == null) 
		info.opener = window;
	else 
		info.focus();			
}	

function showInteractiveTable(tabid, rows) {
	var oForm = document.getElementById("frmShowTable");
	linkBrowser("", 'InteractiveTable');
	oForm.target = 'InteractiveTable';
	oForm["id"].value = tabid;
	oForm["rows"].value = rows;			
	oForm.submit();	
	return false;								
}
