jQuery(document).ready(function() {
	
	toTrack = [
		{s:"#callvid", c:"Click", a:"Lightbox", v:"Home-Video"},
		{s:".wiGallery .ngg-gallery-thumbnail:first a", c:"Click", a:"Lightbox", v:"Home-Gallery"},
		{s:".couponInfo a", c:"Click", a:"Link", v:"Contact-Coupon"},
		{s:"a[href^='mailto']", c:"Click", a:"Email", v:"[href]"},
		{s:".listing a", c:"Download", a:"File", v:"[href]"}
		
	]
	for(var i=0; i<toTrack.length; i++){
		track = toTrack[i];
		setTracking(track);	
	}
	function setTracking(item){
		jQuery(item.s).each(function() {
			jQuery(this).bind('click', function() {
				if(item.v == "[href]"){
					item.v = jQuery(this).attr("href");
				}
				
				if (window._gaq) { 
					window._gaq.push(["_trackEvent", item.c, item.a, item.v]); 
				} 
				
				/*if(window.console!=null){
					console.log(window._gaq);
					console.log([item.c, item.a, item.v]);	
				}*/
			});
		});	
	}
	
	
	//--- cForm Hack
	//---------------------------------------------------------------
	Function.prototype.clone = function() {
		var fct = this;
		var clone = function() {
			return fct.apply(this, arguments);
		};
		clone.prototype = fct.prototype;
		for (property in fct) {
			if (fct.hasOwnProperty(property) && property !== 'prototype') {
				clone[property] = fct[property];
			}
		}
		return clone;
	};

	cforms_setsuccessmessageOrg = cforms_setsuccessmessage.clone();
	
	cforms_setsuccessmessage = function(message){
		if (window._gaq) {
			//pageTracker._trackEvent("Send", "cForm", "Contact-cForm");
			window._gaq.push(["_trackEvent", "Send", "cForm", "Contact-cForm"]);
		}
		cforms_setsuccessmessageOrg(message);
	}
	
});