 function openGlossary(myLink,windowName)
 {
  if(! window.focus)return;
  var myWin=window.open("",windowName,"height=320,width=525,scrollbars=yes,resizable=yes,menubar=yes");
  myWin.focus();
  myLink.target=windowName;
 }

function selectColor(partNumber, partID) {
	selectPartClient(partNumber, partID);
}

function selectPartServer(partNumber, partID) {
	document.forms['form'].part.value = partID;
	document.forms['form'].twcAction.name = 'selectPart';
	document.forms['form'].submit();
}
function selectPartClient(partNumber, partID) {
	document.forms['form'].part.value = partID;

	var oldPartNumber = document.form.partNumber.value;

	//Save new color swatch part number
	document.form.partNumber.value = partNumber;

	//Turn off old color swatch
	swatchRollOut(oldPartNumber);

	//Turn on new color swatch
	swatchRollOver(partNumber);

}

function rollOver(formname, img) {
	eval('document.' + formname + '.' + img).src = eval('document.' + formname + '.' + img).src.replace("_off", "_on");
}

function rollOut(formname, img) {
	eval('document.' + formname + '.' + img).src = eval('document.' + formname + '.' + img).src.replace("_on", "_off");
}


function swatchRollOver(formname, partNumber) {
    if (partNumber != eval('document.' + formname + '.colorId').value) {
        var swatch = eval('document.' + formname + '._' + partNumber);
        swatch.src = eval('_' + partNumber + 'c').src;
        eval('document.' + formname + '.bigpicture').src = eval('_' + partNumber + 'a').src;
        eval('document.' + formname + '.arttext').src = eval('_' + partNumber + 'd').src;
    }
}

function swatchRollOut(formname, partNumber) {
    if (partNumber != eval('document.' + formname + '.colorId').value) {
		if ( oldOnColorId != partNumber ) {
			var swatch = eval('document.' + formname + '._' + partNumber);
			swatch.src = eval('_' + partNumber + 'b').src;
		}
        eval('document.' + formname + '.bigpicture').src = eval('selectedCarImageUri').src;
        eval('document.' + formname + '.arttext').src = eval('selectedArtTextImageUri').src;
    }
}


function popup(url) {
	window.open(url,'','height=320,width=501,scrollbars=yes,resizable=yes,toolbar=no,menubar=yes');
}

function popupCustom(url, name, options) {
	window.open(url, name, options);
}

function closeAndReloadOpener() {
	opener.location.href = opener.location.href;
	window.close();
}

function validateStart() {



   if (document.lexSelectSeriesForm.seriesId.value == '') {
		alert('You must choose a Lexus model from the pull-down menu to begin building your Lexus.');
		return false;
		} else if (document.lexSelectSeriesForm.modelYear.value == '' || document.lexSelectSeriesForm.modelYear.value.length !=4) {
		alert('You must choose a model year from the pull-down menu to begin building your Lexus.');
        return false;
	} else if (isNaN(document.lexSelectSeriesForm.zipCode.value) || document.lexSelectSeriesForm.zipCode.value.length < 5) {
	    alert('You must enter a valid 5 digit zip code to continue..');
        return false;
	}   else {
		document.lexSelectSeriesForm.twcAction.value='submit';
		return true;
		//document.lexSelectSeriesForm.submit();
	}
}


function print() {
	if (window.print) {
		window.print();
	}

}


function emailFriend_validate() {
	var errMsg = "";

	if (document.lexEmailFriendForm.userFirstName.value == "") {
		errMsg += ", Your First Name";
	}
	if (document.lexEmailFriendForm.userLastName.value == "") {
		errMsg += ", Your Last Name";
	}
	if ((document.lexEmailFriendForm.userEmail.value == "") || (!validateEmail(document.lexEmailFriendForm.userEmail.value))) {
		errMsg += ", Your Email Address";
	}
	if (document.lexEmailFriendForm.friendName1.value == "") {
		errMsg += ", Your Friend's Last Name";
	}
	if (document.lexEmailFriendForm.friendName2.value == "") {
		errMsg += ", Your Friend's Last Name";
	}
	if ((document.lexEmailFriendForm.friendEmail.value == "") || (!validateEmail(document.lexEmailFriendForm.friendEmail.value))) {
		errMsg += ", Your Friend's Email Address";
	}

	if (errMsg == "") {
		return true;
	} else {
		alert("Sorry. Before we can send your information, you must fill in the following fields:\n\n" + errMsg.substring(2));
		return false;
	}
}

function emailFriend_preview() {
	if (emailFriend_validate()) {
		document.lexEmailFriendForm.twcAction.value='preview';
		document.lexEmailFriendForm.submit();
	}
}
function emailFriend_submit() {
	if (emailFriend_validate()) {
		document.lexEmailFriendForm.twcAction.value='submit';
		document.lexEmailFriendForm.submit();
	}
}


function emailFriendPreview_modify() {
	document.form.action='Dispatch.jsp?.NewState=_email-friend';
	document.form.submit();
}
function emailFriendPreview_submit() {
	document.form.submit();
}


