// Need to change absolute links to point to correct server on different environments
// Normal (relative):	itl.gm.ca 							preprod.gm.ca						gm.ca
// Apps (absolute)	:	apps.itl.gm.ca	origin.gmcanada.pprod.e-gm.net	apps.gm.ca
// absolute.js will differ than normal js, since the preprod servers don't have any common strings
var mainServer;
var mainSecureServer;
var otherServer;
var devPath = ''; // path for Contact Us
var configDomain = '';
var thisLoc = location.toString();
if (thisLoc.indexOf('itl.') != -1) { // we are on ITL
	mainServer = 'http://apps.itl.gm.ca';
	mainSecureServer = 'https://apps.itl.gm.ca';
	otherServer = 'http://itl.gm.ca';
	devPath = 'dev/';						// "Contact Us" link changes on development servers
	PEDomain = 'http://www.gm.ca';	
	configDomain = 'http%3A%2F%2Fconfigurator%2Eautodata%2Epreprod%2Egm%2Eca';	
} else if (thisLoc.indexOf('preprod.') != -1) { // we are on PREPROD
	mainServer = 'http://apps.preprod.gm.ca';
	mainSecureServer = 'https://apps.preprod.gm.ca';
	otherServer = 'http://preprod.gm.ca';
	devPath = 'dev/';						// "Contact Us" link changes on development servers
	PEDomain = 'http://www.gm.ca';	
	configDomain = 'http%3A%2F%2Fconfigurator%2Eautodata%2Epreprod%2Egm%2Eca';	
} else if (thisLoc.indexOf('pprod.') != -1) { // we are on PREPROD
	mainServer = 'http://apps.preprod.gm.ca';
	mainSecureServer = 'https://apps.preprod.gm.ca';
	otherServer = 'http://preprod.gm.ca';
	devPath = 'dev/';		
	PEDomain = 'http://www.gm.ca';	
	configDomain = 'http%3A%2F%2Fconfigurator%2Eautodata%2Epreprod%2Egm%2Eca';	
} 	else { // default to LIVE
	mainServer = 'http://apps.gm.ca';
	mainSecureServer = 'https://apps.gm.ca';
	otherServer = 'http://www.gm.ca';
	PEDomain = 'http://www.gm.ca';	
	configDomain = 'http%3A%2F%2Fconfigurator%2Eautodata%2Egm%2Eca';	
}

var linkTarget = '_top';
// TO UPDATE A DROP DOWN MENU, ADD ITEM TO APPROPRIATE ARRAY IN DESIRED POSITION
//*******************
// TOP NAV BAR ARRAY
//*******************
// makeObjArray is (href value, display text)
var navArray = new Array(7);
initNavArray();
function initNavArray() {
  navArray[0] = new makeObjArray(otherServer+"/gm/french/home","Accueil GM Canada");
  //Google Appliance URL will need to be updated for launch
  navArray[1] = new makeObjArray(otherServer+"/gm/french/vehicles","V&#233;hicules");
  navArray[2] = new makeObjArray(otherServer+"/gm/french/tools","Outils d'achat");
  navArray[3] = new makeObjArray(otherServer+"/gm/french/finance","Financement");  
  navArray[4] = new makeObjArray(otherServer+"/gm/french/maintenance","Pi&#232;ces et apr&#232;s-vente");  
  navArray[5] = new makeObjArray(otherServer+"/gm/french/about","A notre sujet");  
  navArray[6] = new makeObjArray(mainServer+"/app/GMCanada/DealerLocatorSearch.do?nav=0&cta=blank&lang=fr","Concessionnaires");    
  }
// objectify the navArray  
function makeObjArray(topLocations,topTitles) {
  this.hrefLocation = topLocations;
  this.title = topTitles;
  return this;
 }
 
//*************************
// GM CANADA HOME SUB MENU ARRAY
//*************************
var homeNavArray = new Array(4);
inithomeNavArray();
function inithomeNavArray() {
  homeNavArray[0] = new makeHomeObjArray(otherServer+"/gm/french/vehicles/buick/","Buick");
  homeNavArray[1] = new makeHomeObjArray(otherServer+"/gm/french/vehicles/cadillac/","Cadillac");
  homeNavArray[2] = new makeHomeObjArray(otherServer+"/gm/french/vehicles/chevrolet/","Chevrolet");
  homeNavArray[3] = new makeHomeObjArray(otherServer+"/gm/french/vehicles/gmc/","GMC"); 
  } 
