﻿//-- Define some Colours
var bodystyle  ;
var CHARCOAL = "#232323" ;
var CHROME   = "#c6d6dc" ;
var BLACK    = "#191C1B" ;
var NOCOLOUR = "#cccccc" ;

var colourname = new Array()
    colourname["CB01"] = "Grey" ;
    colourname["CB02"] = "Black" ;
    colourname["CB03"] = "Red" ;
    colourname["CB04"] = "Silver" ;

    colourname["SB_Charcoal"] = "Warm Charcoal" ;
    colourname["SB_Flint"] = "Flint" ;

	// display these names for facia trim
    colourname["facia1_pianoblack"] = "Piano Black" ;
    colourname["facia1_alloy"] = "Micro-Spin Alloy" ;
    colourname["facia1_gunmetal"] = "Gun Metal" ;

    colourname["facia2_pianoblack"] = "Piano Black" ;
    colourname["facia2_prism_alloy"] = "Prism Alloy" ;



/* ========== MENU ACTIONS ============= */
function DoExteriorColour () {
    ShowMenuBlock('exteriorcolour');
    gHiddenCol = "exteriorcolour" ;
    SetupColourBlock ('COL','exteriorcolour');
	InfoOn('colourexterior');
}

function DoHoodColour () {
    ShowMenuBlock('hoodcolour');
    gHiddenCol = "hoodcolour" ;
    SetupColourBlock ('HEX','hoodcolour');
	InfoOn('colour');
    postevent('view_hood');
}

function DoUpperColour () {
    ShowMenuBlock('uppercolour');
    gHiddenCol = "uppercolour" ;
    SetupColourBlock('LTH','uppercolour');
	InfoOn('colour');
}

function DoLowerColour () {
    ShowMenuBlock('lowercolour');
    gHiddenCol = "lowercolour" ;
    SetupColourBlock('LTH','lowercolour');
	InfoOn('colour');
}

function DoStitchingColour () {
    ShowMenuBlock('stitchingcolour');
	var elHeading = document.getElementById( 'stitchingcolourheading' ) ;
    if ( d['stitchingtype'].value == 'thick' ) {
        gHiddenCol='thickstitchingcolour';
        SetupColourBlock('TTHR','stitchingcolour');
        if (elHeading) elHeading.innerText = "Interior Stitching Colour (Coarse)" ;
	} else {
        gHiddenCol='thinstitchingcolour';
        SetupColourBlock('THRD','stitchingcolour');
        if (elHeading) elHeading.innerText = "Interior Stitching Colour (Fine)" ;
	}
}


function DoSeatOuterColour () {
    ShowMenuBlock('seatoutercolour');
    gHiddenCol = "seatoutercolour" ;
    SetupColourBlock('LTH','seatoutercolour');
	InfoOn('colour');
}

function DoSeatInnerColour () {
    ShowMenuBlock('seatinnercolour');
    gHiddenCol = "seatinnercolour" ;
    SetupColourBlock('LTH','seatinnercolour');
	InfoOn('colour');
}


function DoSeatStitchingColour () {
	// hide colourwarning in ShowMenuBlock()
	// display colourwarning with SetupColourBlock()
    ShowMenuBlock('seatstitchingcolour');
	var elHeading = document.getElementById( 'seatstitchingcolourheading' ) ;
    if ( d['stitchingtype'].value == 'thick' ) {
        gHiddenCol='seatthickstitchingcolour';
        if (elHeading) elHeading.innerText = "Seat Stitching Colour (Coarse)" ;
        SetupColourBlock('TTHR','seatstitchingcolour');
	} else {
        gHiddenCol='seatthinstitchingcolour';
        if (elHeading) elHeading.innerText = "Seat Stitching Colour (Fine)" ;
        SetupColourBlock('THRD','seatstitchingcolour');
	}
}


function DoCarpetColour () {
    ShowMenuBlock('carpetcolour');
    gHiddenCol = "carpetcolour" ;
    SetupColourBlock('CARP','carpetcolour');
	InfoOn('colour');
}

function DoCarpetStitchingColour () {
    ShowMenuBlock('carpetstitchingcolour');
    gHiddenCol = "carpetthickstitchingcolour" ;
    SetupColourBlock('TTHR','carpetstitchingcolour');
}

function DoHeadliningColour () {
    ShowMenuBlock('headliningcolour');
    gHiddenCol = "headliningcolour" ;
    SetupColourBlock('HIN','headliningcolour');
	InfoOn('colour');
}


function DoWheels () {
    ShowMenuBlock('wheels');
    postevent('view_wheel');
}

function DoBrakeCaliper () {
    ShowMenuBlock('brakecaliper');
	ShowColourWarning ()
    cellInit('brakecaliper');
}
function DoSeatBelt () {
    ShowMenuBlock('seatbelt');
	ShowColourWarning ()
    cellInit('seatbelt');
    postevent('view_seatbelts');
}

function DoFacia() {
	ShowMenuBlock('fittings');
	if (d.interiorfinish.value=='graphite') {
		hide('facia2');
		show('facia1');
		cellInit('facia1');
	}
	else {
		hide('facia1');
		show('facia2');
		cellInit('facia2');
	}
	vmpInteriorFinish();
}

function DoSteering ( ) {
	// match or colour contrast
	ShowMenuBlock('steering');
	var code = d.steeringchoice.value ;
	var el = document.getElementById('selectsteeringcolour') ;
	if (!el) return ;
	el.style.display = (code=='black' ? 'none' : 'block' ) ;
	if ( code == 'colour' ) {
    	gHiddenCol = "steeringcolour" ;
    	SetupColourBlock('LTH','steeringcolour');
		InfoOn('colour');
	}
	else {
		// weird, but this hides colour warnings, and l.h. info blocks
		ShowMenuBlock ('steering');
	}
	vmpSteering();
}



/* ============== ACTIONS ============== */

//--------
// Set 3D Defaults
//--------
function vmpDefaults () {
    if (!d) d=document.hiddenform ;

    // either leather or leather + mesh
    // postevent('show_leather') ;

    // get data from hiddenform, call javascript to set 3D model
    // want this to work when user does forwards/backwards etc
    // so get all the animations from the hiddenform
    vmpSetColour('exteriorcolour');
    vmpSetColour('uppercolour');
    vmpSetColour('lowercolour');
    vmpSetColour('seatoutercolour');
    vmpSetColour('seatinnercolour');
    vmpSetColour('carpetcolour');
    vmpSetColour('carpetstitchingcolour');
    vmpSetColour('headliningcolour');
	vmpSetColour('hoodcolour');

    vmpSetColour('brakecaliper');
    vmpSetColour('seatbelt');
	
	vmpStitching ( d.stitchingtype.value );
    vmpSetColour('stitchingcolour');
    vmpSetColour('seatstitchingcolour');

    if ( d["territory"].value == "C" || d["territory"].value == "U" )
        postevent('show_fedindicators');
    else
        postevent('hide_fedindicators');

    if ( d["handofdrive"].value == "L" )
        postevent('lefthanddrive');
    else
        postevent('righthanddrive');

    // vmpColourAnim (CHARCOAL,'SteeringColour');
	vmpSteering () ;
	
    // done with vmpSetColour above
    // vmpSeatbelts ( d.seatbelt.value )
	vmpTransmission ( d.transmission.value ) ;
    vmpRearlogo ( d.rearlogo.value )
    vmpGrille ( d.grille.value )
    vmpParkingSensors( d.parkingsensors.value )
    vmpWheels ( d.wheels.value )
    vmpStoneguards ( d.stoneguards.value )
	if (d.winddeflector) vmpWinddeflector (d.winddeflector.value);

	vmpAudio(d.audio.value);
	vmpExteriorMesh(d.exteriormesh.value);
	vmpClearLights(d.clearlights.value);
	vmpBodySills(d.bodysills.value);
	vmpSills( d.alloysillplate.value );
	vmpFrontSeat( d.frontseat.value );
	vmpInteriorFinish();

}


