function RollImage(control,image) {

   control.src = image;
}


   function ChangePricing() {
      document.frmChangePricing.action = 'eStore.asp?WCI=ChangePricing';
      document.frmChangePricing.submit();
      return true;
   }

   function ChangePricingSource() {
      document.frmChangePricing.action = 'eStore.asp?WCI=ChangePricingSource';
      document.frmChangePricing.submit();
      return true;
   }

function WriteFirstReview(NbReviews,CatalogueProductID) 
/*------------------------------------------------------------------------*/
/* writes the hyperlink for first reviewer of a product       */  
/*-----------------------------------------------------------------------*/
{
if (NbReviews == 0)  {
  document.write('<BR><A HREF="eStore.ASP?WCI=AddUserReview&amp;WCE=CatalogueProductID=' + CatalogueProductID + '">Be the first one to review this product</A>');
  }
}

function WriteCartSummary(nbitems,totalprice) 
/*------------------------------------------------------------------------*/
/* writes the summary of the cart content, if not empty   */  
/*-----------------------------------------------------------------------*/
{
  if (nbitems > 0)  {
     /*var plural = (nbitems > 1) ? 's' : '';*/
     var plural = '';
     if (nbitems > 1)
        plural = 's';
     document.write ('&nbsp;' + nbitems + ' item' + plural + ' &nbsp;' + totalprice + '$&nbsp;');
     }
  else
     document.write ('No item');
}

function WriteNbFound(nbfound) 
/*-------------------------------------------------------------------*/
/* writes the number of product(s) found                             */  
/*-------------------------------------------------------------------*/
{
  if (nbfound > 0)  {
     var plural = '';
     document.write ('Empty');
     if (nbfound > 1)
        plural = 's';
     document.write (nbfound + ' product' + plural);
     }
}

function WriteCart(nbitems) 
{
  if (nbitems > 0)  {
     /*var plural = (nbitems > 1) ? 's' : '';*/
     var plural = '';
     if (nbitems > 1)
        plural = 's';
     document.write ('<P CLASS="SmallGrey" STYLE="background-color: rgb(208,216,184); margin: 2pt 2pt 2pt 2pt;"><A HREF="eStore,wciShowShoppingCart.html"><IMG HEIGHT=19 WIDTH=26 SRC="./SmShopping.gif" ALIGN="TOP" BORDER=0 ALT="my cart"></A>&nbsp;<SHOPPINGCART>NbItem</SHOPPINGCART> item' + plural + ' for $<SHOPPINGCART>TotalPrice</SHOPPINGCART></P>');
     }
}

function WriteLoyaltyPtsText(loyaltypts)
/*-------------------------------------------------------------------*/
/* writes the total loyalty pts                                      */  
/*-------------------------------------------------------------------*/
{
   if (loyaltypts>0)
      document.write ('<NOBR>You currently have ' + loyaltypts + '<A HREF="javascript:OpenPopupHelp(\'popup_videopoints\');"><I>Video</I>Points</A></NOBR>');
   else
      document.write ('<NOBR>Accumulate <A HREF="javascript:OpenPopupHelp(\'popup_videopoints\');"><I>Video</I>Points</A></NOBR>');
}

function Plurial(count)
/*-------------------------------------------------------------------*/
/* Will write an 's' if count > 0                                    */  
/*-------------------------------------------------------------------*/
{
   if (count > 1) 
      document.write ('s');
}



function WritePriceHeader(suggestedprice, price)
/*-------------------------------------------------------------------*/
/* Writes the special price                                          */  
/*-------------------------------------------------------------------*/
{
   if (parseFloat(suggestedprice) > parseFloat(price)) 
      document.write ('<FONT COLOR="#990000">Sale price </FONT>$' + price + '</b>');  
   else
      document.write ('<FONT COLOR="#003300">Buy this for $' + price + '</b></FONT>');
}

function WriteFeaturedProdPrice(suggestedprice,price,currency)
/*-------------------------------------------------------------------*/
/* Writes the special price                                          */  
/*-------------------------------------------------------------------*/
{
   if (parseFloat(suggestedprice) > parseFloat(price)) 
      document.write ('Now on sale <b><NOBR>$' + price + '</NOBR></b>&nbsp;' + currency);
   else
      document.write ('Our price <b><NOBR>$' + price + '</NOBR></b>&nbsp;' + currency);
}

function WriteProductPrice(suggestedprice,price,currency)
/*-------------------------------------------------------------------*/
/* Writes the special price                                          */  
/*-------------------------------------------------------------------*/
{
   if (parseFloat(suggestedprice) > parseFloat(price)) 
      document.write ('Now on sale <b><NOBR>$' + price +  '</NOBR></b>&nbsp;' + currency);
   else
      document.write ('<b>$' + price +  '</b>&nbsp;' + currency);
}


