function populateList (thisListID,printPage) {

	// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
	// Defining Application ID
	// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
	var thisAppID = 0;
	
	
	// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
	// Setting global variable "cameraListID"
	// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
	cameraListID = thisListID;
	
	
	// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
	// Defining diffrent HTML parts for the projectlist
	// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++	
	if (printPage) {
		var tableStartHTML = '<table border="0" cellpadding="0" cellspacing="0" width="608">';
	} else {
		var tableStartHTML = '<table border="0" cellpadding="0" cellspacing="0" width="708">';
	}
	var tableStartExportHTML = '<table border="0" cellpadding="0" cellspacing="10" width="100%">';
	
	var rowStartHTML = '<tr class="sectionList"><td width=10><img src="core/graphics/blank.gif" width=10 height=1></td>';
	var rowStartExportHTML = '<tr class="sectionList"><td></td>';
	var rowStartHiddenHTML = '<tr class="sectionListHidden"><td width=10><img src="core/graphics/blank.gif" width=10 height=1></td>';
	
	var rowStartHeaderHTML = '<tr class="sectionListHeader"><td width=10><img src="core/graphics/blank.gif" width=10 height=1></td>';
	
	if (printPage) {
	var headInnerHTML = '' +
		'<td width=158><b>'+localizedArray[localizedLang][5]+'</b></td>' +
		'<td width=80><b>'+localizedArray[localizedLang][6]+'</b></td>' +
		'<td width=80 align="center"><b>'+localizedArray[localizedLang][7]+'</b></td>' +
		'<td width=200 align="right"><b>'+localizedArray[localizedLang][8]+'</b></td>' +
		'<td width=120 align="right"><b>'+localizedArray[localizedLang][9]+'&nbsp;('+userMemory[1][0][1][1]+'&nbsp;'+localizedArray[localizedLang][51]+')</b></td>';
	
	} else {
	var headInnerHTML = '' +
		'<td width=158><b>'+localizedArray[localizedLang][5]+'</b></td>' +
		'<td width=80><b>'+localizedArray[localizedLang][6]+'</b></td>' +
		'<td width=80 align="center"><b>'+localizedArray[localizedLang][7]+'</b></td>' +
		'<td width=200 align="right"><b>'+localizedArray[localizedLang][8]+'</b></td>' +
		'<td width=120 align="right"><b>'+localizedArray[localizedLang][9]+'&nbsp;('+userMemory[1][0][1][1]+'&nbsp;'+localizedArray[localizedLang][51]+')</b></td>';
	}
	
	var rowEndHTML = '</tr>';
	
	var tableEndHTML = '</table>';
	
	
	// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
	// Defining variables for the calculation
	// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++		
	var tmpViewBandwidth = 0;
	var tmpRecBandwidth = 0;
	var tmpTotalRecBandwidth = 0;
	var tmpTotalViewBandwidth = 0;
	var tmpTotalAlarmBandwidth = 0;
	
	var tmpStorageWeek = 0;
	var tmpStorageMax = 0;
	var tmpTotalStorageMax = 0;
	

	// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
	// Building the list part, does include <tr> tag
	// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++		
		var contentHTML = "";
		var contentExportHTML = "";
	
	// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
	// Loop thru userMemory Array and calculate the list output
	// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++	

	for (n1=1; n1<userMemory[thisAppID][thisListID].length; n1++) {
		
		// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
		// Sorting out the values from the userMemory Array
		// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++	
		var thisNoOfCam = userMemory[thisAppID][thisListID][n1][4];
		
		var thisViewUsed = userMemory[thisAppID][thisListID][n1][5];
		var thisViewRateSec = userMemory[thisAppID][thisListID][n1][6];
		var thisViewSize = userMemory[thisAppID][thisListID][n1][10];
		
		var thisRecUsed = userMemory[thisAppID][thisListID][n1][11];
		var thisRecRateSec = userMemory[thisAppID][thisListID][n1][13];
		var thisRecSize = userMemory[thisAppID][thisListID][n1][17];
	
		var thisScheduleHour = userMemory[thisAppID][thisListID][n1][12];		
/*		
		var thisRecRateMin = 0;	
		var thisRecRateHour = 0;		
		
		var thisScheduleDay = 7;
*/		

		var thisAlarmUsed = userMemory[thisAppID][thisListID][n1][18];
		var thisAlarmExpected = userMemory[thisAppID][thisListID][n1][19]/100;
		var thisAlarmRateSec = userMemory[thisAppID][thisListID][n1][20];
		var thisAlarmSize = userMemory[thisAppID][thisListID][n1][24];
		
		var thisNasUsed = userMemory[1][0][1][2];
		
		// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
		// Calculating the view bandwidth
		// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
		var tmpViewBandwidth = calcViewBandwidth(thisViewRateSec,thisViewSize,thisNoOfCam); 		
		
		
		// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
		// Calculating the idle rec bandwidth if it's 100%
		// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++				
		var tmpRecBandwidth = calcRecBandwidth(thisRecRateSec,0,0,thisRecSize,thisNoOfCam);
		
		
		// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
		// Calculating the Alarm rec bandwidth if it's 100%
		// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++				
		var tmpAlarmBandwidth = calcRecBandwidth(thisAlarmRateSec,0,0,thisAlarmSize,thisNoOfCam);
		
		
		// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
		// Calculating the idle rec storage if it's 100%
		// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++				
		var tmpRecStorageWeek = calcRecStorage(thisRecRateSec,thisRecSize,thisNoOfCam,thisScheduleHour,7);
		


		// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
		// Calculating the alarm rec storage if it's 100%
		// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++				
		var tmpAlarmStorageWeek = calcRecStorage(thisAlarmRateSec,thisAlarmSize,thisNoOfCam,24,7);
		
			
		// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
		// Determing if View/Continous Rec/Event rec Checkbox is checked
		// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
		if (thisViewUsed == 1 && thisRecUsed == 0 && thisAlarmUsed == 0) {
			tmpViewBandwidth = Math.round(tmpViewBandwidth);
			tmpRecBandwidth = 0;
			tmpAlarmBandwidth = 0;
			tmpStorageWeek = 0;
			
		} else if (thisViewUsed == 0 && thisRecUsed == 1 && thisAlarmUsed == 0) {
			tmpViewBandwidth = 0;
			tmpRecBandwidth = Math.round(tmpRecBandwidth);
			tmpAlarmBandwidth = 0;
			tmpStorageWeek = tmpRecStorageWeek;
			
		} else if (thisViewUsed == 0 && thisRecUsed == 0 && thisAlarmUsed == 1) {
			tmpViewBandwidth = 0;
			tmpRecBandwidth = 0;
			tmpAlarmBandwidth = Math.round(tmpAlarmBandwidth*thisAlarmExpected);			
			tmpStorageWeek = thisAlarmExpected*tmpAlarmStorageWeek;
		
		} else if (thisViewUsed == 1 && thisRecUsed == 1 && thisAlarmUsed == 0) {
			tmpViewBandwidth = Math.round(tmpViewBandwidth);
			tmpRecBandwidth = Math.round(tmpRecBandwidth);
			tmpAlarmBandwidth = 0;
			tmpStorageWeek = tmpRecStorageWeek;
		
		} else if (thisViewUsed == 0 && thisRecUsed == 1 && thisAlarmUsed == 1) {
			tmpViewBandwidth = 0;
			tmpRecBandwidth = Math.round(tmpRecBandwidth);
			tmpAlarmBandwidth = Math.round(tmpAlarmBandwidth*thisAlarmExpected);
			tmpStorageWeek = ((1-thisAlarmExpected)*tmpRecStorageWeek) + (thisAlarmExpected*tmpAlarmStorageWeek);
		
		} else if (thisViewUsed == 1 && thisRecUsed == 0 && thisAlarmUsed == 1) {
			tmpViewBandwidth = Math.round(tmpViewBandwidth);
			tmpRecBandwidth = 0;
			tmpAlarmBandwidth = Math.round(tmpAlarmBandwidth*thisAlarmExpected);
			tmpStorageWeek = thisAlarmExpected*tmpAlarmStorageWeek;
					
		} else if (thisViewUsed == 0 && thisRecUsed == 0 && thisAlarmUsed == 0) {
			tmpViewBandwidth = 0;
			tmpRecBandwidth = 0;
			tmpAlarmBandwidth = 0;
			tmpStorageWeek = 0;
		
		} else if (thisViewUsed == 1 && thisRecUsed == 1 && thisAlarmUsed == 1) {
			tmpViewBandwidth = Math.round(tmpViewBandwidth);
			tmpRecBandwidth = Math.round(tmpRecBandwidth);
			tmpAlarmBandwidth = Math.round(tmpAlarmBandwidth*thisAlarmExpected);
			tmpStorageWeek = ((1-thisAlarmExpected)*tmpRecStorageWeek) + (thisAlarmExpected*tmpAlarmStorageWeek);
			
		}
		
/*		
			// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
			// Calculating sum of Alarm and Idle bandwidth
			// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++					
			if (tmpIdelRecBandwidth<tmpAlarmRecBandwidth) {
				tmpRecBandwidth = Math.round(tmpAlarmRecBandwidth);
			} else {
				tmpRecBandwidth = Math.round(tmpIdelRecBandwidth);	
			}
			
			
			
			// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
			// Calculating the storage per week both alarm and idle
			// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++					
			tmpStorageWeek = ((1-thisAlarmExpected)*tmpIdelStorageWeek) + (thisAlarmExpected*tmpAlarmStorageWeek);
			
			
			
		} else {
			tmpRecBandwidth = tmpIdelRecBandwidth;
			tmpStorageWeek = tmpIdelStorageWeek;	
		}

		
		// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
		// Determing if nasMultiplicateValue should be used. NAS radiobutton checked = true
		// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++		
		if (thisNasUsed == 1) {
			tmpRecBandwidth = tmpRecBandwidth*nasMultiplicateValue;	
		}
*/		

		// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
		// Calculating storage max values
		// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++				
		tmpStorageMax = Math.round(tmpStorageWeek*userMemory[1][0][1][1]);
		
		
		// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
		// Acumulating the values used later for the sum line
		// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++						
		tmpTotalViewBandwidth += tmpViewBandwidth;
		tmpTotalRecBandwidth += tmpRecBandwidth;
		tmpTotalAlarmBandwidth += tmpAlarmBandwidth;
		tmpTotalStorageMax += tmpStorageMax;
		
		//setDataForm(document.cameraForm,0,cameraListID,cameraSetID,0,0,24);
		//setDataForm(window.parent.document.cameraForm,0,' + cameraListID + ',' + n1 + ',0,0,24);
		
		for (n=0; n<cameraList.length; n++) {
		if (cameraList[n][0] == userMemory[thisAppID][thisListID][n1][3]) {
			var model =	'AXIS '+cameraList[n][1];
		}
	}
		
		
		
		// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
		// Building the content part in the list
		// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++	
		contentHTML +=  rowStartHTML +
			'<td><b>'+ n1 +'</b> <a href="" onclick="window.parent.cameraSetID=' + n1 + ';window.parent.setDataForm(window.parent.document.cameraForm,0,' + cameraListID + ',' + n1 + ',0,0,24); return false;"><b>' + userMemory[thisAppID][thisListID][n1][0] + '</b></a></td>' +
			'<td>' + model + '</td>' + 
			'<td align="center">' + userMemory[thisAppID][thisListID][n1][4] + '</td>' +
			'<td align="right">' + unit(tmpViewBandwidth,false) + ",&nbsp;" + unit(tmpRecBandwidth,false) + ",&nbsp;" + unit(tmpAlarmBandwidth,false) + '</td>' +
			'<td align="right">' + unit(tmpStorageMax,true) + '</td>' +
			rowEndHTML;
			
		// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
		// Building the content part in the list
		// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++	
		contentExportHTML +=  rowStartExportHTML +
			'<td><b>'+ n1 +'</b> <b>' + userMemory[thisAppID][thisListID][n1][0] + '</b></td>' +
			'<td>' + userMemory[thisAppID][thisListID][n1][2] + '</td>' + 
			'<td align="center">' + userMemory[thisAppID][thisListID][n1][3] + '</td>' +
			'<td align="right">' + unit(tmpViewBandwidth,false) + ",&nbsp;" + unit(tmpRecBandwidth,false) + ",&nbsp;" + unit(tmpAlarmBandwidth,false) +'</td>' +
			'<td align="right">' + unit(tmpStorageMax,true) + '</td>' +
			rowEndHTML;	
		
	}


	// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
	// Building the sum part
	// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++	
	var sumInnerHTML = '<td colspan=3 align=left><b>'+localizedArray[localizedLang][71]+'</b></td>' +
		'<td align="right"><b>' + unit(tmpTotalViewBandwidth,false) + ",&nbsp;" + unit(tmpTotalRecBandwidth,false) + ",&nbsp;" + unit(tmpTotalAlarmBandwidth,false) + '</b></td>' + 
		'<td align="right"><b>' + unit(tmpTotalStorageMax,true) + '</b></td>';


	// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
	// Printing the data into the page
	// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++	
	if (printPage) {
		document.getElementById("listDIV").innerHTML = tableStartHTML +
			contentHTML +
			tableEndHTML;
	
		document.getElementById("listHead").innerHTML = tableStartHTML + 
			rowStartHeaderHTML + headInnerHTML + rowEndHTML +
			rowStartHiddenHTML + sumInnerHTML +  rowEndHTML +
			contentHTML +
			tableEndHTML;
		
		document.getElementById("listSum").innerHTML = tableStartHTML + 
			rowStartHTML + sumInnerHTML + rowEndHTML +
			rowStartHiddenHTML + headInnerHTML + rowEndHTML +
			contentHTML +
			tableEndHTML;
	
	} else {
		window.listFrame.document.getElementById("listDIV").innerHTML = tableStartHTML +
			contentHTML +
			rowStartHiddenHTML + headInnerHTML + rowEndHTML +
			rowStartHiddenHTML + sumInnerHTML +  rowEndHTML +
			tableEndHTML;
	
		
		document.getElementById("listHead").innerHTML = tableStartHTML + 
			rowStartHeaderHTML + headInnerHTML + rowEndHTML +
			rowStartHiddenHTML + sumInnerHTML +  rowEndHTML +
			contentHTML +
			tableEndHTML;
		
		document.getElementById("listSum").innerHTML = tableStartHTML + 
			rowStartHTML + sumInnerHTML + rowEndHTML +
			rowStartHiddenHTML + headInnerHTML + rowEndHTML +
			contentHTML +
			tableEndHTML;
		
		exportContainer = tableStartExportHTML +
			rowStartExportHTML + headInnerHTML + rowEndHTML +
			contentExportHTML +
			rowStartExportHTML + sumInnerHTML +  rowEndHTML +
			tableEndHTML;	
	}
}


function saveList (listName,newList) {
	
	thisAppID = 0;
	
	if (newList) {
		var tmpListID = userMemory[thisAppID].length;
	} else { 
		var tmpListID = userMemoryListID;
	}
	
	if (newList) {
		userMemory[thisAppID][tmpListID] = eval(convertArrayToSource(userMemory[thisAppID][userMemoryListID]));
	}
	
	userMemory[thisAppID][tmpListID][0] = listName;
	
	populateList (tmpListID);
	
}


function populateListForm (listFormObj) {

	listFormObj.listID.options.length = 0;
	
	listFormObj.listID.options[0] = new Option("-- Select a list --",0);
	
	for (n1=0; n1<userMemory[0].length; n1++) {		
		
		listFormObj.listID.options[n1+1] = new Option(userMemory[0][n1][0],n1);
	}
}

loaded["list.js"] = true