function makeHomeObjArray(topLocations,topTitles) {
  this.hrefLocation = topLocations;
  this.title = topTitles;
  return this;
 } 

//*************************
// VEHICLES SUB MENU ARRAY
//*************************
var vehNavArray = new Array(10);
initVehNavArray();
function initVehNavArray() {
  vehNavArray[0] = new makeVehObjArray(otherServer+"/gm/french/showrooms/?adv=72466","Salle d'exposition des voitures");
  vehNavArray[1] = new makeVehObjArray(otherServer+"/gm/french/showrooms/cars?adv=72468","Voitures");
  vehNavArray[2] = new makeVehObjArray(otherServer+"/gm/french/showrooms/vans?adv=72470","Fourgonnettes");
  vehNavArray[3] = new makeVehObjArray(otherServer+"/gm/french/showrooms/suv?adv=72472","Multisegments/VUSs");
  vehNavArray[4] = new makeVehObjArray(otherServer+"/gm/french/showrooms/trucks?adv=72474","Camions");    
  vehNavArray[5] = new makeVehObjArray(otherServer+"/gm/french/vehicles/commercial/index","Camions commerciaux");  
  vehNavArray[6] = new makeVehObjArray(otherServer+"/gm/french/shopping/first-new-car/overview","Premi&#232;re voiture neuve");
  vehNavArray[7] = new makeVehObjArray(otherServer+"/gm/french/trailering-guide/all-vehicles/home/overview","Guide sur le remorquage");    
  vehNavArray[8] = new makeVehObjArray(otherServer+"/gm/french/shopping/used/overview","V&#233;hicules d'occasion");  
  vehNavArray[9] = new makeVehObjArray(otherServer+"/gm/french/services/fleet/overview","Parcs");    
  } 
function makeVehObjArray(topLocations,topTitles) {
  this.hrefLocation = topLocations;
  this.title = topTitles;
  return this;
 } 

//*******************************
// SHOPPING TOOLS SUB MENU ARRAY
//*******************************
var shopNavArray = new Array();
initShopNavArray();
function initShopNavArray() {
  shopNavArray[0] = new makeShopObjArray(mainServer+"/app/GMCanada/offersearch/OfferSearch.do?lang=fr","Offres en cours");
  shopNavArray[1] = new makeShopObjArray(mainServer+"/app/mygm/GetUserInfo.do?request=access,lastsavedconfig&amp;goto=" + configDomain + "%2FGMCanada%2FmodelSelect%2Ehtml%3Flang%3Dfr","Fabriquer et obtenir un prix");
  shopNavArray[2] = new makeShopObjArray("http://gm.ca/gm/french/payment-estimator/selectMakeModel","Estimer les paiements");
  shopNavArray[3] = new makeShopObjArray(otherServer+"/gm/english/hostredirect?host=http://gmcanada.autodatadirect.com/compare/main.asp&amp;lang=fr&amp;year=2012","Comparaison de v&#233;hicules");
  shopNavArray[4] = new makeShopObjArray(mainServer+"/app/GMCanada/NewVehicleLocatorCriteria.do?lang=fr&nav=0&cta=blank","Trouvez un v&#233;hicule");  
  shopNavArray[5] = new makeShopObjArray(mainServer+"/app/GMCanada/DealerLocatorSearch.do?nav=0&cta=blank&lang=fr","Trouvez un concessionnaire");
  shopNavArray[6] = new makeShopObjArray(mainSecureServer+"/app/GMCanada/RequestAQuote.do?lang=fr&raqSource=scheduleTestDrive&scheduleSubSource=new&year=2012","Rendez-vous pour un essai routier");
  shopNavArray[7] = new makeShopObjArray(mainSecureServer+"/app/GMCanada/RequestAQuote.do?lang=fr&raqSource=new&year=2012","Demande de soumission");
  shopNavArray[8] = new makeShopObjArray(otherServer+"/gm/french/services/insurance/quote","Demande de soumission d'assurance");
  //shopNavArray[8] = new makeShopObjArray("/gm/french/services/gmac/apply","Demande de cr&eacute;dit");
  }
