/*
 * JS by Gedi
 * @author Gedi <gedi@freedots.com.pl>
 *
 * Comment modyfication:
 * Krzysztof Piwowar <kontakt@kpiwowar.com>
 *
 *	plik   = path to swf file
 *	wdth   = width in px
 *	hght   = height in px
 *	bgdn   = background color in hex: #RRGGBB, default #000000
 *	wmode  = render mode, default "window"
 *	qlty   = quality, default "high"
 *	idName = flash ID
 *	target = destination target (where we put swf file)
 *	fVars  = variables: FlashVars
 *	altImg = alternative image file, default it contain name of destination target ID and interation number of swf file :)  
 */
var nr = 0;
function createFlash(movie, wdth, hght, bgnd, wmode, qlty, idName, target, fVars, altImg)
{
	if (obj_setFlash = document.getElementById(target))
	{
		fVars = fVars.replace(/amp;/, '');
		idName = idName ? idName : target+"_flash"+(nr++);
		objTag = "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' width='"+wdth+"' height='"+hght+"' id='"+idName+"'>";
		objTag2 = "<object data='"+movie+"' type='application/x-shockwave-flash' width='"+wdth+"' height='"+hght+"' id='"+idName+"'>";

		paramTag = "<param name='movie' value='"+movie+"'>"
		+"<param name='bgcolor' value='"+(bgnd ? bgnd : "#000000")+"'>"
		+"<param name='wmode' value='"+(wmode ? wmode : "transparent")+"'>"
		+"<param name='quality' value='"+(qlty ? qlty : "high")+"'>"
		+"<param name='scale' value='noscale'>"
		+"<param name='menu' value='false'>"
		+"<param name='allowScriptAccess' value='always'>"
		+"<param name='swliveconnect' value='true'>"
		+(fVars ? "<param name='FlashVars' value='"+fVars+(altImg ? "&altImg="+altImg : "")+"'>" : "")
		+(altImg ? "<img src='"+altImg+"' alt='"+idName+"' title=''>" : idName)
		+"</object>";

		if (typeof HTMLElement != "undefined")
		{
			if (topImage = document.getElementById('signImage')) obj_setFlash.removeChild(topImage);
			obj = document.createElement("object");
			obj.setAttribute("data", movie);
			obj.setAttribute("type", "application/x-shockwave-flash");
			obj.setAttribute("width", wdth);
			obj.setAttribute("height", hght);
			obj.setAttribute("id", idName);
			par = document.createElement("param");
			par.setAttribute("name", "bgcolor");
			par.setAttribute("value", bgnd ? bgnd : "#000000");
			obj.appendChild(par);
			par = document.createElement("param");
			par.setAttribute("name", "wmode");
			par.setAttribute("value", wmode ? wmode : "transparent");
			obj.appendChild(par);
			par = document.createElement("param");
			par.setAttribute("name", "quality");
			par.setAttribute("value", qlty ? qlty : "high");
			obj.appendChild(par);
			par = document.createElement("param");
			par.setAttribute("name", "scale");
			par.setAttribute("value", "noscale");
			obj.appendChild(par);
			par = document.createElement("param");
			par.setAttribute("name", "menu");
			par.setAttribute("value", "false");
			obj.appendChild(par);
			par = document.createElement("param");
			par.setAttribute("name", "allowScriptAccess");
			par.setAttribute("value", "always");
			obj.appendChild(par);
			par = document.createElement("param");
			par.setAttribute("name", "swliveconnect");
			par.setAttribute("value", "true");
			obj.appendChild(par);
			if (fVars)
			{
				par = document.createElement("param");
				par.setAttribute("name", "FlashVars");
				par.setAttribute("value", fVars+(altImg ? "&altImg="+altImg : ""));
				obj.appendChild(par);
			}
			if (altImg)
			{
				par = document.createElement("img");
				par.setAttribute("src", altImg);
				par.setAttribute("alt", idName);
				par.setAttribute("title", "");
				obj.appendChild(par);
			}
			else
			{
				par = document.createTextNode(idName);
				obj.appendChild(par);
			}
			return obj_setFlash.appendChild(obj);
		}
		else if (document.all && !window.opera)
		{
			obj_setFlash.insertAdjacentHTML('beforeEnd',objTag+paramTag);
		}
		else
		{
			obj_setFlash.write(objTag+paramTag2);
		}
	}
}

/**
 * Funkcja do wstawiania modulu facebook, sprawiajaca ze strona sie waliduje
 * 
 * @param string target id pola w ktorym ma byc wstawiona
 * @param string init argument funkcji FB.init(...)
 * @param integer param_id wartosc param_id z tagu <fb:fan../>
 */
function createFB(target, init, profile_id) {
    if (obj_setFlash = document.getElementById(target)) {
        FB.init(init);
        fb = document.createElement("fb:fan");
        fb.setAttribute("profile_id", profile_id);
        fb.setAttribute("stream", 0);
        fb.setAttribute("connections", 10);
        fb.setAttribute("logobar", 1);
        fb.setAttribute("width", 300);
        obj_setFlash.appendChild(fb);
    }
}
