// codehouse consulting 12.4.09
// track clicks and page loads for listings on buymytrailer.com
 
 
jQuery(document).ready(function() {

jQuery(".link").click(function() {
var ad_id = jQuery(this).attr('rel');
jQuery.ajax({type: "POST", url: "update_click_listings.php",data: "ad="+ad_id+"&type=c",success: function(j){ } });
});

 	
//track attention
/*
jQuery(function( ){ jQuery('.link').hover(over, out); });

function over(event){}

function out(event)
{
var ad_id = jQuery(this).attr('rel');
jQuery.ajax({  type: "POST", url: "update_click_listings.php",  data: "ad="+ad_id+"&type=a",  success: function(j){}}); 
}

*/

 
 //on page load update impressions - need to loop through all links to find listings (as long as its not an ad process), make an array of ids to send to update page
var id = [];
var output = '';
var links_present = false;
jQuery('.link').each (function() { links_present=true;
	if(jQuery(this).attr('id')!='ad') {	id.push(jQuery(this).attr('rel')	);		}   		   
});
if(links_present) {
// Take the array of ids and create querystring series for use my POST
for(i=0;i<id.length;i++){glue = (i)?'&':'';output += glue+'idArry['+i+']='+id[i];}

jQuery.ajax({ type: "POST",  url: "update_click_listings.php", data: ""+output+"&type=i",success: function(j){}});
}
 
 
 
});
 
