// Picture
Picture.prototype.showPicture = _showPicture;

function Picture(id, array_id, picture_src, thumb_src, caption, description, gallery)
{
	this.id = id;
	this.array_id = array_id;
	this.picture_src = picture_src;
	this.thumb_src = thumb_src;
	this.caption = caption;
	this.description = description;
	
	this.img = new Image();
	this.img.src = picture_src;
	this.img.id = 'img_' + id;
	
	this.img_thumb = new Image();
	this.img_thumb.src = thumb_src;
	this.img_thumb.id = 'img_thumb_' + id;
	this.img_thumb.width = '100';
	this.img_thumb.height = '75';
	//alert(this.img_thumb.width);
	//alert(this.img_thumb.height);
	this.gallery = gallery;
}

function _showPicture(current_picture, best_fit, fading_effect)
{
	imgHeightConst = galleryConst.imgHeightConst;
	imgWidthConst = galleryConst.imgWidthConst;
	
	if($('img_'+current_picture))
		pic = $('img_'+current_picture);
	else
	{
		pic = document.createElement('img');
		$('pic-view').innerHTML = '';
		$('pic-view').appendChild(pic);	
	}
	
	pic.id = this.img.id;
	
	if (document.all){
		if (fading_effect){
			pic.style.filter="blendTrans(duration=1)";
			pic.filters.blendTrans.Apply();
			pic.filters.blendTrans.Play();
		}
	}
	
	pic.src = this.img.src;
	
	if(best_fit)
	{
		p = Math.min(imgHeightConst/this.img.height, imgWidthConst/this.img.width);
		
		if(p < 1){
			pic.width = this.img.width * p;
			pic.height = this.img.height * p;
		}
		else {
			pic.width = this.img.width;
			pic.height = this.img.height;
		}
	}
	/*else
	{
		pic.width = this.img.width;
		pic.height = this.img.height;
	}*/
	
	$('pic-caption').innerHTML = this.caption;
	$('pic-description').innerHTML = this.description;
	
}

