﻿/*
	SWF embed flashvars, params & attributes
*/

var vsParams = {
	wmode:'transparent',
    menu:'false',
    salign:'tl'
};
var vsAttributes = {
    id: vsConfigInfo.swfId,
    name:'vehicleSelectorApp'
}; 

var vsFlashvars = {
  lang					: getAppLanguage(),
  getTabs				: getTabs,
  tabsWidth				: getTabsWidth(),
  appSubTitle  			: getAppSubTitle(),
  appTitle  			: getAppTitle(),
  selectVehiclesContext : getAppContext(),
  hasStepsMenu 			: getHasStepsMenu(),
  webServiceURL			: getWebServiceUrl()
};

swfobject.embedSWF(vsConfigInfo.swfUrl, vsConfigInfo.swfId, "100%", getSwfHeight(), "9", "/common/expressinstall.swf", vsFlashvars, vsParams, vsAttributes);

/*
	Get Info
	////////////////////////////////////
	Certain vars are defined on the html 
	doc that includes this js file - this 
	allows the enclosing docs to configure
	the menu for different contexts
	////////////////////////////////////
*/

function getSwfHeight()
{
	if(!vsConfigInfo.swfHeight) return 200;
	return vsConfigInfo.swfHeight;
}

function setSWFSize(id, size){
	return document.getElementById(id).height = size;
}

function getTabs(){
	return tabsMenuConfig;
}

function getTabsWidth(){
	if(vsConfigInfo.tabsWidth == "100%" || !vsConfigInfo.tabsWidth)
	{	
		//make the menu 100% of div width
		return vsConfigInfo.swfWidth / tabsMenuConfig.length;
	}
	return vsConfigInfo.tabsWidth;
}

function getWebServiceUrl(){
	if(!vsConfigInfo.webServiceURL) return null;
	return vsConfigInfo.webServiceURL;
}

function getAppContext(){
	if(!vsConfigInfo.appContext) return null;
	return  vsConfigInfo.appContext;
}

function getHasStepsMenu(){
	if(!vsConfigInfo.hasStepsMenu) return null;
	return  vsConfigInfo.hasStepsMenu;
}

function getAppLanguage(){
	var pathname	= document.location.pathname;
	if(pathname.indexOf('/fr/') !== -1){
		return 'fr';
	}
	//otherwise default to
	return 'en';
}

function getAppTitle(){
	if(!vsConfigInfo.appTitle) return "";
	return vsConfigInfo.appTitle;
}

function getAppSubTitle(){
	if(!vsConfigInfo.appSubTitle) return "";
	return vsConfigInfo.appSubTitle;
}
