addLoadListener(function() { CreateHP();});

function CreateHP()
{
	var getEl = document.getElementById('MainBD');
	if(getEl)
	{
		var olddiv = document.getElementById('HPTable');
		if(olddiv)
		{getEl.removeChild(olddiv);}
		var dispL = 'MenuList';
		var dispVals = '';
		var Count = 1;
		var dynamicMU = '';
		var NumRows = Math.ceil((NumFirstLvlItems/4));
		var NumCols = 4;
		var myWidth = 0, myHeight = 0;
		  if( typeof( window.innerWidth ) == 'number' ) {
			//Non-IE
			myWidth = window.innerWidth;
			myHeight = window.innerHeight;
		  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
			//IE 6+ in 'standards compliant mode'
			myWidth = document.documentElement.clientWidth;
			myHeight = document.documentElement.clientHeight;
		  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
			//IE 4 compatible
			myWidth = document.body.clientWidth;
			myHeight = document.body.clientHeight;
		  }
	    getEl.style.height = (myHeight-230)+'px';
		dynamicMU += '<center><table width="100%" id="HomePageTbl" cellpading="0" cellspacing="0" border="0" height="100px !important">';
		var i = 1;
			for(var nrows=1;nrows<=NumRows;nrows++)
			{
				dynamicMU += '<tr>';
				for(var ncols=1;ncols<=NumCols;ncols++)
				{
					dispL = 'MenuList' + i;
					dispVals = window[dispL.split(',')];
					if(dispVals)
					{
						dynamicMU += '<td>';
						if(!dispVals[2].match('SX40'))
						{
							dynamicMU += '<a href="ProductBrowse.aspx?category='+ dispVals[2] + '"><img height="150px" src="images/TemplateImages/Home Page Images/' + dispVals[0] + '.jpg" border="0" alt="' + dispVals[0] + '"name="'+dispVals[0]+'" /><br />' + dispVals[0] + '</a>';
						}
						else
						{
							dynamicMU += '<a href="ProductBrowse.aspx?category=SX40&role=CustomerSports"><img height="150px" src="images/TemplateImages/Home Page Images/' + dispVals[0] + '.jpg" border="0" alt="' + dispVals[0] + '"name="'+dispVals[0]+'" /><br />' + dispVals[0] + '</a>';
						//	if(dispVals[0].indexOf(" ") >= 0)
						//	{
						//		dynamicMU += '<a href="ProductBrowse.aspx?category='+ dispVals[2] + '"><img height="150px" src="images/' + dispVals[0] + '.jpg" border="0" alt="' + dispVals[0] + '"name="'+dispVals[0]+'" /><br />' + dispVals[0].substr(0,dispVals[0].indexOf(" "))  + '<br />' + dispVals[0].substr(dispVals[0].indexOf(" ") + 1,dispVals[0].length) + '</a>';	
						//	}
						//	else
						//	{
						//		dynamicMU += '<a href="ProductBrowse.aspx?category=SX4001&role=PUBLICSPORTS"><img height="150px" src="images/' + dispVals[0] + '.jpg" border="0" alt="' + dispVals[0] + '"name="'+dispVals[0]+'" /><br />' + dispVals[0] + '</a>';
						//	}
						}
						dynamicMU += '</td>';
					}
					else
					{
						dynamicMU += '<td>&nbsp;</td>'
					}
					i++;
				}
				dynamicMU += '</tr>';
			}
		dynamicMU += '</table></center>';
		var newdiv = document.createElement('div');
		newdiv.setAttribute('id','HPTable');
		newdiv.innerHTML = dynamicMU;
		getEl.appendChild(newdiv);
	}
	return;
}