function WritePrice(price)
/*-------------------------------------------------------------------*/
/* Writes the price                                          */  
/*-------------------------------------------------------------------*/
{
  document.write ('<FONT COLOR="#003300">$' + price);
}


function WriteFree(shcharge)
/*-------------------------------------------------------------------*/
/* Writes 'free' if shcharge = 0                                     */  
/*-------------------------------------------------------------------*/
{
  if (shcharge == '$  0.00')
     document.write ('<FONT COLOR="#FF0000">FREE&nbsp;</FONT>');
}

function WriteSalePrice(suggestedprice, price)
/*-------------------------------------------------------------------*/
/* Writes the sale price                                          */  
/*-------------------------------------------------------------------*/
{
   if (parseFloat(suggestedprice) > parseFloat(price)) 
      document.write ('<FONT COLOR="#990000">on sale </FONT><NOBR>$' + price + '</NOBR></FONT>');
   else
      document.write ('<FONT COLOR="#003300">$' + price + '</FONT>');
}

function WriteSpecialPrice(suggestedprice, price)
/*-------------------------------------------------------------------*/
/* Writes the special price                                          */  
/*-------------------------------------------------------------------*/
{
   if (parseFloat(suggestedprice) > parseFloat(price)) 
      document.write ('<FONT COLOR="#990000">on sale </FONT><NOBR>$' + price + '</NOBR></FONT>');
   else
      document.write ('<FONT COLOR="#003300"><b>$' + price + '</b></FONT>');
}

function WriteShoppingCartSpecialPrice(suggestedprice,price)
/*-------------------------------------------------------------------*/
/* Writes the suggested price of a product within the shopping cart     */  
/*-------------------------------------------------------------------*/
{
   if (suggestedprice != price) 
      document.write ('<FONT SIZE="-2" COLOR="#990000"><STRIKE>' + suggestedprice +'</STRIKE>')
}


function WriteCartRegPrice(suggestedprice,price,isgift)
{
   if (isgift!=0) 
      document.write ('<IMG SRC="./prime_cadeau.gif" HEIGHT=24 WIDTH=53  BORDER=0 ALT="Free Gift" >');
   else
      {
         document.write (price + '<BR>');
         if (suggestedprice != price) 
            document.write ('<FONT SIZE="-2" COLOR="#990000"><STRIKE>' + suggestedprice +'</STRIKE>');
      }
}

function WriteCartQty(nameqty,qty,isgift)
{
   if (isgift==0) 
      document.write ('<INPUT TYPE=TEXT NAME="' + nameqty + '" VALUE="' + qty + '" SIZE=4 MAXLENGTH=22 style="text-align: right; font-size: 8pt; font-family: Arial;  border-style: solid; border-color: #94819A; border-width: 1">'); 
   else
      document.write ('&nbsp;');
}


function WriteCartButtons(orderdetailid,isgift)
{
   if (isgift==0) 
      {
         document.write ('<INPUT ID="FB33" NAME="cmdRefresh" TYPE=image BORDER=0 SRC="./btext_recalculate.gif" ALT="Click here to update the shopping cart"><BR>&nbsp;');
         document.write ('<A HREF="eStore.ASP?WCI=wciDelProductInCart&WCE=OrderDetailID=' + orderdetailid + '"><SPAN STYLE="font-size: 8pt;">remove</SPAN></A>');
      }
   else
      document.write ('&nbsp;');
}


function WriteCartRegTotPrice(price,pricecurrency,isgift)
{
   if (isgift==0) 
      document.write (price + '<BR>' + pricecurrency);
   else
      document.write ('&nbsp;');
}


function WriteISBN(isbn)
/*-------------------------------------------------------------------*/
/* Writes ISBN                                                       */  
/*-------------------------------------------------------------------*/
{
   if (isbn!='') 
      {
	 document.write('ISBN&nbsp;' + isbn);
      }
}

function WriteBarcode(barcode)
/*-------------------------------------------------------------------*/
/* Writes BarCode                                                    */  
/*-------------------------------------------------------------------*/
{
   if (barcode!='') 
      {
	 document.write('Barcode&nbsp;' + barcode);
      }
}


function WriteProdPrice(suggestedprice,price,currency)
/*-------------------------------------------------------------------*/
/* Writes the price of a product on dept page           */  
/*-------------------------------------------------------------------*/
{
   if (parseFloat(suggestedprice) > parseFloat(price)) 
      document.write('<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH="100%" ><TR><TD WIDTH=60%><P STYLE="text-align: center;">Only<BR><b>$' + price + '</b>&nbsp;' + currency + '</P></TD><TD WIDTH=40%><P STYLE="text-align: center;">Was<BR><STRIKE>$' + suggestedprice + '</STRIKE></P></TD></TR></TABLE>');
   else
      document.write('Only<BR><B> $' + price + '</B>&nbsp;' + currency);
}


