var sponsoredLinks = new Class({
	
	Implements: [Options, Events],
	
	options: {
		path : 'service/clickLog'
	},
	
	initialize: function(element, options){
		this.setOptions(options);
		this.obfield 	= element;
		this.baseURL	= '';
		
		$$('#'+element+' a').each(function(el) {		 
			el.addEvent('mousedown', function() {	
				this.s_click(el);
			}.bind(this));
		}, this);
	
	},
	
	s_click: function(el) {
		var params = { 
			'aid' 	: el.id
		};
		ajaxStore( this.baseURL + this.options.path, params );
	}
	
});

var affiliateLinks = new Class({
	
	Implements: [Options, Events],
	
	options: {
		path : 'service/clickAffiliateLog'
	},
	
	initialize: function(element, options){
		this.setOptions(options);
		this.obfield 	= element;
		this.baseURL	= '';
		
		$$(element).each(function(el) {		 
			el.addEvent('mousedown', function() {	
				this.s_click(el);
			}.bind(this));
		}, this);
	
	},
	
	s_click: function(el) {
		var params = { 
			'pid' 	: el.id,
			'plink' : el.href
		};
		ajaxStore( this.baseURL + this.options.path, params );
	}
	
});


/*****************************/
/* Ajax calling methods 3.0 */
/* Author: Simon Ilett 	   */
/**************************/
// Send and retrieve 
function ajaxStore(oURL, oParams, oCallback) {
	return tmp = new Request({  
			 method: 'post',  
			 url: oURL,  
			 data: oParams,  
			 onSuccess: function(response) { if(oCallback) oCallback(response); }  
	}).send();
}

window.addEvent('domready', function() {
	new sponsoredLinks('sponsoredLinks');
	new affiliateLinks('.affiliateLinks');
});