//------------------
// read carcookie
// use it to load previously selected defaults and
// show defaults in (i) hiddenform (ii) frmConfig
// separate from vmp actions
function getCarCookie () {

    if (carcookie.get('grille')) {
        d.grille.value = carcookie.get('grille') ;
        if (document.frmConfig.grille) document.frmConfig.grille.checked = true ;
    }

    if (carcookie.get('rearlogo')) {
        d.rearlogo.value = carcookie.get('rearlogo') ;
        if (document.frmConfig.rearlogo) document.frmConfig.rearlogo.checked = true ;
    }

    if (carcookie.get('headlamp')) {
        d.headlamp.value = carcookie.get('headlamp') ;
        if (document.frmConfig.headlamp) document.frmConfig.headlamp.checked = true ;
    }

    if (carcookie.get('parkingsensors')) {
        d.parkingsensors.value = carcookie.get('parkingsensors') ;
        if (document.frmConfig.parkingsensors) document.frmConfig.parkingsensors.checked = true ;
    }

    if (carcookie.get('stoneguards')) {
        d.stoneguards.value = carcookie.get('stoneguards') ;
        if (document.frmConfig.stoneguards) document.frmConfig.stoneguards.checked = true ;
    }
    if ( carcookie.get('winddeflector') ) {
        d['winddeflector'].value = carcookie.get('winddeflector') ;
        if (document.frmConfig.winddeflector) document.frmConfig.winddeflector.checked = true ;
    }

    if (carcookie.get('battery')) {
        d.battery.value = carcookie.get('battery') ;
        if (document.frmConfig.battery) document.frmConfig.battery.checked = true ;
    }

    if (carcookie.get('heatedfrontseat')) {
        d.heatedfrontseat.value = carcookie.get('heatedfrontseat') ;
        if (document.frmConfig.heatedfrontseat) document.frmConfig.heatedfrontseat.checked = true ;
    }

    if (carcookie.get('memoryseats')) {
        d.memoryseats.value = carcookie.get('memoryseats') ;
        if (document.frmConfig.memoryseats) document.frmConfig.memoryseats.checked = true ;
    }

    if (carcookie.get('fixedseat')) {
        d.fixedseat.value = carcookie.get('fixedseat') ;
        if (document.frmConfig.fixedseat) document.frmConfig.fixedseat.checked = true ;
    }

    if (carcookie.get('heatedwindscreen')) {
        d.heatedwindscreen.value = carcookie.get('heatedwindscreen') ;
        if (document.frmConfig.heatedwindscreen) document.frmConfig.heatedwindscreen.checked = true ;
    }

    if (carcookie.get('smoker')) {
        d.smoker.value = carcookie.get('smoker') ;
        if (document.frmConfig.smoker) document.frmConfig.smoker.checked = true ;
    }

    if (carcookie.get('radiosat')) {
        d.radiosat.value = carcookie.get('radiosat') ;
        if (document.frmConfig.radiosat) document.frmConfig.radiosat.checked = true ;
    }

    if (carcookie.get('phone')) {
        d.phone.value = carcookie.get('phone') ;
        if (document.frmConfig.phone) document.frmConfig.phone.checked = true ;
    }

    if (carcookie.get('bluetooth')) {
        d.bluetooth.value = carcookie.get('bluetooth') ;
        if (document.frmConfig.bluetooth) document.frmConfig.bluetooth.checked = true ;
    }

    if (carcookie.get('cruise')) {
        d.cruise.value = carcookie.get('cruise') ;
        if (document.frmConfig.cruise) document.frmConfig.cruise.checked = true ;
    }

    if (carcookie.get('tracker')) {
        d.tracker.value = carcookie.get('tracker') ;
        if (document.frmConfig.tracker) document.frmConfig.tracker.checked = true ;
    }

    if (carcookie.get('alarm')) {
        d.alarm.value = carcookie.get('alarm') ;
        if (document.frmConfig.alarm) document.frmConfig.alarm.checked = true ;
    }

    if (carcookie.get('firstaid')) {
        d.firstaid.value = carcookie.get('firstaid') ;
        if (document.frmConfig.firstaid) document.frmConfig.firstaid.checked = true ;
    }

    if (carcookie.get('extinguisher')) {
        d.extinguisher.value = carcookie.get('extinguisher') ;
        if (document.frmConfig.extinguisher) document.frmConfig.extinguisher.checked = true ;
    }

    if (carcookie.get('umbrella')) {
        d.umbrella.value = carcookie.get('umbrella') ;
        if (document.frmConfig.umbrella) document.frmConfig.umbrella.checked = true ;
    }

    if (carcookie.get('rearview')) {
        d.rearview.value = carcookie.get('rearview') ;
        if (document.frmConfig.rearview) document.frmConfig.rearview.checked = true ;
    }
    if (carcookie.get('rearviewgarage')) {
        d.rearviewgarage.value = carcookie.get('rearviewgarage') ;
        if (document.frmConfig.rearviewgarage) document.frmConfig.rearviewgarage.checked = true ;
    }

    if (carcookie.get('satnav')) {
        d.satnav.value = carcookie.get('satnav') ;
        if (document.frmConfig.satnav) document.frmConfig.satnav.checked = true ;
    }

    if (carcookie.get('satnavdisc')) {
        d.satnavdisc.value = carcookie.get('satnavdisc') ;
        if (document.frmConfig.satnavdisc) document.frmConfig.satnavdisc.checked = true ;
    }

    if ( carcookie.get('audio') ) {
        d['audio'].value = carcookie.get('audio') ;
        if (document.frmConfig.audio) setRadio ( document.frmConfig.audio, carcookie.get('audio') )
    }


    if ( carcookie.get('handofdrive') ) {
        d['handofdrive'].value = carcookie.get('handofdrive') ;
        setRadio ( document.frmConfig.handofdrive, carcookie.get('handofdrive') )
    }

    if ( carcookie.get('wheels') ) {
        d['wheels'].value = carcookie.get('wheels') ;
        setRadio ( document.frmConfig.wheels, carcookie.get('wheels') )
    }

    if (carcookie.get('transmission')) {
        d['transmission'].value = carcookie.get('transmission') ;
        setRadio ( document.frmConfig.transmission, carcookie.get('transmission') )
    }

    if (carcookie.get('exteriormesh')) {
        d.exteriormesh.value = carcookie.get('exteriormesh') ;
        if (document.frmConfig.exteriormesh) document.frmConfig.exteriormesh.checked = true ;
    }

    if (carcookie.get('clearlights')) {
        d.clearlights.value = carcookie.get('clearlights') ;
        if (document.frmConfig.clearlights) document.frmConfig.clearlights.checked = true ;
    }

    if (carcookie.get('bodysills')) {
        d.bodysills.value = carcookie.get('bodysills') ;
        if (document.frmConfig.bodysills) document.frmConfig.bodysills.checked = true ;
    }

    if ( carcookie.get('frontseat') ) {
        d['frontseat'].value = carcookie.get('frontseat') ;
        setRadio ( document.frmConfig.frontseat, carcookie.get('frontseat') )
        
        if (d.frontseat.value=='thin') {
        	hide('perforatedseatpanel');
        	hide('row_heatedfrontseat');
        	hide('row_fixedseat');
        	hide('row_memoryseats');
        }
    }

    if (carcookie.get('alloysillplate')) {
        d.alloysillplate.value = carcookie.get('alloysillplate') ;
        if (document.frmConfig.alloysillplate) document.frmConfig.alloysillplate.checked = true ;
    }

    if ( carcookie.get('interiorfinish') ) {
        d.interiorfinish.value = carcookie.get('interiorfinish') ;
        setRadio ( document.frmConfig.interiorfinish, carcookie.get('interiorfinish') )
    }


// select boxes
    if ( carcookie.get('handbooklang') ) {
        d['handbooklang'].value = carcookie.get('handbooklang') ;
        setSelect ( document.frmConfig.handbooklang, carcookie.get('handbooklang') )
    }
    if ( carcookie.get('iplang') ) {
        d['iplang'].value = carcookie.get('iplang') ;
        setSelect ( document.frmConfig.iplang, carcookie.get('iplang') )
    }
    if ( carcookie.get('parcelshelfluggage') ) {
        d['parcelshelfluggage'].value = carcookie.get('parcelshelfluggage') ;
        setSelect ( document.frmConfig.parcelshelfluggage, carcookie.get('parcelshelfluggage') )
    }
    if ( carcookie.get('carcover') ) {
        d['carcover'].value = carcookie.get('carcover') ;
        setSelect ( document.frmConfig.carcover, carcookie.get('carcover') )
    }
    if ( carcookie.get('luggage') ) {
        d['luggage'].value = carcookie.get('luggage') ;
        setSelect ( document.frmConfig.luggage, carcookie.get('luggage') )
    }


// input box
    if (carcookie.get('sillmessage')) {
        d.sillmessage.value = carcookie.get('sillmessage') ;
        document.frmConfig.sillmessage.value = carcookie.get('sillmessage') ;
    }

// colours
	getCookieColour ( 'exteriorcolour' ) ;
	getCookieColour ( 'brakecaliper' ) ;
	getCookieColour ( 'seatbelt' ) ;
	getCookieColour ( 'facia1' ) ;
	getCookieColour ( 'facia2' ) ;
	getCookieColour ( 'lowercolour' ) ;
	getCookieColour ( 'uppercolour' ) ;
	getCookieColour ( 'lowercolour' ) ;
	//getCookieColour ( 'stitchingtype' ) ;
	getCookieColour ( 'thickstitchingcolour' ) ;
	getCookieColour ( 'thinstitchingcolour' ) ;
	getCookieColour ( 'seatoutercolour' ) ;
	getCookieColour ( 'seatinnercolour' ) ;
	getCookieColour ( 'seatthickstitchingcolour' ) ;
	getCookieColour ( 'seatthinstitchingcolour' ) ;
	getCookieColour ( 'carpetcolour' ) ;
	getCookieColour ( 'carpetthickstitchingcolour' ) ;
	getCookieColour ( 'carpetthinstitchingcolour' ) ;
	getCookieColour ( 'headliningcolour' ) ;
	getCookieColour ( 'hoodcolour' ) ;
	getCookieColour ( 'steeringcolour' ) ;

    if ( carcookie.get('steeringchoice') ) {
        d['steeringchoice'].value = carcookie.get('steeringchoice') ;
        setRadio ( document.frmConfig.steeringchoice, carcookie.get('steeringchoice') )
    }
    
    if ( carcookie.get('seatinnerchoice') ) {
        d['seatinnerchoice'].value = carcookie.get('seatinnerchoice') ;
        setRadio ( document.frmConfig.seatinnerchoice, carcookie.get('seatinnerchoice') )
    }
    
}