function makeShopObjArray(topLocations,topTitles) {
  this.hrefLocation = topLocations;
  this.title = topTitles;
  return this;
 } 
 
 
//************************
// FINANCE SUB MENU ARRAY
//************************
var finNavArray = new Array(5);
initFinNavArray();

function initFinNavArray() {
	//Sirine July 18/06 - Payment Estimator link, goes to Autodata carrying a list of parameters
	try  {
		var returnToName=escape(sectionDisplayTitle);
	}
	catch(err) {
		var returnToName = "page prcdente";
	}
	
var estimatorLink= "http://gm.ca/gm/french/payment-estimator/selectMakeModel";

  finNavArray[0] = new makeFinObjArray(otherServer+"/gm/french/services/gmac/overview","Financement");
  //finNavArray[1] = new makeFinObjArray(otherServer+"/gm/french/services/gmac/apply","Demande de cr&#233;dit");
  finNavArray[1] = new makeFinObjArray(otherServer+"/gm/french/services/gmac/commercial/credit-line","Ligne de cr&#233;dit commercial");  
  finNavArray[2] = new makeFinObjArray(otherServer+"/gm/french/services/gmac/appraise-trade-in","&#201;valuez votre v&#233;hicule");
  finNavArray[3] = new makeFinObjArray(otherServer+"/gm/french/services/gm-card/overview","La Carte GM");  
  finNavArray[4] = new makeFinObjArray(otherServer+"/gm/french/services/insurance/quote","Assurance");    
  }
function makeFinObjArray(topLocations,topTitles) {
  this.hrefLocation = topLocations;
  this.title = topTitles;
  return this;
 } 
 
//**********************************
// PARTS AND SERVICE SUB MENU ARRAY
//**********************************
var partNavArray = new Array(6);
initPartNavArray();
function initPartNavArray() {
  partNavArray[0] = new makePartObjArray(otherServer+"/gm/french/services/vehicle-service/overview","Entretien des v&#233;hicules");
  partNavArray[1] = new makePartObjArray(otherServer+"/gm/french/services/warranty/overview","Protection et garanties");
  partNavArray[2] = new makePartObjArray(otherServer+"/gm/french/shopping/parts/overview","Pi&#232;ces");
  partNavArray[3] = new makePartObjArray(otherServer+"/gm/french/shopping/accessories/overview","Accessoires");  
  partNavArray[4] = new makePartObjArray(otherServer+"/gm/french/shopping/accessories/onstar","OnStar");
  partNavArray[5] = new makePartObjArray(otherServer+"/gm/french/shopping/xm-radio/overview","Radio XM");  
  }
function makePartObjArray(topLocations,topTitles) {
  this.hrefLocation = topLocations;
  this.title = topTitles;
  return this;
 } 
 
//*********************
// ABOUT SUB MENU ARRAY
//*********************
var aboutNavArray = new Array(5);
initAboutNavArray();
function initAboutNavArray() {
  aboutNavArray[0] = new makeAboutObjArray(otherServer+"/inm/gmcanada/french/about/index.html","Aper&#231;u de la soci&#233;t&#233;");
  aboutNavArray[1] = new makeAboutObjArray(otherServer+"/inm/gmcanada/french/about/News/news.html","Nouvelles et &#233;v&#233;nements");
  aboutNavArray[2] = new makeAboutObjArray(otherServer+"/gm/french/corporate/olympics/overview","Les Jeux olympiques");
  //aboutNavArray[3] = new makeAboutObjArray(otherServer+"/gm/french/corporate/green-by-design/overview","Gnie VERT");
  aboutNavArray[3] = new makeAboutObjArray(otherServer+"/inm/gmcanada/french/about/Careers/careers.html","Centre des carri&#232;res");  
  aboutNavArray[4] = new makeAboutObjArray("https://contactus.gm.ca/"+devPath+"french/email_us.aspx","Renseignements");  
  }