function requestQuote_submit() {
	document.form.userHomePhone.value = document.form.homephone1.value + document.form.homephone2.value + document.form.homephone3.value;
	document.form.userWorkPhone.value = document.form.workphone1.value + document.form.workphone2.value + document.form.workphone3.value;
	document.form.userFax.value = document.form.faxphone1.value + document.form.faxphone2.value + document.form.faxphone3.value;

	var errMsg = "";


	if (document.form.userFirstName.value == "") {
		errMsg += ", First Name";
	}
	if (document.form.userLastName.value == "") {
		errMsg += ", Last Name";
	}
	if ((document.form.userEmail.value == "") || (!validateEmail(document.form.userEmail.value))) {
		errMsg += ", Email Address";
	}

	if (errMsg == "") {
		document.form.submit();
	} else {
		alert("Sorry. Before we can send your information, you must fill in the following fields:\n\n" + errMsg.substring(2));
	}

}


function save_submit() {
	if (document.lexSaveVehicleForm.saveName.value.search(/\S/) == -1) {
		alert("Please enter a name for this vehicle.");
	} else {
		document.lexSaveVehicleForm.twcAction.value='submit';
		document.lexSaveVehicleForm.submit();
	}
}



function validateEmail(address) {
    var exclude=/[^@\-\.\w]|^[_@\.\-]|[\._\-]{2}|[@\.]{2}|(@)[^@]*\1/;
    var check=/@[\w\-]+\./;
    var checkend=/\.[a-zA-Z]{2,4}$/;

    if (((address.search(exclude) != -1)|| (address.search(check)) == -1) || (address.search(checkend) == -1)) {
		return false;
    }
    return true;
}

var isIE4 = false;
var isNS4 = false;
var isIE5 = false;
var isNS6 = false;

isNS4 = (document.layers) ? true : false;
isIE4 = (document.all && !document.getElementById) ? true : false;
isIE5 = (document.all && document.getElementById) ? true : false;
isNS6 = (!document.all && document.getElementById) ? true : false;

function some(object) {
	if (isNS4){
		document.layers[object].visibility = "show";
	}
	else if (isIE4) {
		elm = document.all[object];
		elm.style.visibility = "visible";
	}
	else if (isIE5 || isNS6) {
		elm = document.getElementById(object);
		elm.style.visibility = "visible";
	}
}

function none(object) {
	if (isNS4){
		document.layers[object].visibility = "hide";
	}
	else if (isIE4) {
		elm = document.all[object];
		elm.style.visibility = "hidden";
	}
	else if (isIE5 || isNS6) {
		elm = document.getElementById(object);
		elm.style.visibility = "hidden";
	}
}

<!--
/*
 * NumberFormat 1.0.3
 * v1.0.3 - 23-March-2002
 * v1.0.2 - 13-March-2002
 * v1.0.1 - 20-July-2001
 * v1.0.0 - 13-April-2000
 * http://www.mredkj.com
 */
 
/*
 * NumberFormat -The constructor
 * num - The number to be formatted
 */
function NumberFormat(num)
{

	// member variables
	this.num;
	this.numOriginal;
	this.isCommas;
	this.isCurrency;
	this.currencyPrefix;
	this.places;

	// external methods
	this.setNumber = setNumberNF;
	this.toUnformatted = toUnformattedNF;
	this.setCommas = setCommasNF;
	this.setCurrency = setCurrencyNF;
	this.setCurrencyPrefix = setCurrencyPrefixNF;
	this.setPlaces = setPlacesNF;
	this.toFormatted = toFormattedNF;
	this.getOriginal = getOriginalNF;

	// internal methods
	this.getRounded = getRoundedNF;
	this.preserveZeros = preserveZerosNF;
	this.justNumber = justNumberNF;

	// setup defaults
	this.setNumber(num);
	this.setCommas(true);
	this.setCurrency(true);
	this.setCurrencyPrefix('$');
	this.setPlaces(2);
}

/*
 * setNumber - Sets the number
 * num - The number to be formatted
 */
function setNumberNF(num)
{
	this.numOriginal = num;
	this.num = this.justNumber(num);
}

/*
 * toUnformatted - Returns the number as just a number.
 * If the original value was '100,000', then this method will return the number 100000
 * v1.0.2 - Modified comments, because this method no longer returns the original value.
 */
function toUnformattedNF()
{
	return (this.num);
}

/*
 * getOriginal - Returns the number as it was passed in, which may include non-number characters.
 * This function is new in v1.0.2
 */
function getOriginalNF()
{
	return (this.numOriginal);
}

/*
 * setCommas - Sets a switch that indicates if there should be commas
 * isC - true, if should be commas; false, if no commas
 */
function setCommasNF(isC)
{
	this.isCommas = isC;
}

/*
 * setCurrency - Sets a switch that indicates if should be displayed as currency
 * isC - true, if should be currency; false, if not currency
 */
function setCurrencyNF(isC)
{
	this.isCurrency = isC;
}

/*
 * setCurrencyPrefix - Sets the symbol that precedes currency.
 * cp - The symbol
 */
function setCurrencyPrefixNF(cp)
{
	this.currencyPrefix = cp;
}

