$(function() {

	AddEvents();
	
})

//count ads displayed; need later on adshare calculation
var ads_counter = 0;

function AddEvents(){
						
	$(".sponsoredLinks a").each(function(){
						
		$(this).bind("click", function(){
		  ad_id = $(this).attr("id").substr(9);
		  RecordClicks(ad_id);
		});
		
		ads_counter++;
				
	});
	
}

function RecordClicks(ad_id){
	//total number of ads shown
	if(ads_counter == 0)
		return false;
	
	//search keyword	
	if(search_keyword == null || search_keyword == '')
		return false;	
				
	$.post(HTTP + 'adshare/?record_click', {position:ad_id,total:ads_counter,keyword:search_keyword,search_affiliate:search_affiliate}, function(response) {

	});
}