YAHOO.squarecompare.initWebHostingDataTable = function(options) {

	var fields = [
	    {
	    	name: 'WebHostingProductId',
	    	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">',
	   		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: 20,
	  		formatter: 'text'
	   	},
    	{
	   		name: 'DiskspaceGb',
	   		title: 'Disk',
	   		group: 'basic',
	 		numberDecimals: 2,
	 		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: 'TransferGb',
	 		title: 'Transfer',
	   		group: 'basic',
	 		numberDecimals: 1,
	 		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: 2,
	 		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: 'DomainsCount',
	 		title: 'Domains',
	   		group: 'domain',
	 		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: 'SubDomainsCount',
	 		title: 'SubDomains',
	   		group: 'domain',
	 		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: 'DedicatedIpCount',
	 		title: 'IPs',
	   		group: 'domain',
	 		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: 'Windows',
	 		title: 'Windows',
	   		group: 'other',
	   		sortable: true,
	  		sizable: true,
	  		formatter: 'checked'
	 	},
	 	{
	 		name: 'Unix',
	 		title: 'Unix',
	   		group: 'other',
	   		sortable: true,
	  		sizable: true,
	  		formatter: 'checked'
	 	},
	 	{
	 		name: 'EmailAccountsCount',
	 		title: 'Mailboxes',
	   		group: 'other',
	 		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: 'DatabasesCount',
	 		title: 'Databases',
	   		group: 'other',
	 		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: 'HasPhp',
	 		title: 'PHP',
	   		group: 'scripts',
	   		sortable: true,
	  		sizable: true,
	  		formatter: 'checked'
	 	},
	 	{
	 		name: 'HasAsp',
	 		title: 'ASP',
	   		group: 'scripts',
	   		sortable: true,
	  		sizable: true,
	  		formatter: 'checked'
	 	},
	 	{
	 		name: 'HasJsp',
	 		title: 'JSP',
	   		group: 'scripts',
	   		sortable: true,
	  		sizable: true,
	  		formatter: 'checked'
	 	},
	 	{
	 		name: 'HasRor',
	 		title: 'RoR',
	   		group: 'scripts',
	   		sortable: true,
	  		sizable: true,
	  		formatter: 'checked'
	 	},
	 	{
	 		name: 'HasPerl',
	 		title: 'Perl',
	   		group: 'scripts',
	   		sortable: true,
	  		sizable: true,
	  		formatter: 'checked'
	 	}
	];

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

	var filterInputs = [
	    {
	    	paramName: 'diskspaceGb',
	    	input: YAHOO.util.Selector.query('#filter-diskspace-gb')[0]
	    },
	    {
	    	paramName: 'transferGb',
	    	input: YAHOO.util.Selector.query('#filter-transfer-gb')[0]
	    },
	    {
	    	paramName: 'domainsCount',
	    	input: YAHOO.util.Selector.query('#filter-domains-count')[0]
	    },
	    {
	    	paramName: 'emailAccountsCount',
	    	input: YAHOO.util.Selector.query('#filter-email-accounts-count')[0]
	    },
	    {
	    	paramName: 'subDomainsCount',
	    	input: YAHOO.util.Selector.query('#filter-sub-domains-count')[0]
	    },
	    {
	    	paramName: 'databasesCount',
	    	input: YAHOO.util.Selector.query('#filter-databases-count')[0]
	    },
	    {
	    	paramName: 'dedicatedIpCount',
	    	input: YAHOO.util.Selector.query('#filter-ips-count')[0]
	    },
	    {
	    	paramName: 'hasPhp',
	    	input: YAHOO.util.Selector.query('#filter-has-php')[0]
	    },
	    {
	    	paramName: 'hasAsp',
	    	input: YAHOO.util.Selector.query('#filter-has-asp')[0]
	    },
	    {
	    	paramName: 'hasJsp',
	    	input: YAHOO.util.Selector.query('#filter-has-jsp')[0]
	    },
	    {
	    	paramName: 'hasRor',
	    	input: YAHOO.util.Selector.query('#filter-has-ror')[0]
	    },
	    {
	    	paramName: 'hasPerl',
	    	input: YAHOO.util.Selector.query('#filter-has-perl')[0]
	    },
	    {
	    	paramName: 'os',
	    	input: YAHOO.util.Selector.query('#filter-os input')
	    },
	    {
	    	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: 'flagged',
	    	input: YAHOO.util.Selector.query('#filter-flagged input')
	    }
	];

	var dataTableOptions = YAHOO.lang.merge(options, {
		keyFieldName: 'WebHostingProductId',
		fields: fields,
		initialGroup: 'basic',
		filterInputs: filterInputs,
		defaultSort: {key:'MonthlyFee', dir: YAHOO.widget.DataTable.CLASS_ASC},
		customFormatters: {
			monthlyFee: function(elLiner, oRecord, oColumn, oData) {
	    		var monthlyFee = oRecord.getData('MonthlyFee');
		    	var contractMonths = oRecord.getData('ContractMonths');

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

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

	// 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);
		});
    }
}
