﻿/*!
* \brief
*  Function to trim spaces.
*
*  \details
*  Function to trim leading an trailing spces
*
*  \param[in] stringToTrim a string which is to be trimmed
*  \retval  A Trimmed string
*/
function func_trim(a) { return a.replace(/^\s\s*/, "").replace(/\s\s*$/, "") }
/*!
*  \brief
*  Function for email validation
*
*  \details
*  Function to check validity of an email addres
*
*  \param[in] sEMail An email address to be validated
*  \retval  boolean value true if email address is valid else false
*/
function func_is_valid_email(a) { var b = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/; return b.test(a) }
/*!
*  \brief     Function to make first letter capital
*  \details   Function to make first letter capital
*  \param[in] control value
*  \retval    captalized string
*/
function func_capitalize(e) { if (e) { var d = e.value; var c = ""; var a = d.split(" "); for (var b = 0; b < a.length; b++) { c += a[b].substring(0, 1).toUpperCase() + a[b].substring(1, a[b].length) + " " } e.value = c.trim() } }
/*! \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(j, c, b, a) { var i = "scrollbars=yes, resizable=yes, width=" + b + ", height=" + a; var g = "win_open"; if (window.screen) { var f = (screen.width - b) / 2; var e = (screen.height - a) / 2; i += ", left=" + f + ", top=" + e } var d = Math.floor(Math.random() * 100); if (j = 1) { g = "win_credit_card" + d } else { if (j = 2) { g = "pdPopup" + d; i += ",menubar=no,toolbar=no,status=no" } } var h = window.open(c, g, i); h.focus(); if (j = 1) { return false } }
/*! \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(a) { window.location.href = a } $(document).ready(function () { $("#ctl00_ContentPlaceHolderProductDisplay_wuc_product_display_pnlPreferencePanel").clone().prependTo(".search-error-pnl") }); function func_exchange_rate_popup_window(b) { var a = "height=325, width=600, scrollbars=yes, resizable=yes"; var c = window.open(b, "win_converter_popup", a); c.focus() }
/*! \brief
*  This is a utility function to format currency.
*
*  \details
*  This javascript utility function converse the currency with last two decimal digits value.
*/
function func_format_currency(a) { a = a.toString().replace(/\$|\,/g, ""); if (isNaN(a)) { a = "0" } cents = Math.floor((a * 100 + 0.5) % 100); a = Math.floor((a * 100 + 0.5) / 100).toString(); if (cents < 10) { cents = "0" + cents } for (var b = 0; b < Math.floor((a.length - (1 + b)) / 3); b++) { a = a.substring(0, a.length - (4 * b + 3)) + "," + a.substring(a.length - (4 * b + 3)) } return (a + "." + cents) };
