// VC-LAYOUR
/*

PROJECT:	DEJA.View() (Dynamic Enterprise Java Applications).View Controller
PROGRAMMER:	G. Patnude
FILE:		vc-layout/vc-layout.js
PURPOSE:	DYNAMIC PAGE LAYOUT MANAGER...

Includes functions for:

	-- PAGE LAYOUT MANAGEMENT...
	-- NORTH, SOUTH, EAST, WEST...
	-- 
*/

var LAYOUT = {
	
	// CLASS VARIABLES...
	version: "0.000a",
	t : new Array(),
	
	layout: function layout(L) {
	
		// return "<DIV ID = '" + L.target[0].toUpperCase() + "'>Please make a selection</DIV>";
		var t = "\t\t<TABLE STYLE = 'border: 0px inset threedface;' WIDTH = '100%' CELLPADDING = '5' CELLSPACING = '0'>\n\n" +
		
		// THE GRID CONTAINER...
		"\t\t<TR CLASS = 'content'>\n\n" + 		
		"\t\t<TD COLSPAN = '2' WIDTH = '100%' VALIGN = 'TOP' HEIGHT = '168'>&nbsp;\n\n" +
		// "\t\t<DIV ID = '" + L.target[0].toUpperCase() + "' CLASS = 'content'>Please make a selection...</DIV>\n\n" +
		// "\t\t<DIV ID = '" + L.target[0].toUpperCase() + "' CLASS = 'content'>" + L.target[0].toUpperCase() + "</DIV>\n\n" + "\t\t</TD>\n\n\t\t" + 		
		"\t\t<DIV ID = '" + L.target[0].toUpperCase() + "' CLASS = 'CONTENT'></DIV>\n\n" + "\t\t</TD>\n\n\t\t" + 		
		"</TR>\n\n" +
		
		/* 
		/ LOCATION TO ADD A NEW RECORD...
		"\t\t<TR CLASS = 'content'>\n\n" + 		
		"\t\t<TD VALIGN = 'MIDDLE' ALIGN = 'RIGHT' WIDTH = '100%' >" + ((L.glue != null) ? UI.button((L.glue.length > 2) ? L.glue[2] : "Manage assignments...", ["onClick = RS.groupassign('NEW');"], L.glue[0]) : "&nbsp;") + 
		"\t\t<TD VALIGN = 'MIDDLE' ALIGN = 'RIGHT' WIDTH = '100%' >" + UI.button("Add a new item...", ["onClick = RS.add('NEW');", "DISABLED = 'TRUE'"], L.target[0]) + 
		"\t\t</TD>\n\n\t\t" + 		
		"</TR>\n\n" +
		
		*/
		
		"\t\t</TABLE>\n\n";	
		return t;
		
		// ROW 1...
		if ((L.layout == 1) || (L.layout == 3) || (L.layout == 5)) {
		
			// t += "\t\t<TR CLASS = 'content' onClick = \"javascript:hide('POP', 0);\">\n\n" + 		
			t += "\t\t<TR CLASS = 'content'>\n\n" + 		
			"\t\t<TD COLSPAN = '2' WIDTH = '100%' >\n\n" +
			"\t\t<DIV ID = '" + L.tbl.toUpperCase() + "' CLASS = 'content'>" + L.tbl.toUpperCase() + "\n\n\t\t</DIV>\n\n" +
			"\t\t</TD>\n\n\t\t" + 		
			"</TR>\n\n";
		
		} 
		
		if (L.layout >= 2) {
		
			//* ROW 2...
			t += "\t\t<TR CLASS = 'content'>\n\n" +			
		
			// CELL 1
			"\t\t<TD WIDTH = '50%'>\n\n" + 
			"\t\t<DIV ID = '" + L.tbl.toUpperCase() + "_LEFT' CLASS = 'content'>" + L.tbl.toUpperCase() + "_LEFT\n\n\t\t</DIV>\n\n" +
			"\t\t</TD>\n\n\t\t" +
	
			// CELL 2
			"\t\t<TD  WIDTH = '50%'>\n\n" + 
			"\t\t<DIV ID = '" + L.tbl.toUpperCase() + "_RIGHT' CLASS = 'content'>" + L.tbl.toUpperCase() + "_RIGHT\n\n\t\t</DIV>\n\n" +
			"\t\t</TD>\n\n\t\t" +
			
			"</TR>\n\n";
		
		}
		
		if (L.layout >= 4) {		
		
			t += "\t\t<TR CLASS = 'content'>\n\n" + 		
			"\t\t<TD COLSPAN = '2' WIDTH = '100%'>\n\n" +
			"\t\t<DIV ID = '" + L.tbl.toUpperCase() + "_BOTTOM' CLASS = 'content'>" + L.tbl.toUpperCase() + "_BOTTOM\n\n\t\t</DIV>\n\n" +
			"\t\t</TD>\n\n\t\t" + 		
			"</TR>\n\n";
		
		} 
		
		t += "\t\t</TABLE>\n\n";	
		return t;
	
	},
	
	// GENERATES A DYNAMIC TABLE CONTAINER BASED ON A DEFINER ARRAY...
	setlayout: function setlayout(def) {
	
		UTIL.trace("LAYOUT::setlayout(0) --> Called...");
		var rows = "";		
		
		// LOOP THROUGH THE LAYOUT DEFINITION...
		for (var d = 0; d < def.length; d++) {
		
			var cells = "";		
			// var cells = [];
			for (var c = 0; c < def[d].length; c++) {
			
				// w = parseInt(100 / def[d].length) + "%";
				cells += "\t\t<TD WIDTH = '" + parseInt(100 / def[d].length) + "%' ALIGN = 'LEFT' VALIGN = 'TOP'><DIV ID = '" + def[d][c] + "' CLASS = 'CONTENT'>" + def[d][c] + "&nbsp;</DIV></TD>\n\n";
				// cells.push(TABLE.TD());
				// <TD WIDTH = '" + parseInt(100 / def[d].length) + "%' ALIGN = 'LEFT' VALIGN = 'TOP'><DIV ID = '" + def[d][c] + "' CLASS = 'CONTENT'>" + def[d][c] + "&nbsp;</DIV></TD>\n\n";
			
			}
			
			rows += "\t\t<TR>" + cells + "</TR>\n\n";
		
		}
		
		return "\t<TABLE WIDTH = '100%' BORDER = '1' CELLPADDING = '0' CELLSPACING = '0' STYLE = '1px inset threedlightshadow;'>" + rows + "</TABLE>\n";
		// return "\t<TABLE WIDTH = '99%' BORDER = '1' CELLPADDING = '0' CELLSPACING = '0' CLASS = ''>" + rows + "</TABLE>\n";
	
	}	
	
	

// EOF...
};