//------------------
// set car cookie
// take form and save it as a cookie
function setCarCookie () {

	if (d.grille) carcookie.set('grille',d.grille.value)
	
	if (d.rearlogo) carcookie.set('rearlogo',d.rearlogo.value)
	
	if (d.headlamp) carcookie.set('headlamp',d.headlamp.value)
	
	if (d.parkingsensors) carcookie.set('parkingsensors',d.parkingsensors.value)
	
	if (d.stoneguards) carcookie.set('stoneguards',d.stoneguards.value)
	
	if (d.winddeflector) carcookie.set('winddeflector',d.winddeflector.value)
	
	if (d.battery) carcookie.set('battery',d.battery.value)
	
	if (d.heatedfrontseat) carcookie.set('heatedfrontseat',d.heatedfrontseat.value)
	
	if (d.memoryseats) carcookie.set('memoryseats',d.memoryseats.value)
	
	if (d.fixedseat) carcookie.set('fixedseat',d.fixedseat.value)
	
	if (d.heatedwindscreen) carcookie.set('heatedwindscreen',d.heatedwindscreen.value)
	
	if (d.smoker) carcookie.set('smoker',d.smoker.value)
	
	if (d.radiosat) carcookie.set('radiosat',d.radiosat.value)
	
	if (d.phone) carcookie.set('phone',d.phone.value)
	
	if (d.bluetooth) carcookie.set('bluetooth',d.bluetooth.value)
	if (d.cruise) carcookie.set('cruise',d.cruise.value)
	if (d.tracker) carcookie.set('tracker',d.tracker.value)
	if (d.alarm) carcookie.set('alarm',d.alarm.value)
	if (d.firstaid) carcookie.set('firstaid',d.firstaid.value)
	if (d.extinguisher) carcookie.set('extinguisher',d.extinguisher.value)
	if (d.umbrella) carcookie.set('umbrella',d.umbrella.value)
	if (d.rearview) carcookie.set('rearview',d.rearview.value)
	if (d.rearviewgarage) carcookie.set('rearviewgarage',d.rearviewgarage.value)
	if (d.satnav) carcookie.set('satnav',d.satnav.value)
	if (d.satnavdisc) carcookie.set('satnavdisc',d.satnavdisc.value)
	if (d.audio) carcookie.set('audio',d.audio.value)
	if (d.handofdrive) carcookie.set('handofdrive',d.handofdrive.value)
	if (d.wheels) carcookie.set('wheels',d.wheels.value)
	if (d.transmission) carcookie.set('transmission',d.transmission.value)
	if (d.exteriormesh) carcookie.set('exteriormesh',d.exteriormesh.value)
	if (d.clearlights) carcookie.set('clearlights',d.clearlights.value)
	if (d.bodysills) carcookie.set('bodysills',d.bodysills.value)
	if (d.frontseat) carcookie.set('frontseat',d.frontseat.value)
	if (d.alloysillplate) carcookie.set('alloysillplate',d.alloysillplate.value)
	if (d.interiorfinish) carcookie.set('interiorfinish',d.interiorfinish.value)
	if (d.handbooklang) carcookie.set('handbooklang',d.handbooklang.value)
	if (d.iplang) carcookie.set('iplang',d.iplang.value)
	if (d.sillmessage) carcookie.set('sillmessage',d.sillmessage.value)
	if (d.luggage) carcookie.set('luggage',d.luggage.value)
	if (d.parcelshelfluggage) carcookie.set('parcelshelfluggage',d.parcelshelfluggage.value)
	if (d.carcover) carcookie.set('carcover',d.carcover.value)

	if (d.steeringchoice) carcookie.set('steeringchoice',d.steeringchoice.value)
	if (d.seatinnerchoice) carcookie.set('seatinnerchoice',d.seatinnerchoice.value)

// colours
	setCookieColour ( 'exteriorcolour' ) ;
	setCookieColour ( 'brakecaliper' ) ;
	setCookieColour ( 'seatbelt' ) ;
	setCookieColour ( 'facia1' ) ;
	setCookieColour ( 'facia2' ) ;
	setCookieColour ( 'lowercolour' ) ;
	setCookieColour ( 'uppercolour' ) ;
	setCookieColour ( 'lowercolour' ) ;
	setCookieColour ( 'thickstitchingcolour' ) ;
	setCookieColour ( 'thinstitchingcolour' ) ;
	setCookieColour ( 'seatoutercolour' ) ;
	setCookieColour ( 'seatinnercolour' ) ;
	setCookieColour ( 'seatthickstitchingcolour' ) ;
	setCookieColour ( 'seatthinstitchingcolour' ) ;
	setCookieColour ( 'carpetcolour' ) ;
	setCookieColour ( 'carpetthickstitchingcolour' ) ;
	setCookieColour ( 'carpetthinstitchingcolour' ) ;
	setCookieColour ( 'headliningcolour' ) ;
	setCookieColour ( 'hoodcolour' ) ;
	setCookieColour ( 'steeringcolour' ) ;

	alert('Car Details have been saved')    
}



