//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
 * @package Starweb Webshop System
 * @version See version-file
 * @copyright Copyright (c) 2000 - 2008, Ehandelslogik i Lund AB
 * 
 * @author Ehandelslogik i Lund AB, org.no 556696-9019  (Starweb)
 *  Country: Sweden
 *  Homepage: www.starweb.se
 *  E-mail: support@starweb.se
 * 
 * License:
 * This program is not "free" software and restrictions apply!
 * This file as well as all other files containing the code to our software may ONLY be used and/or redistributed with written permission from us.
 * You'll find information regarding our conditions and pricing on our homepage. Contact us immediately if any of these conditions are not clear.
 */
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/** Initialize: Public variables */
/** @var string - Get: Div name to hide/show */
var sDivName = 'divBtnBuy';






//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
 * @name Function: Set Article Item Field Value List
 * @access public
 */
function SetArtItemFldValList()
{
   // Get: Is there article parameters?
   var frmArtItem = document.forms['frmArtItem'];
   var oArtPrm_0  = frmArtItem.elements['aItem[oArtPrm_0]']; // MUST BE FOUND BY NAME DUE TO LABEL IS IDENTIFIED BY ID!
   var sArtModelIdSel, sStockStatusSel, fArtWeightNrSel, fCostExclVatNrSel, fCostDiscountExclVatNrSel, fCostCustRtlrExclVatNrSel;
   var i, j, iUniqueIdRowNr;
   var sFirstUniqueId      = sUniqueId = "";
   var iFirstUniqueIdRowNr = 0;
   var oArtQtyNrTxtBox      = document.getElementById("aItem[iArtQtyNr]");
   var iArtQtyNr            = 1;
   var oCustOwnTxt_1TxtArea = document.getElementById("aItem[oCustOwnTxt_1]");
   var oCustOwnTxt_2TxtArea = document.getElementById("aItem[oCustOwnTxt_2]");
   var oCustOwnTxt_3TxtArea = document.getElementById("aItem[oCustOwnTxt_3]");
   var oCustOwnTxt_4TxtArea = document.getElementById("aItem[oCustOwnTxt_4]");
   var sWarnMsg;
   
   
   
   switch(true)
   {
      // ARTICLE PARAMETER
      case ((oArtPrm_0 != "") && (oArtPrm_0 != undefined)):
         // Loop: Through all fields in array
         for(i=0, j=1; i<iArtPrmTotalNr; i++, j++)
         {
            // Get: Article parameter object
            var oArtPrmObj = frmArtItem["aItem[oArtPrm_" + i + "]"]; // MUST BE FOUND BY NAME DU TO LABEL IS IDENTIFIED BY ID!
            
            
            /* Article parameter exists, set article parameter cost - Start */
            if(oArtPrmObj)
            {
               switch(true)
               {
                  // RADIO BUTTON
                  case (oArtPrmObj.type == "radio"):
                  case ((oArtPrmObj.type == undefined) && (oArtPrmObj.checked == undefined) && (oArtPrmObj.length > 0)): // Several radio buttons
                     // Check: If several radio buttons per parameter
                     if(oArtPrmObj.length > 0)
                     {
                        for(var k=0; k<oArtPrmObj.length; k++)
                        {
                           // Check: That value is checked
                           if(oArtPrmObj[k].checked)
                           {
                              sUniqueId += oArtPrmObj[k].value;
                              break;
                           }
                        }
                     }
                     // Check: Only ONE radio button per parameter
                     else if(oArtPrmObj.checked == true)
                     { sUniqueId += oArtPrmObj.value; }
                     break;
                     
                     
                  // SELECT LIST
                  default:
                     // Get: Selected article parameter id
                     if(oArtPrmObj.options)
                     { sUniqueId += oArtPrmObj.options[oArtPrmObj.selectedIndex].value; }
                     break;
               }
               
               
               // Set: Add value to total unique id string
               if(iArtPrmTotalNr != j)
               { sUniqueId += sChrStop; }
            }
            /* Article parameter exists, set article parameter cost - End */
         }
         
         
         if(sUniqueId)
         {
            // Loop: Through all fields in array. Get FIRST iFirstUniqueIdRowNr
            for(var sKey in aArtPrm_DataUniqueIdItem[0])
            {
               sFirstUniqueId = sKey;
               
               // Break loop
               break;
            }
            
            
            // Loop: Through all fields in array. Get SELECTED UniqueIdRowNr
            for(iUniqueIdRowNr=0; iUniqueIdRowNr<iArtPrm_DataTotalNr; iUniqueIdRowNr++)
            {
               if(aArtPrm_DataUniqueIdItem[iUniqueIdRowNr][sUniqueId])
               {
                  sArtModelIdSel            = aArtPrm_DataUniqueIdItem[iUniqueIdRowNr][sUniqueId]["ModelId"];
                  sStockStatusSel           = aArtPrm_DataUniqueIdItem[iUniqueIdRowNr][sUniqueId]["sStockStatusTransl"];
                  fArtWeightNrSel           = aArtPrm_DataUniqueIdItem[iUniqueIdRowNr][sUniqueId]["WeightNr"];
                  fCostExclVatNrSel         = aArtPrm_DataUniqueIdItem[iUniqueIdRowNr][sUniqueId]["CostExclVatNr"];
                  fCostDiscountExclVatNrSel = aArtPrm_DataUniqueIdItem[iUniqueIdRowNr][sUniqueId]["CostDiscountExclVatNr"];
                  fCostCustRtlrExclVatNrSel = aArtPrm_DataUniqueIdItem[iUniqueIdRowNr][sUniqueId]["CostCustRtlrExclVatNr"];
                  //sImgArtPrmName            = aArtPrm_DataUniqueIdItem[iUniqueIdRowNr][sUniqueId]["Img"];
                  break;
               }
            }
         }
         break;
         
         
         
      // _NO_ ARTICLE PARAMETER
      default:
         sArtModelIdSel            = sDbArtModelId;
         sStockStatusSel           = sDbStockStatusTransl;
         fArtWeightNrSel           = fDbWeightNr;
         fCostExclVatNrSel         = fDbCostExclVatNr;
         fCostDiscountExclVatNrSel = fDbCostDiscountExclVatNr;
         fCostCustRtlrExclVatNrSel = fDbCostCustRtlrExclVatNr;
         break;
   }
   
   
   
   // Set: Model id, stock status, weight number, url to insert article in cart
   SetModelIdTxtBox(sArtModelIdSel);
   SetStockStatusTxtBox(sStockStatusSel);
   SetWeightNrTxtBox(fArtWeightNrSel);
   SetImgArtPrm(sUniqueId, sFirstUniqueId, iUniqueIdRowNr, iFirstUniqueIdRowNr);
   SetUrlBtnBuy(iDbId, sArtModelIdSel);
   
   
   
   // Check: That accessory is installed, and that CustOwnTxt-field exists
   if((bIsModMultiplyCustOwnTxtRealTime == '1') && oCustOwnTxt_1TxtArea)
   {
      // Get: Article quantity
      iArtQtyNr = IsInteger(oArtQtyNrTxtBox.value) ? oArtQtyNrTxtBox.value : iArtQtyNr;
      
      // Get: Width * height
      var iCustOwnTxtValNr = (IsInteger(oCustOwnTxt_1TxtArea.value) && IsInteger(oCustOwnTxt_2TxtArea.value))
         ? (oCustOwnTxt_1TxtArea.value * oCustOwnTxt_2TxtArea.value)
         : (IsInteger(oCustOwnTxt_1TxtArea.value) ? oCustOwnTxt_1TxtArea.value : 0);
      
      
      // View: Warnings
      if((oCustOwnTxt_1TxtArea.value > "") && (IsInteger(oCustOwnTxt_1TxtArea.value) -1))
      {
         sWarnMsg = sWarnTranslMsg;
      }
      else if(oCustOwnTxt_2TxtArea)
      {
         if((oCustOwnTxt_2TxtArea.value > "") && (IsInteger(oCustOwnTxt_2TxtArea.value) -1))
         { sWarnMsg = sWarnTranslMsg; }
      }
      if(sWarnMsg)
      { alert(sWarnMsg); }
      
      
      if((iCustOwnTxtValNr > 0) && oCustOwnTxt_1TxtArea.value && !sWarnMsg)
      {
         // Get: Costs based on width/height
         var fCustOwnCostExclVatNr         = (iCustOwnTxtValNr * (fCostExclVatNrSel * iArtQtyNr));
         var fCustOwnCostDiscountExclVatNr = (iCustOwnTxtValNr * (fCostDiscountExclVatNrSel * iArtQtyNr));
         var fCustOwnCostCustRtlrExclVatNr = (iCustOwnTxtValNr * (fCostCustRtlrExclVatNrSel * iArtQtyNr));
         
         
         // Set: Cost text boxes
         SetArtCostTxtBoxList(fCustOwnCostExclVatNr, fCustOwnCostDiscountExclVatNr, fCustOwnCostCustRtlrExclVatNr);
         
         
         // View: Buy button
         DivToggle(sDivName, 1);
      }
      else
      {
         // Hide: Buy button
         DivToggle(sDivName, 0);
      }
   }
   else
   {
      // Set: Cost text boxes
      SetArtCostTxtBoxList(fCostExclVatNrSel, fCostDiscountExclVatNrSel, fCostCustRtlrExclVatNrSel);
   }
}






