/* urls where app can be found */
// concat "gaps" put in urls so that global search/replace won't mess with'em - kn Jan11/08
var urlItl = "http://configurator.autodata" + ".preprod.gm.ca/GMCanada/modelSelect.html?";
var urlPreprod = "http://configurator.autodata" + ".preprod.gm.ca/GMCanada/modelSelect.html?";
var urlBase = "http://configurator.autodata" + ".gm.ca/GMCanada/modelSelect.html?";

urlBase = (location.href.indexOf('itl.')>-1) ? urlItl: urlBase;
urlBase = (location.href.indexOf('preprod.')>-1) ? urlPreprod: urlBase;


/*  goConfig is a patch function that has been ported over from the previous Configurator
	app.  It is used here to so that we do not have to re-code all the existing Build Your Own
	links present on the site, but should not be used for next refresh (2006).
	
	For refresh, all Build Your Own links should be constructed using the same model as RaQ.
*/
function goConfig(modelCode, lang , theYear) {
	var model = mapKeys(mapping, modelCode);
	goToLink(ConfiguratorConfig, model, 'lang|'+ lang +'|year|'+ theYear);
}

function mapKeys(arrMapping, key) {
	var keyMap = arrMapping[key];
	if (keyMap != undefined) return keyMap;
	else return key;
}

/*** Array used to map old Configurator model identifiers to new identifiers ***/
/* 
	This should not be used for refresh 2006, it is only for supporting the legacy
	Build your Own presently on the site.  Only those vehicles whose current Configurator
	identifiers do not match external-data.js will be defined here, the others don't need it
*/
var mapping = new Array();
/* saturn */
mapping["ion1"] = "isedan1";
mapping["ion2"] = "isedan2";
mapping["ion3"] = "isedan3";
mapping["ioncoupe2"] = "icoupe2";
mapping["ioncoupe3"] = "icoupe3";
mapping["ioncpredline"] = "icouperedline";
mapping["l3001"] = "lsedan";

/* saab */
mapping["93cn"] = "93convarc";
mapping["93linear"] = "93sedanlinear";
mapping["93arc"] = "93sedanarc";
mapping["93aero"] = "93sedanaero";
mapping["95arc"] = "95sedanarc";
mapping["95aero"] = "95sedanaero";
mapping["95wlinear"] = "95wagonlinear";
mapping["95warc"] = "95wagonarc";
mapping["95waero"] = "95wagonaero";

/***************************************************************************************************************/
/****** legacy Configurator support code ends, everything beyond this point should remain for Refresh 2006 *****/
/***************************************************************************************************************/
function siteCatBuildYourOwn(obj){
	s_linkType="o";
	s_linkName="Build Your Own "+ s_prop6 +" "+ s_prop7;
	//s_events="scCheckout";
	//s_eVar1="Test Link Event2";
	//s_eVar3 ="english";
	//s_eVar10="Tom.com";
	//count=0;for(x in obj){count++;alert(x+' '+obj[x]);if(count > 100)break;}
	s_lnk=s_co(obj);
	
	//var suite_id = (location.href.indexOf('http://gm.ca')>-1 || location.href.indexOf('http://saturncanada.com')>-1 || location.href.indexOf('http://saabcanada.com')>-1 || location.href.indexOf('http://www.')>-1 || location.href.indexOf("saab.gmcanada") > -1 || location.href.indexOf("saturn.gmcanada") > -1) ? "gmcanadacom" : "devgmcanadacom";
	var suite_id = (location.href.indexOf('preprod.') > -1 || location.href.indexOf('itl.') > -1) ? "devgmcanadacom" : "gmcanadacom";
	if (self.location.search.indexOf("?debug=true") != -1) {
		var strAlert = "suite id: "+ suite_id +"\n";
		strAlert += "link name: "+ s_linkName +"\n\n";
		strAlert += "obj name: "+ obj.name +"\n";
		alert(strAlert);
	}	
	s_gs(suite_id);

}

function copy(arr){
	var newArr = new Array()
	for (var item in arr){
		newArr[item] = arr[item];
	}
	return newArr;
}


/*** Configurator configuration options ***/
var ConfiguratorConfig=new Array();
// data refers to the key in the data (in common-external) url is the querystring name piece of it.
ConfiguratorConfig["keys"]=new Array();
ConfiguratorConfig["keys"][0]=new Array();
ConfiguratorConfig["keys"][0]["data"]="compare brand";
ConfiguratorConfig["keys"][0]["url"]="brand";
ConfiguratorConfig["keys"][1]=new Array();
ConfiguratorConfig["keys"][1]["data"]="model code";
ConfiguratorConfig["keys"][1]["url"]="model";
ConfiguratorConfig["keys"][2]=new Array();
ConfiguratorConfig["keys"][2]["data"]="package code";
ConfiguratorConfig["keys"][2]["url"]="package";
ConfiguratorConfig["keys"][3]=new Array();
ConfiguratorConfig["keys"][3]["data"]="year code";
ConfiguratorConfig["keys"][3]["url"]="year";

// static pieces are just name/vals for other bits that need to get passed
ConfiguratorConfig["static pieces"]=new Array();
ConfiguratorConfig["static pieces"]["lang"]=(location.href.indexOf('fr_CA')>-1 || location.href.indexOf('/french/')>-1)?"fr":"en";
ConfiguratorConfig["static pieces"]["s_prop5"]="";
ConfiguratorConfig["static pieces"]["year"]="2009";

// base url for creating links with
ConfiguratorConfig["base url"] = urlBase;
