// JavaScript Document

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

// JavaScript Document
<!--

function ContactFormValidation (sFieldIDs) {
   var i;
   var arrFields = sFieldIDs.split(':');
   var currField;
   var bSubmitForm = true;
   var email= /^[\w-\.]+\@[\w\.-]+\.[a-zA-Z]{2,4}$/;
   
   for (i = 0; i < arrFields.length; i++) {
      // Get form field reference
      currField = document.getElementById(arrFields[i]);
      
      // Check for null in the case of a non existing html element
      if (currField != null) {      
         // Set fields style to default
         SetBorderStyle(currField, 'default');
         
         // If field is empty then set the style to red background and border
         if (currField.name.toLowerCase() == 'email' && (!(email.test(currField.value)))) {
            SetBorderStyle(currField, 'error');
            bSubmitForm = false;
         }
         else if (currField.value == '') {
            SetBorderStyle(currField, 'error');
            bSubmitForm = false;
         }
      }
   }
   return bSubmitForm;
}
function SetBorderStyle(fldFormField, fDefaultOrError){
   if (fDefaultOrError.toLowerCase() == 'error') {
      borderstyle = '1px solid #ea172a';
      bgcolorstyle = '#ffc0c0';
   }
   else if (fDefaultOrError.toLowerCase() == 'default') {
      borderstyle = '1px solid #969696';
      bgcolorstyle = '#FFFFFF';
   }
   
   fldFormField.style.border = borderstyle;
   fldFormField.style.background = bgcolorstyle;
}

//functions for the new vehicle selection page

function car_desc_replace(brand)
	{
			var gmc_content = "At GMC, we show how experience and innovation can overcome compromise. It's why we never say never. GMC We are professional grade.";
			var chevrolet_content = "Chevrolet cars, trucks and crossovers are changing the way you look at driving - from the revolutionaty Chevrolet Volt to the powerful capability of the Silverado pickup; the award-winning Malibu sedan to the versatile performance of the Equinox crossover.";
			var buick_content = "Buick's line up starts with Enclave, the stylish, spacious and well-appointed crossover. Next is LaCrosse. Sculpted lines, intuitive technology and advanced preformance. Now there's Regal, an inspired driving experience. Each distinct. All Buick.";
			var cadillac_content = "From the dramatic styling and performance of the CTS portfolio, including the all new 556hp CTS-V Coupe, to the versatile capability of the SRX Crossover and Escalade, Cadillac blends driving dynamics, refinement and technology to satisfy enthusiasts and luxury-seekers alike.";
			
			
			if(brand == 'gmc')
				{
					document.getElementById('brand_image').innerHTML = '<img src="images/nov_cars/images/img_gmc_layout.jpg" alt="GMC">';
					document.getElementById('brand_description').innerHTML = gmc_content;
					document.getElementById('gmc_logo').src = 'images/bttn_logo_gmc2.jpg';
				}
			if(brand == 'chevrolet')
				{
					document.getElementById('brand_image').innerHTML = '<img src="images/nov_cars/images/img_chevrolet_layout.jpg" alt="Chevrolet">';
					document.getElementById('brand_description').innerHTML = chevrolet_content;
					document.getElementById('chevrolet_logo').src = 'images/bttn_logo_chevrolet2.jpg';
				}
			if(brand == 'buick')
				{
					document.getElementById('brand_image').innerHTML = '<img src="images/nov_cars/images/img_buick_layout.jpg" alt="buick">';
					document.getElementById('brand_description').innerHTML = buick_content;
					document.getElementById('buick_logo').src = 'images/bttn_logo_buick2.jpg';
				}
			if(brand == 'cadillac')
				{
					document.getElementById('brand_image').innerHTML = '<img src="images/nov_cars/images/img_cadillac_layout.jpg" alt="cadillac">';
					document.getElementById('brand_description').innerHTML = cadillac_content;
					document.getElementById('cadillac_logo').src = 'images/bttn_logo_cadillac2.jpg';
				}
	}
	

