//--------------------------------------Count checks------------------------------------------

 var dodge_array = new Array(); 	  
var chrysler_array = new Array(); 
var jeep_array = new Array(); 


function CountChecks(which) {	 



aquirevec = document.getElementById("curaquirevec").value;
currentmodel = 	document.getElementById("curownmodel").value;
yeslease = document.getElementById("vec_used_Own").checked;
nolease = document.getElementById("vec_used_Lease").checked;
curownyear = document.getElementById("curownyear").value; 

							  
if ( aquirevec != ''){
  document.getElementById("isoptin").checked = true; 

  document.getElementById("mandat2").style.visibility='visible';
   document.getElementById("mandat3").style.visibility='visible';
} else if( currentmodel != ''){
   document.getElementById("isoptin").checked = true; 

  document.getElementById("mandat2").style.visibility='visible';
   document.getElementById("mandat3").style.visibility='visible';
}
else if( yeslease != ''){
  document.getElementById("isoptin").checked = true; 

  document.getElementById("mandat2").style.visibility='visible';
   document.getElementById("mandat3").style.visibility='visible';
}
else if( nolease != ''){
  document.getElementById("isoptin").checked = true; 
  
  document.getElementById("mandat2").style.visibility='visible';
   document.getElementById("mandat3").style.visibility='visible';
}
else if( curownyear != ''){
  document.getElementById("isoptin").checked = true; 
 
  document.getElementById("mandat2").style.visibility='visible';
   document.getElementById("mandat3").style.visibility='visible';
}
	
 


}		  


//------------------------------------------------------------------------------------------------------------------------------------------

	    


	  
  			  
				   


	  


//-----------------------This is a Roll Over 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;
   }
}

//-----------------------This is a Roll Over Function ----------------------------	
		

//---- Popup for P&E
function start(namePlate, brand ,lang) {
	var tmp = location.hostname.split(".");
	var env = tmp[0].toLowerCase();
	var lang = lang.toLowerCase();
	  // url = "http://www-5.dodge.ca/configurator/bridge.htm?" + namePlate + "\&" + lang + "\&" + brand;  
	  url = "http://www-5."+brand+".ca/vehsuite/ModelSelector.jsp?vehicle=" + namePlate+"&dreamdrive=true&lang="+lang+"-ca";
 	//  url =  "http://www."+brand+".ca/"+lang+"/buildprice.html?vehicle=" + namePlate + "&brand=" + brand + "&language=" + lang;
	  //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;
}

			   


//----- 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 == "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"; 
  }  
  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 + '");');
 }
}	 

	  




// ---------------------------------------------------------------------------------------
function email_friend_pop() {
// Defining default values
h = 550;
w = 440;	
windowname = "email_a_friend";
input_box = true;
popup = true;
currentwin=false;


//------------------------new section for trilogy BP ------------------

 url ="email_others.php";
    

eval(window.open(url,name,"history=no,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width="+w+",height="+h));

}

// ---------------------------------------------------------------------------------------
		 


		//These are Ajax functions used to save all info for the user on change

    function getcontent_status_saveinfo(content_status_in)	//receives the reply from Ajax and PHP file runquery.php and displays

      {

       // document.getElementById("content").innerHTML = content_status_in; 
		 //document.getElementById("status").innerHTML = content_status_in;
		 alert(content_status_in);
		 //window.status = content_status_in;
      }
	  
	  
	   function saveinfo_to_session(action)	//grabs all values from and saves it to a session

      {		
	  
		  var poststr="";
		

		
		 poststr+= "&title=" + document.getElementById('req_title').value;
		 poststr+= "&firstname=" + document.getElementById('first_name_used').value;
		 poststr+= "&prefername=" + document.getElementById('req_name_used').value;
		 poststr+= "&middleint=" + document.getElementById('mid_int_used').value;
		 poststr+= "&lastname=" + document.getElementById('last_name_used').value;
		 poststr+= "&address1=" + document.getElementById('address1_used').value;
		 poststr+= "&address2=" + document.getElementById('address2_used').value;
		 poststr+= "&city=" + document.getElementById('req_city_used').value;
		 poststr+= "&province=" + document.getElementById('req_province_used').value;
		 poststr+= "&postalcode=" +  document.getElementById('postalcode_used').value;
		
		
		  
		
		
		if( (document.getElementById('home_add_Yes').checked) == true ){
		 poststr+= "&is_home_add=" +  "Yes";
		} else if( (document.getElementById('home_add_No').checked) == true ){
		
		 poststr+= "&is_home_add=" +  "No";
		} else{
		
		 poststr+= "&is_home_add=" +  "";
		}
		  
		
		
		poststr+= "&yearbirth=" +  document.getElementById('year_birth_used').value;
		poststr+= "&pre_lang=" +  document.getElementById('pre_lang_used').value;
		
		poststr+= "&homephone_area=" +  document.getElementById('home_area_used').value;
		poststr+= "&homephone_front=" +  document.getElementById('home_front_used').value; 
		poststr+= "&homephone_back=" + document.getElementById('home_back_used').value;
		
		poststr+= "&workphone_area=" +  document.getElementById('work_area_used').value;
		poststr+= "&workphone_front=" + document.getElementById('work_front_used').value;	 
		poststr+= "&workphone_back=" + document.getElementById('work_back_used').value; 
		
		poststr+= "&email=" + document.getElementById('email_used').value;
		
		

		poststr+= "&optin_input=" + document.getElementById('isoptin').checked;
	
	
		 
		
		poststr+= "&aquire_vec=" + document.getElementById('curaquirevec').value;
		poststr+= "&curr_ownyear=" + document.getElementById('curownyear').value;
		poststr+= "&curr_model=" + document.getElementById('curownmodel').value;
		
		
		
		
		
		if( (document.getElementById('vec_used_Own').checked) == true ){
		   
		  poststr+= "&vec_used_usedornew=" +  "Own";
		} else if( (document.getElementById('vec_used_Lease').checked) == true ){
		
		  
		   poststr+= "&vec_used_usedornew=" +  "Lease";
		}else{
		
		   poststr+= "&vec_used_usedornew=" +  "";
		}	 
		
		
		 
		
		poststr+= "&action=" + action;
	
	  
	   dataout = "&action=" + action;
	   
	   
	   postDataReturnText('modules/save_info.php', poststr, getcontent_status_saveinfo);	  
	   
	   
 }	