/**
 * @name Function: Set Article Cost Text Box List
 * @access private
 *
 * @param float fCostExclVatNrSel
 * @param float fCostDiscountExclVatNrSel
 * @param float fCostCustRtlrExclVatNrSel
 */
function SetArtCostTxtBoxList(fCostExclVatNrSel, fCostDiscountExclVatNrSel, fCostCustRtlrExclVatNrSel)
{
   if(bIsViewCost == true)
   {
      // Set: Cheapest price
      var fCostCheapestExclVatNr = "";
      switch(true)
      {
         // RETAILER
         case ((iCustRtlrNr > 0) && (fCostCustRtlrExclVatNrSel > 0)):
            fCostCheapestExclVatNr = fCostCustRtlrExclVatNrSel;
            break;
            
         // DISCOUNT
         case (fCostDiscountExclVatNrSel > 0):
            fCostCheapestExclVatNr = fCostDiscountExclVatNrSel;
            break;
            
         // COST
         case (fCostExclVatNrSel > 0):
            fCostCheapestExclVatNr = fCostExclVatNrSel;
            break;
      }
      
      
      switch(true)
      {
         // SET: Cost to both text boxes. If discounted cost OR retailer cost is set 
         case ((fCostDiscountExclVatNrSel > 0) && (fCostDiscountExclVatNrSel != fCostExclVatNrSel)):
         case ((fCostCustRtlrExclVatNrSel > 0) && (fCostCustRtlrExclVatNrSel != fCostExclVatNrSel)):
            SetArtCostExclVatNrTxtBox(fCostCheapestExclVatNr);
            SetArtCostDiscountExclVatNrTxtBox(fCostExclVatNrSel);
            break;
            
            
         // SET: Cost to both text boxes. If both prices are the same, hide discount price
         default:
            SetArtCostExclVatNrTxtBox(fCostCheapestExclVatNr);
            SetArtCostDiscountExclVatNrTxtBox(0.0);
            break;
      }
   }
}






