/**
 * @author aberbery
 */


var SimpleController = new Object();

SimpleController.init = function(){	
	
	var moduleArray=widgetsName;
	var allHtml = SimpleController.createAllModulesHtml(moduleArray);	
	var bodyContainer = document.getElementById("leftContainer");
	
	bodyContainer.innerHTML = allHtml;
	
}

SimpleController.createAllModulesHtml = function(moduleArray){
	var allHtml = new Array();
		
	
	allHtml.push('<div>');
	allHtml.push(	'<table class="portletcont" border="0" cellpadding="0" cellspacing="0" height="auto">');
	allHtml.push(		'<tbody>');
	allHtml.push(         '<tr valign="top">');	
	var columnNumber = 0;
    allHtml.push(	'<td class="topLeftCell" style="" align="center" width="50%">');
	for(var i=0;i<moduleArray.length;i++){	
		
		var moduleName = moduleArray[i];		
		var moduleHeight = widgetsHeight[i];
		if(i!=0&&i%4==0){			
		   allHtml.push(	'</td>');
		   allHtml.push(	'<td class="topLeftCell" style="" align="center" width="50%">');		   	
		}
					
		allHtml.push(		SimpleController.createModuleContent(moduleName,moduleHeight));						
		columnNumber ++;
	}
	allHtml.push(	        '</td>');	
	allHtml.push(          '</tr>');
	allHtml.push(		'</tbody>');
	allHtml.push(	'</table>');
	allHtml.push('</div>');
	return allHtml.join('');
}


SimpleController.createModuleContent = function(moduleName,height){
	var moduleHtml = new Array();
moduleHtml.push(	  '<div class="portlet" id="4052" tabnumber="847" style="left: 0px; top: 0px; width: auto; height: auto;">');
moduleHtml.push(		'<div class="portletFrame x-resizable-pinned" id="4052_frame" tabnumber="847" style="position: relative; height: auto; left: 0px; top: 0px; width: 100%;">');			
moduleHtml.push(			'<div class="portletHeader" id="4052_header">');
moduleHtml.push(				   '<div class="title" title="Screenshot" id="4052_title">'+moduleName+'</div>');				
moduleHtml.push(			       '<div class="additionalActions" title="Screenshot" id="4052_additionalActions" style="width: 0px; display: none;"></div>');				
moduleHtml.push(			 '</div>');
moduleHtml.push(			    '<div class="portletEdit" id="4052_edit"></div>');
moduleHtml.push(			    '<div class="portletContent" id="'+moduleName+'_container" style="height:'+height+'px;"></div>');		   	
moduleHtml.push(		 '</div>');			
moduleHtml.push(		'</div>');

	  
	return moduleHtml.join('');
}