var current_domain = (document.location.hostname.test('ford.com','i')) ? 'ford' : 'dev';
var abUrl = document.location.href;
var abTest = '';


// --------- A/B Test -------- //
function testA() {
	Metrics.setMultivariate("testA");
	abTest = 'testA';
	return;
}

function testB() {
	abUrl = '/js/index_ab.htm';
	abTest = 'testB';
	return;
}


// --------- Metrics --------- //
var Metrics = {
	initialize: function() {
		/* Error Page*/
		if(document.title.indexOf("Page Not Found")>-1){
			s.pageType="errorPage";
			s.pageName=s.pageName+": "+document.location;
		}
		s.hier1=(s.hier1!="")?s.hier1:s.channel;
		this.modKPI();
		this.shortenTags();
		this.h2Types={fv:"brands,ford vehicles",ln:"brands,lincoln",my:"brands,mercury",mz:"brands,mazda",mzes:"brands,mazda",vv:"brands,volvo",fves:"brands,ford vehicles",ps:"services,parts and services",f:"services,financing",a:"services,accessories",d:"services,dealers",cpo:"services,certified pre owned",fl:"services,fleet",ct:"services,commercial trucks",mm:"services,mobility motoring",r:"community,racing",b:"community,blogs"};
		this.linkNameTypes={BrandBar:"brand bar",fordLatinoBrands:"latino brand bar",GlobalLinks:"top navigation",Inside:"inside our site",content_area:"content area",article_contents:"article contents",related_content:"related content",global_promo:"global promo",locate_dealer_mod:"dealer locator",schedule_maint_mod:"schedule maintenance",finance_apply:"finance apply",finance_estimatepay:"finance estimate payments",finance_access:"finance access your account",check_vehicle_status_mod: "check vehicle status",find_next_module:"find next vehicle"};
		this.onClickTypes = {tool_print: "print",tool_subs:"subscribe"};
		this.urls = { fv:"fordvehicles",fves:"fordenespanol",ln:"lincoln",my:"mercuryvehicles",mz:"mazdausa",mzes:"mazdaespanol",vv:"volvocars" };

	},
	setOnClicks: function(){
	for(var name in this.onClickTypes){
			var obj=$(name.replace("_","-"));
			if (obj!=undefined&&obj!=false){ 
				var linkName=this.onClickTypes[name];
				//obj.addEvent('click', function() {this.sendOnClick($(name.replace("_","-")),this.onClickTypes[name]);}.bind(this));
				obj.addEvent('click', function() {this.sendOnClick(obj,linkName);}.bind(this));
			}
		} // end for
		/*
		for(var name in this.onClickTypes)
		{
			function bla(n)
			{ //inside this loop, use 'n' instead of 'name'
				alert("INSIDE function(n)");
				var obj=$(n.replace("_","-"));
				if (obj)
				{
					alert("INSIDE (obj)");
					obj.addEvent('click', function() {this.sendOnClick(obj, this.onClickTypes[n]);}.bind(this));
					alert("FINISHED obj.addEvent");
				}
				alert("OUT OF if (obj)");
			}
			alert("OUT OF function(n)");
			
			bla(name);
		} */
		
		// end for
		$$("a").each(function(el){
			for (var brnd_name in this.urls) {
				// test which domain it is
				if (el.href.test(".us") == true) {
					var domain_suffix = ".us";
				} else {
					var domain_suffix = ".com";
				}
				var host=el.href.substring(el.href.indexOf('//'),el.href.indexOf(domain_suffix));
				//add referrer for non-volvo site exit links - REMOVED 1/7/2008 - NOT NEEDED
				//REFERRER SENT IN HEADER, EXCEPT FOR IE6 DOCUMENT.LOCATION.HREF, WHICH IS ONLY USED BY US IN JS WIDGETS AND WON'T BE AFFECTED BY THIS
/*				if (host.test(this.urls[brnd_name]) == true && (host.indexOf('volvo') < 0)) {
					el.href=el.href+((el.href.indexOf("?")>-1)?"&":"?")+"referrer=www%2Eford%2Ecom";
					break;
				}
*/				
				//add glbcmp for FLM site exit links
				if (host.test(this.urls[brnd_name]) == true && (host.indexOf('ford') > -1 || host.indexOf('lincoln') > -1 || host.indexOf('mercury') > -1)) {
					el.href=el.href+((el.href.indexOf("?")>-1)?"&":"?")+"glbcmp=ford|"+s.channel+"|"+this.urls[brnd_name];
					break;
				}
			}  // end for in			  
		}.bind(this));
		$$("dl.related dd a").each(function(el){
			if (el.firstChild.nodeType == 3) {
				el.addEvent('click', function() {this.sendOnClick(el,"tag: "+el.firstChild.nodeValue);}.bind(this));
			}
		}.bind(this));
		$$("#rss-subs a").each(function(el){
			el.addEvent('click', function() {this.sendOnClick(el,"rss feed: "+el.href.substring(el.href.indexOf("tag")));}.bind(this));							
		}.bind(this));
		$$(".latest a").each(function(el){
			if(el.click== undefined){
				if(el.href.indexOf(".ford.com")>-1){
					el.addEvent('click', function() {this.localLink(el);}.bind(this));	
				}
				else{
					el.addEvent('click', function() {this.exitLink(el);}.bind(this));	
				}
			}
		}.bind(this));
	},
	exitLink: function(_obj,_h2Type,_url,_tags) {		
		var h2Prefix=(_h2Type!=null&&this.h2Types[_h2Type]!=undefined)?this.h2Types[_h2Type]:"other";
		if (h2Prefix.indexOf("brands")<0&&h2Prefix.indexOf("services")<0) h2Prefix="other"; 
		h2Prefix = h2Prefix.toLowerCase();
		
		var linkParent = _obj;
		
		var url = _obj.href!=null?_obj.href:(_url!=undefined?_url:"");

		var linkArray    = this.getLinkName(linkParent);
		var linkName     = linkArray[0];
		var linkNameType = linkArray[1];
		
		this.s=s_gi(s_account);
		this.s.linkTrackVars="prop1,prop4,prop5,hier2,eVar1,events";
		this.s.linkTrackEvents="event4";
		this.s.events="event4";
		this.s.eVar1=h2Prefix;
		
		//this.s.hier2=h2Prefix+linkNameType+","+s.hier1+","+url;
		
		var h2Temp = "";
		
		var urlArray = url.split('?');
		
		var h2PrefixSwitch = (h2Prefix!="other") ? h2Prefix.slice(0, h2Prefix.indexOf(",")) : h2Prefix;
		h2PrefixSwitch = h2PrefixSwitch.toLowerCase();
		//keep for future switch to < delimiter
		//var h2PrefixDelimited = h2Prefix.split(",").join("<");
		
		var pageNameFix = (s.pageName.indexOf(",")) ? s.pageName.split(",").join("") : s.pageName;
		
		if (s.channel=='showroom') h2PrefixSwitch="showroom";
		if (s.channel=='ford-global') h2PrefixSwitch="ford-global";
		
		urlArray[1] = (urlArray[1]) ? urlArray[1] : "";
		
		switch (h2PrefixSwitch) {
			case "brands":
				h2Temp=h2Prefix+","+urlArray[0]+","+s.channel+","+pageNameFix+","+linkNameType+","+urlArray[1];
				break;
			case "services":
				h2Temp=h2PrefixSwitch+","+urlArray[0]+","+s.channel+","+pageNameFix+","+linkNameType+","+urlArray[1];
				break;
			case "showroom":
				h2Temp=h2Prefix+","+s.channel+","+urlArray[0]+","+pageNameFix+","+linkNameType+","+urlArray[1];
				break;
			case "ford-global":
				h2Temp=h2PrefixSwitch+","+url;
				break;
			default:
				h2Temp=h2PrefixSwitch+","+urlArray[0]+","+s.channel+","+pageNameFix+","+","+linkNameType+urlArray[1];
				break;
		}
		if (h2Temp.indexOf(",,")) h2Temp = h2Temp.split(",,").join(",");
		if (h2Temp.lastIndexOf(",") == h2Temp.length-1) h2Temp = h2Temp.slice(0,h2Temp.length-1);
		
		//keep for future switch to < delimiter
		/*if (h2Temp.indexOf("<,")) { 
			h2Temp = h2Temp.split("<,").join("<");
		}*/
		
		this.s.hier2 = h2Temp;
		
		this.s.prop4 = (_tags!=null)? "link: " +_tags.toLowerCase():"";
		this.s.prop1=s.pageName;
			
		linkName = (_obj.flash)?   "flash: "+"exit link: "+linkName+url   :   "exit link: "+this.getGrid(_obj)+linkName+": "+url;
		this.s.prop5="ford: "+linkName;
		var lt=_obj.href!=null?this.s.lt(_obj.href):"";
		if (_obj.href == undefined) { _obj = '';}
		if (lt=="" || _obj.flash) { this.s.tl(_obj,"e",linkName+": " + url); }


	},
	localLink: function(_obj,_tags){
		this.s=s_gi(s_account);
		var url = _obj.href!=null?_obj.href:"";
		var linkName = "local link: " + this.getGrid(_obj)+": "+url;
		linkName = (_obj.flash)?"flash: "+linkName:linkName;
		this.s.prop4 = (_tags!=null)? "link: " +_tags.toLowerCase():"";
		this.s.prop1=s.pageName;
		this.s.prop5="ford: "+linkName;
		this.s.linkTrackVars="prop1,prop4,prop5"; 
		this.s.linkTrackEvents="None";
		this.s.tl(_obj,"o",linkName);
	},
	flashLink: function(_url,_tags){
		var obj={"href":_url,"flash":true};
		var brandName=this.getBrandName(_url);
		if (brandName==""){
			this.localLink(obj,_tags);
		}
		else{
			this.exitLink(obj,brandName,_url,_tags);
		}
	},
	sendOnClick: function(_obj,_linkName){
		this.s=s_gi(s_account);
		this.s.prop1=s.pageName;
		this.s.prop5="ford: "+_linkName;
		this.s.linkTrackVars="prop1,prop4,prop5"; 
		this.s.linkTrackEvents="None";
		this.s.tl(_obj,"o",_linkName+": "+s.pageName);
	},
	sendLead: function(_obj,_linkName){
		this.s=s_gi(s_account);
		this.s.prop1=s.pageName;
		this.s.prop5="ford: "+_linkName
		this.s.eVar28=this.s.prop5;
		this.s.prop18=this.s.prop5;
		this.s.evnets="event10";
		this.s.linkTrackVars="prop1,prop5,eVar28,prop18,events"; 
		this.s.linkTrackEvents="event10";
		this.s.tl(_obj,"o",_linkName);
	},
	getHier2: function(_h2Type) {
		fh2Prefix = (_h2Type!=null&&this.h2Types[_h2Type]!=undefined)?this.h2Types[_h2Type]:"other";
		fh2Prefix = fh2Prefix.toLowerCase();
		return fh2Prefix;	
	}, // end getHier2
	getHier2Url: function(url) {
		var brandName = this.getBrandName(url);
		var hier2 = '';

		if (brandName.length > 1) {
			hier2 = this.getHier2(brandName);
		} // end if final_result

		return hier2;
	},
	getBrandName: function(_url){
		var brandName = ""
		for (var brnd_name in this.urls) {
			if (_url.indexOf(this.urls[brnd_name]) > -1) {
				brandName = brnd_name;
				break;
			}
		} 
		return brandName
	},
	getLinkName:  function(linkParent) {
		var resultLinkName = '';
		var resultLinkNameType = '';

		for(var i=0; i<4 ; i++){
			if (linkParent != undefined && linkParent.id != undefined && linkParent.id != '' && linkParent.id != 'null') {
				linkNameTypetmp = this.linkNameTypes[linkParent.id.replace("-","_")];
				if(linkNameTypetmp != undefined && linkNameTypetmp != ''){
					resultLinkName=linkNameTypetmp;
					resultLinkNameType=","+linkNameTypetmp;
					break;
				}
			} // end if no id
			if (linkParent.parentNode != undefined) {
				linkParent=linkParent.parentNode;
			}
		}
		var linkArray =  new Array(resultLinkName,resultLinkNameType);
		return linkArray;
	}, // end getLinkName()
	// modify s.channel for KPI analysis
	modKPI: function() {
		     if (s.hier1.test('about-ford,company-information')) {
			s.channel = 'company-information';
		}
		else if (s.hier1.test('about-ford,investor-relations')) {
			s.channel = 'investor-relations';
		}
		else if (s.hier1.test('about-ford,careers')) {
			s.channel = 'careers';
		}
		else if (s.hier1.test('about-ford,heritage')) {
			s.channel = 'heritage';
		}
		else if (s.hier1.test('about-ford,news-announcements')) {
			s.channel = 'news-announcements';
			// for featured articles
			if (s.hier1.test('featured-stories,featured-stories-detail')) {
				s.pageName="ford: featured story: "+document.title;
			} // featured articles
		}
	}, // end modKPI()
	shortenTags: function(){
		var t=s.prop4
		var t_arr=t.split(",");
		var newt="";
		for(var i=0; i<t_arr.length;i++){
			var tag=t_arr[i].substr(0,t_arr[i].indexOf("|"))
			tag = tag.length<4?tag:tag.substr(0,3)+tag.length;
			var rank=t_arr[i].substr(t_arr[i].indexOf("|"))
			newt=i==0?tag+rank:newt+","+tag+rank;
		}
		s.prop4=newt;
	},
	getGrid: function (_obj) {
		var featureRowObj = _obj.getParent()
		var featureChild = _obj;
		for( var i=0; i<4; i++){
			if(featureRowObj.hasClass("feature-row"))
				break;	
			featureChild = featureRowObj;
			featureRowObj = featureRowObj.getParent()
		}
		if (featureRowObj.hasClass("feature-row"))  {
				//counts the number of .feature-row's that are previous to clicked one
				
				var sibling = featureRowObj.getPrevious();
				var rowNo=1;
				while(sibling && sibling.hasClass("feature-row")){
					rowNo++;
					sibling = sibling.getPrevious();	
				}
				//if .feature-row is a child of #right-rail set the col to 3
				var latest =""
				if (featureRowObj.getParent().getProperty("id")=="right-rail"){
					colNo = "3";
					var latestObj = _obj;
					for( var l=0; l<4; l++){
						if(featureRowObj.hasClass("latest")){
							latest=": latest";
							break;
						}
						latestObj = latestObj.getParent()
					}
				}
				else
				//if .feature-row is a child of left-feature or right feature, ser col to 1 or 2 respectively
				switch(featureChild.getProperty("class"))
				{
					case 'left-feature' : var colNo = "1"; break;
					case 'right-feature' : var colNo = "2"; break;
					default : var colNo = "1_2";
				}
				return "r"+rowNo+"c"+colNo+latest;
			}
		else return "";
	},
	videoPlayOnClick: function(_obj,_videoName){
		this.s=s_gi(s_account);
		this.s.prop1=s.pageName;
		this.s.prop5="ford: video play "+_videoName;
		this.s.prop6="ford: "+_videoName;
		this.s.linkTrackVars="prop1,prop5,prop6"; 
		this.s.linkTrackEvents="None";
		this.s.tl(_obj,"o"," video play"+_videoName+": "+s.pageName);
	},
	articleView: function(articleID){
	}
}

