
var lookingGlassHidden = true;
var currentProductElem = null;

function init()
{
	var products = getElementsByTagAndClassName(null, 'miniBath');
	for (var i = 0; i < products.length; i++)
	{
		var product = products[i];
		updateNodeAttributes(product, {'onmouseover': 'showLookingGlass(this)'});
		updateNodeAttributes(product, {'onmouseout': 'hideLookingGlass()'});
	}
}

function resetfilter()
{
	document.filter.CATEGORY.value="AND PMCATG IN ('1','2','3','18')";
	document.filter.COLLECTION.value='';
	document.filter.SHAPE.value='';
	document.filter.LENGTH.value='';
	document.filter.PRICE.value='';
	document.filter.INSTALL.value='';	
	document.filter.SKIRTED.value='';
	document.filter.JETS.value='';
	document.filter.submit();

}

function showLookingGlass(elem)
{
	var lookingGlass = $('lookingGlass');
	
	if (elem)
	{
		currentProductElem = elem;
		lookingGlass.blur();
		var elemPos = elementPosition(elem);
		var elemDims = elementDimensions(elem);
		setElementPosition(lookingGlass, {x: elemPos.x + 15, y: elemPos.y + 8});
	}
	showElement(lookingGlass);
	lookingGlassHidden = false;
	
}

function hideLookingGlass()
{
	if (!lookingGlassHidden)
	{
		hideElement('lookingGlass');
		lookingGlassHidden = true;
	}
}

function showQuickLook()
{
	var lookingGlass = $('lookingGlass');
	var xpos = lookingGlass.offsetLeft;
	var ypos = lookingGlass.offsetTop;
	
	// Retrieve supergroup key from hidden DIV
	var supergrp = getFirstElementByTagAndClassName('div', 'quickLookSG', currentProductElem);
	
	// Execute AJAX to retrieve data and generate HTML for quicklook
	AJAX_QUICKLOOK(supergrp.innerHTML);
	var img = getFirstElementByTagAndClassName('img', null, currentProductElem);

	//Position quicklook relative to the click
	if (ypos<=500){
		document.getElementById('QL_AJAX').style.top = ypos-200 + 'px';
	}
	else {
		document.getElementById('QL_AJAX').style.top = ypos-500 + 'px';
	}
	// Display quicklook
	showElement('quickLook');
}

function hideQuickLook()
{
	hideElement('quickLook');
}

function viewDetails()
{
	var link = getFirstElementByTagAndClassName('a', null, currentProductElem);
	location.assign(link.href);
}

addLoadEvent(init);
