// JavaScript Document

// Class

function SportByJs(module,domainName)
{
	this._ajaxUrl = domainName + 'handleAjax.php';
	this._module = module;
	this._container = $j('#body_container');
	this._photocontainer = $j('#Sportsby-photo');
	this._headertitle = $j('#Sportsby-title');
	this._msgBox = this._container.prev('div').prev('div').children('.errorBox');
	
	this._timeOut = null;
	
	
	this._loading = '<img src="images/loading-thickbox.gif" alt="Loading" width="208" height="13" />';
	
	$j(this._loading)
		.prependTo('body')
		.hide();
		
		
}
SportByJs.prototype.loading = function()
{
	var obj = this;
	
	/*obj.closeBox();*/
	$j.blockUI({
		message: obj._loading,
		css: {
			border: 'none',
			background: 'transparent'
		},
		overlayCSS: {
			'background-color': '#282828',
			opacity: 0.7
		}
	});
}
SportByJs.prototype.closeBox = function()
{
	$j.unblockUI();
}
SportByJs.prototype.getContent = function(elem,id,action)
{	
	
	var obj = this;
	
	//obj.loading();
	var data = {
		module: obj._module,
		action: 'getFullSportsBy',
		id: id
		};
	$j.ajax({
	url: obj._ajaxUrl,
	data: data,
	type: 'POST',
	dataType: 'json',
	success: function(hdata){
			if(hdata.flag)
			{
				//alert(hdata.msg);
				obj._container.slideUp('slow',function(){
				obj._container.html(hdata.msg);
				obj._photocontainer.html(hdata.image);
				//alert(obj._container.html());
				//obj._headertitle.html(hdata.title);
				obj._container.slideDown('slow');
				});
			}
		},
	timeout: 60000,
	error: function(XMLHttpRequest, textStatus, errorThrown){
			obj._msgBox
				.text('Error: A critical error occured.')
				.show();
			clearTimeout(obj._timeOut);
			obj._timeOut = setTimeout(function(){
				obj._msgBox.fadeOut(500);
			}, 3000);
		}		
	});
	
	obj.closeBox();
	
	
}
