  /*! \brief Function to open popup window.
   *
   *  \details Generic function to open popup windows.
   *
   *  \todo parameters documentation. 
   *
   *  \note it was not opening a popup inside from a popup window, on r&d it was found that it is because of same popup window name, so added random generated numbers to make difference in popup window name.
   */
  function func_win_open(iType, sUrl, iWidth, iHeight)
  {
    var sFeatures = "scrollbars=yes, resizable=yes, width=" + iWidth + ", height=" + iHeight;
    var sWindowName = "win_open";
    if(window.screen)
    {
        var iLeft = (screen.width - iWidth) / 2;
        var iTop = (screen.height - iHeight) / 2;
        sFeatures += ", left=" + iLeft + ", top=" + iTop;
    }
    var sRandomNumber = Math.floor(Math.random() * 100);
    if(iType = 1) //Update credit card popup window
    {
      sWindowName = "win_credit_card" + sRandomNumber;
    }
    else if(iType = 2)
    {
      sWindowName = "pdPopup" + sRandomNumber;
      sFeatures += ",menubar=no,toolbar=no,status=no";
    }
    var winComments = window.open(sUrl, sWindowName, sFeatures);
    winComments.focus();
    if(iType = 1) //Update credit card popup window
    {
      return false;
    }
  }

  /*! \brief 
   *  Function to display extra large image of a product.
   *
   *  \details
   *  Function is used to display extra large image of a product and if it doesn't exists or any error occurs while loading the extra large image then calling another function func_img_large_load() to display large image.
   *
   *  \param[in] oImgobj object of image controle.
   *  \param[in] sELargeImgSrc extra large image url.
   *  \param[in] sLargeImgSrc large image url.
   */
  function func_img_elarge_load(oImgobj, sELargeImgSrc, sLargeImgSrc) 
  { 
    var oImg = new Image; 
    oImg.onload = function(){document.getElementById(oImgobj).src = oImg.src;} 
    oImg.onerror = function(){func_img_large_load(oImgobj, sLargeImgSrc);} 
    oImg.src = sELargeImgSrc;
  }  

  /*! \brief 
   *  Function to display large image of a product.
   *
   *  \details
   *  Function is used to display large image of a product and get called by function func_img_elarge_load() when any error occurs while loading the extra large image.
   *
   *  \param[in] oImgobj object of image controle.
   *  \param[in] sELargeImgSrc extra large image url.
   *  \param[in] sLargeImgSrc large image url.
   */
  function func_img_large_load(oImgobj, sLargeImgSrc) 
  { 
    var oImg = new Image; 
    oImg.onload = function(){document.getElementById(oImgobj).src = oImg.src;} 
    oImg.onerror = function(){document.getElementById(oImgobj).src = "/product_elarge_images/no-manufacturers.gif";} 
    oImg.src = sLargeImgSrc;
  }

  /*! \brief 
  *  Function to redirect the pages.
  *
  *  \details
  *  Function is used to redirect the page onchange event of menu dropdown.
  *
  *  \param[in] url of the page.
  */
  function func_redirect_page(url) 
  {
    window.location.href = url;
  }
  
  function func_capitalize(oCtrl)
  {
    if(oCtrl)
    {
      var sValue = oCtrl.value;
      var sCapsValue = '';
      var arrValue = sValue.split(' ');
      for (var iCtr = 0; iCtr < arrValue.length; iCtr++)
      {
        sCapsValue += arrValue[iCtr].substring(0,1).toUpperCase() + arrValue[iCtr].substring(1, arrValue[iCtr].length) + ' ';        
      }
      oCtrl.value = sCapsValue.trim();
    }
   }

   /*! \brief function to limit the character in textbox.
   *
   *  \details function to limit the character in textbox.
   *
   *  \param[in] field takes the object of textbox.
   *  \param[in] maxlimit contains the maximum no. of character for the textbox. 
   */
   function func_check_max_length(objField, iMaxLimit) {
   	if (document.getElementById(objField).value.length > iMaxLimit) {
   		alert("Only " + iMaxLimit + " characters allowed");
   		document.getElementById(objField).value = document.getElementById(objField).value.substring(0, iMaxLimit);
   	}
   }
