var gReloadProdRecOverlay = false;
function UpdatePriceCompare(PriceData) {
	var oPrice = document.getElementById(PriceData.PriceId);
	var subtotal = (PriceData.Qty * PriceData.BasePrice);
	oPrice.innerHTML = "$" + subtotal.toFixed(2);
	
	if(PriceData.PriceEffectiveId) {
		var oPrice = document.getElementById(PriceData.PriceEffectiveId);
		if(oPrice) {
			if(PriceData.BasePrice > PriceData.PriceEffective) {
				subtotal = (PriceData.Qty * PriceData.PriceEffective);
				oPrice.innerHTML = "$" + subtotal.toFixed(2);
			}
		}
	}
}

function PriceData(qty, price, priceId, priceEffective, priceEffectiveId) {
	this.Qty = qty;
	this.BasePrice = price;
	this.PriceId = priceId;
	this.PriceEffective = priceEffective;
	this.PriceEffectiveId = priceEffectiveId;
}


function BaseZoomConfig()
{
	this.Name = 'zoom_win';
	this.Config = 'zoom_config';
	this.ZoomWidth = 420;
	this.ZoomHeight = 500;
	this.WindowWidth = 420;
	this.WindowHeight = 490;
	this.WindowTitle = 'Product Zoom';
	this.Top = (screen.height-this.WindowHeight)/2;
	this.Left = (screen.width-this.WindowWidth)/2;
	this.Right = 0;
	this.Bottom = 0;
}
BaseZoomConfig.prototype.GetURL=function() {
	return this.URL+'?company=Drugstore&windowtitle=' + this.WindowTitle + '&sku='+this.ProductID+'&zoomwidth='+this.ZoomWidth+'&zoomheight='+this.ZoomHeight+'&config='+this.Config;
}
function ZoomConfig(url, pid, windowTitle, siteId)
{
	this.URL = url;
	this.ProductID = pid;
	this.WindowTitle = windowTitle;
	if(siteId != 'undefined') {
		if (siteId != 1) {this.Config = 'zoom_config_dscm';}
	}
}
ZoomConfig.prototype = new BaseZoomConfig();
function zoom_window(config) {
	try{
		popUp(config.GetURL(),config.Name,config.WindowWidth,config.WindowHeight,'','yes','','','',config.Top,config.Right,config.Bottom,config.Left);
	} catch(e) {}
}

function FireClickEvent(id)
{
     try
     {
           var el = document.getElementById(id);
           if(el)
           {       
               el.click();
           }
     } catch(e) {}
}

// function to render the auto delivery overlay
// loads the iframe only for the first time
function openAutoDeliveryOverlay(obj, src)
{
	var exists = false;
	var adOverlayName = "ADOverlay";
	
	if(gE(adOverlayName) != null) exists = true;
	
	if (exists)
	{
		showOverlay(obj, adOverlayName, true, false);
	}
	else
	{
		var html = "";
		html = html + "<div id=\"ADFrameCntr\">";
			html = html + "<iframe title=\"Autodelivery Overlay\" id=\"iFrmAutoDelivery\" name=\"iFrmAutoDelivery\" src='" + src + "' hspace=\"0\" vspace=\"0\" marginwidth=\"0\" marginheight=\"0\" frameborder=\"0\" scrolling=\"auto\" onload=\"resizeContainerFrame('iFrmAutoDelivery');\"></iframe>"
		html = html + "</div>";
		createOverlay(html, "Auto Delivery", adOverlayName, null);
	}
}

// function to render the auto delivery overlay
// loads the iframe only for the first time
function openProductRecommenderOverlay(obj, src)
{
	var exists = false;
	var overlayName = "ProdRecOverlay";
	
	if(gE(overlayName) != null) exists = true;
	
	if (exists && !gReloadProdRecOverlay)
	{
		showOverlay(obj, overlayName, true, false);
	}
	else
	{
		var html = "";
		html = html + "<div id=\"ProdRecFrameCntr\">";
			html = html + "<iframe title=\"Product recommend Overlay\" id=\"iFrmProdRec\" name=\"iFrmProdRec\" src='" + src + "' hspace=\"0\" vspace=\"0\" marginwidth=\"0\" marginheight=\"0\" frameborder=\"0\" scrolling=\"auto\"></iframe>"
		html = html + "</div>";
		createOverlay(html, "Email a Friend", overlayName, null);
		gReloadProdRecOverlay = false;//this will be set to "true" by email overlay after submitting the form.
	}
}