/**
 * @name Function: Set Article Cost Excl VAT Text Box
 * @access private
 *
 * @param float fArtCostExclVatNr
 */
function SetArtCostExclVatNrTxtBox(fArtCostExclVatNr)
{
   // Get: Settings
   var oArtCostExclVatNr    = document.getElementById("oArtCostExclVatNr");
   var bIsViewCostInclVatNr = ((sVat == 'InclVatNr') && (bIsInclVat == true)) ? true : false;
   
   
   if(oArtCostExclVatNr)
   {
      // Get: Cost incl/excl VAT
      switch(bIsViewCostInclVatNr)
      {
         // INCL VAT - Due to customer within EU
         case true:
            var sVatStr       = (iDbArtVatNr.length == 1) ? '1.0' + iDbArtVatNr : '1.' + iDbArtVatNr;
            fArtCostExclVatNr = GetRoundCostNr((fArtCostExclVatNr * sVatStr) / fCurrWorthNr);
            break;
            
            
         // EXCL VAT - Due to customer outside of EU
         default:
            fArtCostExclVatNr = GetRoundCostNr(fArtCostExclVatNr / fCurrWorthNr);
            break;
      }
      
      
      // Set: Article cost and currency char
      oArtCostExclVatNr.value = fArtCostExclVatNr + sCurrChr;
   }
}






