function extractURLParameter(url,parameterName)
{
   // extract the product id from the url
	var start = url.indexOf(parameterName+"=");
	if( start < 0 )
	{
		return "";
	}
	// ignore the parameter name and "="
	start += parameterName.length + 1
	
	
	var end = url.indexOf("&", start);
	
	if( end < start )
	{
		end = url.length;
	}
	return url.substr(start, end-start );
}

var buyOverlayOpen;
buyOverlayOpen = false;

function openBuyOverlay(e,qtyCtrlID)
{
	
	if(iFrameOpen)
	{
		closeSpecialWindow();
	}
	iFrameOb=document.getElementById('shopOverlayIFrame');
	// determine the qty
	var qty = 1;
	if( qtyCtrlID != null && document.getElementById( qtyCtrlID ) != null )
	{
		qty = document.getElementById( qtyCtrlID ).value;
	}

	var originalURL = typeof(e) == "string" ? e : e.href;
	// extract the appropraite values from the url
	var productid = extractURLParameter(originalURL,"productid");
	var object = extractURLParameter(originalURL,"object");
	var type = extractURLParameter(originalURL,"type");
	var itemV = extractURLParameter(originalURL,"item");
	var duration = extractURLParameter(originalURL,"duration");
	var camera = extractURLParameter(originalURL,"camera");
	
	// format the new url		
	var url = "/consumer/digital/Addoverlay?productid=" + productid + "&object=" + object + "&type=" + type+"&item=" + itemV+"&qty="+qty+"&duration="+duration+"&camera="+camera;
	// show the overlay
	openSpecialWindow(url,600,800);
	return false;
}

function resizeBuyOverlay(newHeight)
{
	document.getElementById('shopOverlayIFrame').style.height = newHeight+'px';
//	document.getElementById('shopOverlayIFrame').style.left = '10px';
//	document.getElementById('shopOverlayIFrame').innerHTML = "hellosdasdsa ads das asd sas";
}