/**
* @fileoverview ebiz.js: A module used for client specific functionality
*
* This module defines a single symbol named "Venda.Ebiz"
* all ebiz utility functions are stored as properties of this namespace
* functions that are spacific this site shoudl be added to this file only.
*/

//Declare namespace for ebiz
Venda.namespace("Ebiz");

/**
* Split a string so it can be displayed on multiple lines so it does not break display layout - used on order confirmation and order receipt page
* @param {string} strToSplit string that needs to be split
* @param {Integer} rowLen length of row which will hold the string
* @param {string} displayElem the html container which will display the splitted string
*/
Venda.Ebiz.splitString = function(strToSplit, rowLen, dispElem) {
var stringlist = new Array();
while (strToSplit.length > rowLen) {
stringlist.push( strToSplit.slice(0,rowLen));
strToSplit=strToSplit.substr(rowLen);
}
if (strToSplit.length) {
stringlist.push(strToSplit);
}
document.getElementById(dispElem).innerHTML = stringlist.join('<br>');
};

Venda.Ebiz.validateUserExtendedFields = function(initialpage) {
  // cater for any type image of input tags ( <INPUT REQUIRED=YES> )   
         var oInputs = document.getElementsByTagName("input");   
         for (k=0;k<oInputs.length;k++) {   
                 if(oInputs[k].className == "requiredfields"){   
                                 if(oInputs[k].value==''){   
                                         alert(oInputs[k].title);   
                                         return false;   
                                 }   
                 }   
         }   
         if(initialpage){   
                 document.form.submit();   
         }   
         else{   
                 return true;   
         }   
};