//-----------------
// click on a checkbox - do somthing
function setOption( option, value ) {
    switch (option) {

		case 'wheels' :
			d.wheels.value = value;
			postevent('view_wheel_move');
			vmpWheels(d.wheels.value);
			carcookie.set('wheels',d.wheels.value);
			break ;

        case 'grille' :
            postevent('view_grille');
            d.grille.value=(value?'on':'');
            vmpGrille(d.grille.value);
            carcookie.set('grille',d.grille.value);
            break ;

        case 'parkingsensors' :
            postevent('view_grille');
            d.parkingsensors.value=(value?'on':'');
            vmpParkingSensors(d.parkingsensors.value);
            carcookie.set('parkingsensors',d.parkingsensors.value);
            break ;

        case 'headlamp' :
            postevent('view_grille');
            d.headlamp.value=(value?'on':'');
            carcookie.set('headlamp',d.headlamp.value);
            break ;

        case 'rearlogo' :
            postevent('view_rearlogo');
            d.rearlogo.value=(value?'off':'');
            vmpRearlogo(d.rearlogo.value);
            carcookie.set('rearlogo',d.rearlogo.value);
            break ;

        case 'exteriormesh' :
            postevent('view_exteriormesh');
            d.exteriormesh.value=(value?'on':'');
            vmpExteriorMesh(d.exteriormesh.value);
            carcookie.set('exteriormesh',d.exteriormesh.value);
            break ;

        case 'clearlights' :
            vmp.TriggerAnim('anim_view_rearlights');
            d.clearlights.value=(value?'on':'');
            vmpClearLights(d.clearlights.value);
            carcookie.set('clearlights',d.clearlights.value);
            break ;

        case 'bodysills' :
            postevent('view_bodysills');
            d.bodysills.value=(value?'on':'');
            vmpBodySills(d.bodysills.value);
            carcookie.set('bodysills',d.bodysills.value);
            break ;

        case 'alloysillplate' :
            d.alloysillplate.value=(value?'on':'');
            vmpSills(d.alloysillplate.value)
            carcookie.set('alloysillplate',d.alloysillplate.value);
            break ;

        case 'luggage' :
            d.luggage.value=(value?'on':'');
            carcookie.set('luggage',d.luggage.value);
            break ;
            
        case 'parcelshelfluggage' :
            d.parcelshelfluggage.value=(value?'on':'');
            carcookie.set('parcelshelfluggage',d.parcelshelfluggage.value);
            break ;
            
		case 'stoneguards' :
			postevent('view_stoneguards');
			d.stoneguards.value=(value?'on':'');
			carcookie.set('stoneguards',d.stoneguards.value);
			vmpStoneguards (d.stoneguards.value)

		case 'battery' :
			postevent('view_stoneguards');
			d.battery.value=(value?'on':'');
			carcookie.set('battery',d.battery.value);
		
		case 'frontseat' :
			d.frontseat.value=value;
			vmpFrontSeat(value);
			
			if (d.frontseat.value=='fat') {
				// sports seat
				// perforated leather is available
				show('perforatedseatpanel')
				// heated frontseat is available (heatedfrontseat is a table row - do not use show() or display:block)
				el = document.getElementById('row_heatedfrontseat'); if (el) el.style.display=''
				el = document.getElementById('row_memoryseats'); if (el) el.style.display=''
				el = document.getElementById('row_fixedseat'); if (el) el.style.display=''
			}
			else if (d.frontseat.value=='thin') {
				// lightweight seat

				// perforated leather not available
				d.seatinnerchoice.value = 'plain'
				setRadio ( document.frmConfig.seatinnerchoice, 'plain' )
				hide('perforatedseatpanel')

				// heated frontseat not available
        		d.heatedfrontseat.value = '' ;
        		if (document.frmConfig.heatedfrontseat) document.frmConfig.heatedfrontseat.checked = false ;
				hide('row_heatedfrontseat')

        		d.memoryseats.value = '' ;
        		if (document.frmConfig.memoryseats) document.frmConfig.memoryseats.checked = false ;
				hide('row_memoryseats')

        		d.fixedseat.value = '' ;
        		if (document.frmConfig.fixedseat) document.frmConfig.fixedseat.checked = false ;
				hide('row_fixedseat')
				
			}
    }
}

