
/*
	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 is_flash8 = false;
var is_flash9 = false;
var latestFlash = 9; // Edit this with a 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('is_flash8 = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.8"))) \n');
	document.write('is_flash9 = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.9"))) \n');
	document.write('</scr' + 'ipt\> \n');
}

function checkFlash(minVersion) {
	var ua = navigator.userAgent.toLowerCase();
	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.gecko = (ua.indexOf('gecko') > -1);
	this.webTV = (ua.indexOf('webtv') > -1);
	this.opera = (ua.indexOf('opera') > -1);
	
	var b = navigator.appName.toLowerCase();
	if (ua.indexOf('msie') > -1 && !this.webTV && !this.opera) { this.explorer = true; }
	if (ua.indexOf('mozilla') > -1 && !this.webTV && !this.opera && !this.explorer) { this.netscape = true; }
		
	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;
			is_flash8 = flashVersion == 8;
			is_flash9 = flashVersion >= 9;
		}
	}
	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.basePath = 'http://www.sacbee.com/static/live/ads';
	this.clkTgPfx = '&clickTag';
	this.xtraQS = '';
	
	this.altTxt = null;
	this.altTxt2 = '';
	
	this.minVer = 6;
	this.flashFile = '';
	this.ID = 'flashObj';
	this.width = '520';
	this.height = '30';
	this.quality = 'high';
	this.bgcolor = '#ffffff';
	this.scale = 'showall';
	this.menu = 'false';
	this.flashvars = '';
	this.wmode = 'opaque';
	this.scriptaccess = 'always';
	this.deviceFont = 'false';
	this.LiveConnect = 'false';
	this.cabVer = '6,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;
	this.create = create;
	parseQS();
}

function create() {
	document.write(this.render());
}

function parseQS() {
	var qs = unescape(location.search.substring(1));
	var tA = qs.split("&");
	var qsA = new Array();
	
	for (var i = 0; i < tA.length; i++) { 
		qsA[i] = tA[i].substring((tA[i].indexOf("=") + 1), tA[i].length);
	}
	
	PAGE = qsA[0];
	RAND = qsA[1];
	POS = qsA[2];
	CAMP = qsA[3];
	USER = qsA[4];
	
	redirPfx = 'http://ads.sacbee.com/RealMedia/ads/click_lx.ads/' + PAGE + '/' + RAND + '/' + POS + '/' + CAMP + '/empty';
	redirSfx = '.gif/' + USER;
}

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] + "=" + redirPfx + [i] + redirSfx;
	}
	if (this.minVer >= 6) {
		this.flashvars += clickTags;
		clickTags = '';
	}
	
	if (this.clkLength) 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.explorer || Ticket.netscape || Ticket.mac && ((Ticket.ie || Ticket.nn) >= 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 + this.xtraQS + '" /> \n';
			sCR += '<param name="wmode" value="' + this.wmode + '" /> \n';
			sCR += '<param name="allowScriptAccess" value="' + this.scriptaccess + '" />';
			if (this.menu != '') sCR += '<param name="menu" value="' + this.menu + '" /> \n';
			if (this.flashvars != '') sCR += '<param name="flashvars" value="' + this.flashvars + '" /> \n';
			if (this.quality != '') sCR += '<param name="quality" value="' + this.quality + '" /> \n';
			if (this.scale != '') sCR += '<param name="scale" value="' + this.scale + '" /> \n';
			if (this.bgcolor != '') sCR += '<param name="bgcolor" value="' + this.bgcolor + '" /> \n';
			if (this.devicefont != '') sCR += '<param name="devicefont" value="' + this.devicefont	+ '" /> \n';
			sCR += '<embed id="' + this.ID + '" width="' + this.width + '" height="' + this.height + '" src="' + swfSrc + clickTags + this.xtraQS + '" ';
			sCR += 'wmode="' + this.wmode + '" ';
			sCR += 'allowScriptAccess="' + this.scriptaccess + '" ';
			if (this.menu != '') sCR += 'menu="' + this.menu + '" ';
			if (this.flashvars != '') sCR += 'flashvars="' + this.flashvars + '" ';			
			if (this.quality != '') sCR += 'quality="' + this.quality + '" ';
			if (this.scale != '') sCR += 'scale="' + this.scale + '" ';
			if (this.bgcolor != '') sCR += 'bgcolor="' + this.bgcolor + '" ';
			if (this.deviceFont != '') sCR += 'devicefont="' + this.deviceFont + '" ';
			if (this.LiveConnect != '') sCR += 'swliveconnect="' + this.LiveConnect + '" ';
			sCR += 'type="' + this.type + '" pluginspage="' + this.pluginsPage + '"></embed>';
			sCR += '</object>\n';
		}
		else {
			if (this.imgAlt) {
				sCR = this.imgAlt;
			}
			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 = this.imgAlt;
		}
		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;
}
