var h_a = h_a;
h_a = h_a?h_a:'right';
var v_a = v_a;
v_a = v_a?v_a:'bottom';
var p = p;
p = p?p:'absolute';

var x_o = x_o;
x_o = x_o?x_o:0;
var y_o = y_o;
y_o = y_o?y_o:0;

var w = w;
w = w?w:640;
var h = h;
h = h?h:360;

var get_flash = get_flash;
if (get_flash==undefined) get_flash = true;

var is_ie = /msie/.test(navigator.userAgent.toLowerCase());

if (is_ie) window.attachEvent('onload',loaded);
else window.addEventListener('load',loaded,false);

var div;

function get(v) {
	return(top[v]);
}

function ie_get_flash() {
	
	var version = 0;
	
	for (i=1; i<=20; i++) {
		try {
			var obj= new ActiveXObject('ShockwaveFlash.ShockwaveFlash.'+i);
			version = obj.GetVariable('$version');
		} catch (e) {
		}
	}
	
	if (version != 0) {
		var _a = version.split(' ')[1].split(',');
		version = _a[0]+'.'+_a[1]+'.'+_a[2];
	}
	
	return version;
}

function ns_get_flash() {
	
	var version = 0;
	
	if (navigator.plugins['Shockwave Flash']) {
		var _s = navigator.plugins['Shockwave Flash'].description.split(' ');
		var _ms = _s[3].split('r');
		version = _s[2]+'.'+_ms[1];
	}
	
	return version;
}


function get_flash_v() {
	
	var _str = is_ie?ie_get_flash():ns_get_flash();
	
	var version = { major:0, minor:0, revision:0 };
	if (_str != 0) {
		_s = _str.split('.');
		version = { major:parseInt(_s[0]),minor:parseInt(_s[1]),revision:parseInt(_s[2]) };
	}
	
	return version;
}

var req_flash = 9;
var flash_good = get_flash_v().major >= req_flash;

function loaded() {
	
	div = document.getElementById('spokesperson');
	
	if (flash_good) {
		
		/*div.style.width = w+'px';
		div.style.height = 48+'px';
		div.style.overflow = 'auto';*/
		doFlash({id:'spokesperson',file:'http://www.addaspokesperson.com/members/deploy/vbeta/spokesperson.swf',w:w,h:h,allowscriptaccess:'always',swliveconnect:'true',wmode:'transparent',loop:'false',quality:'high',MV:9,flashVars:vars});
	} else if (get_flash) {
		div.style.backgroundColor = '#ffffff';
		div.style.border = '1px solid #000000';
		div.style.fontFamily = 'Verdana, Arial, Helvetica, sans-serif';
		div.style.fontSize = '12px';
		var _htm = '<table cellpadding="0" cellspacing="0" border="0" style="padding:10px; text-align=center">';
		_htm += '<tr><td>Flash Player version 9 is required to view content on this page.</td></tr>';
		_htm += '<tr><td style="padding:10px 0px"><a href="http://www.adobe.com/go/getflashplayer" target="_blank"><img src="http://www.addaspokesperson.com/video/shared/get_flash_player.gif" width="88" height="31" border="0" /></a></td></tr>';
		_htm += '<tr><td><a href="http://www.adobe.com/go/getflashplayer" target="_blank">Click here</a> to download and install the software.</td></tr>';
		_htm += '</table>';
		div.innerHTML = _htm;
		x_o = h_a=='left'?10:(h_a=='center'?0:-10);
		y_o = v_a=='top'?10:(v_a=='middle'?0:-10);
	}
	
	if (is_ie) {
		div.style.position = 'absolute';
		if (p=='relative') {
			if (v_a=='middle') div.style.top = Math.round((div.parentNode.clientHeight-div.clientHeight)/2)+'px';
			else div.style[v_a] = y_o+'px';
			if (h_a=='center') div.style.left = Math.round((div.parentNode.clientWidth-div.clientWidth)/2)+'px';
			else div.style[h_a] = x_o+'px';
		} else {
			window.attachEvent('onresize',move_it);
			window.attachEvent('onscroll',move_it);
			move_it();
		}
	} else {
		div.style.position = p=='absolute'?'fixed':'absolute';
		if (h_a=='center') {
			if (p=='relative') div.style.left = Math.round((div.parentNode.clientWidth-div.clientWidth)/2)+'px';
			else {
				window.addEventListener('resize',c_h_moz,false);
				c_h_moz();
			}
		} else div.style[h_a] = x_o+'px';
		
		if (v_a=='middle') {
			if (p=='relative') div.style.top = Math.round((div.parentNode.clientHeight-div.clientHeight)/2)+'px';
			else {
				window.addEventListener('resize',c_v_moz,false);
				c_v_moz();
			}
		} else div.style[v_a] = y_o+'px';
	}
}