function makeAboutObjArray(topLocations,topTitles) {
  this.hrefLocation = topLocations;
  this.title = topTitles;
  return this;
 } 

//*********************
// MY GM SUB MENU ARRAY
//*********************

//First, the 2 main link labels
var myNavArray = new Array(2);
initMyNavArray();
function initMyNavArray() {
  myNavArray[0] = new makeMyObjArray(mainSecureServer+"/app/mygm/Logon.do?lang=fr","Mon GM Canada");
  //Google Appliance URL will need to be updated for launch
  myNavArray[1] = new makeMyObjArray(otherServer+"/gm/french/corporate/help/overview","Aide"); 
  }
// objectify the navArray  
function makeMyObjArray(topLocations,topTitles) {
  this.hrefLocation = topLocations;
  this.title = topTitles;
  return this;
 }
 
// Second, the subNav for MyGM
var myGmSubNavArray = new Array(4);
initMyGmSubNavArray();
function initMyGmSubNavArray() {
  myGmSubNavArray[0] = new makeMyGmSubNavObjArray(mainSecureServer+"/app/mygm/MyShowroom.do?lang=fr&cta=myshowroom","Ma salle d'exposition");
  myGmSubNavArray[1] = new makeMyGmSubNavObjArray(mainSecureServer+"/app/mygm/MyDealers.do?lang=fr&cta=mydealers&ComponentName=buycentre","Mes concessionnaires");
  myGmSubNavArray[2] = new makeMyGmSubNavObjArray(mainSecureServer+"/app/mygm/MyDriveway.do?nav=mygm&lang=fr","Mon garage");
  myGmSubNavArray[3] = new makeMyGmSubNavObjArray(mainSecureServer+"/app/mygm/ManageProfile.do?reqtype=retrieve&lang=fr&nav=mng&cta=mng","Mes pr&#233;f&#233;rences");
  }                                                                 
 //END subnav for My GM

 
 //SIRINE   
var HelpSubNavArray = new Array(4);
initHelpSubNavArray();
function initHelpSubNavArray() {
  HelpSubNavArray[0] = new makeMyGmSubNavObjArray("http://gm.ca/servlet/advsearch?client=french_pref_search&proxystylesheet=french_pref_search&output=xml_no_dtd&site=french_pref_search&proxycustom=%3CHOME/%3E","Recherche");
  HelpSubNavArray[1] = new makeMyGmSubNavObjArray(otherServer+"/gm/french/corporate/help/faql","FAQs");
//  HelpSubNavArray[2] = new makeMyGmSubNavObjArray(otherServer+"/french/about/help/using/index.html","Utilisation du site");
  HelpSubNavArray[2] = new makeMyGmSubNavObjArray(otherServer+"/gm/french/corporate/help/privacy/overview","Vie Priv&#233;e");
  HelpSubNavArray[3] = new makeMyGmSubNavObjArray(otherServer+"/gm/french/corporate/help/legal","Juridique");
  }
    
function makeMyGmSubNavObjArray(topLocations,topTitles) {
  this.hrefLocation = topLocations;
  this.title = topTitles;
  return this;
 } 
