// JavaScript Document
// Class

function IndexTab(module)
{
	this._ajaxUrl = 'handleAjax.php';
	this._module = module;
	
	this._container = $j('#divTabContent');
	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();
}
IndexTab.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
		}
	});
}
IndexTab.prototype.closeBox = function()
{
	$j.unblockUI();
}
IndexTab.prototype.getTabContent = function(elem,tab_id)
{
	var obj = this;
		//obj.loading();
	var data = {
		module: obj._module,
		action: 'getTabContent',
		tab_id:  tab_id
		};
	$j.ajax({
		url: obj._ajaxUrl,
		data: data,
		type: 'POST',
		dataType: 'html',
		success: function(response){
		//	obj.closeBox();
			$j('#divTabContent').slideUp('slow',function(){
				$j('#divTabContent').html(response);
				$j('#divTabContent').slideDown('slow');
			});
			var tabs = $j(elem).parent().parent().find('a');
			tabs.removeClass('active');
			$j(elem).addClass('active');
			},
		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);
		}		
			});
}
IndexTab.prototype.setTabs = function(index)
{	
	var tabs = $j('#ulTabs').find('a');
	$j(tabs).removeClass('active');
	$j(tabs[index]).addClass('active');	
}
IndexTab.prototype.reviewDrop = function(url)
{
	var obj = this;
	var id = $j('#reviewDropdown').val();
	if(id == 0)
		return;
	var data = {
				id:     id,
				urlType: ''
				};
		$j.ajax({
			url:url+'getURL.php',
			data:data,
			type:'POST',
			dataType:'json',
			success:function(res){
		//	alert(res.url)
			if(res.flag)
			{
				var nurl = res.url.replace(/|/g,'&zwnj;');
				//alert(nurl);
				window.location=res.url;
			}
			}
		
		});
	
}