function c_h_moz() {
	div.style.left = Math.round((window.innerWidth-div.clientWidth)/2)+'px';
}

function c_v_moz() {
	div.style.top = Math.round((window.innerHeight-div.clientHeight)/2)+'px';
}

function move_it() {
	
	var mode = document.firstChild.tagName=='!'?!document.compatMode=='CSS1Compat':true;
	var _ts = mode?document.body.scrollTop:document.documentElement.scrollTop;
	var _h = mode?document.body.clientHeight:document.documentElement.clientHeight;
	var _ls = mode?document.body.scrollLeft:document.documentElement.scrollLeft;
	var _w = mode?document.body.clientWidth:document.documentElement.clientWidth;
	var b_o_v = div.parentNode.offsetTop;
	var b_o_h = div.parentNode.offsetLeft;
		
	switch (v_a) {
		case 'top': div.style.top = (_ts+x_o-b_o_v)+'px'; break;
		case 'middle': div.style.top = (_ts+Math.round((_h-div.clientHeight)/2)-b_o_v+y_o)+'px'; break;
		case 'bottom': div.style.top = (_ts+_h-div.clientHeight-b_o_v+y_o)+'px'; break;
	}
	
	switch (h_a) {
		case 'left': div.style.left = (x_o+b_o_h)+'px'; break;
		case 'center': div.style.left = (Math.round((_w-div.clientWidth)/2)-b_o_h+x_o)+'px'; break;
		case 'right': div.style.left = (_ls+_w-div.clientWidth-b_o_h+x_o)+'px'; break;
	}
}

function close_flash() {
	div.style.display = 'none';
}

function isSpecial(tag,param) {
	var result = false;
	switch(param) {
		case 'w':
		case 'h':
		case 'id':
		case 'top':
		case 'left':
		case 'bottom':
		case 'right':
		case 'file':
		case 'MV':
		case 'mV':
		case 'rV':
		case 'bV':
			result = true;
			break;
	}
	if ((tag == 'object') && (param == 'swliveconnect')) {
		result = true;
	}
	return result;
}

function doFlash(args) {
		
	var info = navigator.userAgent.toLowerCase();
	var isGecko = /gecko/.test(info) && !/applewebkit/.test(info);
	var isActiveX = (/msie/.test(info) && !/opera/.test(info)) && /windows/.test(info);
	
	var flashName = args.id+'_swf';
		
	if (!isActiveX) {
		if (isGecko) {
			while (div.hasChildNodes()) {
				div.removeChild(div.firstChild);
			}
			
			var obj = document.createElement('object');
			obj.setAttribute('type','application/x-shockwave-flash');
			obj.setAttribute('data',args.file);
			obj.setAttribute('width',args.w);
			obj.setAttribute('height',args.h);
			obj.setAttribute('id',flashName);
			
			var param;
			
			for (var i in args) {
				if (!isSpecial('object',i)) {
					param = document.createElement('param');
					param.setAttribute('name',i);
					param.setAttribute('value',args[i]);
					obj.appendChild(param);
				}
			}
			
			div.appendChild(obj);
		}
		else {
			var attr = '';
			for (var i in args) {
				if (!isSpecial('embed',i)) {
					attr += ' '+i+'="'+args[i]+'"';
				}
			}
			div.innerHTML = '<embed src="'+args.file+'" name="'+flashName+'" width="'+args.w+'" height="'+args.h+'"'+attr+' type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>';
		}
	}
	else {
		var _params = '';
		for (var i in args) {
			if (!isSpecial('object',i)) {
				_params += '<param name="'+i+'" value="'+args[i]+'"></param>';
			}
		}
		var version = args.MV+','+(args.mV?args.mV:0)+','+(args.rV?args.rV:0)+','+(args.bV?args.bV:0);
		div.innerHTML = '<object id="'+flashName+'" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version='+version+'" width="'+args.w+'" height="'+args.h+'" /><param name="movie" value="'+args.file+'"></param>'+_params+'</object>';
	}	
}

function get_htm() {
	
	return /^http:\/\/(.*)$/.exec(location.href)[1];
}