/*********************************************************************************************************	This Script is designed to aid a Test & Target Campaign with button or link click reporting. 	ARRAY clickEventFuncts	Description: This Array stores the original onclick event function of the links and buttons. 	Do not manually add to this array, because there is a function that assigns the values to this 	global Array     	FUNCTION addRecordClick	Parameters:	el 		(String or HTML Element) 	-> This is the HTML Id or HTML Element Object	mbName 		(String) 			-> A Name of a mbox on the page. 	mbParam		(String)			-> This param excepts mboxParam that is desired to be included during the mboxUpdate Function	cb		(Function)			-> This is a call back function when the mboxUpdate is executed		runlast		(Boolean)			-> Determins is the mboxUpdate should be performed before or after an existing onclick function	FUNCTION addSetsOfLinks	Parameters:	arl		(Array)				-> An Array or links or buttons can be passed to assign a set of links all at once	mbName 		(String) 			-> A Name of a mbox on the page. 		 	mbParam		(String)			-> This param excepts mboxParam that is desired to be included during the mboxUpdate Function	runlast		(Boolean)			-> Determins is the mboxUpdate should be performed before or after an existing onclick function	FUNCTION parseParamValue		Parameters:	v		(string)			-> url to be passed to parse out querystring value	p		(string)			-> name of querystring to search value			Completed By Philip Kinlow		***********************************************************************************************************/var clickEventFuncts = [];var cbClickFunts = [];var addRecordClick = function(el,mbName,mbParams,cb,runLast){	el = (typeof el=="string") ? ((document.getElementById(el)) ? document.getElementById(el) : null ) : ((typeof el=="object") ? el : null);	if(el!=null){		var linkToSrc = (el.href) ? el.href : ((el.form) ? el.form.action : "" );		if(linkToSrc!=null && linkToSrc!=""){			/* If lpos parameter exist */			var lposParamVal = parseParamValue(linkToSrc,'lpos');			if(lposParamVal!=""){						mbParams = mbParams + ",clickToLposVal=" + lposParamVal;			}			/* If Basket  parameter exist */			var isBasketParam = (parseParamValue(linkToSrc,'item')!="" && (parseParamValue(linkToSrc,'go').toLowerCase() == "buy" && parseParamValue(linkToSrc,'qty')!= ""))			if(isBasketParam){				mbParams = mbParams + ",clickToBasketPage=true";			}		}				hasOnclickFunct = (typeof el.onclick == "function") ? true : false ;		cFn = (hasOnclickFunct)	? el.onclick : function(){return false};		mbP = "\"" + mbParams.replace(/(,)/g,'","') + "\"";		ffBody = 'mboxUpdate("'+ mbName +'",' + mbP + ')';		ffBody = "setTimeout('"+  ffBody +"',500);";		if(runLast && hasOnclickFunct){			ffBody = ffBody + "\n return clickEventFuncts[" + clickEventFuncts.length +"]();";		}else if(hasOnclickFunct){			ffBody = "var rtnVal = clickEventFuncts[" + clickEventFuncts.length +"]();\n" + ffBody +"\n" + "if(typeof rtnVal!='undefined' || rtnVal!=null){return rtnVal}";		}			if(hasOnclickFunct){clickEventFuncts[clickEventFuncts.length] = cFn}		//alert(ffBody);		el.onclick = new Function(ffBody);	}		} function addSetsOfLinks(arl,mboxName,mbParams,runLast){	if(arl){		for(var i=0;i<arl.length;i++){			addRecordClick(arl[i],mboxName,mbParams,runLast);		}		}}function parseParamValue(v,p){	var rv = "";	if(v!="" && v!=null && typeof v != "undefined"){		var paramval = new RegExp('[?&]'+p+'=([^&#]*)?').exec(v);		if(paramval != null){			rv = (typeof paramval[1]!= "undefined") ? paramval[1] : "";		}	}	return rv;}
