if(!sb_trackLinks) { var sb_trackLinks = new Object(); };

sb_trackLinks.init = function() {
	if(!document.getElementsByTagName) return false;
	sb_trackLinks.startTime = new Date();
	var anchors = document.getElementsByTagName('a');
	for(var i=anchors.length-1;i>=0;i--) {
		var objURL = {};
		var rel;
		if (typeof anchors[i].getAttribute('rel') === 'string') {
			rel = anchors[i].getAttribute('rel');
			if (rel.length === 0) {
				continue;
			};
		} else {
			continue;
		};
		if (rel.indexOf('profile') > -1) {
			anchors[i].href.replace(new RegExp("([^?=&]+)(=([^&]*))?", "g"), function($0, $1, $2, $3) { objURL[$1] = $3; });
			anchors[i].onclick = (function(g) {
				return function() {
					try {
						sb_trackLinks.track(this, 'profile', g);
					} catch(e) {}
					return true;
				};
			})(objURL.adv);
		} else if (rel.indexOf('listings') > -1) {
			anchors[i].href.replace(new RegExp("([^?=&]+)(=([^&]*))?", "g"), function($0, $1, $2, $3) { objURL[$1] = $3; });
			anchors[i].onclick = (function(g) {
				return function() {
					try {
						sb_trackLinks.track(this, 'listings', g);
					} catch(e) {}
					return true;
				};
			})(objURL.cat);
		} else if (rel.indexOf('categories') > -1) {
			anchors[i].onclick = (function(g) {
				return function() {
					try {
						sb_trackLinks.track(this, 'categories', g);
					} catch(e) {}
					return true;
				};
			})('');
		} else if (rel.indexOf('citieslist') > -1) {
			anchors[i].onclick = (function(g) {
				return function() {
					try {
						sb_trackLinks.track(this, 'citieslist', g);
					} catch(e) {}
					return true;
				};
			})('');
		} else if (rel.indexOf('ratebusiness') > -1) {
			anchors[i].href.replace(new RegExp("([^?=&]+)(=([^&]*))?", "g"), function($0, $1, $2, $3) { objURL[$1] = $3; });
			anchors[i].onclick = (function(g) {
			return function() {
				try {
						sb_trackLinks.track(this, 'ratebusiness', g);
					} catch(e) {}
					return true;
				};
			})(objURL.adv);
		} else if (rel.indexOf('admin') > -1) {
			anchors[i].onclick = (function(g) {
				return function() {
					try {
						sb_trackLinks.track(this, 'admin', g);
					} catch(e) {}
					return true;
				};
			})('');
		} else if (rel.indexOf('rop') > -1) {
			anchors[i].href.replace(new RegExp("([^?=&]+)(=([^&]*))?", "g"), function($0, $1, $2, $3) { objURL[$1] = $3; });
			anchors[i].onclick = (function(g) {
				return function() {
					try {
						sb_trackLinks.track(this, 'rop', g);
					} catch(e) {}
					return true;
				};
			})(objURL.advid);
		} else if (rel.indexOf('external') > -1) {
			anchors[i].onclick = (function(g) {
				return function() {
					try {
						sb_trackLinks.track(this, 'external', g);
					} catch(e) {}
					return true;
				};
			})(anchors[i].childNodes[0].nodeValue);
		};
	};
};

sb_trackLinks.track = function(obj, linkPage, id) {
	var lcPath = window.location.pathname.toLowerCase();
	s_az = s_gi(s_account);
	s_az.linkTrackVars = 'prop35,prop36';
	s_az.linkTrackEvents = 'None';
	s_az.prop35 = lcPath + ' | ' + linkPage + ' | ' + id;
	s_az.prop36 = lcPath + ' | ' + Math.round((new Date() - sb_trackLinks.startTime)/1000) + ' | ' + linkPage;
	s_az.tl(obj, 'o');
};

sb_trackLinks.addEvent = function(obj, evType, fn, useCapture) {
	if(obj.addEventListener) {
		obj.addEventListener(evType, fn, useCapture);
		return true;
	} else if(obj.attachEvent) {
		var r = obj.attachEvent('on' + evType, fn);
		return r;
	} else {
		obj['on' + evType] = fn;
	};
};

sb_trackLinks.addEvent(window, 'load', sb_trackLinks.init);