//end new

 
// start writing out the nav beginning with a div container 
var topNavList = '';
// and now write in the list menus
topNavList += '<ul id="nav">';
	topNavList += '<li id="nav1" style="cursor:hand" onclick="top.location.href=\''+ navArray[0].hrefLocation +'\'"><a href="' + navArray[0].hrefLocation + '" target="'+linkTarget+'"><span>' + navArray[0].title + '</span></a>';
		topNavList += '<ul>';
			for(i=0;i<homeNavArray.length;i++) {
				if(i==0){
					topNavList += '<li class="topMenu"><a href="' + homeNavArray[i].hrefLocation + '" target="'+linkTarget+'">' + homeNavArray[i].title + '</a></li>';
				}			
				if(i!==0){			
					topNavList += '<li><a href="' + homeNavArray[i].hrefLocation + '" target="'+linkTarget+'">' + homeNavArray[i].title + '</a></li>';
				}				
			}
			topNavList += '<li class="botMenu" id="botMenu"><a href="#"></a></li>'; 
		topNavList += '</ul>';	
	topNavList += '</li>';
	topNavList += '<li id="nav2" style="cursor:hand" onclick="top.location.href=\''+ navArray[1].hrefLocation +'\'"><a href="' + navArray[1].hrefLocation + '" target="'+linkTarget+'"><span>' + navArray[1].title + '</span></a>';
		topNavList += '<ul>';
			for(i=0;i<vehNavArray.length;i++) {
				if(i==0){
					topNavList += '<li class="topMenu"><a href="' + vehNavArray[i].hrefLocation + '" target="'+linkTarget+'">' + vehNavArray[i].title + '</a></li>';
				}			
				if(i!==0){			
					topNavList += '<li><a href="' + vehNavArray[i].hrefLocation + '" target="'+linkTarget+'">' + vehNavArray[i].title + '</a></li>';
				}			
			}
			topNavList += '<li class="botMenu" id="botMenu"><a href="#"></a></li>';
		topNavList += '</ul>';	
	topNavList += '</li>';
	topNavList += '<li id="nav3" style="cursor:hand" onclick="top.location.href=\''+ navArray[2].hrefLocation +'\'"><a href="' + navArray[2].hrefLocation + '" target="'+linkTarget+'" ><span>' + navArray[2].title + '</span></a>';
		topNavList += '<ul>';
			for(i=0;i<shopNavArray.length;i++) {
				if(i==0){
					topNavList += '<li class="topMenu"><a href="' + shopNavArray[i].hrefLocation + '" target="'+linkTarget+'">' + shopNavArray[i].title + '</a></li>';
				}	
				if(i==5){			
					topNavList += '<li class="dblMenu"><a href="' + shopNavArray[i].hrefLocation + '" target="'+linkTarget+'">' + shopNavArray[i].title + '</a></li>';
				}									
				if(i!==0 && i!==5){			
					topNavList += '<li><a href="' + shopNavArray[i].hrefLocation + '" target="'+linkTarget+'">' + shopNavArray[i].title + '</a></li>';
				}
			}		
			topNavList += '<li class="botMenu" id="botMenu"><a href="#"></a></li>';
		topNavList += '</ul>';	
	topNavList += '</li>';	
	topNavList += '<li id="nav4" style="cursor:hand" onclick="top.location.href=\''+ navArray[3].hrefLocation +'\'"><a href="' + navArray[3].hrefLocation + '" target="'+linkTarget+'"><span>' + navArray[3].title + '</span></a>';
		topNavList += '<ul>';
			for(i=0;i<finNavArray.length;i++) {
				if(i==0){
					topNavList += '<li class="topMenu"><a href="' + finNavArray[i].hrefLocation + '" target="'+linkTarget+'">' + finNavArray[i].title + '</a></li>';
				}			
				if(i!==0){			
					topNavList += '<li><a href="' + finNavArray[i].hrefLocation + '" target="'+linkTarget+'">' + finNavArray[i].title + '</a></li>';
				}
			}	
			topNavList += '<li class="botMenu" id="botMenu"><a href="#"></a></li>'; 
		topNavList += '</ul>';	
	topNavList += '</li>';	
	topNavList += '<li id="nav5" style="cursor:hand" onclick="top.location.href=\''+ navArray[4].hrefLocation +'\'"><a href="' + navArray[4].hrefLocation + '" target="'+linkTarget+'"><span>' + navArray[4].title + '</span></a>';
		topNavList += '<ul>';
			for(i=0;i<partNavArray.length;i++) {
				if(i==0){
					topNavList += '<li class="topMenu"><a href="' + partNavArray[i].hrefLocation + '" target="'+linkTarget+'">' + partNavArray[i].title + '</a></li>';				
				}			
				if(i!==0){			
					topNavList += '<li><a href="' + partNavArray[i].hrefLocation + '" target="'+linkTarget+'">' + partNavArray[i].title + '</a></li>';
				}
			} 
			topNavList += '<li class="botMenu" id="botMenu"><a href="#"></a></li>'; 			
		topNavList += '</ul>';	
	topNavList += '</li>';
	topNavList += '<li id="nav6" style="cursor:hand" onclick="top.location.href=\''+ navArray[5].hrefLocation +'\'"><a href="' + navArray[5].hrefLocation + '" target="'+linkTarget+'"><span>' + navArray[5].title + '</span></a>';
		topNavList += '<ul>';
			for(i=0;i<aboutNavArray.length;i++) {
				if(i==0){
					topNavList += '<li class="topMenu"><a href="' + aboutNavArray[i].hrefLocation + '" target="'+linkTarget+'">' + aboutNavArray[i].title + '</a></li>';
				}
				if(i!==0){
					topNavList += '<li><a href="' + aboutNavArray[i].hrefLocation + '" target="'+linkTarget+'">' + aboutNavArray[i].title + '</a></li>';
				}
			}
			topNavList += '<li class="botMenu" id="botMenu"><a href="#"></a></li>'; 
		topNavList += '</ul>';	
	topNavList += '</li>';
	topNavList += '<li style="cursor:hand" id="nav7" onclick="top.location.href=\''+ navArray[6].hrefLocation +'\'"><a href="' + navArray[6].hrefLocation + '" target="'+linkTarget+'"><span>' + navArray[6].title + '</span></a></li>';
