lightBox.prototype.init = function(a)
{
	this.imageLoad = null;
	this.description = null;

	this.urlSmall = '/s/';
	this.urlBig = '/b/';

	if(a[1])  this.urlSmall = a[1];
	if(a[2]) this.urlBig = a[2];
	if( a[0].tagName )
	{
		if(a[0].tagName.toLowerCase()=='img')
			return this.toEnlarge(a[0], a[0]);
		else if(a[0].tagName.toLowerCase()=='a') {
			var tg = $t('img', a[0])[0];
			if(!tg) tg = a[0];
			return this.toEnlarge(a[0], tg);
		}
	}

	this.childsToEnlarge(a[0]);
}


lightBox.prototype.createAreaToImages = function(_target)
{
	this.createArea();

	this.imageLoad = cE('img', this.areaTarget, 'imageLoad');
	this.showHideImage(false);

	this.description = cE('p', this.areaTarget, 'descriptionTextArea');
};

lightBox.prototype.showHideImage = function(sh) {
	if(sh) this.imageLoad.style.display = 'block';
	else this.imageLoad.style.display = 'none';
};

lightBox.prototype.formatSrc = function(objImg) {
	if(typeof objImg=='string') return objImg;
	var _src = objImg.getAttribute("src");
	_src = (!_src) ? objImg.getAttribute("href") : _src ;
	if(!_src) return false;
	var newSrc = _src.replace(this.urlSmall, this.urlBig);
	return newSrc;
};

lightBox.prototype.enlargeThis = function(_target) {
	var description = (typeof _target!='string') ? _target.getAttribute("title") : '';

	this.createAreaToImages();

	this.showHideImage(false);
	this.area.className = 'loading';

	var _img = new Image();
	var o = this;
	_img.onload = function() {
		o.imageLoad.src = this.src;
		o.area.className = '';
		o.showHideImage(true);
		o.area.style.width = this.width + 'px';
		if(description)
			o.description.innerHTML = description;
		centralizeElement(o.area);
		o.area.style.visibility = 'visible';
		o.showArea();
	}
	_img.src = this.formatSrc(_target);
};

lightBox.prototype.childsToEnlarge = function(_target)
{
	var c = $t("a", _target);
	var o = this;
	c.forEach(
		function(e) {
			var _img = $t('img', e)[0];
			if(_img)
			{
				e.onclick = function(){ o.enlargeThis($t('img', this)[0]); return false; };
			}
		}
	);
};

lightBox.prototype.toEnlarge = function(caller, _target) {
	var o = this;
	caller.onclick = function() {
		o.enlargeThis(_target);
		return false;
	}
}