
/*
	FLA.headerGen v.1.0

	Written by Design Technologist
		- Seth Van Booven [svanbooven@sacbee.com]

	Copyright © The Sacramento Bee
	Created: July 01, 2001 (sv)  /  Last update: 07/01/01 (sv)

	FLA.Detect concepts and ideas originated from the Flash Pimp
		- Colin Moock [colin_moock@iceinc.com]
		  	and his moock fpi [f.lash p.layer i.nspector]
			http://www.moock.org/webdesign/flash/detection/moockfpi/

			Get his book if you want to learn ActionScript...
			ActionScript: The Definative Guide
			http://www.moock.org/asdg/

	FLA.Obj concepts and ideas originated from the Head Bangerz
		- http://www.espn.com

	****************************************************
		IF YOU DON'T KNOW WHAT YOU ARE DOING
		THEN YOU DON'T BELONG HERE.
		.........................CLOSE IMMEDIATELY!
	****************************************************
------------------------------------------------------------*/

var is_flash     = false;
var is_flash2    = false;
var is_flash3    = false;
var is_flash4    = false;
var is_flash5    = false;
var is_flash6    = false;
var is_flash7    = false;
var latestFlash  = 7; // Edit this with the new release of Flash
var clientFlash  = 0;

var isIE  = (navigator.appVersion.indexOf('MSIE')    != -1) ? true : false;
var isWin = (navigator.appVersion.indexOf('Windows') != -1) ? true : false;

if(isIE && isWin)
{
	document.write('<scr' + 'ipt language="vbscript"\> \n');
	document.write('on error resume next \n');
	document.write('is_flash2 = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.2"))) \n');
	document.write('is_flash3 = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.3"))) \n');
	document.write('is_flash4 = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.4"))) \n');
	document.write('is_flash5 = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.5"))) \n');
	document.write('is_flash6 = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.6"))) \n');
	document.write('is_flash7 = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.7"))) \n');
	document.write('</scr' + 'ipt\> \n');
}

function checkFlash(minVersion)
{
	var ua = navigator.userAgent.toLowerCase();
	this.webTV  = (ua.indexOf('webtv') > -1);
	this.ie     = (parseFloat(ua.slice(ua.indexOf('msie') + 5)));
	this.nn     = (parseFloat(ua.slice(ua.indexOf('mozilla/') + 8)));
	this.mac    = (ua.indexOf('mac') > -1);
	this.flash  = false;
	this.swfVer = false;
	
	if (navigator.plugins)
	{
		if (navigator.plugins['Shockwave Flash 2.0'] || navigator.plugins['Shockwave Flash'])
		{
			var isVersion2 = navigator.plugins['Shockwave Flash 2.0'] ? ' 2.0' : '';
			var flashDescription = navigator.plugins['Shockwave Flash' + isVersion2].description;
			var flashVersion = parseInt(flashDescription.charAt(flashDescription.indexOf('.') - 1));
			is_flash2 = flashVersion == 2;
			is_flash3 = flashVersion == 3;
			is_flash4 = flashVersion == 4;
			is_flash5 = flashVersion == 5;
			is_flash6 = flashVersion == 6;
			is_flash7 = flashVersion >= 7;
		}
	}
	for (var i = 2; i <= latestFlash; i++) if (eval('is_flash' + i) == true) clientFlash = i;
	
	if (clientFlash >= minVersion) 
	{
		this.flash = true;
		if (clientFlash >= 5) this.swfVer = true;
	}
}

function flashObj() 
{
	this.clkLength      = null;
	this.client         = '';
	this.campaign       = '';
	this.imgAlt         = null;
	this.imgTrg         = '_blank';
	this.imgType        = 'gif'; // gif or jpg // lowercase only
	
	this.basePath       = 'http://www.sacbee.com/static/live/ads';
	this.clkTgPfx       = '&clickTag';
	this.redirPfx       = 'http://ads.nandomedia.com/RealMedia/ads/click_lx.ads/%%PAGE%%/%%RAND%%/%%POS%%/%%CAMP%%/empty';
	this.redirSfx       = '.gif/%%USER%%';
	
	this.altTxt			= null;
	this.altTxt2		= '';
	
	this.minVer			= 4;
	this.flashFile      = '';
	this.ID				= 'flashObj';
	this.width			= '520';
	this.height			= '30';
	this.quality		= 'high';
	this.bgcolor        = '#ffffff';
	this.scale			= 'showall';
	this.menu			= 'false';
	this.wmode			= 'opaque';
	this.deviceFont		= 'false';
	this.LiveConnect	= 'false';
	this.cabVer			= '4,0,0,0';
	this.codeBase		= 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=';
	this.pluginsPage	= 'http://www.macromedia.com/go/getflashplayer';
	this.type			= 'application/x-shockwave-flash';
	this.DenyIEdl		= 'false';
	this.render			= writeOutput;
} 

