var ebiz = Venda.namespace("Ebiz");
Venda.Ebiz.awCookieChecker = function (awCookieURL){ 
		var AW_COOKIE_NAME = 'awchecking';
		if(awCookieURL.indexOf("src=aw")!=-1)
		{
			var cjaw = new CookieJar({expires: 3600 * 24 * 30, path: '/'});  
			cjaw.put(AW_COOKIE_NAME, "1");    
		}
};
Venda.Ebiz.buyAtCookieChecker = function (buyatCookieURL){ 
		var BUYAT_COOKIE_NAME = 'buyatchecking';
		if(buyatCookieURL.indexOf("src=buyat")!=-1)
		{
			var cjbuyat = new CookieJar({expires: 3600 * 24 * 30, path: '/'});  
			cjbuyat.put(BUYAT_COOKIE_NAME, "1");    
		}
};

/**
* 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>');
};

/**
* A skeleton function for validating user extened fields - needs to be amended by the build team
* @param {object} frmObj HTML form containing user extended field elements
*/
/**
Venda.Ebiz.validateUserExtendedFields = function(frmObj) {
	if(frmObj) {
		if ( (frmObj.usxtexample1.checked==false) && (frmObj.usxtexample2.checked==false) && (frmObj.usxtexample3.checked==false))  {
			alert("Please tick at least one checkbox");
			return false;
		}
		return true;
	}
	return false;
};
*/

/** 
    * Gets the value of a specified URL parameter 
    * @param {String} currURL              this is the URL which you wish to get the URL parameter value from 
    * @param {String} urlParam     this is the name of the URL parameter you want to get the value for 
    * @return match                                                        unescaped value for parameter specified urlParam if true else false 
    */ 
   var feedComcj = new CookieJar({expires:'',path: '/'}); 
           if(Venda.Platform.getUrlParam(window.location.href,'source')!=""){ 
                   var feedComparamValue = Venda.Platform.getUrlParam(window.location.href,'source'); 
                   var feedComCookie = feedComcj.put("source",feedComparamValue); 
           } 
