	
	
	/* ANSO NYLON/SMARTCARE - BASIC JAVASCRIPT (basic.js) - 
	   this file contains basic JavaScript for rollovers, popups, etc
	   and is included on all pages. It also contains the DHTML scripting for
	   the pop-up navigation menu scheme. */
	   
	var lastMenuOne = null;
	var lastMenuTwo = null;
	var lastHighSub = null;
	
	function goToFAQtopic() {
		id = document.golink.catid.selectedIndex;
		if (id >= 0) {
			cid = document.golink.catid.options[id].value;
			location.href = "#faqcat" + cid;
		}
	}
	
	function findDealerOnEnter(e){ 
		// (e is event object passed from function call)		
		var keyCode 
	
		if (e && e.which) { 
			// key code is contained in mozilla's (netscape/firefox) which property
			e = e;
			keyCode = e.which;
		} else {
			// key code is contained in IE's keyCode property
			e = event;
			keyCode = e.keyCode; 
		}
	
		// if character code is ascii 13 (enter key), submit form
		if (keyCode == 13) { 
			// document.forms[0].submit();
			findDealer();
			return false; 
		} else {
			return true;
		}		
	}
	
	function clearSearch() {
		document.search.zip.value = "";
	}
	
	function findDealer() {
		var testzip = null;
		testzip = document.search.zip.value;
		// *** DMS 6-3-08 - oops wasn't letting 3 digit CA zips go through
		if (testzip.length < 3 || testzip == "Enter Postal Code") 
			alert("Please enter a zip code to begin your search.");
		else
			document.search.submit();
	}
	
	function SelectLevelOne(ibase) {
		var obj;
		obj = "navlvl2_" + ibase;
		// deselect all of them
		setElementVisibility("navlvl2_selecting", "h");
		setElementVisibility("navlvl2_caring", "h");
		setElementVisibility("navlvl2_warranty", "h");
		setElementVisibility(obj, "v");
		// roll off all top level nav buttons (will not un-highlight currently selected one)
		RollOffMenu("selecting");
		RollOffMenu("caring");
		RollOffMenu("warranty");
	}
	
	function setElementVisibility (obj, mode) {
		// update visibility of element requested
		if (mode == "h")
			var setstyl = "hidden";
		else
			var setstyl = "visible";
		if (document.getElementsByTagName && document.getElementById) {
			//Netscape 6+ model (also works in IE 6)
			document.getElementById(obj).style.visibility = setstyl;
		} else {
			if (document.all) {
				//IE model (at least, versions prior to 6)
				document.all(obj).style.visibility = setstyl;
			}	
		}		
	}	
	
	function setElementText (obj, str) {
		// update HTML of element requested
		if (document.getElementsByTagName && document.getElementById) {
			//Netscape 6+ model (also works in IE 6)
			document.getElementById(obj).innerHTML = str;
		} else {
			if (document.all) {
				//IE model (at least, versions prior to 6)
				document.all(obj).innerHTML = str;	
			}	
		}		
	}	
	
	function getElementText (obj) {
		// get HTML of element requested
		var str;
		if (document.getElementsByTagName && document.getElementById) {
			//Netscape 6+ model (also works in IE 6)
			str = document.getElementById(obj).innerHTML;
		} else {
			if (document.all) {
				//IE model (at least, versions prior to 6)
				str = document.all(obj).innerHTML;	
			}	
		}	
		return str;
	}	
	
	function setElementBkgdColor (obj, clr) {
		// update background-color of element requested
		if (document.getElementsByTagName && document.getElementById) {
			//Netscape 6+ model (also works in IE 6)
			document.getElementById(obj).style.backgroundColor = clr;
		} else {
			if (document.all) {
				//IE model (at least, versions prior to 6)
				document.all(obj).style.backgroundColor = clr;	
			}	
		}		
	}	
	
	function setElementColor (obj, clr) {
		// update background-color of element requested
		if (document.getElementsByTagName && document.getElementById) {
			//Netscape 6+ model (also works in IE 6)
			document.getElementById(obj).style.color = clr;
		} else {
			if (document.all) {
				//IE model (at least, versions prior to 6)
				document.all(obj).style.color = clr;	
			}	
		}		
	}
	
	function showWinH() {
		var winh;
		//winh = window.innerHeight;
		winh = document.body.clientHeight;
		alert(winh);
	}
	
	
	// **** BELOW IS COPIED FROM ADVANTAGE AND NEEDS TO BE EDITED FOR THIS SITE ****
	
	if (document.all) {
		// with IE, we can add this global event handler here for the whole menu structure.
		//with NS, the event capture/bubble sequence always creates an extra event to contend with
		//that will screw up something no matter how we deal with it, it seems. 
		//document.attachEvent("onclick", popMenus);
		document.attachEvent("onmouseover", popMenus);
		//document.attachEvent("onmouseout", popMenus);
	} 
	
	function popMenus(e) {
		//handle all pop-up menu events
		var eventSrc = null;
		var eventType = null;
		var gotClass = null;
		var gotId = null;
		var uspos, basestr, menunm, textnm, goon, debugstr;
		
		//get the source of the current event (differs for IE vs NS)
		//debugstr = "";
		if (window.event) {
			// IE syntax
			eventSrc = window.event.srcElement;
			eventType = window.event.type;
			//updateText('debug', 'class = ' + eventSrc.className + '; id = ' + eventSrc.id + '; type = ' + eventType);
		} else {
			// Netscape syntax
			//eventSrc = arguments.callee.caller.arguments[0].currentTarget;
			eventSrc = e.currentTarget;
			eventType = e.type;
			//updateText('debug', 'type = ' + eventType + '; class = ' + eventSrc.className + '; id = ' + eventSrc.id);
		}
		
		//if we found the source, get the class and id of the item clicked
		if (eventSrc != null) {
			gotClass = eventSrc.className;
			gotId = eventSrc.id;	
		}
		
		if (gotClass == "navMenu") {
			//clicked on navigation menu graphic (top level). try to get id and parse to find which menu to toggle.
			//note that with NS, the document click event will fire first, then will get to here.
			uspos = gotId.lastIndexOf("_");
			if ((uspos > 0) && (gotId.length > uspos)) {
				basestr = gotId.substr(uspos+1, gotId.length-uspos);
				if (basestr.length > 0) {
					menunm = "menublock_" + basestr;
					if (menunm == lastMenuOne) {
						//force the menu OFF (we know it is currently on). now that we have turned the
						//document event off for NS (so with NS you have to click on the menu again to
						//turn it off), NS will get here too.
						//debugstr = "clicked top level - toggling lastMenuOne OFF";
						//updateText('debug', debugstr);
						toggleMenu(lastMenuOne, 0, 1);
					} else {
						//if any other menu open, close it first
						if (lastMenuOne != null) {
							//debugstr = "clicked top level - toggling lastMenuOne OFF";
							//updateText('debug', debugstr);
							toggleMenu(lastMenuOne, 0, 1);
						}
						
						//toggle the menu off or on, the opposite of whatever it is now
						//debugstr = "clicked top level - toggling " + menunm + " OFF/ON";
						//updateText('debug', debugstr);
						toggleMenu(menunm, -1, 1);			
					}
					
					//no matter what, kill any open submenu below this level
					if (lastMenuTwo != null) {
						//debugstr = "clicked top level - toggling lastMenuTwo OFF";
						//updateText('debug', debugstr);
						toggleMenu(lastMenuTwo, 0, 2);
					}				
				}		
			}
		} else {
			if (gotClass == "secondary") {
				//clicked on submenu element. can be level 2 or 3. for now, assume level 2. as above,
				//get id and parse to find which submenu block to toggle.
				uspos = gotId.lastIndexOf("_");
				if ((uspos > 0) && (gotId.length > uspos)) {
					basestr = gotId.substr(uspos+1, gotId.length-uspos);
					if (basestr.length > 0) {
						menunm = "submenublock_" + basestr;	
						if (menunm == lastMenuTwo) {
							//force the submenu OFF (we know it is currently on).
							//debugstr = "clicked " + gotId + "(secondary) - toggling menunm/lastMenuTwo OFF";
							//updateText('debug', debugstr);
							toggleMenu(lastMenuTwo, 0, 2);
						} else {
							//if any other submenu open, close it first
							if (lastMenuTwo != null) {
								//debugstr = "clicked " + gotId + "(secondary) - toggling lastMenuTwo OFF";
								//updateText('debug', debugstr);
								toggleMenu(lastMenuTwo, 0, 2);
							}
							
							//toggle the menu off or on, the opposite of whatever it is now
							//debugstr = "clicked " + gotId + "(secondary) - toggling " + menunm + " OFF/ON";
							//updateText('debug', debugstr);
							toggleMenu(menunm, -1, 2);	
							
							if (eventType.toLowerCase() == "mouseover") {
								// highlight this submenu and turn off any other submenu highlight
								//debugstr = "need to highlight submenu: " + gotId;
								//updateText('debug', debugstr);
								highlightSubmenu(gotId);
							}
						}					
					}
				}		
			} else {
				if (gotClass != 'menuLevelTwo' && gotClass != 'menuLevelThree' && gotClass != 'tertiary') {
					//clicked anywhere else, kill any open menus
					//alert ("lastMenuOne = " + lastMenuOne + ", lastMenuTwo = " + lastMenuTwo);
					if (lastMenuOne != null) {
						//debugstr = "clicked elsewhere - toggling lastMenuOne OFF";
						//updateText('debug', debugstr);
						toggleMenu(lastMenuOne, 0, 1);
					}
					if (lastMenuTwo != null) {
						//debugstr = "clicked elsewhere - toggling lastMenuTwo OFF";
						//updateText('debug', debugstr);				
						toggleMenu(lastMenuTwo, 0, 2);
					}
				}
			}			
		}	
	}
	
	function highlightSubmenu(obj) {
		// turn off any currently highlighted submenu and highlight requested object
		var baseid = null;
		var menuobj, linkobj;
		if (lastHighSub != null) {
			// get id for menu div object and link object inside div (for last menu highlighted)
			baseid = getBaseID(lastHighSub);
			if (baseid != null) {
				// valid id found, construct object names and reset colors
				//debugstr = "turning off last highlight for submenu, id = " + baseid;
				//updateText('debug', debugstr);	
				menuobj = "submenu_" + baseid;
				linkobj = "submenu_link_" + baseid;
				setElementBkgdColor (linkobj, "#A09B88");		// was 5F5542
				setElementColor (linkobj, "#FFFFFF");			// was FFFFFF, then 333333
				setElementBkgdColor (menuobj, "#A09B88");		// was 5F5542
			}
		}
		// as above for new menu to highlight
		baseid = getBaseID(obj);
		if (baseid != null) {
			// valid id found, construct object names and reset colors
			//debugstr = "turning on new highlight for submenu, id = " + baseid;
			//updateText('debug', debugstr);	
			menuobj = "submenu_" + baseid;
			linkobj = "submenu_link_" + baseid;
			// also store new menu highlighted
			lastHighSub = menuobj;
			setElementBkgdColor (linkobj, "#5F5542");			// was A09B88
			setElementColor (linkobj, "#FFFFFF");				// was 333333
			setElementBkgdColor (menuobj, "#5F5542");			// was A09B88
		}
	}
	
	function getBaseID(obj) {
		// find last underscore and look for number after that; return null if not in desired format 
		idstr = null;
		if (obj.lastIndexOf('_') >= 0) {
			idstr = obj.substring(obj.lastIndexOf('_')+1, obj.length);
			if (isNaN(idstr))
				idstr = null;
			//debugstr = "base id = " + idstr;
			//updateText('debug', debugstr);
		}
		return idstr;
	}
	
	function toggleMenu(obj, force, lvl) {
		//change mode of requested drop-down menu object (if no force parameter, just toggle
		//the display mode. if force parameter >= 0, display or hide as requested.
		//lvl parameter tells us level of menu clicked, so we can react accordingly.
		var stat = null;
		var setstyl = null;
		var uspos, basestr, imgName, menunm, goon;
		
		//debugstr = "-- toggleMenu called; obj = " + obj + "; force = " + force + "; lvl = " + lvl;
		//updateText('debug', debugstr);
		
		if ((obj == lastMenuTwo) && (force == 0) && (lvl == 2)) {
			/* a level 2 menu is being clicked off, make sure the submenu controller
			that was clicked to turn the menu on is no longer highlighted */
			menunm = lastMenuTwo.replace("submenublock_", "submenu_");
			// see if object actually exists before calling handler to turn it off
			goon = 0;
			if (document.getElementsByTagName && document.getElementById) {
				//Netscape 6+ model (also works in IE 6)
				if (document.getElementById(menunm))
					goon = 1;
			} else {
				if (document.all) {
					//IE model (at least, versions prior to 6)
					if (document.all(menunm))
						goon = 1;
				}	
			}
			if (goon) {
				////debugstr = "turning off highlight for element: " + menunm + " (if we can figure out how)";
				////updateText('debug', debugstr);
				//highlightSub(menunm, 0, 0);	
			}
		}
		
		if (force >= 0) {
			//if force parameter passed, don't toggle mode, set it to mode passed in
			if (force == 1)
				setstyl = 'visible';
			else
				setstyl = 'hidden';
		} else {
			//toggle mode from whatever it is now, so need to check current status
			stat = null;
		    if (document.getElementsByTagName && document.getElementById) {
				//Netscape 6+ model (also works in IE 6)
				if (document.getElementById(obj))
					stat = document.getElementById(obj).style.visibility;
		    } else {
		    	if (document.all) {
					//IE model (at least, versions prior to 6)
					if (document.all(obj))
						stat = document.all(obj).style.visibility;	
				}	
			}		
			//set to opposite of current status
			setstyl = null;
			if (stat == 'visible')
				setstyl = 'hidden';
			else {
				if (stat == 'hidden')
					setstyl = 'visible';
			}		
		}
		
		//debugstr = "-- toggleMenu: setstyl = " + setstyl + " (force = " + force + ") ";
		//updateText('debug', debugstr);		
		if (setstyl != null) {
			//if we know what to do, set mode of object	
		    if (document.getElementsByTagName && document.getElementById) {
				//Netscape 6+ model (also works in IE 6)
				document.getElementById(obj).style.visibility = setstyl;
		    } else {
		    	if (document.all) {
					//IE model (at least, versions prior to 6)
					document.all(obj).style.visibility = setstyl;	
				}	
			}
			//update last menu and submenu variables
			if (lvl > 1) {
				// if level 2 (sub) menu clicked, update lastMenuTwo based on status of submenu clicked.
				if (setstyl == 'visible')
					lastMenuTwo = obj;
				else
					lastMenuTwo = null;		
			} else {
				// if level 1 menu clicked, update lastMenu based on status of menu clicked.
				if (setstyl == 'visible') {
					lastMenuOne = obj;
				} else {
					lastMenuOne = null;	
					//if turning off level 1 menu, make sure nav button gets turned off as well
					//need to construct image name from object name
					uspos = obj.lastIndexOf("_");
					if ((uspos > 0) && (obj.length > uspos)) {
						basestr = obj.substr(uspos+1, obj.length-uspos);
						if (basestr.length > 0) {		
							RollOffBasic(basestr);
						}
					}				
				}
			}	
		}
	}
	
	function RollOffMenu(imgName) {
		// before calling roll off function for this level one nav graphic, see if corresponding
		// level two menu is open. if so, don't roll off.
		var uspos, basestr, menunm;
		var stat = null;
		
		if (imgName.length > 0) {
			//this is corresponding level two menu name, see if it is visible
			menunm = "navlvl2_" + imgName;
		    if (document.getElementsByTagName && document.getElementById) {
				//Netscape 6+ model (also works in IE 6)
				stat = document.getElementById(menunm).style.visibility;
		    } else {
		    	if (document.all) {
					//IE model (at least, versions prior to 6)
					stat = document.all(menunm).style.visibility;	
				}	
			}	
			if (stat != "visible")
				RollOffBasic(imgName);		
		}
	}
	   
	function RollOnBasic(imgName) {
		if (document.images){
			imgFileName = "";
			imgOld = document.images[imgName].src;
			dotPos = imgOld.lastIndexOf('.');
			imgExt = imgOld.substring(dotPos+1, dotPos+4); 
			imgFileName = imgOld.substring(0, imgOld.lastIndexOf('_'));
			imgFileName = imgFileName + "_2." + imgExt;
			document.images[imgName].src = imgFileName;
		}
	}
	
	function RollOffBasic(imgName) {
		if (document.images){
			imgFileName = "";
			imgOld = document.images[imgName].src;
			dotPos = imgOld.lastIndexOf('.');
			imgExt = imgOld.substring(dotPos+1, dotPos+4); 
			imgFileName = imgOld.substring(0, imgOld.lastIndexOf('_'));
			imgFileName = imgFileName + "_1." + imgExt;
			document.images[imgName].src = imgFileName;
		}
	}
	
	function openHelp(path_maindir){
		var wURL, wAttrs;
	
		wURL = path_maindir + "/help/helpcenter.html";
		wAttrs = "height=464,width=620,resizable=no,scrollbars=no,status=no,toolbar=no,location=no";
		window.open(wURL, "", wAttrs);
		window.focus;
	}
	
	function hideOrShowItem (obj, stat) {
		var vis;
		if (stat == 1) {
			vis = "visible";
			lastVisDiv = obj;
		} else {
			vis = "hidden";
			lastVisDiv = "";
		}
		if (document.getElementsByTagName && document.getElementById) {
			//Netscape 6+ model (also works in IE 6)
			document.getElementById(obj).style.visibility = vis;
		} else {
			if (document.all) {
				//IE model (at least, versions prior to 6)
				document.all(obj).style.visibility = vis;	
			}	
		}
	}
	
	function toggleFldMode(obj, basenm) {
		var stat = null;
		var setstyl = null;
		var fldid;
		
		fldid = obj + '_id';
		//toggle mode from whatever it is now, so need to check current status
		if (document.getElementsByTagName && document.getElementById) {
			//Netscape 6+ model (also works in IE 6)
			stat = document.getElementById(obj).style.visibility;
		} else {
			if (document.all) {
				//IE model (at least, versions prior to 6)
				stat = document.all(obj).style.visibility;	
			}	
		}
				
		//set to opposite of current status
		if (stat == 'visible')
			setstyl = 'hidden';
		else
			setstyl = 'visible';
					
		//now set mode of object	
		if (document.getElementsByTagName && document.getElementById) {
			//Netscape 6+ model (also works in IE 6)
			document.getElementById(obj).style.visibility = setstyl;
			//disable the field if hidden, so only one field passed
			if (setstyl == 'hidden')
				document.getElementById(fldid).disabled = true;
			else
				document.getElementById(fldid).disabled = false;
		} else {
			if (document.all) {
				//IE model (at least, versions prior to 6)
				document.all(obj).style.visibility = setstyl;
				//disable the field if hidden, so only one field passed
				if (setstyl == 'hidden')
					document.all(fldid).disabled = true;
				else
					document.all(fldid).disabled = false;	
			}
		}
		return setstyl;	
	}	
	
	function updateText(obj, str) {
		// update text of element requested - this is for debugging popup script above
		var str;
		str = str + "<br>" + getElementText(obj);
		setElementText (obj, str);
	}
	
	
	
	// *** DMS 5-12-06: pasted in Sarah's IE active content kluge:
	// this function lets javascript output the necessary Flash object and embed tags
	// to workaround IE 6's new 'active content' security warnings 
	// *** DMS 5-13-06: added width & height params so can use for Help or other Flash content as well
	function RunFlash(flashfile, flashW, flashH) {
	   document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab##version=6,0,0,0" width="' + flashW + '" height="' + flashH + '">\n');
	    document.write(' <param name=movie value="' + flashfile + '" />\n');
		document.write(' <param name=quality value=high />\n');
		document.write(' <embed src="' + flashfile + '" quality=high pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="' + flashW + '" height="' + flashH + '">\n');
		document.write('</embed>\n');
	    document.write('</object>\n');
	}	
		
		