/*
 * setPlaces - Sets the precision of decimal places
 * p - The number of places. Any number of places less than or equal to zero is considered zero.
 */
function setPlacesNF(p)
{
	this.places = p;
}

/*
 * toFormatted - Returns the number formatted according to the settings (a string)
 */
function toFormattedNF()
{
	var pos;
	var nNum = this.num; // v1.0.1 - number as a number
	var nStr;            // v1.0.1 - number as a string

	// round decimal places
	nNum = this.getRounded(nNum);
	nStr = this.preserveZeros(Math.abs(nNum)); // this step makes nNum into a string. v1.0.1 Math.abs

	if (this.isCommas)
	{
		pos = nStr.indexOf('.');
		if (pos == -1)
		{
			pos = nStr.length;
		}
		while (pos > 0)
		{
			pos -= 3;
			if (pos <= 0) break;
			nStr = nStr.substring(0,pos) + ',' + nStr.substring(pos, nStr.length);
		}
	}
	
	nStr = (nNum < 0) ? '-' + nStr : nStr; // v1.0.1

	if (this.isCurrency)
	{
		// add dollar sign in front
		nStr = this.currencyPrefix + nStr;
	}

	return (nStr);
}

/*
 * getRounded - Used internally to round a value
 * val - The number to be rounded
 */
function getRoundedNF(val)
{
	var factor;
	var i;

	// round to a certain precision
	factor = 1;
	for (i=0; i<this.places; i++)
	{	factor *= 10; }
	val *= factor;
	val = Math.round(val);
	val /= factor;

	return (val);
}

/*
 * preserveZeros - Used internally to make the number a string
 * 	that preserves zeros at the end of the number
 * val - The number
 */
function preserveZerosNF(val)
{
	var i;

	// make a string - to preserve the zeros at the end
	val = val + '';
	if (this.places <= 0) return val; // leave now. no zeros are necessary - v1.0.1 less than or equal
	
	var decimalPos = val.indexOf('.');
	if (decimalPos == -1)
	{
		val += '.';
		for (i=0; i<this.places; i++)
		{
			val += '0';
		}
	}
	else
	{
		var actualDecimals = (val.length - 1) - decimalPos;
		var difference = this.places - actualDecimals;
		for (i=0; i<difference; i++)
		{
			val += '0';
		}
	}
	
	return val;
}

/*
 * justNumber - Used internally to parse the value into a floating point number.
 * If the value is not set, then return 0.
 * If the value is not a number, then replace all characters that are not 0-9, a decimal point, or a negative sign.
 *
 *  Note: The regular expression cleans up the number, but doesn't get rid of - and .
 *  Because all negative signs and all decimal points are allowed,
 *  extra negative signs or decimal points may corrupt the result.
 *  parseFloat will ignore all values after any character that is NaN.
 *
 *  A number can be entered using special notation.
 *  For example, the following is a valid number: 0.0314E+2
 *
 * This function is new in v1.0.2
 */
function justNumberNF(val)
{
	val = (val==null) ? 0 : val;

	// check if a number, otherwise try taking out non-number characters.
	if (isNaN(val))
	{
		var newVal = parseFloat(val.replace(/[^\d\.\-]/g, ''));

		// check if still not a number. Might be undefined, '', etc., so just replace with 0.
		// v1.0.3
		return (isNaN(newVal) ? 0 : newVal); 
	}
	// return 0 in place of infinite numbers.
	// v1.0.3
	else if (!isFinite(val))
	{
		return 0;
  }
	
	return val;
}

//-->


	function formatNumber(number) {
		return new NumberFormat(number).toFormatted();
	}

	function updateDiv(divId, newText, spanClass) {
		if (isNS4){
			
			if (document.copyText1ILayer)	{
			document.copyText1ILayer.resizeBy(100,100); //(100,100) is just big enough to fix NS4 layer clipped error
			}
			var obj = eval('document.' + divId + 'ILayer.document.' + divId + 'Layer1.document');
			obj.open();
			obj.write('<span class=' + spanClass + '>' + newText + '</span>');
			obj.close();
		}
		else if (isIE4 ) {
			obj = document.all[divId];
			obj.innerHTML = newText;
		}
		else if ( isIE5 || isNS6 ) {
			obj = document.getElementById(divId);
			obj.innerHTML = newText;
		}
	}

	
	
		
/* GM DISABLE CONFLICT WITH LP3         
        function swapOut(imageTagName, imageName) {
 imageTagName.src = imageName.src;
  return true;
}


function swapBack(imageTagName, imageName){
  imageTagName.src = imageName.src;
  return true;
}

*/


// Macromedia Scripts

	function MM_jumpMenu(targ,selObj,restore){ //v3.0
	  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
	  if (restore) selObj.selectedIndex=0;
	}
	function MM_swapImgRestore() { //v3.0
	  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
	}
	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];}}
	}
	function MM_findObj(n, d) { //v4.0
	  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
		d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
	  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
	  if(!x && document.getElementById) x=document.getElementById(n); return x;
	}
	function MM_swapImage() { //v3.0
	  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
	   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
	}
