function getAtt(o, a) {
	if (o.attributes[a]) {
		return o.attributes[a].nodeValue;
	} else if (o[a]) {
		return o[a];
	}
	return false;
}

function showList(list) {
	var oDiv=document.getElementById(list.id);
	oDiv.innerHTML=getList(list);
}

var Column = function(id, props){
	this.id=id;
	this.title  = props.title?props.title:'NO_TITLE';
	this.width  = props.width;
	this.hidden = props.hidden?(props.hidden=='Y'):false; 
	this.type   = props.type?props.type:'CHAR';
	this.align  = props.align?props.align:'LEFT';
}

var List = function(id, listProps, columns) {
	this.id=id;
	this.rows=listProps.rows?listProps.rows:10;
	this.columns = new Array();
	
	if (columns) {
		for (var j=0; j<columns.length; j++) {
			var col = columns[j];
			this.columns[j]=new Column(col.id, {title: col.title, width: col.width, hidden: col.hidden, type: col.type, align: col.align});
		}
	}
}	


function getList(list){
	var s='';
	
	s+='<TABLE width="100%" class="listTitle" border="0" cellpadding="2" cellspacing="1">\n';	
	s+='<TR valign="middle">\n';
	s+='<TD>\n';
	s+='    <TABLE cellspacing="0" cellpadding="0">\n';
	s+='    <TR>\n';
	s+='    <TD class="listTitleCell">'+list.id+'</TD>\n';
	s+='    <TD width="100%" align="left"></TD>\n';
	s+='    </TR>\n';
	s+='    </TABLE>\n';
	s+='</TD>\n';
	s+='</TR>\n';	
	s+='</table>\n';

	s+='<TABLE width="100%" id="tbl_'+list.id+'" border="0" cellpadding="1" cellspacing="1" class="tableColor">\n';
	s+='<TBODY>'			
	s+='<TR>\n';
	var countColumns=0;
	for (var i=0;i<list.columns.length;i++) {
		var oCol=list.columns[i];
		if (!oCol.hidden) {
			s+='<TH valign="top" class="columnHeader" width="'+oCol.width+'%"><a class="tableSortASC" name="'+list.id+'_sort_'+oCol.id+'" id="'+list.id+'_sort_'+oCol.id+'" href="javascript:void(0)" onclick="alert(\'sortMe\')">'+oCol.title+'</a></TH>\n';
			countColumns++;
		}
	}
	s+='</TR>\n';
	
	s+='<TR class="tableRow" valign="middle">\n';
	s+='<TD valign="middle" width="100%" colspan="'+countColumns+'" class="tableCell">No records loaded</TD>\n';
	s+='</TR>\n';
	
	for (var i=0; i<(list.rows-1);i++) {
		s+='<TR class="tableRow"><TD class="tableCell" colspan="'+countColumns+'">&nbsp;</TD></TR>';
	}
		
	s+='</TBODY>\n';
	s+='</TABLE>\n';
	
	s+='<TABLE class="pagingTable" border="0" cellpadding="0" cellspacing="0" width="100%">\n';
	s+='	<TR>\n';
	s+='		<TD class="pagingCell" nowrap>\n';
	s+='			<TABLE width="100%" border="0" cellpadding="0" cellspacing="0">\n';
	s+='			<TR>\n';
	s+='                <TD align="left">\n';
	s+='                </TD>\n';
	s+='				<TD align="right" valign="baseline">\n';
	s+='                </TD>\n';	
	s+='			</TR>\n';
	s+='			</TABLE>\n';
	s+='        </TD>\n';
	s+='	</TR>\n';
	s+='</TABLE>\n';
	return s;
}
