
// New eFamily pilot project
function Getpilotinfo(vecname,lang){
url = "http://www.daimlerchryslerefamily.ca/efamily_pilot/"+lang+"/index.php?vecid="+ vecname;

eval(window.open(url,vecname,"history=no,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,width=800,height=600"));
}



// THE FOLLOWING TWO FUNCTIONS ARE USED TO SHOW/HIDE LAYERS IN THE CONTENT SECTIONS
 

  function showLayer(name) {
   var showArrow = name + "_show";
   var hideArrow = name + "_hide";
   var layerName = document.getElementById(name);
   var showArrowLayer = document.getElementById(showArrow);
   var hideArrowLayer = document.getElementById(hideArrow);
   layerName.style.display='block';
   showArrowLayer.style.display='none';
   hideArrowLayer.style.display='block';   
  }
  
  function hideLayer(name) {
   var showArrow = name + "_show";
   var hideArrow = name + "_hide";
   var layerName = document.getElementById(name);
   var showArrowLayer = document.getElementById(showArrow);
   var hideArrowLayer = document.getElementById(hideArrow);
   layerName.style.display='none';
   showArrowLayer.style.display='block';
   hideArrowLayer.style.display='none';
  }


  function showAll(numberOfQuestions) {
  for (var x = 1; x <= numberOfQuestions; x++) {
    var name = "q" + x;
    var layerName = document.getElementById(name);	
    layerName.style.display='block';
   }
  document.getElementById('showAllLayer').style.display = 'none'; 
  document.getElementById('hideAllLayer').style.display = 'block'; 
  }  
  
  function hideAll(divname,numberOfQuestions) {
  for (var x = 1; x <= numberOfQuestions; x++) {
    var name = divname + x;
	if (document.getElementById(name)) {
     var layerName = document.getElementById(name);	
     layerName.style.display='none';
	}
   }
  }


// THE FOLLOWING FOUR FUNCTIONS ARE USED TO SHOW A LARGER VERSION OF THE IMAGE FROM THE CONTENT SECTIONS  
function showMinor(vehicle,imgname,imgext,sw,sh,enlarge,lw,lh,caption) {
 popupHeight = (lh);
 if (enlarge == 'yes') {
  caption = replaceAll(caption,"&#65533;","QUOTE");
  document.write("<a href=\"javascript:popup_all('../common/enlarge.html?vehicle="+vehicle+"&name="+imgname+"&ext="+imgext+"&w="+lw+"&h="+lh+"&caption="+caption+"','openme3','0','0','0','0','0','no','yes','"+popupHeight+"','510');\"><img src=\"../"+vehicle+"/"+imgname+"."+imgext+"\" width="+sw+" height="+sh+" border=\"0\"><br><img src=\"../common/img/all_view_larger_image.gif\" width=\"200\" height=\"30\" alt=\"\" border=\"0\" /></a>");
 } else {
  document.write("<img src=\"../"+vehicle+"/"+imgname+"."+imgext+"\" width="+sw+" height="+sh+" border=\"0\"><br><img src=\"../common/img/c.gif\" width=\"200\" height=\"10\" alt=\"\">");
 }  
}

function replaceAll(str, srch, rplc) {
    var idx = str.indexOf(srch);
    while (idx > -1) {
        str = str.replace(srch, rplc);
        idx = str.indexOf(srch);
    }
    return str;
}

//----- Get Query String from url
function getQueryVariable(variable) {
  var query = window.location.search.substring(1);
  var vars = query.split("&");
  for (var i=0;i<vars.length;i++) {
    var pair = vars[i].split("=");
    if (pair[0] == variable) {
      return pair[1];
    }
  } 
}