// --------- Flash Replacement ------- //
// some global variables for flash window sizing
var swf_minwidth = 0;
var swf_minheight = 0;
var swf_width = 0;
var swf_height = 0;
var swf_block_id = '';

var SWFWrite = {

	/**
	* @param String FLASHNAME the page name for the flash to load
	*/
	initialize: function(FLASHNAME) {
		this.flMarker = Cookie.get('nflc');
		this.section = '';
		this.page_url = document.location.href;
		this.refUrl = document.referrer;
		this.default_path = (current_domain == 'ford') ? '/':'';
		// see which section we are writing our swf into
		if (FLASHNAME.length > 1) {
			this.setPage(FLASHNAME);
		}
		//this.loadFlash =  (document.location.href.indexOf("flash=false")>-1)?false:true;
		if (this.page_url.indexOf('flash=false')>-1 || this.refUrl.indexOf('flash=false')>-1 || (this.flMarker == 'flashoff' && this.page_url.indexOf('flash=true')<0)) {
			Cookie.set('nflc', 'flashoff', {duration:false, path:"/"});
			this.loadFlash = false;
		} else if (this.page_url.indexOf('flash=true')>-1) {
			Cookie.set('nflc', 'flashon', {duration:false, path:"/"});
			this.loadFlash = true;
		} else {
			this.loadFlash = true;
		}
		 
		this.checkSection();
		this.flashLoaded = false;
	}, // end initialize()
	setPage: function(FLASHNAME) {
		if (FLASHNAME.length > 1) {
			this.flashName = FLASHNAME;
		} // end if length
	}, // end setPage()
	// debug
	debug: function(url) {
		this.page_url = url;
	}, // end debug()
	checkConnection: function(){
		if(this.flashLoaded==false && this.loadFlash==true){
			this.loadFlash = false;
			document.location = document.location.href+((document.location.href.indexOf("?")>-1)?"&":"?")+"flash=false";
		}
		clearTimeout(this.t);
	},

	flashLoad: function(bool) {
		this.flashLoaded = bool;
	}, // end flashLoad()

	flashTimerStop: function() {
		clearTimeout(this.t);
	},

	/*flashTimerStart: function() {
		if (this.page_url.test('home') || document.location.pathname == '/') {
			this.t=setTimeout("SWFWrite.checkConnection()",25000);
		}
	},*/

	checkSection: function() {
		// test to see which section it is
		if (this.flashName == 'careers') {
			this.section      = 'about-ford';
			this.block_id     = 'career-opps';
			this.swf_url      = this.default_path + 'swf/career_opps_feature.swf';
			this.swf_name     = 'careers';
			this.swf_width    = '515';
			this.swf_height   = '214';
			this.swf_player   = '9.0.45';
			this.swf_bgcolor  = '#FFFFFF';
			this.page_bgcolor = '#255788';
			this.page_bgImage = 'images/body-bg.jpg';
			this.s_account    = s_account;
			this.flashLoaded = true;
		}
		if (this.flashName == 'owning') {
			this.section      = 'owner-services';
			this.block_id     = 'owner-feature';
			this.swf_url      = this.default_path + 'swf/owner_feature.swf';
			this.swf_name     = 'owning';
			this.swf_width    = '514';
			this.swf_height   = '241';
			this.swf_player   = '8';
			this.swf_bgcolor  = '#FFFFFF';
			this.page_bgcolor = '#255788';
			this.page_bgImage = 'images/body-bg.jpg';
			this.s_account    = s_account;
			//this.oas_url      = this.default_path + 'swf/OmnitureActionSource.swf';
			this.flashLoaded = true;
		}
		if (this.flashName == 'global') {
			this.section      = 'ford-global';
			this.block_id     = 'global-links';
			this.swf_url      = this.default_path + 'swf/global.swf';
			this.swf_name     = 'Global';
			this.swf_width    = '514';
			this.swf_height   = '300';
			this.swf_player   = '8';
			this.swf_bgcolor  = '#FFFFFF';
			this.page_bgcolor = '#255788';
			this.page_bgImage = 'images/body-bg.jpg';
			this.s_account    = s_account;
			this.oas_url      = this.default_path + 'swf/OmnitureActionSource.swf';
			this.flashLoaded = true;
		}
		if (this.flashName == 'showroom') {
			this.section      = 'showroom';
			this.block_id     = 'vehicles';
			this.swf_url      = this.default_path + 'swf/showroomContainer.swf';
			this.swf_name     = 'showroomSwf';
			this.swf_width    = '950';
			this.swf_height   = '770';
			this.swf_player   = '8';
			this.swf_bgcolor  = '#255788';
			this.page_bgcolor = '#255788';
			this.page_bgImage = 'images/body-bg.jpg';
			this.s_account    = s_account;
			this.oas_url      = this.default_path + 'swf/OmnitureActionSource.swf';
			this.flashLoaded = true;
		}
		/*if  (this.flashName == 'home') {
			this.section       = 'home';
			this.block_id      = 'home';
			this.swf_url       = this.default_path + 'swf/home.swf';
			this.swf_name      = 'Ford';
			this.swf_width     = '100%';
			this.swf_height    = '100%';
			this.swf_player    = '8';
			this.swf_bgcolor   = '#091632';
			this.page_bgcolor  = '#091632';
			this.page_bgImage  = '';
			this.add_div       = true;
			this.minWidth      = '950';
			this.minHeight     = '710';
			this.swf_minwidth  = this.minWidth;
			this.swf_minheight = this.minHeight;
			this.swf_block_id  = this.block_id;
			swf_block_id       = this.block_id;
			swf_width	   = this.swf_width;
			swf_height	   = this.swf_height;
			swf_minwidth       = this.minWidth;
			swf_minheight      = this.minHeight;
			this.s_account     = s_account;
			this.oas_url       = this.default_path + 'swf/OmnitureActionSource.swf';
			this.add_attributes = 'position:absolute;top:0;left:0;width:950px;height:710px;z-index:-1;';
			this.flashLoaded = false;
			this.t=setTimeout("SWFWrite.checkConnection()",25000);
		}*/

	if (this.loadFlash == true) {
		this.blockResize();
	}

	}, // end checkSection()

	blockResize: function() {
			$('js').style.display = 'block';
			$('js').style.position = 'absolute';
			$('js').style.zIndex = '1000';
			$('js').style.width = (Window.getWidth() - 1) + 'px';
			$('js').style.height = (Window.getHeight() - 1) + 'px';
			$('js').style.backgroundColor = this.page_bgcolor;
			/*if (this.page_bgImage != '') {
				$('js').style.backgroundImage = 'url(' + this.default_path + this.page_bgImage + ')';
				$('js').style.backgroundRepeat = 'repeat-y';
			}*/

	}, // end blockResize()

	write: function() { 
		// see which flash we're loading
		this.checkSection();
		falsepositive = false;
		var flashcheck = 0;
		if (this.block_id != undefined && this.block_id.length > 1) {
			switch(this.section) {
				case 'about-ford':
					// check to see if the ID exists
					if (!$('career-opps')) {
						falsepositive = true;
					}
					this.so =  new SWFObject(this.swf_url, this.swf_name, this.swf_width, this.swf_height, this.swf_player, this.swf_bgcolor);
					this.so.addParam("scale", "noscale");
					this.so.addParam("wmode", "transparent");
					this.so.addParam("AllowScriptAccess", "always");
					this.so.addVariable("xmlPpath", "/xml/career_opps_feature.xml");
					flashcheck = 1;
				break;
				
				
				case 'owner-services':
					// check to see if the ID exists
					if (!$('owner-feature')) {
						falsepositive = true;
					}
					// IE 6 swfobjeft hack
					if (window.ie6) { 
						this.swf_url += '?url1=' + url1 + '&url2=' + url2 + '&url3=' + url3 + '&url4=' + url4 + '&url5=' + url5 + '&url6=' + url6 + '&url7=' + url7;
					}
					this.so =  new SWFObject(this.swf_url, this.swf_name, this.swf_width, this.swf_height, this.swf_player, this.swf_bgcolor);
					this.so.addParam("scale", "noscale");
					this.so.addParam("wmode", "transparent");
					this.so.addParam("AllowScriptAccess", "always");
					
					this.so.addVariable("url1", url1);
					this.so.addVariable("url2", url2);
					this.so.addVariable("url3", url3);
					this.so.addVariable("url4", url4);
					this.so.addVariable("url5", url5);
					this.so.addVariable("url6", url6);
					this.so.addVariable("url7", url7);

					flashcheck = 1;
				break;
				case 'ford-global':
					// check to see if the ID exists
					if (!$('global-links')) {
						falsepositive = true;
					}
					// IE 6 swfobjeft hack
					if (window.ie6) { 
						this.swf_url += '?XMLURL=' + document.location.href;
						this.swf_url += '&s_account=' + this.s_account;
						this.swf_url += '&oas_url=' + this.oas_url;
					}
					this.so =  new SWFObject(this.swf_url, this.swf_name, this.swf_width, this.swf_height, this.swf_player, this.swf_bgcolor);
					this.so.addParam("scale", "noscale");
					this.so.addParam("wmode", "transparent");
					this.so.addParam("AllowScriptAccess", "always");
					this.so.addVariable("XMLURL", document.location.href);
					this.so.addVariable("s_account", this.s_account);
					this.so.addVariable("oas_url", this.oas_url);
					flashcheck = 1;
				break;
				case 'showroom':
					// check to see if the ID exists
					if (!$('showroom')) {
						falsepositive = true;
					}
					// let's see if it's a ford latino showroom page
					if (document.getElementsByTagName('body')[0].id == 'fordlatino') {
						this.block_id = 'fordlatino';
					} // end if ford latino

					// IE 6 swfobject hack
					if (window.ie6) {
						this.swf_url += '?base_url=' + document.location.href;
						this.swf_url += '&nav_data=' + document.location.href;
						this.swf_url += '&spanish_url=' +  document.getElementById("tool-esp");
						this.swf_url += '&english_url=' + document.getElementById("tool-eng");
						this.swf_url += '&header_url=' +  this.default_path + "swf/topnav.swf";
						this.swf_url += '&showroom_url=' + this.default_path +  "swf/showroom.swf";
						this.swf_url += '&s_account=' + this.s_account;
						this.swf_url += '&oas_url=' + this.oas_url;
					}
					this.so =  new SWFObject(this.swf_url, this.swf_name, this.swf_width, this.swf_height, this.swf_player, this.swf_bgcolor);
					this.so.addParam("scale", "noscale");
					this.so.addParam("wmode", "transparent");
					this.so.addParam("AllowScriptAccess", "always");
					this.so.addVariable("base_url", document.location.href);
					this.so.addVariable("nav_data", document.location.href);
					this.so.addVariable("browser", BrowserDetect.browser);
					this.so.addVariable("spanish_url", document.getElementById("tool-esp"));
					this.so.addVariable("english_url", document.getElementById("tool-eng"));
					this.so.addVariable("header_url", this.default_path + "swf/topnav.swf");
					this.so.addVariable("showroom_url", this.default_path + "swf/showroom.swf");
					this.so.addVariable("s_account", this.s_account);
					this.so.addVariable("oas_url", this.oas_url);
					flashcheck = 1;
				break;
				case 'home':
					// check to see if the ID exists
					if (!$('home')) {
						falsepositive = true;
					}

					// IE 6 swfobject hack
					if (window.ie6) {
						this.swf_url += '?nav_data=' + abUrl;
						this.swf_url += '&header_url=' +  this.default_path + "swf/topnav.swf";
						this.swf_url += '&s_account=' + this.s_account;
						this.swf_url += '&oas_url=' + this.oas_url;
						this.swf_url += '&plaza_data=' + this.default_path + "xml/plazaSettings.xml";
					}
					
					//flash cachebuster
					if (document.getElementById("flcb")) { var swfv = document.getElementById("flcb").getAttribute("swfv"); }
					this.swf_url += (swfv) ? ((this.swf_url.indexOf("?")<0) ? "?swfv=" + swfv : "&swfv=" + swfv) : "";

					// testing minimim height and width for firefox and IE bug
					if (Window.getWidth() < this.swf_minwidth) {
						width = this.swf_minwidth;
					} else {
						width = this.swf_width;
					}

					if (Window.getHeight() < swf_minheight) {
						height = this.minHeight;
					} else {
						height = this.swf_height;
					}


					this.so =  new SWFObject(this.swf_url, this.swf_name, width, height, this.swf_player, this.swf_bgcolor);
					this.so.addParam("scale", "noscale");
					this.so.addParam("wmode", "transparent");
					this.so.addParam("AllowScriptAccess", "always");
					this.so.addVariable("nav_data", abUrl);
					this.so.addVariable("topnav_swf", this.default_path + "swf/topnav.swf");
					this.so.addVariable("plaza_data", this.default_path + "xml/plazaSettings.xml");
					this.so.addVariable("plaza_swf", this.default_path + "swf/plaza.swf");
					this.so.addVariable("s_account", this.s_account);
					this.so.addVariable("oas_url", this.oas_url);
					flashcheck = 1;
				break;
			} // end switch

			if (falsepositive == false && this.loadFlash==true) {
				flashReplaced = this.so.write(this.block_id);
			} // end if falsepositive

			if ($('js')) {
				$('js').style.width = '1px';
				$('js').style.height = '1px';
				$('js').style.display = 'none';
				$('js').style.zIndex = '-1';
			}
			// scrollbars fix
			if (this.add_div == true && falsepositive == false && this.loadFlash == true) {
				if (document.all) {
					// IE does not handle 100% width and height
					// for flash correctly
					// this is the workaround
					this.resize();
					window.onresize = this.resize;
				} else {
					$(this.block_id).innerHTML += '<div style="' + this.add_attributes + '">&nbsp</div>';
				}
			}
		}
		if ($('js')) {
			$('js').style.width = '1px';
			$('js').style.height = '1px';
			$('js').style.zIndex = '-1';
		}				
		//write div for locally hosted div-popup surveys
		//this.fsrWindowObj = new Element('div').setProperty('id','fsr_window_outer').injectInside(document.body);
		//$('fsr_window_outer').innerHTML = '&nbsp;';

		//text link on flash pages for non-flash option (screen reader accessibility)
		var baseFlashUrl = document.location.href;
		
		if (baseFlashUrl.indexOf("flash=false")<0 && (Cookie.get('nflc') == false || Cookie.get('nflc') == null || Cookie.get('nflc') == 'flashon')) {
			//trim url for showroom
			if (baseFlashUrl.indexOf('#')>-1) { 
				baseFlashUrl = baseFlashUrl.split("#", 1);
			}
			
			if (baseFlashUrl.indexOf('flash=true')>-1) {
				this.repStrRex = /flash=true/;
				var nfLink = baseFlashUrl.replace(this.repStrRex, "flash=false");
			} else {
				var nfLink = (baseFlashUrl.indexOf('?')>-1) ? baseFlashUrl + '&flash=false' : baseFlashUrl + '?flash=false';
			}
			
			this.nfLinkObj = new Element('div').setProperty('id','nonFlashLink').injectInside(document.body);
			$('nonFlashLink').innerHTML = '<a href="' + nfLink + '">Click here for non flash page</a>';
		}

		//if (flashcheck == 1) { var script = new Asset.javascript('//group11.iperceptions.com/Invitations/Javascripts/ip_Layer_Invitation_489.js', {id: 'ipsurvey'}); }

	}, // end write()

	resize: function() {
		if (Window.getWidth() < this.swf_minwidth) {
			width = swf_minwidth;
		} else {
			width = swf_width;
		}

		if (Window.getHeight() < this.swf_minheight) {
			height = swf_minheight;
		} else {
			height = swf_height;
		}
		if (width != 0) {
			$(swf_block_id).style.width = width;
		}
		$(swf_block_id).style.height = height;
	} // end resize()
	

} // end SWFWrite

/*----- Begin: Flash Replacement -----*/
flashReplaced = false;

/*----- Begin: Initialization Functions -----*/
window.addEvent('domready', Metrics.setOnClicks.bind(Metrics));
/*----- End: Initialization Functions -----*/