/*
** Common. Shows overlay.
*/
function showOverlay(objectName)
{
  document.getElementById(objectName).style.display = "block";
}

/*
** Common. Hides overlay.
*/
function hideOverlay(objectName)
{
  document.getElementById(objectName).style.display = "none";
}

/*
** Common. Prints the header info for the dialog.
*/
function printHeader(objectName, title)
{
  document.getElementById(objectName).innerHTML='<DIV style="float:left;font-size:110%;font-weight:bolder;">' + title + '</DIV><DIV style="float:right;"><A style="background-color:#991111;padding:3px;border:1px solid black" href="javascript:void(0)" onclick="hideOverlay(\'' + objectName + '\');">X</A></DIV><DIV style="clear:both;"></DIV><HR style="color:black;">';
}

/***  End of Common functions ***/

/*
** Shows stock info.
*/
function showStockInfoOverlay(objectName, stockQtyAvailable, stockQtyWanted)
{
  if (stockQtyAvailable <= 0)
  {
    printHeader(objectName, "Special order");
    document.getElementById(objectName).innerHTML+='This item is currently not in stock. However it may be special ordered directly from the manufacturer.<BR><UL><LI>It usually takes 5-10 days to get stock.<LI>If longer delay is expected, you will be notified &amp; given the option to retract the order.<LI>End of the line merchandise cannot be special ordered.<LI>If an item cannot be special ordered, an immediate refund will be issued.</UL>';
  }
  else if(stockQtyAvailable < stockQtyWanted)
  {
    printHeader(objectName, "Insufficient Stock");
    document.getElementById(objectName).innerHTML+='We have insufficient stock to fill your order. However more stock may be special ordered from the manufacturer.<BR><UL><LI>Special orders usually take 5-10 days.<LI>If longer delay is expected, you will be notified &amp; given an option to retract the order.<LI>End of the line merchandise cannot be special ordered.<LI>If we cannot special order this item an immediate refund will be issued.<LI>Order will be shipped complete.</UL>';
  }
  else //(stockQtyAvailable >= stockQtyWanted)
  {
    printHeader(objectName, "In Stock");
  document.getElementById(objectName).innerHTML+='This item is currently in stock.<UL><LI>In stock items are generally shipped in 1 to 3 business days.</UL></A>';
  }
  document.getElementById(objectName).innerHTML+='<BR><B>Note:</B><BR>Stock info is accurate as of end of last business day. Changes in stock during each business day may not be reflected.';
  showOverlay(objectName);
}


/*
** Shows Product Inquiry Form.
*/
function showProductInquiry(objectName)
{
  var prefix = "";
  if(document.location.toString().indexOf('https://') != -1)
    prefix = "https://secure.virtech.ca/";

  printHeader(objectName, "Product Inquiry");
  document.getElementById(objectName).innerHTML+='<IFRAME style="width:100%;height:275px;border:0px;" src="' + prefix + 'productInquiry.php">Sorry your browser does not support iframes. <A href="productInquiry.php">Click here</A></IFRAME>';
  showOverlay(objectName);
}


/*
** Shows currency calculator.
*/
function showCurrencyConvertor(objectName)
{
  printHeader(objectName, "Currency Converter");
  document.getElementById(objectName).innerHTML+='<IFRAME style="width:100%;height:275px;border:0px;" src="currencyConvertor.html">Sorry your browser does not support iframes. <A href="currencyConvertor.html">Click here</A></IFRAME>';
  showOverlay(objectName);
}



/*
** Shows Large Product Picture
*/
function showBigPicture(objectName, prodDesc, picLoc)
{
  printHeader(objectName, prodDesc);
  document.getElementById(objectName).innerHTML+='<DIV style="background-color:#FFFFFF"><CENTER><IMG alt="Product Image" style="max-width:550px;" src="'+picLoc+'"></CENTER></DIV>';
  showOverlay(objectName);
}

/*
**
*/
function confirmLocale(objectName)
{
  var curPage = location.href;

  if (curPage.indexOf('currency') == -1)
    curPage = curPage + '&currency=CAD';
  else
    curPage = curPage.replace('USD', 'CAD');

  printHeader(objectName, 'Would you like to see this page in Canadian dollars?');
  document.getElementById(objectName).innerHTML+='<DIV style="padding:5px;background-color:#FFFFFF;color:#000000;">We believe you are located in Canada. Your are currently attempting to view pricing in American dollars. Would you like to see these prices in Canadian dollars instead?<BR><BR><DIV style="text-align:center;font-weight:bold;font-size:125%;"><A href="' + curPage + '">Yes, show price in CAD</A></DIV><BR><DIV style="text-align:center;font-weight:bold;"><A href="javascript:void(0)" onclick="hideOverlay(\'' + objectName + '\');">No, show price in USD</A></DIV></DIV>';
  showOverlay(objectName);
}

//document.write('<DIV class="overlay" id="overlay"></DIV>');
