﻿/**
* This script contains embed functions for common plugins. This scripts are complety free to use for any purpose.
*/

function writeFlash(p) {
    writeEmbed(
		'D27CDB6E-AE6D-11cf-96B8-444553540000',
		'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0',
		'application/x-shockwave-flash',
		p
	);
}

function writeShockWave(p) {
    writeEmbed(
	'166B1BCA-3F9C-11CF-8075-444553540000',
	'http://download.macromedia.com/pub/shockwave/cabs/director/sw.cab#version=8,5,1,0',
	'application/x-director',
		p
	);
}

function writeQuickTime(p) {
    writeEmbed(
		'02BF25D5-8C17-4B23-BC80-D3488ABDDC6B',
		'http://www.apple.com/qtactivex/qtplugin.cab#version=6,0,2,0',
		'video/quicktime',
		p
	);
}

function writeRealMedia(p) {
    writeEmbed(
		'CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA',
		'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0',
		'audio/x-pn-realaudio-plugin',
		p
	);
}

function writeWindowsMedia(p) {
    p.url = p.src;
    writeEmbed(
		'6BF52A52-394A-11D3-B153-00C04F79FAA6',
		'http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701',
		'application/x-mplayer2',
		p
	);
}

/*
function writeEmbed(cls, cb, mt, p) {
    var h = '', n;

    h += '<object classid="clsid:' + cls + '" codebase="' + cb + '"';
    h += typeof (p.id) != "undefined" ? 'id="' + p.id + '"' : '';
    h += typeof (p.name) != "undefined" ? 'name="' + p.name + '"' : '';
    h += typeof (p.width) != "undefined" ? 'width="' + p.width + '"' : '';
    h += typeof (p.height) != "undefined" ? 'height="' + p.height + '"' : '';
    h += typeof (p.align) != "undefined" ? 'align="' + p.align + '"' : '';
    h += '>';

    for (n in p)
        h += '<param name="' + n + '" value="' + p[n] + '">';

    h += '<embed type="' + mt + '"';

    for (n in p)
        h += n + '="' + p[n] + '" ';

    h += '></embed></object>';

    document.write(h);
}
*/

function writeEmbed(cls, cb, mt, p) {
    var playerSWF = '/Design/Scripts/FlvPlayer.swf';
    var h = '', n;
h += '<div id="flashcontent">\r\n';
h += '  <div>\r\n';
h += '      <p>Para visualizar correctamente este conte&uacute;do &quot;clique&quot; no bot&atilde;o em baixo e fa&ccedil;a download do &uacute;ltimo plug-in do Flash Player.</p>\r\n';
h += '      <p>Obrigado.</p>\r\n';
h += '  </div>\r\n';
h += '  <div><a href="http://www.adobe.com/go/getflashplayer/" target="_blank"><img src="images/get_adobe_flash_player.png" alt="get flash player"/></a></div>\r\n';
h += '</div>\r\n';
h += '<script type="text/javascript">\r\n';
h += 'var flashvars = {};\r\n';
//h += 'flashvars.imagePath= "' + p.src + '";\r\n';
h += 'flashvars.imagePath= "' + p.flashvars + '";\r\n';
h += 'flashvars.videoPath= "' + p.src + '";\r\n';
h += 'flashvars.autoStart= "false";\r\n';
h += 'flashvars.autoHide= "false";\r\n';
h += 'flashvars.autoHideTime= "5";\r\n';
h += 'flashvars.hideLogo= "true";\r\n';
h += 'flashvars.volAudio= "100";\r\n';

var width = typeof (p.width) != "undefined" ? p.width : '320';

h += 'flashvars.newWidth= "' + width + '";\r\n';

var height = typeof (p.height) != "undefined" ? p.height : '240';

h += 'flashvars.newHeight= "' + height + '";\r\n';
h += 'flashvars.disableMiddleButton= "false";\r\n';
h += 'flashvars.playSounds= "true";\r\n';
h += 'flashvars.soundBarColor= "0x0066FF";\r\n';
h += 'flashvars.barColor= "0x0066FF";\r\n';
h += 'flashvars.barShadowColor= "0x91BBFB";\r\n';
h += 'flashvars.subbarColor= "0xffffff";\r\n';
h += 'var params = {};\r\n';
h += 'params.allowfullscreen = "true";\r\n';
h += 'var attributes = {};\r\n';
h += 'swfobject.embedSWF("' + playerSWF + '", "flashcontent", "' + width + '", "' + height + '", "8", "", flashvars, params, attributes);\r\n';
h += '</script>\r\n';
h += '<noscript>Carregamento do elemento flash.</noscript>';
    document.write(h);
}

function writeVideo(cls, cb, mt, p) {
    var h = '', n;

    h += '<object classid="clsid:' + cls + '" codebase="' + cb + '"';
    h += typeof (p.id) != "undefined" ? 'id="' + p.id + '"' : '';
    h += typeof (p.name) != "undefined" ? 'name="' + p.name + '"' : '';
    h += typeof (p.width) != "undefined" ? 'width="' + p.width + '"' : '';
    h += typeof (p.height) != "undefined" ? 'height="' + p.height + '"' : '';
    h += typeof (p.align) != "undefined" ? 'align="' + p.align + '"' : '';
    h += '>';

    for (n in p)
        h += '<param name="' + n + '" value="' + p[n] + '">';

    h += '<embed type="' + mt + '"';

    for (n in p)
        h += n + '="' + p[n] + '" ';

    h += '></embed></object>';

    return h;
}
