/******************************************************************************
 * ZAds - Ads management
 * @author Pedro Henrique de M. Rodrigues
 * @version 2.0
 * @date 30/03/2009
 *
 * Framework used:
 *  - JQuery 1.2.6
 */

var ZAds = function()
{
	/*
	 * Last click timestamp
	 */
	this.lastClick = [];
	
	/*
	 * Class init
	 */	
	this.init = function (params)
	{

	};
	
	/*
	 * Registry a click
	 */
	this.registryClick = function (ad, pi)
	{
		// test if the ad was clicked in last than 2 seconds (avoid double-click)
		var now = (new Date()).getTime();
		if((this.lastClick[ad]) && (this.lastClick[ad] > now - 2000))
			return;

		// save the click timestamp
		else
			this.lastClick[ad] = now;
		
		// send ajax call
		$.post(pageRoot + '/zads_ajax.php', { fun: 'registryClick', ad: ad, pi: pi });
	};

}; /* ZAds */

var zads = new ZAds();