function enlargePhoto(vehicle,name,ext,w,h,caption) {
document.write("<div align=\"left\">");
document.write("<img src=\"../"+vehicle+"/"+name+"_lg."+ext+" \" width="+w+" height="+h+" border=\"0\" alt=\"\">");
document.write("</div>");
caption = replaceAll(caption,'%20'," ");
caption = replaceAll(caption,"QUOTE","&#65533;");
 caption = replaceAll(caption,"(TM)","™");
 caption = replaceAll(caption,"(R)","<sup>®</sup>");//for (R) sup
 caption = replaceAll(caption,"(R_SUB)","<sub>®</sub>");//for (R) sub
document.write("<div class=\"disclaimer\" style=\"padding: 3px; text-align: right;\">"+caption+"</div>");
}


//----- To be used for popup windows all parameters passed
function popup_all(topic,namer,tool,loc,dir,stat,menu,scroll,resize,x,y) {

 var tmp = location.hostname.split(".");
 var env = tmp[0].toLowerCase();	 

 if(namer == "contact"){
  if(env == "test"){
	urlmod = "http://test-5.dodge.ca/wccs-ca/index_en.jsp";
  }
  if(env == "dev"){
	urlmod = "http://uat-5.dodge.ca/wccs-ca/index_en.jsp"; 
  }
  if(env == "uat"){
	urlmod = "http://uat-5.dodge.ca/wccs-ca/index_en.jsp"; 
  }
  if(env == "www"){
   urlmod = "http://www-5.dodge.ca/wccs-ca/index_en.jsp"; 
  }
  if(env == "53"){
   urlmod = "http://test-5.dodge.ca/wccs-ca/index_en.jsp"; 
  }
  if(env == "jeep"){
   urlmod = "http://www-5.jeep.ca/wccs-ca/index_en.jsp"; 
  }
  if(env == "dodge"){
   urlmod = "http://www-5.dodge.ca/wccs-ca/index_en.jsp"; 
  }
  if(env == "chrysler"){
   urlmod = "http://www-5.chrysler.ca/wccs-ca/index_en.jsp"; 
  } 
          // ASC environments
          if(env == "qa-dcci-config"){
             env = "uat-5";
          }
          if(env == "dcci-config"){
             env = "www-5";
          }  
  eval('window.open(urlmod, namer, "history=no,toolbar='+tool+',location='+loc+',directories='+dir+',status='+stat+',menubar='+menu+ ',scrollbars='+scroll+',resizable='+resize+',width=' +  y  + ',height=' +  x + '");');
 } else {
  eval('window.open(topic, namer, "history=no,toolbar='+tool+',location='+loc+',directories='+dir+',status='+stat+',menubar='+menu+ ',scrollbars='+scroll+',resizable='+resize+',width=' +  y  + ',height=' +  x + '");');
 }
}

//ROLLOVER FUNCTION

var loaded = new Array();

function loadRollover(image,imageName) {
   if (image && image.src &&
    (null == image.out || typeof(image.out) == typeof(void(0)))) {
      s = image.src;
      image.out = new Image();
      image.out.src = s;
      image.over = new Image();
      if (imageName.lastIndexOf('/') >= 0 || imageName.lastIndexOf('\\') >=0) {
         s = imageName;
      } else {
         i = s.lastIndexOf('/');
         if (i<0) i = s.lastIndexOf('\\');
         if (i<0) { s = imageName; }
         else     { s = s.substring(0,i+1) + imageName; }
      }
      image.over.src = s;
      loaded[image.name] = image;
   }
}
function roll(imageName,over) {
   if (document.images) {
      if (over) { imageObject = "over"; }
      else      { imageObject = "out"; }
   image = loaded[imageName];
   if (image) {
       ref = eval("image."+imageObject);
       if (ref) image.src = eval("image."+imageObject+".src");
   }
   if (window.event)
      window.event.cancelBubble = true;
   }
}



function closeDivs() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myHeight = document.body.clientHeight;
  }
if (myHeight < 700) {
 hideAll();
}  
}


 function hideAll() {
  x = 1;	 
  while (layerName != '') {
    var name = "feature" + x + "_content";
	var more = "feature" + x + "_content_show";
	var less = "feature" + x + "_content_hide";

    var layerName = document.getElementById(name);	
    var moreLayerName = document.getElementById(more);	
    var lessLayerName = document.getElementById(less);	
	
    if (layerName == null) {
     break
	} else {
     layerName.style.display='none';
     moreLayerName.style.display='block';
     lessLayerName.style.display='none';
	}
	x++;
   }
  //document.getElementById('showAllLayer').style.display = 'block'; 
  //document.getElementById('hideAllLayer').style.display = 'none';
  } 