// make sure user doesn't select both rearview mirror+garage and rearview mirror
function setRearviewOptions () {
	if (document.frmConfig.rearviewgarage) {
		d.rearviewgarage.value=(document.frmConfig.rearviewgarage.checked?'on':'');
	}
	if (document.frmConfig.rearview) {
		d.rearview.value=(document.frmConfig.rearview.checked?'on':'');
	}
}

//------------
// vmpSetColour
// called from colour blocks (COLS,LTHR,FACIA,etc)
//-------------
function vmpSetColour ( sCol ) {
    switch (sCol) {
    	case "facia1" :
			vmpFacia ( d["facia1_cellid"].value ) ;
            break ;
        case "facia2" :
    		vmpFacia ( d["facia2_cellid"].value ) ;
            break ;
        case "brakecaliper" :
            vmpColourAnim ( d["brakecaliper_hexcode"].value, "CalipersColour" ) ;
            break ;
        case "steeringcolour" :
			vmpColourAnim ( d["steeringcolour_hexcode"].value, "SteeringColour" )
            break ;
        case "seatbelt" :
            vmpColourAnim ( d["seatbelt_hexcode"].value, "SeatbeltColour" )
            break ;
        case "exteriorcolour":
            vmpColourAnim ( d["exteriorcolour_hexcode"].value, "ExteriorColour" )
            break ;
        case "uppercolour":
            vmpColourAnim ( d["uppercolour_hexcode"].value, "UpperLeatherColour" )
            break;
        case "lowercolour":
            vmpColourAnim ( d["lowercolour_hexcode"].value, "LowerLeatherColour" )
            break ;
		case "thickstitchingcolour":
		case "thinstitchingcolour":
        case "stitchingcolour":
			vmpColourAnim ( d["thickstitchingcolour_hexcode"].value, "StitchingColour" ) ;
            break ;
        case "seatoutercolour":
            vmpColourAnim ( d["seatoutercolour_hexcode"].value, "SeatOuterColour" )
            break ;
        case "seatinnercolour":
            vmpColourAnim ( d["seatinnercolour_hexcode"].value, "SeatInnerColour" )
            break ;
		case "seatthickstitchingcolour":
		case "seatthinstitchingcolour":
        case "seatstitchingcolour":
			vmpColourAnim ( d["seatthickstitchingcolour_hexcode"].value, "SeatStitchingColour" ) ;
            break ;
        case "carpetcolour":
            vmpColourAnim ( d["carpetcolour_hexcode"].value, "CarpetColour" )
            break ;
		case "carpetthickstitchingcolour":
		case "carpetthinstitchingcolour":
        case "carpetstitchingcolour":
            vmpColourAnim ( d["carpetthickstitchingcolour_hexcode"].value, "CarpetBindingColour" )
            break ;
        case "headliningcolour":
            vmpColourAnim ( d["headliningcolour_hexcode"].value, "HeadliningColour" )
            break ;
        case "hoodcolour":
			if (d["hoodcolour_hexcode"]) vmpColourAnim ( d["hoodcolour_hexcode"].value, "HoodColour" )
            break ;
    }
}


//----------
//-- Limit number of colours available for car interior
// get all the leather colours, populate array lthColour with distinct interior colours
var SelectedColours = [] ;

function SetSelectedColours () {
	// called (i) when colourblock is initialised (SetupColourBlock)
	// (ii) when colour is changed (cellColourOn)

	var debug = '' ;
	SelectedColours = [] ;

	// get all the leather items
	var leather_names = [ 'uppercolour', 'lowercolour', 'seatoutercolour', 'seatinnercolour' ];

	if ( d.steeringchoice && d.steeringchoice.value == 'colour') {
		// add steering trim to list
		leather_names.push ( 'steeringcolour');
	}

    for (var i=0; i<leather_names.length; i++) {
    	if ( ! d[leather_names[i]+'_cellid'] ) continue ;
    	var cellid = d[leather_names[i]+'_cellid'].value ;
		// get all the colour codes used
		if( !in_array(SelectedColours, cellid) ) {
			debug += leather_names[i] + ' = ' + cellid + "\n"
			SelectedColours.push(cellid);
		    cellSelected( cellid );  // is this a selected leather colour elsewhere ?
		}
	}
	ShowColourWarning('LTH');
	// alert( debug );
}


/*============ OPTIONS ==============*/

//-----------------
function vmpGrille ( code ) {
    if (code=='') {
        // standard grille
        vmpColourAnim ('#808080','GrilleColour');
    } else {
        // shiny grille
		vmpColourAnim (CHROME,'GrilleColour');
        // vmpColourAnim ('#ececec','GrilleColour');
    }
}

function vmpParkingSensors( code ) {
	if (code=='') {
		postevent('hide_parkingsensors');
	} else {
		postevent('show_parkingsensors');
	}
}


function vmpStitching ( code ) {
	if (code=='thick') {
		postevent('show_stitching');
	} else {
		postevent('hide_stitching');
	}
}


function vmpHeadliningMesh ( code ) {
    switch (code) {
        case "blackblack":
            vmpColourAnim ( '#232323', 'HeadliningMeshColour' );break;
        case "blacksilver" :
            vmpColourAnim ( '#606060', 'HeadliningMeshColour' );break;
        case "silverbeige" :
            vmpColourAnim ( '#c6a488', 'HeadliningMeshColour' );break;
        case "silversilver" :
            vmpColourAnim ( '#c6d6dc', 'HeadliningMeshColour' );break;
    }
    return false;
}

//------
// Change colour of steering wheel
function vmpSteering() {

    var option = d["steeringchoice"].value ;

    if (option=='black') {
        vmpColourAnim (CHARCOAL,'SteeringColour');
    }
    else if (option=='colour') {
 		vmpColourAnim ( d["steeringcolour_hexcode"].value, "SteeringColour" )
 		//var hexcode = d["uppercolour_hexcode"].value
        //if (hexcode) vmpColourAnim (hexcode,'SteeringColour');
    }
}

//-------------------
// changed to colour block, not radio choice
function vmpSeatbelts ( code ) {

    switch (code) {
        case "charcoal":
            vmpColourAnim ( '#1E1C1D', 'SeatbeltColour' ); break;
        case "flint":
            vmpColourAnim ( '#67615B', 'SeatbeltColour' ); break;
    }
}


//-----------
// change colour of console surround
// changed to colour block, not radio choice
/*
function vmpFinish ( code ) {
    switch (code) {
        case "iridium" :
            // platinum
            vmpColourAnim ("#c3c3c3",'ConsoleColour');
            vmpColourAnim ("#c3c3c3",'ButtonColour');
            break;
        case "graphite" :
        default :   // default = SF02
            // anthracite
            vmpColourAnim (ANTHRACITE,'ConsoleColour');
            vmpColourAnim (ANTHRACITE,'ButtonColour');
            break;
    }
}*/