function WritePreOrderDate(ispreorder,dateavailable)
/*-------------------------------------------------------------------*/
/* Writes the pre-order date                                         */  
/*-------------------------------------------------------------------*/
{
   if (ispreorder == 1)
      document.write('<B>Release Date: ' + dateavailable + '</B>');
}

function WriteBuyItButton(ispreorder,catalogueproductid,productname)
/*-------------------------------------------------------------------*/
/* Writes the Buy it button                                          */  
/*-------------------------------------------------------------------*/
{
  document.write('<A HREF="eStore.ASP?WCI=wciAddProductInCart&WCE=CatalogueProductID=' + catalogueproductid + '">'); 
  if (ispreorder == 1) 
      document.write('<IMG HEIGHT=17 WIDTH=77 SRC="./bt_preorder_nr.gif" VSPACE=0 HSPACE=10 ALIGN="MIDDLE" BORDER=0 ALT="preorder ' + productname + '" onMouseOver="RollImage(this,\'bt_preorder_hg.gif\')" onMouseOut="RollImage(this,\'bt_preorder_nr.gif\')"></A>');
   else
      {
         document.write('<IMG HEIGHT=17 WIDTH=77 SRC="./bt_buy_nr.gif" VSPACE=0 HSPACE=10 ALIGN="MIDDLE" BORDER=0 ALT="buy ' + productname + '" onMouseOver="RollImage(this,\'bt_buy_hg.gif\')" onMouseOut="RollImage(this,\'bt_buy_nr.gif\')"></A>');
      }
}

function WriteCartLoyaltyPts(loyaltypts)
/*-------------------------------------------------------------------*/
/* Writes the number of loyalty pts that would be added in page      */
/* ShoppingCart                                                      */  
/*-------------------------------------------------------------------*/
{
   if (loyaltypts > 0) 
      document.write ('<B>' + loyaltypts + ' <A HREF="javascript:OpenPopupHelp(\'popup_videopoints\');"><I>Video</I>Points</A></B> will be added to your account if you place this order');	
}

function WriteCheckoutLoyaltyPts(loyaltypts)
/*-------------------------------------------------------------------*/
/* Writes the number of loyalty pts that would be added in page      */
/* Credit Card and/or Confirmation                                   */  
/*-------------------------------------------------------------------*/
{
   if (loyaltypts > 0) 
      document.write ('By placing this order, you will get <B>' + loyaltypts + ' new <A HREF="javascript:OpenPopupHelp(\'popup_videopoints\');"><I>Video</I>Points</A></B>.');	
}

function WriteFeaturedProdRebate(suggestedprice,price,amountrebate)
/*-------------------------------------------------------------------*/
/* Writes the rebate text                                            */  
/*-------------------------------------------------------------------*/
{
   if (parseFloat(suggestedprice) > parseFloat(price)) 
      {
	 document.write('<FONT COLOR="#990000">Save $' + amountrebate + '</FONT>');
      }
}

function WriteRebate(suggestedprice,price,amountrebate)
/*-------------------------------------------------------------------*/
/* Writes the rebate text                                            */  
/*-------------------------------------------------------------------*/
{
   if (parseFloat(suggestedprice) > parseFloat(price)) 
      {
	 document.write('<FONT COLOR="#990000">Save $' + amountrebate + '<br></FONT>');
	 document.write('Was&nbsp;<STRIKE>$' + suggestedprice + '</STRIKE>');
      }
}

function WriteProductRebate(suggestedprice,price,amountrebate)
/*-------------------------------------------------------------------*/
/* Writes the rebate text                                            */  
/*-------------------------------------------------------------------*/
{
   if (parseFloat(suggestedprice) > parseFloat(price)) 
      {
	 document.write('<FONT COLOR="#990000">Save $' + amountrebate + '&nbsp;');
	 document.write('Was&nbsp;<STRIKE>$' + suggestedprice + '</STRIKE></FONT><BR>');
      }
}


function WriteOrderStatus(orderid,ordervaluenotreceived,totamtrefunded)
/*-------------------------------------------------------------------*/
/* Writes the status of a order in the order history                 */  
/*-------------------------------------------------------------------*/
{
   if (totamtrefunded != "$  0.00" )
      document.write ('Refunded');
   else 
      if (ordervaluenotreceived == "$  0.00" )
	 document.write ('Paid');
      else
	 document.write ('<A HREF="eStore.ASP?WCI=wciChooseOrderToPaySubmit&WCE=OrderID=' + orderid + '"><IMG ID="PictPay" SRC="./payorder.gif" BORDER=0 ></A>');
}

function OpenPopupHelp(strWebPage) {
   window.open("eStore,ProcessWebPage,PageName-" + strWebPage + ".html","wAide","width=590,height=450,scrollbars=yes");
   }
