function PreviewLobbyFormatRowCreator(formatRowConfig) {
	this.formatRowConfig = formatRowConfig;
}

/**
 * Create a Table cell with Text Node
 */
PreviewLobbyFormatRowCreator.prototype.createTextNodeCell = function(text, tableRow, disableContent) {
	var cell = document.createElement('td');	
	var span = document.createElement('span');
	if (disableContent && this.formatRowConfig.disable) {	
		span.style.color = '#C0C0C0';
	}	
	span.appendChild(document.createTextNode(text == '' ? '\u00a0' : text));
	cell.appendChild(span);
	tableRow.appendChild(cell);		
}

/**
 * Create the Row
 */
PreviewLobbyFormatRowCreator.prototype.create = function() {	
	var tableElem = document.getElementById('formatsTable');
	var previewLobbyFormatRow = document.createElement('tr'); // Row
	this.createTextNodeCell(tableElem.rows.length, previewLobbyFormatRow, false);	// Option Column	
	// Pre-Selected
	if (this.formatRowConfig.formatCode != preSelectedStreamFormat) {		
		this.createTextNodeCell('', previewLobbyFormatRow);	
	} else {		
		this.createPreSelected(previewLobbyFormatRow);
	}
	this.createTextNodeCell(this.formatRowConfig.formatName, previewLobbyFormatRow, true); // Format Name
	this.createTextNodeCell(this.formatRowConfig.formatDetails, previewLobbyFormatRow, true); // Format Details
	this.createConsoleOptions(previewLobbyFormatRow); // Console Options
	tableElem.getElementsByTagName('tbody')[0].appendChild(previewLobbyFormatRow); // Add row to table
}

/**
 * Create 'Pre-Selected' Column
 */
PreviewLobbyFormatRowCreator.prototype.createPreSelected = function(tableRow) {
	var preSelectedCell = document.createElement('td');
	preSelectedCell.align = 'center';
	var imgSource = '/utilApp/webcastcentral/images/';
	if (this.formatRowConfig.disable) {
		imgSource += 'star_off.gif';
	} else {
		imgSource += 'star_on.gif';
	}	
	var imgElem = createImageElement('', imgSource, '', '0');
	preSelectedCell.appendChild(imgElem);
	tableRow.appendChild(preSelectedCell);	
}

/**
 * Create 'Console Options' Column
 */
PreviewLobbyFormatRowCreator.prototype.createConsoleOptions = function(tableRow) {
	var consoleOptionsCell = document.createElement('td');
	consoleOptionsCell.align = 'center';	
	if (this.formatRowConfig.disable) {
		consoleOptionsCell.appendChild(createImageElement('', this.formatRowConfig.formatImgSource, '', '0'));		
	} else {
		if (this.formatRowConfig.mobileFormat) {
			addAnchor('launchMobileWebcast("' + this.formatRowConfig.formatCode + '", false);return false;', this.formatRowConfig.formatImgSource, consoleOptionsCell, '', '0', this.getPlayerIconToolTip());
		} else if (this.formatRowConfig.formatCode.startsWith('wm') && (!isIE || !isWin)) {
			consoleOptionsCell.appendChild(createImageElement('', '/eventManager/images/eventstreams/icon-wmp_disabled.gif', '', '0'));
		} else {
			addAnchor('launchWebcast("' + this.formatRowConfig.formatCode + '", false);return false;', this.formatRowConfig.formatImgSource, consoleOptionsCell, '', '0', this.getPlayerIconToolTip());
		}	
	}
	if (this.formatRowConfig.formatCode.startsWith('wm') && isSilverlightEnabled) {
		addSpaces(consoleOptionsCell, 2);		
		if (this.formatRowConfig.disable || !silverlightPlayerDetected) {
			consoleOptionsCell.appendChild(createImageElement('', '/eventManager/images/eventstreams/icon_silverlight_2_disabled.gif', '', '0'));
		} else {
			addAnchor('launchWebcast("' + this.formatRowConfig.formatCode + '", true);return false;', '/eventManager/images/eventstreams/Silverlight-enabled_15x15.png', consoleOptionsCell, '', '0', 'Silverlight Player');
		}	
	}					
	tableRow.appendChild(consoleOptionsCell);
}

PreviewLobbyFormatRowCreator.prototype.getPlayerIconToolTip = function () {
	if (this.formatRowConfig.formatCode.indexOf('nonstreaming') != -1) {
		return 'Non-Streaming';
	} else if (this.formatRowConfig.formatCode.startsWith('wm')) {
		return 'Windows Media Player';
	} else if (this.formatRowConfig.formatCode.startsWith('rm')) {
		return 'Real Player';
	} else if (this.formatRowConfig.formatCode.startsWith('fh')) {
		return 'Flash Player';
	} 
	return '';
}