// ---------------------------------------------------------------------------------------
// Universal Popup function
function universal(name,vehicle,noinvoke) {
	
	var noinvoke = (noinvoke == null) ? noinvoke=false : noinvoke;
	
	
h = 480;
w = 490;
scrolling = "yes";
windowname = "open_me";
input_box = true;
popup = true;
currentwin=false;

//------------------------new section for trilogy BP ------------------
var tmp = location.hostname.split(".");
var env = tmp[0].toLowerCase();
var site = tmp[1].toLowerCase();

          if(env == "test"){
	   env = "test-5";  
	  }
	  if(env == "dev"){
	   env = "uat-5";
	  }
	  if(env == "uat"){
	   env = "uat-5";
	  }
	  if(env == "www"){
	    env = "www-5";
	  }
          if(env == "53"){
            env = "test-5";
          }
          if(env == "jeep"){
             env = "www-5";
          }
          if(env == "dodge"){
             env = "www-5";
          }
          if(env == "chrysler"){
             env = "www-5";
          }  
          // ASC environments
          if(env == "qa-dcci-config"){
             env = "uat-5";
          }
          if(env == "dcci-config"){
             env = "www-5";
          }		  

//------------------------new section for trilogy BP ------------------


// Associating the name of the link with the url
switch (name)
{
      
    case "getaquote": url = "http://" + env + ".dodge.ca/vehsuite/GetQuote.jsp?vehicle="+ vehicle +"&lang=en-ca";h=600;w=774;break;
    
	
	//case "retailer": url = "http://" + env + ".dodge.ca/vehsuite/DealerSearch.jsp?lang=en-ca";;windowname=name;h=420;w=770;break;
	
	
	   case "retailer": url = "http://www.chrysler.ca/retailer/index.php?brand=chrysler&language=en";windowname=name;h=565;w=992;break;	
	   
   // case "getaquote": url = "http://www.daimlerchrysler.ca/CA/04/EN/DODGE/1,,CA-04-EN-DODGE-QUOTE,.html";h=580;w=620;break;
   // case "retailer": url = "http://www.c1hrapps.com/locator/CA/?presentationId=dlen_CAsdc1&brand=D";windowname=name;h=420;w=620;break;
    case "inventory": url = "http://www.c1hrapps.com/locator/CA/?presentationId=dlen_CAinc1&brand=D";windowname=name;h=420;w=620;break;    
   // case "specialoffers": url = "http://www.daimlerchryslerhotdeals.ca/en";h=600;w=700;break;
   case "specialoffers": url = "http://www.chryslercanada.ca/en/specialoffers/index.php?brand=dodge";popup = false; currentwin=true; break;
   
      // case "specialofferspopup": url = "http://www.chryslercanada.ca/en/specialoffers/index.php?brand=dodge";windowname="specialoffers";h=755;w=1024;break;
	
  case "specialofferspopup": url = "http://www.getachryslerjeepdodge.ca/";windowname="specialoffers";h=800;w=1024;break;
	  
    //case "specialoffers": url = "http://www.daimlerchrysler.ca/EN/CHRYSLER/1,,EN-CHRYSLER-PLUS,.html";h=610;w=650;break;
    //case "blackbook": url = "http://www.daimlerchrysler.ca/cgi-bin/getcbb.cgi?en"; input_box=confirm("You are now leaving the DaimlerChrysler Canada web site. DaimlerChrysler Canada Inc., its agents, affiliates, officers, directors, employees and insurers (DaimlerChrysler Canada)  make no warranty of any kind regarding the accuracy and use of the information on the Canadian Black Book site and is not liable for damages of any kind arising out of your access to or use of this Site. Your use of and browsing in this site are at your own risk. Would you like to continue? ");break;
    case "blackbook": url = "http://www.canadianblackbook.com/prv/auth.cfm?token=AB04DC39ZKL01"; input_box=confirm("You are now leaving the DaimlerChrysler Canada web site. DaimlerChrysler Canada Inc., its agents, affiliates, officers, directors, employees and insurers (DaimlerChrysler Canada)  make no warranty of any kind regarding the accuracy and use of the information on the Canadian Black Book site and is not liable for damages of any kind arising out of your access to or use of this Site. Your use of and browsing in this site are at your own risk. Would you like to continue? ");break;

    case "buildyourown": url = "http://www.daimlerchrysler.ca/CA/04/EN/CHRYSLER/1,,CA-04-EN-CHRYSLER-BUILD_AND_PRICE,.html";popup=false;currentwin=true;break;
 
 /*
  case "getabrochure": url = "http://www-5.dodge.ca/crmforms/GetForm.jam?PageName=personal_info&SalesMarket=C&CountryCode=CA&LanguageCode=EN&Brand=Dodge&FormName=getabrochure&MediaCode=WS20&MediumCode=DGGABR&PromoCode=0000000";w=600;break;
  
    case "efamily": url = "http://www-5.dodge.ca/crmforms/GetForm.jam?PageName=personal_info&SalesMarket=C&CountryCode=CA&LanguageCode=EN&Brand=Dodge&FormName=efamilyregistration&MediaCode=WS20&MediumCode=EFAMIL&PromoCode=0000000";w=600;break;*/
	
case "getabrochure": url = "http://www.chryslercanada.ca/en/crm/index.php?brand=dodge&form=gab";windowname=name;popup=false;currentwin=true;break;
case "efamily": url = "http://www.chryslercanada.ca/en/crm/index.php?brand=dodge&form=efamily";windowname=name;popup=false;currentwin=true;break;
  

	
    case "compare": url = "http://www.daimlerchrysler.ca/CA/04/EN/CHRYSLER/1,,CA-04-EN-CHRYSLER-COMPARE,.html";w=610;h=610;self.name="Configurator";break;
    case "accessories": w=800;h=540;windowname=name;break;
    case "recommendations": url = "http://www.daimlerchrysler.ca/EN/RECOMMENDATIONS/1,,EN-RECOMMENDATIONS,.html";h=315;w=463;windowname=name;break;
    case "fleet": url = "http://www.fleet.daimlerchrysler.ca/CA/04/EN/FLEET/1,,CA-04-EN-FLEET,.html";windowname=name;popup=false;break;	
    case "financial": url = "http://www.daimlerchryslerfinancial.ca/en/index.jsp";windowname=name;popup=false;break;
    case "owners": url = "http://www.daimlerchrysler.ca/CA/03/EN/OWNERS/1,,CA-03-EN-OWNERS,.html?Chrysler";windowname=name;popup=false;break;
    case "worldwide": url="http://www.international.chryslercorp.com";h=520;w=840;break;
    case "disclaimer": url = "http://www.daimlerchrysler.ca/CA/04/EN/LEGAL/1,,CA-04-EN-LEGAL,.html";h=450;w=790;break;
    case "recommender": url = "http://www-5.dodge.ca/vehicleRecommender/RecommenderController?action=vehicleRecommender&language=EN&sales_market=C&brand=Dodge";w=775;h=605;break;
    case "store": url = "http://www.dodgegear.ca";windowname=name;h=470;w=860;break;
    default:
}












if(name == "accessories" && vehicle != null) {
	origin="Mopar1"
	switch (vehicle) {
		case "sebringsedan": vehicle = "SebringSedan";break;
		case "sebringconvertible": vehicle = "SebringConvertible";break;
		case "intrepid": vehicle = "Intrepid";break;
		case "concorde": vehicle = "Concorde";break;
		case "300m": vehicle = "300m";break;
		case "town_country": vehicle = "TownCountry";break;
		case "pt_cruiser": vehicle = "PTCruiser";break;
		case "pacifica": vehicle = "Pacifica";break;
		case "crossfire": vehicle = "Crossfire";break;
		default:
	}
	url = "http://www.daimlerchrysler.ca/configurator/FrontController?SalesMarket=C&Origin="+origin+"&Brand=Dodge&Language=EN&Year=2003&Nameplate="+vehicle+"&ModelTitle=&DefaultConfig=&MainPaint=&ConfigData=&MaxNav=1&CurrentNav=1&PartsSummary=&PartsQuantity=&PartsSubTotal=&ButtonPressed=NextStep&MaxNav=1";
	//url = "http://www.daimlerchrysler.ca/configurator/FrontController?SalesMarket=C&Origin="+origin+"&Brand=Dodge&Language=EN&Year=2003&Nameplate="+vehicle+"&ModelTitle=&DefaultConfig=&MainPaint=&ConfigData=&MaxNav=1&CurrentNav=1&PartsSummary=&PartsQuantity=&PartsSubTotal=&ButtonPressed=NextStep&MaxNav=1";
} else if(name == "accessories" && vehicle == null) {
	origin="MOPAR";
	url = "http://www.daimlerchrysler.ca/configurator/FrontController?Origin="+origin+"&Year=2003&SalesMarket=C&Language=EN&Brand=Dodge";
}
// Determining if popup

if(   ((site == "chrysler")  ||  (env == "chrysler"))  && noinvoke == false  ){
   
invokeElement('LocateDealer');

}else{//else use univeral as normal

if (popup == false && url != null) {
	if (currentwin==true){
		location.href=url;
	} else {
		eval(window.open(url,windowname));
	}
} else if (input_box==true && url != null) {
	// Output when OK is clicked
	eval(window.open(url,windowname,"history=no,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars="+scrolling+",resizable=yes,width="+w+",height="+h));
} else {
	// Output when CANCEL is clicked and url is a null value
  }
}//end of new if AA for invoke


}

