		  var colorMessage, formMessage, tableWindow;
		  var colorWindow = null;
		  var notColorCompatible = notCompatible();
		  var notTableCompatible = notCompatible("table");
		  var submitPressed = false;

		  //Tests if browser is compatible.
          function notCompatible(type) {
            var agent = navigator.userAgent.toLowerCase();
            var major = parseInt(navigator.appVersion);
            var minor = parseFloat(navigator.appVersion);
			if (agent.indexOf("msie") != -1) {
			  if (major < 4) {
			    return true;
			  }
			  else {return false;}
			}
			if ((agent.indexOf('mozilla')!=-1) && ((agent.indexOf('spoofer')==-1) && (agent.indexOf('compatible') == -1))) {
			  if (major < 5) {
			    return true;
			  }
			  else {return false;}
			}
			if (agent.indexOf("opera") != -1) {
			  if (major < 3) {
			    return true;
			  }
			  else if (type) {
			    return true;
			  }
			  else {return false;}
			}
		  }

		  function combineBadLuck() {
			if (submitPressed) {
			  alert("Please be patient, your survey is being submitted.");
			  return false;
			}
		    var color1 = document.colorForm["Bad Luck1"][document.colorForm["Bad Luck1"].selectedIndex].value;
			var color2 = document.colorForm["Bad Luck2"][document.colorForm["Bad Luck2"].selectedIndex].value;
			if (color1 > color2 ) {
			  document.colorForm["Bad Luck"].value = color2 + "#" + color1;
			}
			else {
			  document.colorForm["Bad Luck"].value = color1 + "#" + color2;
			}
			submitPressed = true;
			return true;
		  }

		  function combineBadLuck2() {
			if (submitPressed) {
			  alert("Please be patient, your survey is being submitted.");
			  return false;
			}
		    var color1 = document.colorForm["Bad Luck1"][document.colorForm["Bad Luck1"].selectedIndex].value;
			var color2 = document.colorForm["Bad Luck2"][document.colorForm["Bad Luck2"].selectedIndex].value;
			if (color1 > color2 ) {
			  document.colorForm["BadLuck"].value = color2 + "#" + color1;
			}
			else {
			  document.colorForm["BadLuck"].value = color1 + "#" + color2;
			}
			submitPressed = true;
			return true;
		  }

		  //Called when a color is chosen.
		  function onchangeAction(dropdownMenu) {
		    dropdownMenu.blur();
			popColor(dropdownMenu);
		  }

		  //Pops up a window with the color selected.
		  function popColor(dropdownMenu) {
			if (notColorCompatible){
			  return;
			}
		    var color, fontColor
			var metallic = false;
		    var dropdownValue = dropdownMenu[dropdownMenu.selectedIndex].value;
		    if(dropdownValue == "" || dropdownValue == "None") {
			  return;
			}
			if (dropdownValue == "Silver" || dropdownValue == "Platinum" || dropdownValue == "Gold") {
			  metallic = true;
			}
			color = dropdownMenu.options[dropdownMenu.selectedIndex].style.backgroundColor;
			fontColor = dropdownMenu.options[dropdownMenu.selectedIndex].style.color;
		    colorMessage = '<HTML><HEAD>';
			if (!metallic) {
			  colorMessage += '<STYLE TYPE="text/css">TD{color:' + fontColor + 
			  '; font-family:Arial,Helvetica,Geneva,Swiss,SunSans-Regular; background-color:'+ color + ';}';
			  colorMessage += 'BODY{background-color:' + color + ';}</STYLE>';
			}
			colorMessage += '<TITLE>Color</TITLE></HEAD><BODY onLoad="';
		    colorMessage += 'setTimeout(\'close();\', 7000);">';
			if (metallic) {
			  colorMessage += '<div style="position:absolute; left:0; top:0;" onclick="window.close()"><img src="http://express.colormatters.com/colorsurvey/' + dropdownValue + '.jpg" width=250 height=250 onclick="window.close()"></div>' + 
			  '<div style="position:absolute; left:160; top:20; height:30; width:30;" onclick="window.close();"><font size=1><a href="javascript:window.close();">Close</a></font></div>' +
			  '<div align=center style="position:absolute; left:30; top:150; height:20; width:150;" onclick="window.close();"><font size=1 face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular">This window will remain open for 7 seconds.</font></div>';
			}
			else {
			  colorMessage += '<TABLE BORDER=0><TR><TD valign=top align=right width=250 height=98 onclick="window.close()">' + '<font size=1><a href="javascript:window.close();">Close</a></font></TD></TR><TR><TD valign=bottom align=center width=250 height=82 onclick="window.close()"><font size=1 >This window will remain open for 7 seconds.</font></TD></TR></TABLE>';
			}
		    colorMessage += '</BODY></HTML>';
		    colorWindow = window.open('', 'color', 'resizable,scrollbars=no,width=200,height=200,screenX=0,left=0,screenY=0,top=0');
		    colorWindow.focus();
			colorWindow.location.href = 'javascript:opener.colorMessage';
		  }

		  //Pops Color table
		  function popColorTable(dropdownMenu) {
		    if (notTableCompatible) {
			  alert("Sorry, the color chart is not available for this browser");
			  return;
		    }
		    formMessage = dropdownMenu;
			tableWindow = window.open('/colorsurvey/colorTable.html', 'colorTable', 'scrollbars=no,width=365,height=378,screenX=0,left=0,screenY=0,top=0, resizable, scrollbars=yes');
			tableWindow.focus();
		  }

		  //preload Metalic color swatches.
		  function preloadImages() {
			if(document.images){ 
			  if(!document.p)
			    document.p = new Array();
		        var i;
				var j = document.p.length;
				var pics = preloadImages.arguments;
				for(i=0; i < pics.length; i++)
				    document.p[j] = new Image; 
					document.p[j++].src = "/colorsurvey/" + pics[i];
			}
          }