// codehouse consulting 12.4.09
// track clicks and page loads for graphic ads 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.php", data: "ad="+ad_id+"&type=c",success: function(j){}});
});
	
//track attention (not sure if this will be meaningful)
/*
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.php",  data: "ad="+ad_id+"&type=a", success: function(j){}  });
}
*/
//on page load update impressions - need to loop through all links to find ads, make an array of ids to send to update page
var id = [];
var output = '';
var ads_present = false;
jQuery('.link').each (function() { ads_present=true;
	if(jQuery(this).attr('id')=='ad') {	id.push(jQuery(this).attr('rel')	);		}   		   
});
if(ads_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.php", data: ""+output+"&type=i",success: function(j){}});
}


});
 
