/*
* Siete library
* @Author: Alexander Gavazov
* @Site: www.studio.bg
*/


function writeSwf(element, swfFile, width, height, bgColor, parameters, flashId)
{
	var htmlCode = '';
	var flashVars = '';
	var embedColorCode = (bgColor) ? 'bgcolor="' + bgColor + '"' : 'wmode="transparent"';


	if(parameters)
	{
		for(var i in parameters)
		{
			if(typeof parameters[i] != 'string')
			{
				alert('Parameter: ' + i + ' must by string');
			}
			else
			{
				parameters[i] = parameters[i].replace(/&amp;/gi, '%26');
				parameters[i] = parameters[i].replace(/&/gi, '%26');

				flashVars += i + '=' + parameters[i] + '&';
			}
		}

		if(flashVars)
		{
			flashVars = flashVars.substr(0, flashVars.length - 1);
		}
	}

	htmlCode += '<object ' + (flashId ? 'id="' + flashId + '"' : '') + ' classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="' + width + '" height="' + height + '">';
		htmlCode += '<param name="movie" value="' + swfFile + '" />';
		htmlCode += '<param name="quality" value="high" />';
		htmlCode += '<param name="flashvars" value="' + flashVars + '" />';
		htmlCode += '<param name="AllowScriptAccess" value="always" />';

		if(bgColor)
		{
			htmlCode += '<param name="bgcolor" value="' + bgColor + '" />';
		}
		else
		{
			htmlCode += '<param name="wmode" value="transparent" />';
		}

		htmlCode += '<embed ' + (flashId ? 'name="' + flashId + '"' : '') + embedColorCode + ' allowscriptaccess="someDomain" flashvars="' + flashVars + '" src="' + swfFile + '" quality="high" width="' + width + '" height="' + height + '" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
	htmlCode += '</object>';

	element.innerHTML = htmlCode;
}


function emailReplace(emails, replaceStr)
{
	emails.each(function(node) {
		var mail = node.innerHTML.replace(replaceStr, '@');
		node.update('<a href="mailto:' + mail + '">' + mail + '</a>');
	});
}



function img_win(link_id)
{
	window.open(link_id.href, '_blank', 'status = 1, width = 250, height = 350, resizable = 0');
	return false;
}



function moveScroll(start, end)
{
	if(!this.Eingine)
	{
		this.Eingine = new VE;
	}

	this.Eingine.stop();
	this.Eingine.init(start, end, Easing.expoOut, 1);
	this.Eingine.onChange = function(position)
	{
		window.scrollTo(0, position)
	}
	this.Eingine.start();
}