//-------------------
// swap between automatic and manual
function vmpTransmission ( code ) {
    if (code=='automatic') {
        postevent('show_automatic');
    }
    else {
        postevent('show_manual');
    }
}



//--- Turn the rearlogo on or off
function vmpRearlogo ( code ) {
    if (code) {
        // checkbox ticked - turn off rear logo
        postevent('hide_rearlogo');
    }
    else {
        // Yes = turn the rear logo on
        postevent('show_rearlogo');
    }
}

//---------
// volante wind deflector
function vmpWinddeflector ( code ) {
    if (code) {
        postevent('winddeflector_on');
    } else {
        postevent('winddeflector_off');
    }
}

//---------
// stoneguards
function vmpStoneguards ( code ) {
    if (code) {
        postevent('stoneguards_on');
    } else {
        postevent('stoneguards_off');
    }
}

function vmpWheels ( code ) {
	switch (code) {
		case '5spoke' :
			vmpColourAnim ( 'c6d6dc', 'WheelColour',0.5 ) ;
			postevent('show_wheels_5spoke',0.5);
			break ;

		case '10spoke_graphite' :	
			vmpColourAnim ( 'c6d6dc', 'WheelColour',0.5 ) ;
			vmpColourAnim ( '555555', 'WheelRimColour',0.5 ) ;	
			postevent('show_wheels_10spoke',0.5);
			break ;
			
		case '10spoke_silver' :
			vmpColourAnim ( 'c6d6dc', 'WheelColour',0.5 ) ;
			vmpColourAnim ( 'c6d6dc', 'WheelRimColour',0.5 ) ;	
			postevent('show_wheels_10spoke',0.5);
			break ;
			
		case '20spoke' :	// standard
			vmpColourAnim ( 'a6a6a6', 'WheelColour',0.5 ) ;
			vmpColourAnim ( 'a6a6a6', 'WheelRimColour',0.5 ) ;	
			postevent('show_wheels_20spoke',0.5);
			break ;

		case '20spoke_silver' :  // 2-tone wheels - diamond front, silver spokes
			vmpColourAnim ( 'c6d6dc', 'WheelColour',0.5 ) ;	// silver
			vmpColourAnim ( 'a6a6a6', 'WheelRimColour',0.5 ) ;	// grey
			postevent('show_wheels_20spoke',0.5);
			break ;

		case '20spoke_graphite' :	// 2-tone wheels - diamond front, graphite spokes
			vmpColourAnim ( 'c6d6dc', 'WheelColour',0.5 ) ;	// silver
			vmpColourAnim ( '303030', 'WheelRimColour',0.5 ) ;	// silver
			postevent('show_wheels_20spoke',0.5);
			break ;
	}
}

function vmpExteriorMesh( checkbox ) {
	if (checkbox) { // on
		if (vmp) vmp.TriggerAnim('set_mesh_silver');
	}
	else {
		if (vmp) vmp.TriggerAnim('set_mesh_std');
	}
}

function vmpClearLights( checkbox ) {
	if (checkbox) { // on
		if (vmp) vmp.TriggerAnim('set_rearlights_clear');
	}
	else {
		if (vmp) vmp.TriggerAnim('set_rearlights_red');
	}
}


function vmpBodySills( checkbox ) {
	if (checkbox) { // on
		postevent('show_bodysills');
	}
	else {
		postevent('hide_bodysills');
	}
}

function vmpAudio( code ) {
	if (code=='bang') { // bang olfensen
        postevent('audio_on');
        postevent('set_door_bospeaker');
        postevent('anim_speaker');
    } else {
        postevent('audio_off');
        postevent('set_door_speaker');
	}
}	

function vmpSills(checkbox) {
	if (checkbox == '') {	
		// defaults to black
		vmpColourAnim ( '000000', 'SillColour' ) ;
		//vmp.TriggerAnim('sillcolour_black');
	}
	else {	
		// checkbox ticked - silver
		vmpColourAnim ( 'c9d9dc', 'SillColour' ) ;
		//vmp.TriggerAnim('sillcolour_chrome');
	}
}

function vmpFrontSeat(code) {
	switch (code) {
		case 'fat' :
			postevent('show_fatseats', 0.5);
			break ;

		case 'thin' :
			postevent('show_thinseats', 0.5);
			break ;
	}
}


function vmpInteriorFinish() {
	if (d.interiorfinish.value=='graphite') {
		vmpColourAnim ( "#3c3c3c", "ConsoleColour" )
		vmpFacia ( d["facia1_cellid"].value ) ;
	}
	else {
		vmpColourAnim ( "#c5c5c5", "ConsoleColour" )
		vmpFacia ( d["facia2_cellid"].value ) ;
	}
}

function vmpFacia(code) {

	// facia1 = graphite, facia2 = iridium

    switch (code) {
        case "facia1_gunmetal" :
        case "facia2_gunmetal" :
            if (vmp) vmp.TriggerAnim('dash_gunmetal'); break;

        case "facia1_alloy":
            if (vmp) vmp.TriggerAnim('dash_alloy'); break;

        case "facia2_prism_alloy":
            if (vmp) vmp.TriggerAnim('dash_silver'); break;
		
        case "facia1_pianoblack":
        case "facia2_pianoblack":
            if (vmp) vmp.TriggerAnim('dash_pianoblack'); break;
	}
}



/* ========== OUTPUT CAR READY FOR PRINTING ============= */

