function cSlideshow() { 

	var _imgPath 	= new Array();
	var _comments 	= new Array();
	var _width 		= new Array();
	var _height 	= new Array();
	var _id		 	= null;
	var _name		= null;
	var _tabs 		= 0;
	var _count		= 0;
	var _this		= this;

		
	var requestData = function(pointer) { 
		_count		= 0;
		_name = $(pointer).text();
		_id = $(pointer).attr('id'); 
		_imgPath 	= new Array();
		_comments 	= new Array();
		_width 		= new Array();
		_height 	= new Array();

		$.ajax({ type: "GET", 
				url: 'src/php/actions/action.images.php?q='+_id,
				async:false,
				success: function(phpData) { 
					var data = $.parseJSON(phpData);
					for(var i=0; i < data.length ;i++) {
						_imgPath[i]	= data[i][0]; 
						_height[i] 	= data[i][1];
						_width[i]	= data[i][2];
						_comments[i] = data[i][3];
					}
				}
		 });

		return (_imgPath != null && typeof(_imgPath) != undefined) ? true : false;
	}

	this.getTabs = function() {
		return _tabs;
	}

	this.open = function(pointer) {
		try {
			if (!requestData(pointer))
				throw "Unable to request data";
			if(!prepareTabs())
				throw "Unable to start Tabs"; 

			populateOverlay();
		}
		catch (e) {
			console.log(e); 
		}
		
	}

	var populateOverlay = function() { 
		$("#overlay .comment").html(_comments[0]); 
		$("#overlay #name").html(_name); 
		var i = 0;
		$(".images div").each(function(i) {
			$(this).html('<img src="'+_imgPath[i]+'" width="'+_width[i]+'" height="'+_height[i]+'" />');
			i++;
		});
	}

	var prepareTabs = function () {
		cleanDivs(); 
		for (var i = 0; i < _imgPath.length; i++) {
			$("#overlay .images").append('<div class="imgDiv"></div>');
			$("#overlay .slidetabs").append('<a href="#"></a>');
		}; 

		_tabs = $(".slidetabs").tabs(".images > div", { api: true, effect: 'fade', fadeOutSpeed: "slow", rotate: true, next: ".forward", back: ".backward" });

		return (_tabs != null && typeof(_tabs) != undefined) ? true : false;
	} 

	var cleanDivs = function() {
		$("#overlay .images").html('');
		$("#overlay .slidetabs").html(''); 
	}


	this.nextSlide = function() { 
		if (_count >= (_comments.length -1)) {
			_count = 0;	
			$("#overlay .comment").html(_comments[_count]);
		}
		else { 
			_count ++;
			$("#overlay .comment").html(_comments[_count]);
		} 
		_tabs.next();
	}


	this.prevSlide = function() {
		if (_count <= 0) {
			_count = (_comments.length -1);	
			$("#overlay .comment").html(_comments[_count]);
		}
		else { 
			_count --;
			$("#overlay .comment").html(_comments[_count]);
		}
		_tabs.prev(); 
	}
}

