window.addEvent('domready', function() {

$$('.jdv_readmore').addEvent('click', function(e) {
	e = new Event(e).stop();
	var url = this.href;
	
	var firstreq = 0;
	var stat = $('jdv_stat'+this.id);
	var fulltext = $('jdv_fulltext'+this.id);
	var introtext = $('jdv_introtext'+this.id);
	
	stat.style.display='block';
	
	
	/**
	 * The simple way for an Ajax request, use onRequest/onComplete/onFailure
	 * to do add your own Ajax depended code.
	 */
	//alert(fulltext.style.display);
	if (fulltext.style.display=='block') {
		fulltext.style.display='none';
		stat.removeClass('ajax-loading');
		return;
	} else {
		
		stat.addClass('ajax-loading');
		stat.style.display='block';
		if (fulltext.style.display) {
			stat.removeClass('ajax-loading');
			fulltext.style.display='block';
			introtext.style.display='none';
			return;
		}
	}
	
	new Ajax(url, {
		method: 'get',
		update: $('jdv_fulltext'+this.id),
		onComplete: oncompleteActions
	}).request();

	

	function oncompleteActions(request) {

		if (fulltext.style.display != 'block') {
			fulltext.style.display='block';
			//stat.style.display='block';
		}
			

		stat.removeClass('ajax-loading');
		
	}

	
});
});
