var ttProductsNoQuantitySlectedId = 'ttProductsNoQuantitySelected';
var ttProductsErrorFadeDuration = 500;
var ttProductsErrorMessageOverlayOpacity = 0.8;
function checkQuantity(fieldId)	{
	var fieldValue = $(fieldId).value;
	
	if(fieldValue > 0)	{
		return true;
	}

	txTtProductsActualErrorField = fieldId;
	showErrorNoQuantitySelected();
	
	return false;
}

function showErrorNoQuantitySelected()	{
	var ww = (window.getWidth() == 0) ? window.getScrollWidth()-22 : window.getWidth();
	var wh = (window.getHeight() == 0) ? window.getScrollHeight() : window.getHeight();
	var st = document.body.scrollTop  || document.documentElement.scrollTop;

		//set opacity to 0 and display to block;
	txTtProductsErrorMessageOverlay.setStyles({'opacity' : 0, 'display': 'block', top: st+'px', height: wh+'px', width:ww+'px'});
		//initialize effect
	txTtProductsErrorMessageOverlay.effect('opacity', {duration: ttProductsErrorFadeDuration}).start(ttProductsErrorMessageOverlayOpacity);
	
	
	$(ttProductsNoQuantitySlectedId).setStyle('display', 'none').setStyles({'opacity' : 0, 'display': 'block', top: (st+(wh/2))+'px'}).effect('opacity', {duration: ttProductsErrorFadeDuration}).start(1);
}

function hideErrorNoQuantitySelected()	{
		//hide the error message
	txTtProductsErrorMessageOverlay.effect('opacity', {duration: ttProductsErrorFadeDuration}).start(0).chain(function() {
		//set focus to the actual field
		$(txTtProductsActualErrorField).focus();
	
		txTtProductsErrorMessageOverlay.setStyle('display', 'none');
		$(ttProductsNoQuantitySlectedId).setStyle('display', 'none');
	});
	
	$(ttProductsNoQuantitySlectedId).effect('opacity', {duration: ttProductsErrorFadeDuration}).start(0);
}


window.addEvent('domready', function() {
		//create the overlay element
	txTtProductsErrorMessageOverlay = new Element('div').setProperty('id', ttProductsNoQuantitySlectedId+'Overlay').setStyle('display', 'none').injectInside(document.body);
	
		//first removing the element out of the dom and then inject it after the overlay.
	$(ttProductsNoQuantitySlectedId).remove().setStyles({'display': 'none', 'opacity' : 0}).injectAfter(txTtProductsErrorMessageOverlay);
});
