/**
 * FlashTag
 * - vytvori browser specific tag pro vkladani flashe
 * - umoznuje version sensitive neflash variantu 
 */

/**
 * vytvori novou instanci FlashTagu
 * src: cesta k souboru
 * width: sirka flashe
 * height: vyska
 */
function FlashTag(src, width, height)
{
    this.src       = src;
    this.width     = width;
    this.height    = height;
    this.version   = '8,0,0,0';
    this.id        = null;
    this.bgcolor   = 'ffffff';
    this.flashVars = null;
	this.nonflash = false;
	this.flashCanPlay = flashCanPlay;
}
/**
 * nastavi custom verzi flash contentu
 */
FlashTag.prototype.setVersion = function(v)
{
    this.version = v;
}
/**
 * nastavi neflash variantu
 */
FlashTag.prototype.setNoFlashHTML = function(nfv)
{
    this.nonflash = nfv;
}

/**
 * id pro flashovy element
 */
FlashTag.prototype.setId = function(id)
{
    this.id = id;
}

/**
 * custom barva pozadi
 */
FlashTag.prototype.setBgcolor = function(bgc)
{
    this.bgcolor = bgc;
}

/**
 * posilane vars do flashe
 */
FlashTag.prototype.setFlashvars = function(fv)
{
    this.flashVars = fv;
}

/**
 * vrati flash tag jako string
 */
FlashTag.prototype.toString = function()
{
    var ie = (navigator.appName.indexOf ("Microsoft") != -1) ? 1 : 0;
    var flashTag = new String();
    if (ie)
    {
        flashTag += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ';
        if (this.id != null)
        {
            flashTag += 'id="'+this.id+'" ';
        }
        flashTag += 'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version='+this.version+'" ';
        flashTag += 'width="'+this.width+'" ';
        flashTag += 'height="'+this.height+'">';
        flashTag += '<param name="movie" value="'+this.src+'"/>';
        flashTag += '<param name="quality" value="high"/>';
        flashTag += '<param name="allowScriptAccess" value="always"/>';
        flashTag += '<param name="wmode" value="transparent"/>';
        flashTag += '<param name="bgcolor" value="#'+this.bgcolor+'"/>';
        if (this.flashVars != null)
        {
            flashTag += '<param name="flashvars" value="'+this.flashVars+'"/>';
        }
        flashTag += '</object>';
    }
    else
    {
        flashTag += '<embed src="'+this.src+'" ';
        flashTag += 'quality="high" '; 
        flashTag += 'allowScriptAccess="always" '; 
        flashTag += 'bgcolor="#'+this.bgcolor+'" ';
        flashTag += 'width="'+this.width+'" ';
        flashTag += 'wmode="transparent" ';
        flashTag += 'height="'+this.height+'" ';
        flashTag += 'type="application/x-shockwave-flash" ';
        if (this.flashVars != null)
        {
            flashTag += 'flashvars="'+this.flashVars+'" ';
        }
        if (this.id != null)
        {
            flashTag += 'name="'+this.id+'" ';
        }
        flashTag += 'pluginspage="http://www.macromedia.com/go/getflashplayer">';
        flashTag += '</embed>';
    }
    return flashTag;
}

/**
 * vypise flash tag nebo jeho neflash variantu
 * doc : reference k objektu kam se bude vypisovat
 */
FlashTag.prototype.write = function(doc)
{
	// pokud je definovana neflash varianta
	if(this.nonflash !== false) {
		if(this.flashCanPlay) {
			doc.write(this.toString());
		} else {
			doc.write(this.nonflash);
		}
	}
	// pokud neni
	else {
		doc.write(this.toString());
	}
}

var MM_contentVersion = 8;
var plugin = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;
if ( plugin ) {
		var words = navigator.plugins["Shockwave Flash"].description.split(" ");
	    for (var i = 0; i < words.length; ++i)
	    {
		if (isNaN(parseInt(words[i])))
		continue;
		var MM_PluginVersion = words[i]; 
	    }
	var MM_FlashCanPlay = MM_PluginVersion >= MM_contentVersion;
}
else if (navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0 
   && (navigator.appVersion.indexOf("Win") != -1)) {
	document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n'); //FS hide this from IE4.5 Mac by splitting the tag
	document.write('on error resume next \n');
	document.write('MM_FlashCanPlay = ( IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash." & MM_contentVersion)))\n');
	document.write('</SCR' + 'IPT\> \n');
}
if ( MM_FlashCanPlay ) {
	var flashCanPlay = true;
} else{
	var flashCanPlay = false;
}