function getCarDetails () {

    var cardetails = '\n<table cellpadding=4 cellspacing=0 border=0 id="cardetails">';
    cardetails += '\n<tr><th>Vehicle Details</th><th style="text-align:right"><input type="image" src="images/bt_print.gif" value="Print" onclick="window.print()"></th></tr>';

    if ( d.bodystyle.value.toLowerCase() == 'coupe' )
        cardetails += '\n<tr><td colspan="2">V8 Vantage Coupe</td></tr>' ;
    else
        cardetails += '\n<tr><td colspan="2">V8 Vantage Roadster</td></tr>' ;

    cardetails += '\n<tr><td>Country</td><td>' + d.country.value + '</td></tr>' ;
    cardetails += '\n<tr><td>Specification Date</td><td>' + d.date.value + '</td></tr>' ;

    if (d.handofdrive.value == 'R')
        cardetails += '\n<tr><td colspan=2>Right Hand Drive</td></tr>' ;
    else
        cardetails += '\n<tr><td colspan=2>Left Hand Drive</td></tr>' ;

    if ( d.transmission.value == 'automatic' ) {
        cardetails += '\n<tr><td colspan="2">Sportshift Transmission</td></tr>' ;
    } else {
        cardetails += '\n<tr><td colspan="2">Manual Transmission</td></tr>' ;
    }
	
	//-- Exterior 
	
    cardetails += '\n<tr><th colspan="2">Exterior Detailing</td></tr>' ;
    cardetails += '\n<tr><td>Car Body Colour</td><td>' + d.exteriorcolour_name.value + '</td></tr>' ;

	switch (d.wheels.value) {
		case '5spoke' :
			cardetails += '\n<tr><td colspan="2">Optional Sports Pack with lightweight 5-spoke Alloy Wheels</td></tr>' ;
			break ;
			
		case '10spoke_silver' :
			cardetails += '\n<tr><td colspan="2">Optional 10-spoke Diamond Turned Wheels with silver finish</td></tr>' ;
			break ;
			
		case '10spoke_graphite' :
			cardetails += '\n<tr><td colspan="2">Optional Sports Pack with 10-spoke Diamond Turned Wheels with graphite finish</td></tr>' ;
			break ;
			
		case '20spoke' :
			cardetails += '\n<tr><td colspan="2">Standard 19" 20-spoke Alloy Wheels</td></tr>' ;
			break ;
		case '20spoke_silver' :
			cardetails += '\n<tr><td colspan="2">Optional 19" 20-spoke Silver Diamond Turned Alloy Wheels</td></tr>' ;
			break ;
		case '20spoke_graphite' :
			cardetails += '\n<tr><td colspan="2">Optional 19" 20-spoke Graphite Diamond Turned Alloy Wheels</td></tr>' ;
			break ;
	}

    cardetails += '\n<tr><td>Brake Calipers</td><td>' + d.brakecaliper_name.value + '</td></tr>' ;

    if ( d.hoodcolour_name && d.hoodcolour_name.value != '' ) {
        cardetails += '\n<tr><td>Hood Colour</td><td>' + d.hoodcolour_name.value + fc(d.hoodcolour_menu.value) + '</td></tr>' ;
    }

    if ( d.grille.value != '' ) {
        cardetails += '\n<tr><td colspan="2">Bright Finish Front Grille</td></tr>' ;
    }

    if ( d.bodysills.value != '' ) {
        cardetails += '\n<tr><td colspan="2">N400 Sill Design</td></tr>' ;
    }
    if ( d.exteriormesh.value != '' ) {
        cardetails += '\n<tr><td colspan="2">Magnum Silver Mesh Pack</td></tr>' ;
    }
    if ( d.clearlights.value != '' ) {
        cardetails += '\n<tr><td colspan="2">Clear Rear Lamps</td></tr>' ;
    }
	
    if (d.parkingsensors.value != '') {
        cardetails += '\n<tr><td colspan="2">Front Parking Sensors</td></tr>' ;
    }

    if (d.rearlogo.value != '') {
        cardetails += '\n<tr><td colspan="2">Delete "Vantage" badge</td></tr>' ;
    }

    if (d.stoneguards.value != '') {
        cardetails += '\n<tr><td colspan="2">Stoneguards</td></tr>' ;
    }
    if ( d.winddeflector && d.winddeflector.value != '' ) {
        cardetails += '\n<tr><td colspan="2">Wind Deflector</td></tr>' ;
    }


	//-- inside 
    cardetails += '\n<tr><th colspan="2">Interior Detailing</td></tr>' ;

    if ( d.frontseat.value == 'fat' ) {
		cardetails += '\n<tr><td>Front seats</td><td>Sports Seats with 10-way electric adjustment (includes height, tilt and lumbar adjustment)</td></tr>' ;
	} else {
		cardetails += '\n<tr><td>Front seats</td><td>Lightweight Seats with 6-way adjustment (includes front and rear height adjustment)</td></tr>' ;
	}	

    cardetails += '\n<tr><td>Upper Leather Colour</td><td>' + d.uppercolour_name.value + '</td></tr>' ;
    cardetails += '\n<tr><td>Lower Leather Colour</td><td>' + d.lowercolour_name.value + '</td></tr>' ;

	switch (d.seatinnerchoice.value) {
		case 'plain' :
			cardetails += '\n<tr><td>Type of Seat Insert</td><td>Plain Leather</td></tr>' ;
			break ;
		case 'embossed' :
			cardetails += '\n<tr><td>Type of Seat Insert</td><td>Embossed Leather</td></tr>' ;
			break ;
		case 'perforated' :
			cardetails += '\n<tr><td>Type of Seat Insert</td><td>Perforated Leather</td></tr>' ;
			break ;
	}

    cardetails += '\n<tr><td>Seat Outer Colour</td><td>' + d.seatoutercolour_name.value + '</td></tr>' ;
    cardetails += '\n<tr><td>Seat Inner Colour</td><td>' + d.seatinnercolour_name.value + '</td></tr>' ;

    switch (d.stitchingtype.value) {
        case 'thin' :
    		cardetails += '\n<tr><td>Interior Stitching</td><td>' + d.thinstitchingcolour_name.value + ' (fine stitching)</td></tr>' ;
		    cardetails += '\n<tr><td>Seat Stitching</td><td>' + d.seatthinstitchingcolour_name.value + ' (fine stitching)</td></tr>' ;
            break ;
        case 'thick' :
    		cardetails += '\n<tr><td>Interior Stitching</td><td>' + d.thickstitchingcolour_name.value + ' (coarse stitching)</td></tr>' ;
		    cardetails += '\n<tr><td>Seat Stitching</td><td>' + d.seatthickstitchingcolour_name.value + ' (coarse stitching)</td></tr>' ;
            break ;
    }

    cardetails += '\n<tr><td>Carpet Colour</td><td>' + d.carpetcolour_name.value + '</td></tr>' ;
    cardetails += '\n<tr><td>Carpet Stitching Colour</td><td>' + d.carpetthickstitchingcolour_name.value + '</td></tr>' ;
    cardetails += '\n<tr><td>Headlining Colour</td><td>' + d.headliningcolour_name.value + '</td></tr>' ;

    cardetails += '\n<tr><td>Seatbelts</td><td>' + d.seatbelt_name.value + '</td></tr>' ;

    if (d.interiorfinish.value=='graphite') {
		cardetails += '\n<tr><td>Interior Fittings</td><td>Graphite</td></tr>' ;
		cardetails += '\n<tr><td>Facia Trim</td><td>' + d.facia1_name.value + '</td></tr>' ;
	}
	else {
		cardetails += '\n<tr><td>Interior Fittings</td><td>Iridium</td></tr>' ;
		cardetails += '\n<tr><td>Facia Trim</td><td>' + d.facia2_name.value + '</td></tr>' ;
	}
	

	//-- Standard Features
    cardetails += '\n<tr><th colspan="2">Standard Features</th></tr>' ;
	cardetails += '\n<tr><td colspan="2">Rear Parking Distance Sensors</td></tr>' ;
	cardetails += '\n<tr><td colspan="2">Tyre Pressure Monitoring</td></tr>' ;
	cardetails += '\n<tr><td colspan="2">Bright Finish Window Surround</td></tr>' ;
	// added 9/Aug/07
	cardetails += '\n<tr><td colspan="2">MP3 Device Audio Connection</td></tr>' ;

	// Nov/09
	cardetails += '\n<tr><td colspan="2">Xenon Headlamps (with auto-levelling and powerwash)</td></tr>' ;
	cardetails += '\n<tr><td colspan="2">Powerfold Mirrors</td></tr>' ;
	

	//-- other options
    cardetails += '\n<tr><th colspan="2">Options</th></tr>' ;


    if ( d.iplang.value != '' ) {
        cardetails += '\n<tr><td>Instrument Pack</td><td>' + d.iplang.value + '</td></tr>' ;
    }

    if ( d.handbooklang.value != '' ) {
        cardetails += '\n<tr><td>Handbook Language</td><td>' + d.handbooklang.value + '</td></tr>' ;
    }

    if ( d.sillmessage.value != '') {
        cardetails += '\n<tr><td>Personalised Sill Plaques</td><td>' + d.sillmessage.value + '</td></tr>' ;
    }
	
    if ( d.alloysillplate.value != '') {
        cardetails += '\n<tr><td colspan="2">Polished Alloy Tread Plates</td></tr>' ;
    }

    if ( d.audio.value == '') {
        cardetails += '\n<tr><td colspan="2">Aston Martin Audio System (128W)</td></tr>' ;
    }
    else if ( d.audio.value == 'AU05') {
        cardetails += '\n<tr><td colspan="2">Aston Martin Premium Audio System (700W)</td></tr>' ;
    }
    else if ( d.audio.value == 'bang') {
        cardetails += '\n<tr><td colspan="2">Bang &amp; Olufsen BeoSound Audio System (1000W)</td></tr>' ;
    }

    if ( d.smoker.value != '' ) {
        cardetails += '\n<tr><td colspan="2">Smoker\'s Pack - Ashtray and Cigar Lighter</td></tr>' ;
    }
	
    if ( d.alarm.value != '' ) {
        cardetails += '<tr><td colspan="2">Alarm Upgrade (Volumetric and tilt sensor)</td></tr>'  ;
	}
	
    if ( d.tracker.value != '' ) {
        cardetails += '<tr><td colspan="2">Aston Martin Tracking System</td></tr>'  ;
	}
	
    if ( d.cruise.value != '' ) {
        cardetails += '<tr><td colspan="2">Cruise Control</td></tr>' 
	}
    if ( d.bluetooth.value != '' ) {
        cardetails += '<tr><td colspan="2">Bluetooth Telephone System</td></tr>' 
	}

    if ( d.heatedfrontseat.value != '' ) {
        cardetails += '<tr><td colspan="2">Heated Front Seats</td></tr>' 
	}

    if ( d.memoryseats.value != '' ) {
        cardetails += '<tr><td colspan="2">Memory Seats and Mirrors</td></tr>' 
	}
    if ( d.fixedseat.value != '' ) {
        cardetails += '<tr><td colspan="2">Delete Passenger Seat Height Adjustment includes ISOFIX</td></tr>' 
	}

    if ( d.satnav.value != '' ) {
        cardetails += '<tr><td colspan="2">Satellite Navigation System</td></tr>' 
	}
	if (d.rearview.value != '' ) {
        cardetails += '\n<tr><td colspan="2">Auto-Dimming Rear View Mirror</td></tr>' ;
    }
	if (d.rearviewgarage.value != '' ) {
        cardetails += '\n<tr><td colspan="2">Auto-Dimming Rear View Mirror with Garage Door Opener</td></tr>' ;
    }
    if ( d.firstaid.value != '' ) {
        cardetails += '<tr><td colspan="2">First Aid Kit</td></tr>' 
	}
    if ( d.umbrella.value != '' ) {
        cardetails += '<tr><td colspan="2">Umbrella and Holder</td></tr>' 
	}

    if ( d.battery.value != '' ) {
        cardetails += '<tr><td colspan="2">Battery Conditioner</td></tr>' 
	}
    if ( d.luggage.value != '' ) {
        cardetails += '<tr><td>Luggage Set</td>' + d.luggage.value + '</td></tr>' 
	}
    if ( d.parcelshelfluggage.value != '' ) {
        cardetails += '<tr><td>Parcel Shelf Luggage Set</td>' + d.parcelshelfluggage.value + '</td></tr>' 
	}
    if ( d.carcover.value != '' ) {
        cardetails += '<tr><td>Car Cover</td>' + d.carcover.value + '</td></tr>' 
	}
    
    cardetails += '\n</table>' ;

    cardetails += '\n<p>Please contact your <a href="http://www.astonmartin.com/contactus/dealerlocator">local Aston Martin dealer</a> for information on prices and availability.</p>' ;

    return cardetails ;
}