topNavList += '</ul>';

//alert(topNavList);
document.write(topNavList);

var myGmNavList = '';
// and now write in the list menus
myGmNavList += '<ul id="navicons">';
	myGmNavList += '<li id="icon1" style="cursor:hand" onclick="top.location.href=\''+ myNavArray[0].hrefLocation +'\'"><a href="' + myNavArray[0].hrefLocation + '" target="'+linkTarget+'"><span>' + myNavArray[0].title + '</span></a>';
		myGmNavList += '<ul>';
			for(i=0;i<myGmSubNavArray.length;i++) {
				if(i==0){
					myGmNavList += '<li class="topMenu"><a href="' + myGmSubNavArray[i].hrefLocation + '" target="'+linkTarget+'">' + myGmSubNavArray[i].title + '</a></li>';
				}			
				if(i!==0){			
					myGmNavList += '<li><a href="' + myGmSubNavArray[i].hrefLocation + '" target="'+linkTarget+'">' + myGmSubNavArray[i].title + '</a></li>';
				}				
			}
			myGmNavList += '<li class="botMenu" id="botMenu"><a href="#"></a></li>'; 
		myGmNavList += '</ul>';	
	myGmNavList += '</li>';
	myGmNavList += '<li id="icon2" style="cursor:hand" onclick="top.location.href=\''+ myNavArray[1].hrefLocation +'\'"><a href="' + myNavArray[1].hrefLocation + '" target="'+linkTarget+'"><span>' + myNavArray[1].title + '</span></a>';
		myGmNavList += '<ul>';
					for(i=0;i<HelpSubNavArray.length;i++) {
						if(i==0){
							myGmNavList += '<li class="topMenu"><a href="' + HelpSubNavArray[i].hrefLocation + '" target="'+linkTarget+'">' + HelpSubNavArray[i].title + '</a></li>';
						}			
						if(i!==0){			
							myGmNavList += '<li><a href="' + HelpSubNavArray[i].hrefLocation + '" target="'+linkTarget+'">' + HelpSubNavArray[i].title + '</a></li>';
						}				
					}
					myGmNavList += '<li class="botMenu" id="botMenu"><a href="#"></a></li>'; 
				myGmNavList += '</ul>';	
			myGmNavList += '</li>';
		myGmNavList += '</ul>';

//alert(myGmNavList);
document.write(myGmNavList);


//*******************
// TOP NAV JS INCLUDE
//*******************

<!-- Apply hover to li for IE-->
sfHover = function() {
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	var sfElsR = document.getElementById("navicons").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
	for (var i=0; i<sfElsR.length; i++) {
		sfElsR[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfElsR[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}

if (window.attachEvent) window.attachEvent("onload", sfHover);

<!-- Change class for NAV bar ICONS (generic function) -->
function change(id, newClass) {
	identity=document.getElementById(id);
	identity.className=newClass;
}










