/* urls where app can be found */
// modded jan11/08 kn for gm.ca
var urlItl = "http://apps.itl" + ".gm.ca/app/GMCanada/DealerLocatorSearch.do?";
var urlPreprod = "http://apps.preprod" + ".gm.ca/app/GMCanada/DealerLocatorSearch.do?";
var urlBase = "http://apps" + ".gm.ca/app/GMCanada/DealerLocatorSearch.do?";

//urlBase = (location.href.indexOf('itl.')>-1) ? urlItl: urlBase;
urlBase = (location.href.indexOf('preprod.')>-1) ? urlPreprod: urlBase;

// Retrieve a named cookie value
function getRCookie(name) {
	var dc = document.cookie;

	// find beginning of cookie value in document.cookie
	var prefix = name + "=";
	var begin = dc.indexOf("; " + prefix);
	if (begin == -1) {
		begin = dc.indexOf(prefix);
		if (begin != 0) return null;
	}
	else begin += 2;

	// find end of cookie value
	var end = document.cookie.indexOf(";", begin);
	if (end == -1) end = dc.length;

	// return cookie value
	return unescape(dc.substring(begin + prefix.length, end));
}

// feb 21/08 kn - splice postal code onto url
var pcCookie = getRCookie("pc");
if(pcCookie && pcCookie.length == 6) {
	//urlBase += "POSTLCD=" + pcCookie + "&";	
}
else {
	pcCookie = "";
}

function copy(arr){
	var newArr = new Array()
	for (var item in arr){
		newArr[item] = arr[item];
	}
	return newArr;
}

/*** RaQ configuration options ***/
var findRetailerConfig=new Array();
// data refers to the key in the data (in common-external) url is the querystring name piece of it.
findRetailerConfig["keys"]=new Array();
findRetailerConfig["keys"][0]=new Array();
findRetailerConfig["keys"][0]["data"]="find nav key";
findRetailerConfig["keys"][0]["url"]="nav";
findRetailerConfig["keys"][1]=new Array();
findRetailerConfig["keys"][1]["data"]="compare brand";
findRetailerConfig["keys"][1]["url"]="brand";
findRetailerConfig["keys"][2]=new Array();
findRetailerConfig["keys"][2]["data"]="compare brand";
findRetailerConfig["keys"][2]["url"]= (top.location.href.indexOf('brand=saab') > -1 || top.location.href.indexOf('saab') > -1 || top.location.href.indexOf('.saabcanada.') > -1) ? "MMNAMPLT_3" : "MMNAMPLT_6";

// static pieces are just name/vals for other bits that need to get passed
findRetailerConfig["static pieces"]=new Array();
findRetailerConfig["static pieces"]["lang"]=(location.href.indexOf('fr_CA')>-1 || location.href.indexOf('/french/')>-1)?"fr":"en";
findRetailerConfig["static pieces"]["cta"]="blank";
findRetailerConfig["static pieces"]["POSTLCD"]=pcCookie;




// base url for creating links with - as set at top of page
findRetailerConfig["base url"] = urlBase;