var docHead =
    '\n<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">' +
    '\n<html>' +
    '\n<head>' +
    '\n<title>Aston Martin V8 Vantage</title>' +
    '\n<link href="styles/default.css" media="all" rel="stylesheet" type="text/css" />' +
    '\n<link href="styles/configurator.css" media="all" rel="stylesheet" type="text/css" />' +
    '\n<link href="styles/configurator-print.css" media="all" rel="stylesheet" type="text/css" />' +
    '\n<scri' + 'pt src="scripts/configurator.js" language="javascript" type="text/javascript"></sc' + 'ript>' +
    '\n<scri' + 'pt src="scripts/v8vantage.js" language="javascript" type="text/javascript"></sc' + 'ript>' +
    '\n</head>' +
    '\n' +
    '\n<body>' +
    '\n<div id="outer">' +
    '\n<div class="sitedetails">' +
    '\n<div id="logo">' +
    '\n<a href="http://www.astonmartin.com/home"><img src="images/logo_astonmartin.gif" alt="Aston Martin" width="97" height="43" /></a>' +
    '\n</div>' +
    '\n</div>' +
    '\n<div id="pagedetails">' +
    '\n<div id="configcontent">'

    if ( bodystyle == 'coupe' ) {
		var heading = '\n<h2><img src="images/welcome_v8vantage_coupe.gif" width="396" height="21" alt="Welcome to the configurator for the V8 Vantage Coupe" title="" /></h2>' ;
		var model =
			'\n<div class="contentblock" id="banner">' +
			'\n<iframe src="v8vantage_load.html" title="Viewpoint 3D Model V8 Vantage Coupe" name="car" id="carframe" frameborder="0" scrolling="no"></iframe>' +
			'\n</div>' ;

    } else {
        var heading = '\n<h2><img src="images/welcome_v8roadster.gif" width="413" height="21" alt="Welcome to the configurator for the V8 Vantage Roadster" title="" /></h2>' ;
		var model =
			'\n<div class="contentblock" id="banner">' +
			'\n<iframe src="v8roadster_load.html" title="Viewpoint 3D Model V8 Vantage Roadster" name="car" id="carframe" frameborder="0" scrolling="no"></iframe>' +
			'\n</div>' ;
    }


var docFoot =
    '\n</div>' +
    '\n</div>' +
    '\n</div><br><br>' +
    '\n</body>' +
    '\n</html>'

