
function submitStars(numStars, prodId)
{						
	top.document.getElementById('priority[' + prodId + ']').value = numStars;	
	top.document.wishlist.submit();
}

function fillStars(numStars, prodId)
{			
	var strHtml = '';
	
	for(var i=0; i < 5; i++)
	{
		if(i <= eval(numStars))
			strHtml = strHtml + '<img onClick="fillStars(\'' + i + '\', \'' + prodId + '\')" class="clickable_star" src="includes/templates/lama/images/star_filled.gif" alt="">';
		else
			strHtml = strHtml + '<img onClick="fillStars(\'' + i + '\', \'' + prodId + '\')" class="clickable_star" src="includes/templates/lama/images/star_empty.gif" alt="">';			
	}
	
	top.document.getElementById('starbox[' + prodId + ']').innerHTML = strHtml;	
	top.document.getElementById('priority[' + prodId + ']').value = numStars;	
}


function showGrayLayer()
{
	grayDiv = top.document.getElementById('grayLayer');	
	grayDiv.style.display = 'inline';
}

function hideGrayLayer()
{
	grayDiv = top.document.getElementById('grayLayer');	
	grayDiv.style.display = 'none';
}

function closeDiamondPopup()
{
	if(top.document.getElementById('divPopupStones').style.visibility='visible')
	{
		placeHolder = top.document.getElementById('iframePopupStonesDiv');
		while(placeHolder.childNodes[0])
			placeHolder.removeChild(placeHolder.childNodes[0]);
		top.document.getElementById('divPopupStones').style.visibility='hidden';
	}
}

function closePopup()
{		
	if(top.document.getElementById('divPopup').style.visibility='visible')
	{
		placeHolder = top.document.getElementById('iframePopupDiv');
		while(placeHolder.childNodes[0])
			placeHolder.removeChild(placeHolder.childNodes[0]);
		top.document.getElementById('divPopup').style.visibility='hidden';
	}
}

function closePopupStones()
{
	placeHolder = top.document.getElementById('iframePopupStonesDiv');
	while(placeHolder.childNodes[0])
		placeHolder.removeChild(placeHolder.childNodes[0]);
	top.document.getElementById('divPopupStones').style.visibility='hidden';
}

function popupStones(url)
{	
	popupWindow(url, 650, 430, 'iframePopupStonesDiv', 'divPopupStones');
}

function popupPaymentPlan(url)
{	
	popupWindow(url, 430, 350, 'iframePopupDiv', 'divPopup');
}

function popupInfo(url)
{
	popupWindow(url, 430, 330, 'iframePopupDiv', 'divPopup');
}

function popupGlossary(url)
{
	popupWindow(url, 430, 330, 'iframePopupDiv', 'divPopup');
}

function popupIllustration(url)
{
	popupWindow(url, 400, 490, 'iframePopupDiv', 'divPopup');
}

function popupWindow(url, x, y, theFrame, theDiv)
{
	var ifrm, placeHolder;
		
	ifrm = top.document.createElement("IFRAME"); 
	ifrm.setAttribute("src", url);
	ifrm.setAttribute('frameBorder', '0');
	ifrm.style.width = x + "px";
	ifrm.style.height = y + "px";
	
	placeHolder = top.document.getElementById(theFrame);
	while(placeHolder.childNodes[0])
		placeHolder.removeChild(placeHolder.childNodes[0]);
		
	placeHolder.appendChild(ifrm);

	tmpDiv = top.document.getElementById(theDiv);

	tmpDiv.style.width = x + 'px';
	tmpDiv.style.height = y + 'px';
	
	positionThePopup(x, y, theDiv);
		
	tmpDiv.style.visibility = 'visible';
}

function positionThePopup(x, y, theDiv)
{
	var scrolledX, scrolledY, posX;
	
	if( self.pageYOffset )
	{
		scrolledX = self.pageXOffset;
		scrolledY = self.pageYOffset;
	}
	else if( top.document.documentElement && top.document.documentElement.scrollTop )
	{
		scrolledX = top.document.documentElement.scrollLeft;
		scrolledY = top.document.documentElement.scrollTop; 
	}
	else if( top.document.body )
	{
		scrolledX = top.document.body.scrollLeft;
		scrolledY = top.document.body.scrollTop;
	}
		
	//offset from top of page
	if(scrolledY < 118)
		scrolledY = 118;

	posX = getPageWidth() / 2.0;	
	posX = posX - 285;		
		
	tmpDiv = top.document.getElementById(theDiv);
	tmpDiv.style.top = (scrolledY + 3) + 'px';
	tmpDiv.style.left = posX + 'px';	
}

function getPageWidth()
{
	return top.document.body.clientWidth;
}