/**
 * @name Function: Set Article Cost Discount Excl VAT Text Box
 * @access private
 *
 * @param float fArtCostDiscountExclVatNr
 */
function SetArtCostDiscountExclVatNrTxtBox(fArtCostDiscountExclVatNr)
{
   // Get: Setting
   var oArtCostDiscountExclVatNr = document.getElementById("oArtCostDiscountExclVatNr");
   
   
   // Check: If discount cost exists
   if(fArtCostDiscountExclVatNr && oArtCostDiscountExclVatNr)
   {
      // Get: Is cost incl VAT? (Depending on customer country)
      var bIsViewCostInclVatNr = ((sVat == 'InclVatNr') && (bIsInclVat == true)) ? true : false;
      
      
      // Get: Cost incl/excl VAT
      switch(bIsViewCostInclVatNr)
      {
         // INCL VAT - Due to customer within EU
         case true:
            var sVatStr = (iDbArtVatNr.length == 1) ? '1.0' + iDbArtVatNr : '1.' + iDbArtVatNr;
            fArtCostDiscountExclVatNr = GetRoundCostNr((fArtCostDiscountExclVatNr * sVatStr) / fCurrWorthNr);
            break;
            
            
         // EXCL VAT - Due to customer outside of EU
         default:
            fArtCostDiscountExclVatNr = GetRoundCostNr(fArtCostDiscountExclVatNr / fCurrWorthNr);
            break;
      }
      
   
      // Set: Cost to article discount cost and currency char
      oArtCostDiscountExclVatNr.value = fArtCostDiscountExclVatNr + sCurrChr;
   }
   else
   {
      // Set: Empty value in text box
      oArtCostDiscountExclVatNr.value = "";
   }
}






/**
 * @name Function: Set Model Id Text Box
 * @access private
 *
 * @param string sArtModelId
 */
function SetModelIdTxtBox(sArtModelId)
{
   // Get: Setting
   var oArtModelId = document.getElementById("oArtModelId");
   
   
   if(sArtModelId && oArtModelId)
   { oArtModelId.value = sArtModelId; }
}






/**
 * @name Function: Set Stock Status Text Box
 * @access private
 *
 * @param array sStockStatus
 */
function SetStockStatusTxtBox(sStockStatus)
{
   // Get: Setting
   var oArtStockStatus = document.getElementById("oArtStockStatus");
   
   
   if(sStockStatus && oArtStockStatus)
   {
      oArtStockStatus.value = sStockStatus;
      
      
      // Set: Hide or show buy button
      (sStockStatus == sLangStockStatusIsEmpty) ? DivToggle(sDivName, 0) : DivToggle(sDivName, 1);
   }
}






/**
 * @name Function: Set Weight Number Text Box
 * @access private
 *
 * @param float fArtWeightNr
 */
function SetWeightNrTxtBox(fArtWeightNr)
{
   // Get: Settings
   var oArtWeightNr            = document.getElementById("oArtWeightNr");
   var sDivArtItemWeightNrName = "divArtItemWeightNr";
   
   
   if(fArtWeightNr && oArtWeightNr)
   {
      // Set: Hide weight number label
      DivToggle(sDivArtItemWeightNrName, 0);
      
      // Set: Weight to nothing
      oArtWeightNr.value = "";
      
      
      if(fArtWeightNr > 0)
      {
         // Set: Show weight number label
         DivToggle(sDivArtItemWeightNrName, 1);
         
         // Get: Weight number string
         if(fArtWeightNr < 1)
         {
            var sArtWeightNr  = (fArtWeightNr * 1000);
            sArtWeightNr     += ""; // Force string
            
            // Set: Max number of decimals
            sArtWeightNr = sArtWeightNr.substring(0, 7);
            
            sArtWeightNr += " gram";
         }
         else
         { sArtWeightNr = fArtWeightNr + " kg"; }
         
         
         // Set: Textbox to value
         oArtWeightNr.value = sArtWeightNr;
      }
   }
}






