// -----------------------------------------------------------------------------------
//
//	Lightbox flash adapter v1.0b
//	by Lucas Ferreira - http://www.lucasferreira.com/
//	Last Modification: 8/23/08
//
//	Licensed under the Creative Commons Attribution 2.5 License - http://creativecommons.org/licenses/by/2.5/
//  	- Free for use in both personal and commercial projects
//		- Attribution requires leaving author name, author link, and the license info intact.
//
// -----------------------------------------------------------------------------------

if(Lightbox == undefined)
{
	alert('You need lightbox.js for use this script.');
}

Object.extend(Lightbox.prototype, {
	_start: Lightbox.prototype.start,
	_initialize: Lightbox.prototype.initialize,
	initialize: function()
	{
		this._initialize();
		
		if(document.body)
		{
			document.body.appendChild(Builder.node('div', {
				id:'_temp_links',
				style:'position:absolute;width:1px;height:1px;overflow:hidden;top:-1000em;left:-1000em;display:none;'
			}));
		}
		
		Lightbox._sing = this;
	},
	start: function(imageLink) {
		
		this._start(imageLink);
		
		var os = (navigator.platform || "win").toString().toLowerCase();
		if(os.indexOf("lin") < 0)
		{
			$$('object', 'embed').each(function(node){ node.style.visibility = 'visible' });
			if(document.body) document.body.focus();
		}
		
	}
});

//callback for flash...
Lightbox.start = function(src, title,comeca)
{
	function _createTempLink(_src, _title, _group)
	{
		var _a = document.createElement("A");
		_a.setAttribute("href", _src);
		_a.setAttribute("rel", (_group ? "lightbox[" + _group + "]" : "lightbox"));
		_a.setAttribute("title", (_title || ""));
		
		return _a;
	}
	
	if(Lightbox._sing != null)
	{
		if($('_temp_links')) $('_temp_links').innerHTML = "";
		
		src = (typeof src == 'string' ? [src] : src);
		if(title != undefined) title = (typeof title == 'string' ? [title] : title);
		
		for(var first=null, i=0; i<src.length; i++)
		{
			_a = _createTempLink(src[i], (title && title.length > i && title[i] ? title[i] : ""), (src.length > 1 ? "temp" : false));
			
			if( i == comeca)
			{
				first = _a;
			}
			
			if($('_temp_links')) $('_temp_links').appendChild( _a );
		}
		
		Lightbox._sing.start( first );
	}
};
Lightbox._sing = null;