function writeOutput() 
{
	var Ticket = new checkFlash(this.minVer);
	var sCR, imgURL, imgSrc, swfSrc;
	var clickTags = '';
	
	for (i = 1; i <= this.clkLength; i++)
	{
		clickTags += this.clkTgPfx + [i] + "=" + this.redirPfx + [i] + this.redirSfx;
	}
	
	if (this.clkLength)
	{
		imgURL = this.redirPfx + "0"  + this.redirSfx;
		imgSrc = this.redirPfx + "00" + this.redirSfx;
		swfSrc = this.basePath + "/"  + this.client + "/" + this.client + "_" + this.width + "x" + this.height + "_" + this.campaign + this.flashFile + "?";
	}
	else 
	{
		swfSrc = this.flashFile;
	}
	
	if (Ticket.flash) 
	{
		if (Ticket.mac || Ticket.nn || this.DenyIEdl != 'false') 
		{
			sCR = '<embed src="' + swfSrc + clickTags + '" id="' + this.ID + '" width="' + this.width + '" height="' + this.height + '" quality="' + this.quality + '" bgcolor="' + this.bgcolor + '" scale="' + this.scale + '" menu="' + this.menu + '" devicefont="' + this.deviceFont + '" swliveconnect="' + this.LiveConnect + '" type="' + this.type + '" pluginspage="' + this.pluginsPage + '"></embed>';
		}
		else if (Ticket.ie >= 4) 
		{
			sCR =  '<object id="' + this.ID + '" width="' + this.width + '" height="' + this.height + '" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="' + this.codeBase + this.cabVer + '"> \n';
			sCR += '<param name="movie"   value="' + swfSrc + clickTags + '" /> \n';
			sCR += '<param name="quality" value="' + this.quality	+ '" /> \n';
			sCR += '<param name="bgcolor" value="' + this.bgcolor	+ '" /> \n';
			sCR += '<param name="scale"   value="' + this.scale		+ '" /> \n';
			sCR += '<param name="menu"    value="' + this.menu		+ '" /> \n';
			sCR += '<param name="wmode"   value="' + this.wmode		+ '" /> \n';
			sCR += '<param name="devicefont" value="' + this.devicefont	+ '" /> \n';
			sCR += '</object>\n';
		} 
		else if (Ticket.webTV) 
		{
			sCR = '<embed src="' + swfSrc + clickTags + '" id="' + this.ID + '" width="' + this.width + '" height="' + this.height + '" quality="' + this.quality + '" bgcolor="' + this.bgcolor + '" scale="' + this.scale + '" menu="' + this.menu + '" devicefont="' + this.deviceFont + '" swliveconnect="true" type="' + this.type + '" pluginspage="' + this.pluginsPage + '"></embed>';
		}
		else 
		{
			if (this.imgAlt)
			{
				sCR = '<a href="' + imgURL + '" target="' + this.imgTrg + '"><img src="' + imgSrc + '" alt=" ' + this.imgAlt + ' " width="' + this.width + '" height="' + this.height + '" border="0" /></a>';
			}
			else if (this.altTxt)
			{
				var filter = /\+/g;
				this.altTxt  = this.altTxt.replace(filter, " ");
				this.altTxt2 = this.altTxt2.replace(filter, " ");
				sCR = '<span class="sHead">' + this.altTxt + '</span>&nbsp;<span class="sHeadSub">' + this.altTxt2 + '</span>';
			} 
			else sCR = '';
		}
	} 
	else 
	{
		if (this.imgAlt)
		{
			sCR = '<a href="' + imgURL + '" target="' + this.imgTrg + '"><img src="' + imgSrc + '" alt=" ' + this.imgAlt + ' " width="' + this.width + '" height="' + this.height + '" border="0" /></a>';
		}
		else if (this.altTxt)
		{
			var filter = /\+/g;
			this.altTxt  = this.altTxt.replace(filter, " ");
			this.altTxt2 = this.altTxt2.replace(filter, " ");
			sCR = '<span class="sHead">' + this.altTxt + '</span>&nbsp;<span class="sHeadSub">' + this.altTxt2 + '</span>';
		} 
		else sCR = '';
	}
	return sCR;
}