/**
 * @name Function: Set Image Article Parameter
 * @access private
 *
 * @param string sUniqueId
 * @param string sFirstUniqueId
 * @param int iUniqueIdRowNr
 * @param int iFirstUniqueIdRowNr
 */
function SetImgArtPrm(sUniqueId, sFirstUniqueId, iUniqueIdRowNr, iFirstUniqueIdRowNr)
{
   // Get: Settings
   var oArtImg_1    = document.getElementById("img_1");
   var oArtDivImg_1 = document.getElementById("divImg_1");
   
   
   if(oArtImg_1)
   {
      switch(true)
      {
         // GET: Selected article parameter image
         case ((sUniqueId != "") && (iUniqueIdRowNr != undefined)):
            if(aImgArtPrmItem[iUniqueIdRowNr][sUniqueId] != "")
            {
               switch(true)
               {
                  // Check: That it's not the default image
                  case (aImgArtPrmItem[iUniqueIdRowNr][sUniqueId]["sUrlImgSoft"].indexOf(sImgArtNameDefault) == -1):
                     // Get: Url image
                     var sUrlImgHtml = GetUrlImgHtml(
                        aImgArtPrmItem[iUniqueIdRowNr][sUniqueId]["sUrlImgSoft"],
                        aImgArtPrmItem[iUniqueIdRowNr][sUniqueId]["sImgFileName"],
                        sUniqueId,
                        aImgArtPrmItem[iUniqueIdRowNr][sUniqueId]["iWdtNr"],
                        aImgArtPrmItem[iUniqueIdRowNr][sUniqueId]["iHgtNr"]
                     );
                     
                     // Get: Image
                     var sImgHtml = GetImgHtml(
                        aImgArtPrmItem[iUniqueIdRowNr][sUniqueId]["sUrlImgSoft"],
                        aImgArtPrmItem[iUniqueIdRowNr][sUniqueId]["iWdtNr"],
                        aImgArtPrmItem[iUniqueIdRowNr][sUniqueId]["iHgtNr"]
                     );
                     
                     
                     // View: Url and image
                     oArtDivImg_1.innerHTML = sUrlImgHtml + sImgHtml;
                     break;
                     
                     
                     
                  // Get: Image to first article image
                  default:
                     var sArtPrmUrlImgSoft;
                     var sArtPrmImgFileName;
                     var iArtPrmWdtNr;
                     var iArtPrmHgtNr;
                     var sArtPrmUniqueId;
                     
                     
                     // Check: That article parameter one has an article image, if it does, then use it. If it does not, then use -IngenBildVald-.jpg
                     if(sFirstUniqueId != "")
                     {
                        // Check: That image isn't the default image
                        if(aImgArtPrmItem[iFirstUniqueIdRowNr][sFirstUniqueId]["sUrlImgSoft"].indexOf(sImgArtNameDefault) == -1)
                        {
                           sArtPrmUrlImgSoft  = aImgArtPrmItem[iFirstUniqueIdRowNr][sFirstUniqueId]["sUrlImgSoft"];
                           sArtPrmImgFileName = aImgArtPrmItem[iFirstUniqueIdRowNr][sFirstUniqueId]["sImgFileName"];
                           iArtPrmWdtNr       = aImgArtPrmItem[iFirstUniqueIdRowNr][sFirstUniqueId]["iWdtNr"];
                           iArtPrmHgtNr       = aImgArtPrmItem[iFirstUniqueIdRowNr][sFirstUniqueId]["iHgtNr"];
                           sArtPrmUniqueId    = sFirstUniqueId;
                        }
                     }
                     sArtPrmUrlImgSoft  = sArtPrmUrlImgSoft ? sArtPrmUrlImgSoft : sUrlImgSoft_1;
                     sArtPrmImgFileName = sArtPrmImgFileName ? sArtPrmImgFileName : sImgFileName_1;
                     iArtPrmWdtNr       = iArtPrmWdtNr ? iArtPrmWdtNr : iWdtNr_1;
                     iArtPrmHgtNr       = iArtPrmHgtNr ? iArtPrmHgtNr : iHgtNr_1;
                     sArtPrmUniqueId    = sArtPrmUniqueId ? sArtPrmUniqueId : sUniqueId;
                     
                     
                     // Get: Url image
                     var sUrlImgHtml = GetUrlImgHtml(
                        sArtPrmUrlImgSoft,
                        sArtPrmImgFileName,
                        sArtPrmUniqueId,
                        iArtPrmWdtNr,
                        iArtPrmHgtNr
                     );
                     
                     // Get: Image
                     var sImgHtml = GetImgHtml(
                        sArtPrmUrlImgSoft,
                        iArtPrmWdtNr,
                        iArtPrmHgtNr
                     );
                     
                     
                     // View: Url and image
                     oArtDivImg_1.innerHTML = sUrlImgHtml + sImgHtml;
                     break;
               }
            }
            else
            {
               // Set: Image to default article image
               oArtImg_1.src = sUrlArtImg + sImgArtNameDefault;
            }
            break;
      }
   }
}






