// Requires jQuery
function EventTrackMailTo(Category,Action,Label)
{
	var lnkCollection;
	var intLinkIndex;
	var intAttrIndex;
	var intAttrIndexPos;
	
	var lnkHyper;
	var attData;
	var strData;
	var strLabel;
	
	lnkCollection = $('a:[href^=mailto]');
	strData = "";
	intAttrIndexPos = -1;
	strLabel = "";
	
	// For each hyperlink
	for (intLinkIndex=0; intLinkIndex < lnkCollection.length;intLinkIndex++)
	{
		lnkHyper = lnkCollection[intLinkIndex];
		
		// Need to get the existing data
		if (lnkHyper.attributes.length > 0)
		{
			for(intAttrIndex=0; intAttrIndex < lnkHyper.attributes.length; intAttrIndex++)
			{
				attData = lnkHyper.attributes[intAttrIndex];
				
				// We read the onclick and href attributes and store them
				if (attData.name.toLowerCase() == "onclick")
				{
					strData = attData.value;
					intAttrIndexPos = intAttrIndex;
				}
				else if(attData.name.toLowerCase() == "href")
				{
					strLabel = attData.value;;
				}
					
			}
		}
		
		// We create the Google Analytics Event
		if (Label != "")
		{
			strLabel = Label;
		}
		else
		{
			strLabel = strLabel.replace("mailto:","");
			strLabel = strLabel.replace(" ","");
		}
		
		if (strData != "")
		{
			strData = "_gaq.push(['_trackEvent','" + Category + "','" + Action + "','" + strLabel + "']);" + strData;
		}
		else
		{
			strData = "_gaq.push(['_trackEvent','" + Category + "','" + Action + "','" + strLabel + "']);"
		}
		
		// Now set the onclick
		if (intAttrIndexPos != -1)
		{
			lnkHyper.attributes[intAttrIndex].value = strData;
		}
		else
		{
			lnkHyper.setAttribute("onclick",strData);
		}
		
		
	}
	
}
