var $j = jQuery.noConflict();

//Initialize the array
var arr = new Array();

//storeValue function works when teaser changes
function storeValue(uid){
	//Example of teaserUid that sent from flash
	arr[arr.length] = uid;
}

function updateStatus(){
	//Generate JSON in String format
	a = "{";
	for(key in arr){
		if(key==arr.length-1){
			a = a + "\"" + key + "\"" + ":" + arr[key];
		}
		else{
			a = a + "\"" + key + "\"" + ":" + arr[key] + ",";
		}
	}
	a = a + "}";
	//if size of array = 0, not post to server
	if(a){
		//format the string to JSON object by JSON.parse() and send to server by $.post()
		$j.post("/index.php?&eID=tx_teaserbar&action=countImpression",$j.parseJSON(a));
	}
	arr = new Array();
}

$j(window).blur(function () { 
	//Call to updateStatus for posting data by AJAX
	updateStatus();
});

$j(window).unload(function () { 
	//Call to updateStatus for posting data by AJAX
	updateStatus();
});
