function GWOHelper(testId){
	
	GWOHelper.CONV_MODE_BUTTON 	= "click_button";
	GWOHelper.CONV_MODE_VENDOR 	= "click_vendor";
	this.testId 								= testId;
	this.buttons								= [];
	this.conversionStates				= [];
	this.conversionMode 				= GWOHelper.CONV_MODE_BUTTON;
	
	// TODO - implement CONV_MODE_VENDOR
	
}

GWOHelper.prototype.registerButton = function(containerID){
	var context = document.getElementById(containerID);
	var that = this;
	var button = GWOHelper.getElementsByClassName("emi_buy_button", context)[0]
	if(typeof button != undefined) {
		this.buttons.push(button);
		this.conversionStates.push(false);
		button.onclick = function(){that.trackConversionEvent(this)};
	};
}

GWOHelper.getElementsByClassName = function(cName, context){
	
	if(typeof context == undefined){
		context = document.body;
	}
	
	var els = context.getElementsByTagName("*");
	var matched = [];
	var rx = new RegExp("(\\s" + cName + "\\s)|(\\s" + cName + "$)|(^" + cName + "\\s)|(^" + cName + "$)");
	
	for(var i = 0; i< els.length; i++){
		var el = els[i];
		var m = el.className.match(rx);
		if( m ){
			matched.push(el)
		}
	}
	
	return matched;	
}

GWOHelper.prototype.trackConversionEvent = function(button){
	var ind = null;
	
	for(var i = 0; i < this.buttons.length; i++){
		if(this.buttons[i] == button){
			ind = i;
			break;
		}
	}
	
	if(!isNaN(ind)){
		if(this.conversionStates[ind] == false){
			var gwoGoalPageView = "/" + gwoHelper.testId + "/goal";
			gwoTracker._trackPageview(gwoGoalPageView);
			this.conversionStates[ind] = true;
		}
	}
}

GWOHelper.prototype.toString = function(){
	return "[Object GWOHelper]";
}

var gwoHelper = new GWOHelper(GWOtestId);

function utmx_section(){}function utmx(){}
(function(){var k=gwoHelper.testId,d=document,l=d.location,c=d.cookie;function f(n){
if(c){var i=c.indexOf(n+'=');if(i>-1){var j=c.indexOf(';',i);return c.substring(i+n.
length+1,j<0?c.length:j)}}}var x=f('__utmx'),xx=f('__utmxx'),h=l.hash;
d.write('<sc'+'ript src="'+
'http'+(l.protocol=='https:'?'s://ssl':'://www')+'.google-analytics.com'
+'/siteopt.js?v=1&utmxkey='+k+'&utmx='+(x?x:'')+'&utmxx='+(xx?xx:'')+'&utmxtime='
+new Date().valueOf()+(h?'&utmxhash='+escape(h.substr(1)):'')+
'" type="text/javascript" charset="utf-8"></sc'+'ript>')})();