//-------------------------------------------------------------------------------------------



//---- Popup for P&E  New - Trilogy
function start(namePlate, brand ,lang) {   

if (namePlate == "CARAVAN") {
 namePlate = "2006caravan";
} else if (namePlate == "CHARGER") {
 namePlate = "2006charger";
} else if (namePlate == "MAGNUM") {
 namePlate = "2006magnum";
} else if (namePlate == "DURANGO") {
 namePlate = "2006durango";
} else if (namePlate == "DAKOTA") {
 namePlate = "2006dakota";
} else if (namePlate == "RAM_PICKUP_1500") {
 namePlate = "2006ram1500";
} else if (namePlate == "RAM_PICKUP_2500_3500") {
 namePlate = "2006ram2500";
} else if (namePlate == "SX20") {
 namePlate = "2006srt4";
} else if (namePlate == "VIPER") {
 namePlate = "2006viper";
} else if (namePlate == "SPRINTER") {
 namePlate = "2006sprinter";
}else if (namePlate == "CALIBER") {
 namePlate = "2007caliber";
}

	 var lang = lang.toLowerCase();
	var tmp = location.hostname.split(".");
	var env = tmp[0].toLowerCase();
          if(env == "test"){
	   env = "test-5";  
	  }
	  if(env == "dev"){
	   env = "uat-5";
	  }
	  if(env == "uat"){
	   env = "uat-5";
	  }
	  if(env == "www"){
	    env = "www-5";
	  }
          if(env == "53"){
            env = "test-5";
          }
          if(env == "jeep"){
             env = "www-5";
          }
          if(env == "dodge"){
             env = "www-5";
          }
          if(env == "chrysler"){
             env = "www-5";
          }  
          // ASC environments
          if(env == "qa-dcci-config"){
             env = "uat-5";
          }
          if(env == "dcci-config"){
             env = "www-5";
          }		  
         // url = "http://"+ env + ".dodge.ca/vehsuite/ModelSelector.jsp?vehicle=" + namePlate+"&lang="+lang+"-ca"; 
		// url = "http://dcci-config.autodatadirect.com/chryslerca/buildYourVehicle.html?modelYearCode="+namePlate+"&language="+lang
		  url = "http://www.chryslerhotdeals.ca/exo/en/index.php?vehicle=" + namePlate+"&lang=en-ca&brand=dodge"; 
	  //alert("PLEASE NOTE: We are in the process of updating the pricing information within Build and Price. The prices shown are valid for vehicles received at dealerships before October 2, 2005. There may be an increase in the MSRP of the vehicles received after this date.  Please see your local retailer for current vehicle pricing.");
          self.name = "Configurator";
	  location.href=url;
}




