 namespace('Page.Display')['Initialize'] = function() {
	switch (Page.Display.Parameters.CLIENT_BROWSER_ID) {
		case '1':
			if (WebPage.Compatibility.Browser.isIE()) {
				AttachEvent(window, 'load', (function(){window.setInterval('Page.Display.AutoFontSizeForIE()', 200);}));
			}
			break;

		case '2':
			AttachEvent(window, 'load', (function(){window.setInterval('Page.Display.AutoFontSizeForFF()', 200);}));
			break;

		default:
			break;
	}
	AttachEvent(window,'load',Page.Display.AutoWidthProductCell);
	AttachEvent(window,'resize',Page.Display.AutoWidthProductCell);
}

 namespace('Web.Template')['Rollover'] = {
	displayId : '',
	timer : null,
	over : function(e){
		e = Web.Compatibility.Event(e);
		var tgn = e.srcElement.nodeName;
		var lastId = Web.Template.Rollover.displayId;
		var o = (tgn == 'IMG' || tgn== 'TD') ? e.srcElement.parentNode.parentNode.childNodes[0]:null;
		//alert('tgn=' + tgn);
		//alert('o=' + o);
		if (o && o.id != lastId) {
			o.style.display = 'block';
			var f = o.parentNode.childNodes[1];
			if (f && f.nodeName == 'UL'){
				f.style.width = o.offsetWidth;
				f.style.height = o.offsetHeight;
				f.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)';
				f.style.display = 'block';
			}
			Web.Template.Rollover.hidden();
			Web.Template.Rollover.displayId = o.id;

		}
		if(Web.Template.Rollover.timer){clearTimeout(Web.Template.Rollover.timer);}
	},
	out : function(e){
		e = Web.Compatibility.Event(e);
		var tgn = e.srcElement.nodeName;
		var o = (tgn == 'UL') ? e.srcElement : (tgn == 'LI') ? e.srcElement.parentNode:(tgn == 'A') ? e.srcElement.parentNode.parentNode : (tgn == 'IMG') ? e.srcElement.parentNode.parentNode.childNodes[0]:{id:''};
		if (o.id==Web.Template.Rollover.displayId) {
			Web.Template.Rollover.timer = setTimeout(Web.Template.Rollover.hidden,100);
		}
	},
	hidden : function(){
		if(Web.Template.Rollover.displayId.length>0){
			var o = $(Web.Template.Rollover.displayId);
			var f = o.parentNode.childNodes[1];
			if (f && f.nodeName == 'UL')	{
			  f.style.display = 'none';
			}
			o.style.display = 'none';
		}
		Web.Template.Rollover.displayId = '';
	}
}

function SetStyle(id,css,type) {
	var o;
	if (o = document.getElementById(id)) {
		switch (type){
			case 0:
				o.className = css;
				break;

			case 1:
				o.className += " "+css;
				break;

			default:
				break;
		}
	}
}

function ClearStyle(id,css,type) {
	var o;
	if (o = document.getElementById(id)){
		switch (type) {
			case 0:
				o.className = "";
				break;

			case 1:
				o.className = o.className.replace(" "+css,"");
				break;

			default:
				break;
		}
	}
}

Page.Display.AutoFontSizeForFF = function() {
	var dBody = document.defaultView.getComputedStyle(document.body,null);
	var dSize = dBody.getPropertyValue("font-size");
	dSize = parseInt(dSize.replace("/[^\d]/",""));
	if (dSize == Page.Display.Parameters.LAST_SIZE){return;}

	if (dSize > 16){
		if (dSize < 24){
			SetStyle("leftNav","FontSizeLarger",0);
			SetStyle("centerArea","FontSizeLarger",0);
			SetStyle("prdTopNav","prdTopNavSize1",0);

		}else{
			SetStyle("leftNav","FontSizeLargest",0);
			SetStyle("centerArea","FontSizeLargest",0);
			SetStyle("prdTopNav","prdTopNavSize1",0);
		}
	}else{
		ClearStyle("leftNav","",0);
		ClearStyle("centerArea","",0);
		ClearStyle("prdTopNav","",0);
	}
	var bfw;
	if (bfw = document.getElementById("BigFontWarring")){
		if (dSize > 24){
			bfw.style.display = "block";
		}else{
			bfw.style.display = "none";
		}
	}
	Page.Display.Parameters.LAST_SIZE = dSize;
	Page.Display.AutoWidthProductCell();
}

Page.Display.AutoFontSizeForIE = function() {
	if (!window.readyState == "complete"){return;}
	if (!document.getElementById("IEFontCheck")){return;}
	var dSize = document.getElementById("IEFontCheck").offsetWidth;
	var action = 1;
	if (dSize == Page.Display.Parameters.LAST_SIZE){return;}

	if (dSize <= 8){
		action = 1;
	}else if(dSize <= 10){
		action = 2;
	}
	else{
		action = 3;
	}

	//SetActivedCSS(action);
	if (action != Page.Parameters.CSS['L']) {
		if (!$('lvl'+action)) {
			var styleObject = document.createElement('link');
			styleObject.setAttribute('id', 'lvl' + action)
			styleObject.setAttribute('rel', 'stylesheet');
			styleObject.setAttribute('type', 'text/css');
			styleObject.setAttribute('href', Page.Parameters.CSS[action]);
			document.body.appendChild(styleObject);
			AttachEvent(styleObject, 'load', (function(){
				Page.Display.AutoFontSizeForIEApply(action);
				Page.Display.AutoFontSizeForIEUpdate(dSize);
			}));
		} else {
			Page.Display.AutoFontSizeForIEApply(action);
		}
	}
}

Page.Display.AutoFontSizeForIEApply = function(action) {
	if (action != Page.Parameters.CSS['L']) {
		$('lvl'+action).disabled = false;
		$('lvl'+Page.Parameters.CSS['L']).disabled = true;
		Page.Parameters.CSS['L'] = action;
		SetJSCookie('NV_LARGETEXT',action);
	}
}

Page.Display.AutoFontSizeForIEUpdate = function(dSize) {
	Page.Display.Parameters.LAST_SIZE = dSize;
	Page.Display.AutoWidthProductCell();
}



Page.Display.AutoWidthProductCell = function() {
//	if (!document.getElementById("centerArea")){return;}
	if (!document.getElementById("FeaturedProducts")){return;}
	if (!document.getElementById("HomepagePrd")){return;}
//	var w = parseInt(document.getElementById("centerArea").offsetWidth);
	var w = parseInt(document.getElementById("FeaturedProducts").offsetWidth) - 1;
	var ic = document.getElementById("HomepagePrd").className.replace(/[^\d]/ig,'') - 0;
	w = (w < 765) ? 765:w;
	// alert ('w = ' + w);
	w = w; // hack to make it stop writing 4 boxes and wrapping 3
	var cc = Math.floor(w / 197); // 197 is the width of the home_product box plus a little padding
	var mx = (ic < 4) ? ic:4;
	cc = (cc > mx) ? mx:cc;
	var pd = parseInt((w - (197 * cc)) / (cc*2 - 1)) + 'px'; // figured out padding between each, -1 chunk of padding for rightmost
	var homesection;
	for (var i = 1; i <= ic; ++i) {
		if (homesection = document.getElementById('Section' + i)) {
			homesection.style.posTop = '0px';
			homesection.style.paddingLeft = pd;
			if ((i % cc) == 0) {
				homesection.className = "SectionRt";
				homesection.style.paddingRight = '0px';
			} else {
				homesection.className = "Section";
				homesection.style.paddingRight = pd;
			}
		}
	}
}

