//Function to display the Images on the Showroom Performance And Safety Page
function PerformanceAndSafety_DisplayImageDiv(id)
{
  
    //Hide all the divs that start with pimageContent
    var divs = document.getElementsByTagName("div");

    for (var i=0;i<divs.length;i++) 
    { 
        
        if (divs[i].id.substring(0,13)=="pimageContent" && id.indexOf("pimageContent") != -1) 
        {      
            divs[i].style.display = "none";
        }  
        
         if (divs[i].id.substring(0,13)=="simageContent" && id.indexOf("simageContent") != -1) 
         {
            divs[i].style.display = "none";
         }
       
    }
    //Display the div that was passed in
    el = document.getElementById(id);    
	el.style.display = 'block';		    
}

//Function to clear the value of an input field
function ClearText(id)
{   
    var el = document.getElementById(id); 
    if (el.value == 'Postal Code')   
    {
        el.value = "";
    }    
}

//Function to clear the value of an input field
function changepic(id)
{   
    alert(id);
    var el = document.getElementById(id); 
    el.src = "";
}

//Function used to display the disclaimer for an accessory
//Used by Showroom Accessory Page
function showDisclaimer(id)
{   
   var el = document.getElementById(id); 
   
   if (el.style.display == 'block')
   {
        el.style.display = 'none';
   }
   else
   {
        el.style.display = 'block';
   }
   

}

//Function to change the vehicle Image and display the available interior colors
//Used by Showroom Colours Page
function colorSelected(varExteriorColordiv, varInteriorColorList, varImageLocation)
{   

    //Hide all the interior color divs     
    var divs = document.getElementsByTagName("div");
    
    for (var i=0;i<divs.length;i++) 
    {     
        if (divs[i].id.substring(0,16)=="divInteriorColor") 
        {      
            divs[i].style.display = "none";
        }   
        
        if(divs[i].id.substring(0,16)=="divExteriorColor")
        {
            divs[i].className = "swatchExterior";
        }
    }       
    
    //Display the valid interior divs
    intArray = varInteriorColorList.split(",");
    
    for(var x in intArray)
    {   
    
        //Display the div that was passed in
        el = document.getElementById("divInteriorColor" + intArray[x].toString());    
	    el.style.display = 'block';	  
    }
    
    //Change the VehicleImage
    el = document.getElementById("vehicleImage");
    el.src = varImageLocation;
    
    
    //Change the selected div class
    el = document.getElementById(varExteriorColordiv);
    el.className = "swatchSelected";              
}

//Change the div inner text to display an image
//Used by showroom Gallery page
function Gallery_LoadImage(varDivId, variableImageLocation, varImageName)
{   
    el = document.getElementById(varDivId);
    el.innerHTML = "<img src='" + variableImageLocation + "' alt='" + varImageName + "'/>";
}

//Change the div inner text to display a flash file
//Used by showroom Gallery page
function Gallery_LoadSWF(varDivId, variableFlashLocation, varFlashLang)
{   
   //el = document.getElementById(varDivId);
   //el.innerHTML = "<object width=\"770\" height=\"254\"><param name=\"wmode\" value=\"transparent\"><param name=\"movie\" value=\"" + variableFlashLocation + "\"><embed src=\"" + variableFlashLocation + "\" width=\"770\" height=\"354\" wmode=\"transparent\"></embed></object>";   
   
    var fo = new FlashObject(variableFlashLocation, "3D", "770", "354", "8", "#FFFFFF");
    fo.addParam("wmode", "transparent");
    fo.addParam("movie", variableFlashLocation);
    if(varFlashLang == "en")
    fo.addParam("FlashVars","lang=en");
    else
     fo.addParam("FlashVars","lang=fr");
    fo.write(varDivId);
   
}