// ---------------------------------------------------------------------------------------




//---DISCLAIMER FUNCTIONS --

  

//start of all purpose mouse tracker-------------------------  	 


var mouseX, mouseY;

function getMousePos(e){
        if (!e)
                var e = window.event||window.Event;
       
        if('undefined'!=typeof e.pageX){
                mouseX = e.pageX;
                mouseY = e.pageY;
        } else {
                mouseX = e.clientX + document.body.scrollLeft;
                mouseY = e.clientY + document.body.scrollTop;
        }
}



if(window.Event && document.captureEvents)
 document.captureEvents(Event.MOUSEMOVE);
 document.onmousemove = getMousePos;

//this is the all purpose mouse tracker---------------------------------------------------------------------------------------------------------

										   
									  



	   //remove learnmore ----------------------------
    function Remove_learn_more(){
    obj = document.getElementById("outlayer_lm");
    obj.style.display = "none";
}





//this is learnmore callback ajax function  ---------------------------------------------------------------------------------------------------------    
function getcontent_status_lm(content_status_in)       //receives the reply from Ajax and PHP file runquery.php and displays
{
                  
  obj = document.getElementById("outlayer_lm");
  
  if(mouseX > 800){compensate = 350;}else{compensate=20;}
  
  obj.style.left = mouseX - compensate +"px";           //addition of 10 pixels for style reasons  - left
  obj.style.top = mouseY + "px";      //addition of -2 pixels for style reasons  - top
       
  obj.style.display = "block";

	
  document.getElementById("outlayer_lm").innerHTML = content_status_in;

 }
 
 