/**
 * @name Function: Get Url, Image Html
 * @access private
 *
 * @param string sUrlImgSoft
 * @param string sImgFileName
 * @param string sUniqueId
 * @param int $iWdtNr
 * @param int $iHgtNr
 */
function GetUrlImgHtml(sUrlImgSoft, sImgFileName, sUniqueId, iWdtNr, iHgtNr)
{
   // Get: Settings
   iWdtNr                 += 90;
   iHgtNr                 += 80;
   var sTbl                = "Art";
   var sImgFileNameValid   = sImgFileName.replace(" ", "%20");
   var sImgHtmlCode        = "<img src=\\'" + sUrlArtImg + sImgFileNameValid + "\\' style=\\'border:1px solid #efefef;\\' alt=\\'\\' />";
   var sUrlImgFile         = sUrlShop + "Page/pgImgPopup.php?sTbl=" + sTbl + "&sImgFileName=" + sImgFileNameValid;
   var bIsImgAutoZoom      = (bIsImgIsArtItemAutoZoom == '1') ? true : false;
   var bIsImgArtHighslide  = ((bIsImgIsArtHighslide == '1') || (sApp == "__ADMIN")) ? true : false;
   var sUrlCss             = "cssUrlImg";
   var sUrlItemImg         = "";
   
   
   // Check: That it's not the default image
   if(sUrlImgSoft.indexOf(sImgArtNameDefault) == -1)
   {
      // View: Url to image
      switch(bIsImgArtHighslide)
      {
         // GET: Highslide url
         case true:
            sUrlItemImg  = "<a href=\"" + sUrlImgSoft + "\"";
            sUrlItemImg += GetUrlOverlib(sImgHtmlCode, bIsImgAutoZoom);
            sUrlItemImg += GetUrlHighslide(sUniqueId, sUrlCss);
            sUrlItemImg += "title=\"" + sArtName + "\">";
            break;
            
            
            
         // GET: Image popup window url
         default:
            sUrlItemImg  = "<a href=\"javascript:OpenPopupWnd('" + sUrlImgFile + "', '" + iWdtNr + "', '" + iHgtNr + "', 'yes');\"";
            sUrlItemImg += GetUrlOverlib(sImgHtmlCode, bIsImgAutoZoom);
            sUrlItemImg += " class=\"" + sUrlCss + "\" title=\"" + sLangClickToViewLargerImg + "\">";
            break;
      }
   }
   
   
   return sUrlItemImg;
}






/**
 * @name Function: Get Url Overlib
 * @access private
 *
 * @param string sImgHtmlCode
 * @param boolean bIsImgAutoZoom
 *
 * @return string
 */
function GetUrlOverlib(sImgHtmlCode, bIsImgAutoZoom)
{
   // Check: That auto-zoom is installed
   if(bIsImgAutoZoom == true)
   { return "onmouseover=\"return overlib('" + sImgHtmlCode + "', HAUTO, VAUTO, FULLHTML);\" onmouseout=\"return nd();\""; }
}






