YAHOO.squarecompare.initDedicatedHostingDataTable = function(options) {

	var fields = [
	    {
	    	name: 'DedicatedHostingProductId',
	    	internal: true
	    },
	    {
	    	name: 'MerchantSiteId',
	    	internal: true
	    },
	    {
	    	name: 'ContractMonths',
	    	internal: true
	    },
	    {
	    	name: 'MerchantSiteListingTypeId',
	    	internal: true
	    },
	    {
	    	name: 'EnhancedListingScore',
	    	internal: true
	    },
	    {
	    	name: 'FeePerClickTypeId',
	    	internal: true
	    },
	  	{
	   		name: 'Flagged',
	   		title: '<img src="/ext/silk/icons/flag_yellow.png" width="12" height="12" class="info-icon" style="float: none" title="Click cells in this column to flag/unflag rows. Use the Flagged filter then to only see flagged rows.">',
	   		width: 12,
	   		sortable: false,
	  		sizable: false,
	  		formatter: 'flagged'
	   	},
	    {
	   		name: 'MerchantSiteName',
	   		title: 'Host',
	   		sortable: true,
	  		sizable: true,
	  		formatter: 'merchantSiteName'
	   	},
	    {
	   		name: 'PlanName',
	   		title: 'Plan',
	   		sortable: true,
	  		sizable: true,
	  		maxLength: 25,
	  		formatter: 'text'
	   	},
    	{
	   		name: 'DiskCount',
	   		title: 'Disks',
	   		group: 'disk',
	 		numberDecimals: 0,
	 		numberPrefix: '',
	 		numberSuffix: '',
	   		sortable: true,
	  		sizable: true,
	  		formatter: 'number'
	   	},
    	{
	   		name: 'DiskSizeGb',
	   		title: 'Disk Size',
	   		group: 'disk',
	 		numberDecimals: 0,
	 		numberPrefix: '',
	 		numberSuffix: ' GB',
	   		sortable: true,
	  		sizable: true,
	  		formatter: 'number'
	   	},
    	{
	   		name: 'DiskType',
	   		title: 'Disk Type',
	   		group: 'disk'
	   	},
    	{
	   		name: 'UsableDiskspaceGb',
	   		title: 'Storage',
	   		group: 'basic',
	 		numberDecimals: 0,
	 		numberPrefix: '',
	 		numberSuffix: ' GB',
	   		sortable: true,
	  		sizable: true,
	  		formatter: 'number'
	   	},
	 	{
	 		name: 'TransferGb',
	 		title: 'Transfer',
	   		group: 'basic',
	 		numberDecimals: 0,
	 		numberPrefix: '',
	 		numberSuffix: ' GB',
	   		sortable: true,
	  		sizable: true,
	  		formatter: 'number',
	  		magicValues: {
	   			999999.0: 'Unlimited|Be sure to check the fine print to determine if restrictions apply to this <i>Unlimited</i> value.'
	   		}
	 	},
	 	{
	 		name: 'MonthlyFee',
	 		title: 'Monthly',
	   		group: 'basic',
	 		numberDecimals: 0,
	 		numberPrefix: '$',
	 		numberSuffix: '',
	   		sortable: true,
	  		sizable: true,
	  		formatter: 'monthlyFee'
	 	},
	 	{
	 		name: 'SetupFee',
	 		title: 'Setup',
	   		group: 'basic',
	 		numberDecimals: 2,
	 		numberPrefix: '$',
	 		numberSuffix: '',
	   		sortable: true,
	  		sizable: true,
	  		formatter: 'number'
	 	},
	 	{
	 		name: 'DedicatedIpCount',
	 		title: 'IPs',
	   		group: 'advanced',
	 		numberDecimals: 0,
	 		numberPrefix: '',
	 		numberSuffix: '',
	   		sortable: true,
	  		sizable: true,
	  		formatter: 'number',
	  		magicValues: {
	   			999999: 'Unlimited|Be sure to check the fine print to determine if restrictions apply to this <i>Unlimited</i> value.'
	   		}
	 	},
	 	{
	 		name: 'RamGb',
	 		title: 'RAM',
	   		group: 'advanced',
	 		numberDecimals: 2,
	 		numberPrefix: '',
	 		numberSuffix: ' GB',
	   		sortable: true,
	  		sizable: true,
	  		formatter: 'number'
	 	}
	];

	var filterOsInputs = YAHOO.util.Selector.query('#filter-os input');
	var filterColumnInputs = YAHOO.util.Selector.query('#filter-columns input');

	var filterInputs = [
	    {
	    	paramName: 'usableDiskspaceGb',
	    	input: YAHOO.util.Selector.query('#filter-usable-diskspace-gb')[0]
	    },
	    {
	    	paramName: 'diskTypeIds',
	    	input: YAHOO.util.Selector.query('#filter-disk-type input')
	    },
	    {
	    	paramName: 'transferGb',
	    	input: YAHOO.util.Selector.query('#filter-transfer-gb')[0]
	    },
	    {
	    	paramName: 'dedicatedIpCount',
	    	input: YAHOO.util.Selector.query('#filter-ips-count')[0]
	    },
	    {
	    	paramName: 'ramGb',
	    	input: YAHOO.util.Selector.query('#filter-ram-gb')[0]
	    },
	    {
	    	paramName: 'processorTypeIds',
	    	input: YAHOO.util.Selector.query('#filter-processor-type input')
	    },
	    {
	    	paramName: 'processorCount',
	    	input: YAHOO.util.Selector.query('#filter-processor-count')[0]
	    },
	    {
	    	paramName: 'coreCount',
	    	input: YAHOO.util.Selector.query('#filter-processor-core-count')[0]
	    },
	    {
	    	paramName: 'monthlyFee',
	    	input: YAHOO.util.Selector.query('#filter-monthly-fee')[0]
	    },
	    {
	    	paramName: 'contractMonths',
	    	input: YAHOO.util.Selector.query('#filter-contract-months input')
	    },
	    {
	    	paramName: 'setupFee',
	    	input: YAHOO.util.Selector.query('#filter-setup-fee')[0]
	    },
	    {
	    	paramName: 'windowsVista',
	    	input: YAHOO.util.Selector.query('#filter-os-windows-vista')[0]
	    },
	    {
	    	paramName: 'windows2008',
	    	input: YAHOO.util.Selector.query('#filter-os-windows-2008')[0]
	    },
	    {
	    	paramName: 'windows2003',
	    	input: YAHOO.util.Selector.query('#filter-os-windows-2003')[0]
	    },
	    {
	    	paramName: 'windowsXp',
	    	input: YAHOO.util.Selector.query('#filter-os-windows-xp')[0]
	    },
	    {
	    	paramName: 'centOs',
	    	input: YAHOO.util.Selector.query('#filter-os-cent-os')[0]
	    },
	    {
	    	paramName: 'ubuntu',
	    	input: YAHOO.util.Selector.query('#filter-os-ubuntu')[0]
	    },
	    {
	    	paramName: 'redhat',
	    	input: YAHOO.util.Selector.query('#filter-os-red-hat')[0]
	    },
	    {
	    	paramName: 'arch',
	    	input: YAHOO.util.Selector.query('#filter-os-arch')[0]
	    },
	    {
	    	paramName: 'debian',
	    	input: YAHOO.util.Selector.query('#filter-os-debian')[0]
	    },
	    {
	    	paramName: 'gentoo',
	    	input: YAHOO.util.Selector.query('#filter-os-gentoo')[0]
	    },
	    {
	    	paramName: 'slackware',
	    	input: YAHOO.util.Selector.query('#filter-os-slackware')[0]
	    },
	    {
	    	paramName: 'mandrake',
	    	input: YAHOO.util.Selector.query('#filter-os-mandrake')[0]
	    },
	    {
	    	paramName: 'freeBsd',
	    	input: YAHOO.util.Selector.query('#filter-os-free-bsd')[0]
	    },
	    {
	    	paramName: 'openBsd',
	    	input: YAHOO.util.Selector.query('#filter-os-open-bsd')[0]
	    },
	    {
	    	paramName: 'solaris',
	    	input: YAHOO.util.Selector.query('#filter-os-solaris')[0]
	    },
	    {
	    	paramName: 'flagged',
	    	input: YAHOO.util.Selector.query('#filter-flagged input')
	    }
	];

	var dataTableOptions = YAHOO.lang.merge(options, {
		keyFieldName: 'DedicatedHostingProductId',
		fields: fields,
		initialGroup: 'basic',
		filterInputs: filterInputs,
		defaultSort: {key:'MonthlyFee', dir: YAHOO.widget.DataTable.CLASS_ASC},
		customFormatters: {
			diskConfig: function(elLiner, oRecord, oColumn, oData) {
				var diskCount = oRecord.getData('DiskCount');
		    	var diskSizeGb = oRecord.getData('DiskSizeGb');
		    	var diskType = oRecord.getData('DiskType');
		    	var value = diskCount + 'x' + diskSizeGb + ' GB ' + diskType;

		    	elLiner.innerHTML = value;
				YAHOO.util.Dom.setStyle(elLiner, 'text-align', 'right');
		    },
			monthlyFee: function(elLiner, oRecord, oColumn, oData) {
				var monthlyFee = oRecord.getData('MonthlyFee');
		    	var contractMonths = oRecord.getData('ContractMonths');

		    	var value = YAHOO.squarecompare.formatCurrency(monthlyFee, 0) + '&#47;mo (' + contractMonths + ')';
		    	elLiner.innerHTML = value;
				YAHOO.util.Dom.setStyle(elLiner, 'text-align', 'right');

		    	var toolTipText = YAHOO.squarecompare.formatCurrency(monthlyFee, 0) + ' per month with a ' + contractMonths + ' month commitment or prepayment';
				YAHOO.util.Dom.addClass(elLiner, 'info-icon');
				elLiner.setAttribute('title', toolTipText);
		    }
		},
		getDataStep: 'get-dedicated-hosting-plans'
	});
	var dataTable = YAHOO.squarecompare.DataTable(dataTableOptions);

	// Check all Fixed Term Types
	var osCheckAll = YAHOO.util.Selector.query('#filter-os-check-all')[0];
	YAHOO.util.Event.addListener(osCheckAll, 'click', function(e) {
		YAHOO.util.Event.stopEvent(e);
		for (var i=0; i<filterOsInputs.length; i++) {
			filterOsInputs[i].checked = true;
		}
		dataTable.requery();
	});

	// Uncheck all Fixed Term Types
	var osUncheckAll = YAHOO.util.Selector.query('#filter-os-uncheck-all')[0];
	YAHOO.util.Event.addListener(osUncheckAll, 'click', function(e) {
		YAHOO.util.Event.stopEvent(e);
		for (var i=0; i<filterOsInputs.length; i++) {
			filterOsInputs[i].checked = false;
		}
		dataTable.requery();
	});

	// Listen for column group changes
    for (var i=0; i<filterColumnInputs.length; i++) {
		YAHOO.util.Event.addListener(filterColumnInputs[i], 'click', function(e) {
			dataTable.showColumnGroup(this.value);
		});
    }

}
