// Copyright Quality Leads, Inc. 2009

if (!NOVO)
{
	var NOVO = new Object();
}
if (!NOVO.artist)
{
	NOVO.artist = new Artist(NOVO);
}

// FORM VALIDATOR
function Artist( NOVO_obj )
{
	this.NOVO = NOVO_obj;
	this.active_id = false;
	return this;
}

Artist.prototype.hide = function(x_but)
{
	if (!this.active_id)
	{
		return;
	}
	var active_id = this.active_id;
	var fullsize = $("fullsize_" + active_id);
	var screen_div = $("photo_screen");

	this.active_id = false;
	var fullsize_dim = fullsize.getDimensions();
	var screen_dim = screen_div.getDimensions();
	fullsize.morph("top: -" + fullsize_dim.height + "px; left: -" + fullsize_dim.width + "px; opacity: 0;");
	screen_div.morph("top: -" + screen_dim.height + "px; left: -" + screen_dim.width + "px; opacity: 0;");
};

Artist.prototype.move_photo = function()
{
	if (!this.active_id)
	{
		return;
	}
	var active_id = NOVO.artist.active_id;
	var fullsize = $("fullsize_" + active_id);
	var screen_div = $("photo_screen");
	
	var win_scr_off = document.viewport.getScrollOffsets();
	var win_scr_off_x = win_scr_off[0];
	var win_scr_off_y = win_scr_off[1];
	var win_dim = document.viewport.getDimensions();
	var win_w = win_dim.width;
	var win_h = win_dim.height;
	
	var photo_dim = fullsize.getDimensions();
	var photo_w = photo_dim.width;
	var photo_h = photo_dim.height;
	
	var win_w_big = win_w > photo_w;
	var win_h_big = win_h > photo_h;
	
	var x_diff = (win_w_big ? (win_w - photo_w) : -(photo_w - win_w)) / 2;
	var y_diff = (win_h_big ? (win_h - photo_h) : -(photo_h - win_h)) / 2;
	
	screen_div.style.width = (photo_w + 40) + "px";
	screen_div.style.height = (photo_h + 40) + "px";

	screen_x = ((win_scr_off_x + x_diff - 20) > 0) ? (win_scr_off_x + x_diff - 20) : 0;
	screen_y = ((win_scr_off_y + y_diff - 20) > 0) ? (win_scr_off_y + y_diff - 20) : 0;
	screen_div.morph("left:" + screen_x + "px; top:" + screen_y + "px; opacity:.80");

	fullsize_x = ((win_scr_off_x + x_diff) > 20) ? (win_scr_off_x + x_diff) : 20;
	fullsize_y = ((win_scr_off_y + y_diff) > 20) ? (win_scr_off_y + y_diff) : 20;
	fullsize.morph("top:" + fullsize_y + "px; left:" + (win_scr_off_x + x_diff) + "px; opacity:1");
};

Artist.prototype.show = function(a_tag)
{
	if (this.active_id)
	{
		return;
	}
	var thumb_div = Element.up(a_tag);
	thumb_id = thumb_div.id;
	num = thumb_id.slice(thumb_id.lastIndexOf("_") + 1);
	this.active_id = num;

	var fullsize = $("fullsize_" + num);
	var screen_div = $("photo_screen");

	fullsize.setStyle({
		opacity: 0,
		display: "block"
	});
	screen_div.setStyle({
		opacity: 0,
		display: "block"
	});
	
	this.move_photo();
};