/**
 * @name Function: Get Url Highslide
 * @access private
 *
 * @param string sUniqueId
 * @param string sUrlCss
 *
 * @return string
 */
function GetUrlHighslide(sUniqueId, sUrlCss)
{
   return " class=\"highslide " + sUrlCss + "\" onclick=\"return hs.expand(this, { align:'center' })\" id=\"" + sUniqueId + "\"";
}






/**
 * @name Function: Get Image Html
 * @access private
 *
 * @param string $sUrlImgSoft
 * @param int $iWdtNr
 * @param int $iHgtNr
 */
function GetImgHtml(sUrlImgSoft, iWdtNr, iHgtNr)
{
   var sImgHtml;
   
   // Get: Image html
   sImgHtml  = "<img src=\"" + sUrlImgSoft + "\" id=\"img_1\" style=\"height:" + iHgtNr + "px; width:" + iWdtNr + "px;\"";
   sImgHtml += "class=\"cssImgBorder\" alt=\"" + sLangClickToViewLargerImg + "\" /></a>";
   
   return sImgHtml;
}






/**
 * @name Function: Set Url Btn Buy
 * @access private
 *
 * @param int iId
 * @param string sArtModelId
 */
function SetUrlBtnBuy(iId, sArtModelId)
{
   // Get: Settings
   var sCustOwnTxt_1        = sCustOwnTxt_2 = sCustOwnTxt_3 = sCustOwnTxt_4 = "";
   var oCustOwnTxt_1TxtArea = document.getElementById("aItem[oCustOwnTxt_1]");
   var oCustOwnTxt_2TxtArea = document.getElementById("aItem[oCustOwnTxt_2]");
   var oCustOwnTxt_3TxtArea = document.getElementById("aItem[oCustOwnTxt_3]");
   var oCustOwnTxt_4TxtArea = document.getElementById("aItem[oCustOwnTxt_4]");
   var oArtQtyNrTxtBox      = document.getElementById("aItem[iArtQtyNr]");
   var iArtQtyNr            = 1;
   var sArtModelIdSafe      = sArtModelId.replace("+", "///");
   
   // Get: Customer own texts
   if(oCustOwnTxt_1TxtArea){ sCustOwnTxt_1 = oCustOwnTxt_1TxtArea.value; }
   if(oCustOwnTxt_2TxtArea){ sCustOwnTxt_2 = oCustOwnTxt_2TxtArea.value; }
   if(oCustOwnTxt_3TxtArea){ sCustOwnTxt_3 = oCustOwnTxt_3TxtArea.value; }
   if(oCustOwnTxt_4TxtArea){ sCustOwnTxt_4 = oCustOwnTxt_4TxtArea.value; }
   
   // Get: Article quantity
   if(oArtQtyNrTxtBox)
   { iArtQtyNr = IsInteger(oArtQtyNrTxtBox.value) ? oArtQtyNrTxtBox.value : iArtQtyNr; }
   
   
   // Set: Url for inserting an article to the cart
   sUrlBtnBuyPty = (
      '?sAction=bIsInsertArt'
      + '&iId='           + iId
      + '&sArtModelId='   + sArtModelIdSafe
      + '&iArtQtyNr='     + iArtQtyNr
      + '&sCustOwnTxt_1=' + sCustOwnTxt_1
      + '&sCustOwnTxt_2=' + sCustOwnTxt_2
      + '&sCustOwnTxt_3=' + sCustOwnTxt_3
      + '&sCustOwnTxt_4=' + sCustOwnTxt_4);
}






/**
 * @name Function: Get Url Btn Buy
 * @access public
 */
function GetUrlBtnBuy()
{
   // Get: Random string as BtnBuyKey
   var sBtnBuyKey = GetRandStr();
   
   
   // Return: Complete button buy url, with unique BtnBuyKey
   return sUrlBtnBuy + sUrlBtnBuyPty + '&sBtnBuyKey=' + sBtnBuyKey;
}






/**
 * @name Function: Get Article Model Id Selected
 * @access public
 */
function GetArtModelIdSel()
{
   return sArtModelIdSel;
}