//JavaScript Alert Function
function popPage(page,w,h) {
 eval('window.open(page, "popname", "height='+h+',width='+w+',location=no,scrollbars=yes,menubars=yes,toolbars=no,resizable=yes");');
}

function alertPop(url,message,w,h) {
	var prompt = confirm(message)
	if (prompt){
    	popPage(url,w,h);
	}
}	 



	 function getcontent_status_show(content_status)	//receives the reply from Ajax and PHP file runquery.php and displays

      {
	
		
       //document.getElementById("ajax_container").innerHTML = content_status; 

		 //sp1 = new Spry.Widget.SlidingPanels("SlidingPanels1");

      }

//Change StyleSheet Function
function changeStyle(styleID,changeToName) {
 document.getElementById(styleID).href = changeToName;
 var poststr="";
 poststr = "&styleSht=" + changeToName;
 postDataReturnText('includes/setSession.php', poststr, getcontent_status_show);	  
}


//NavRollover
function buzzRO(img,state) {
 if (state == 'on') { document.images[img].src = eval(img + "_on.src"); }
 else { document.images[img].src = eval(img + ".src"); }
}

function preload(imgObj) {
	if (document.images) {
		eval(imgObj+' = new Image()');
		imgSrc = ('img/' + imgObj + '.gif');			
		eval(imgObj+'.src = "'+imgSrc+'"');
		eval(imgObj+'_on = new Image()');
		imgSrc = ('img/' + imgObj + '_on.gif');			
		eval(imgObj+'_on.src = "'+imgSrc+'"');		
	}
}

preload('nav_sponsorship');
preload('nav_presidentscorner');
preload('nav_activities');
preload('nav_gallery');
preload('nav_ourpartners');
preload('nav_cheerzone');
preload('nav_about');
preload('nav_2010news');
preload('nav_videos');

