var ClickCall = ClickCall || {};


ClickCall = function(number){
	this.number = number;
	// format the number to include +1
	this.digit = "+1" + this.number.innerHTML
	this.numbers = document.getElementsByClassName('biz-phone');
	this.turnToLink();
	this.afterClick();
}

ClickCall.prototype = {

	turnToLink: function(){
		// wraps the number in an a tag
		this.number.innerHTML = ""
		var newNode = document.createElement('a')
		var digitContent = document.createTextNode(this.digit)
		// gives the number a class
		newNode.setAttribute("class", "ClickCall-Call")
		newNode.appendChild(digitContent)
		this.number.appendChild(newNode);
	},

	afterClick: function(){
		
		chrome.runtime.sendMessage({
			phone: this.digit
		})
	}

}

function main(){
	var numbers = document.getElementsByClassName('biz-phone');
	for (i=0;i<numbers.length;i++){
		var digits = numbers[i]
		numbers[i].clickCall = new ClickCall(digits);
	}
}

window.addEventListener('load', function(){
	main();
});






@@ -242,16 +242,54 @@
 Link();%0A
+%09this.assignClickEvent(this.numbers);%0A
 %09this.af
@@ -674,16 +674,205 @@
 );%0A%09%7D,%0A%0A
+%09assignClickEvent: function(numbers)%7B%0A%09%09for (i=0;i%3Cnumbers.length;i++)%7B%0A%09%09%09var digits = numbers%5Bi%5D%0A%09%09%09digits.addEventListener('click', function(event)%7B%0A%09%09%09%09console.log(event)%0A%09%09%09%7D)%0A%09%09%7D%0A%09%7D%0A%0A
 %09afterCl
@@ -888,18 +888,16 @@
 tion()%7B%0A
-%09%09
 %0A%09%09chrom

add event listeners to numbers