//*************************************************************************************************
/*!
	\brief		Function: Creates a sticker object
	\param  		resdir Resource directory (without trailing slash)
	\param  		image  Background image file name
	\param  		text   Text to show
	\param  		sound  Mouseover played sound file name
	\param  		line  Text to show on Mouseover
	\param		left   Left position
	\param		top    Top position
	\param		width  Width position
	\param		height Height position
	\return		The created dom object
	\internal
	\date			Apr 2006
	\author		(c) PATANEGRA Soft - www.patanegra.com - AGS
*/
//*************************************************************************************************
function AddStickerObjectDibusSound(resdir, image, text, sound, line, left, top, width, height)
{
	var obj = new SlDom(null, null, left, top, width, height);

	// Keep some constructor parameters
	obj.__image = !image ? null : image;
	obj.__text  = !text  ? null : text ;
	obj.__sound = !sound ? null : sound;
	obj.__line  = !line  ? null : line;

	// Move/resize status
	obj._status['MoveOnUsing'   ] = 'always';
	obj._status['ResizeOnDesign'] = 'always';

	// Top for Z axis
	obj.dom.style.zIndex = SlGetDomMaxZIndex(SlSys._body);

	// No select text!
	obj.setSelection(false);

	// Has text?
	if(text)
	{
		// Set content
		obj.dom.innerHTML = text;

		// text + image at same time?
		if(image)
			obj.dom.style.backgroundColor = 'transparent';
	}

	// Has line?
	if(line)
	{
		// Set content
		SlCaptureDomEvent(obj.dom, 'mouseover', function(e) { document.getElementById('txtsti').innerHTML = line; });
		SlCaptureDomEvent(obj.dom, 'mouseout', function(e) { document.getElementById('txtsti').innerHTML = '&nbsp;'; });
	}

	// Has image?
	if(image)
		obj.setBGImage(resdir + "/" + image, true);

	// Has sound?
	if(sound)
	{
  	// Mouse over play sound (if not image neither text)
    if(image || text)
			
		// CrossBrowsing: IE needs wav file, others use flash
		if(SlSys._ie)
			SlCaptureDomEvent(obj.dom, 'mouseover', function(e) { document.getElementById('sonsti').innerHTML =
				'<EMBED src="' + resdir + '/' + sound + '.wav" WIDTH="1" HEIGHT="1" VISIBILITY="hidden" TYPE="audio/x-wav" AUTOSTART="true" loop="false" />'; });
		else
			SlCaptureDomEvent(obj.dom, 'mouseover', function(e) { document.getElementById('sonsti').innerHTML =
				'<EMBED src="' + resdir + '/' + sound + '.swf" WIDTH="1" HEIGHT="1" VISIBILITY="hidden" TYPE="application/x-shockwave-flash" quality="high" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer" />'; });
	}                                                                           
	
	//! Double click duplicate the object
	SlCaptureDomEvent(obj.dom, 'dblclick', obj.dom.__dblclick = function(e)
		{ AddStickerObjectDibusSound(resdir, image, text, sound, line, obj.dom.style.left, obj.dom.style.top, obj.dom.style.width, obj.dom.style.height); });

	//! Right click delete the object
	SlCaptureDomEvent(obj.dom, 'contextmenu', function(e)
	{
		obj.destroy();

		// Ignore default action
		if(e.preventDefault)
		{
			e.preventDefault();
			return;
		}
		else
		{
			e.returnValue = false;
			return false; // Mandatory
		}
	});

	// Return the created dom object
	return obj.dom;
}
