/***********************************************
* Recall Form Values script II- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

function getCookie(Name){
var re=new RegExp(Name+"=[^;]+", "i"); //construct RE to search for target name/value pair
if (document.cookie.match(re)) //if cookie found
return document.cookie.match(re)[0].split("=")[1] //return its value
return ""
}

function setCookie(name, value, days){
var expireDate = new Date()
//set "expstring" to either future or past date, to set or delete cookie, respectively
var expstring=expireDate.setDate(expireDate.getDate()+parseInt(days))
document.cookie = name+"="+value+"; expires="+expireDate.toGMTString()+"; path=/";
}

function rememberForm(formid){ //Main remember form values object
this.formref=document.getElementById(formid)? document.getElementById(formid) : document.forms[formid]
this.cookiename=formid
this.persistdays=180 //days to persist form values
this.fields=new Array()
this.cookiestr=""
var forminstance=this
rememberForm.dotask(this.formref, function(){forminstance.savevalues()}, "submit") //save form values onsubmit
rememberForm.dotask(window, function(){forminstance.recallvalues()}, "load") //populate form with saved values onload (body)
}

rememberForm.prototype.getfield=function(attr){ //get form field based on its ID or name attribute
var fieldref=document.getElementById(attr)? document.getElementById(attr) : this.formref[attr]
return fieldref
}

rememberForm.prototype.persistfields=function(){ //get form fields to persist values for
for (var i=0; i<arguments.length; i++){
this.fields[i]=this.getfield(arguments[i])
this.fields[i].fname=arguments[i] //store name or id of field in custom property
}
}

rememberForm.prototype.savevalues=function(){ //get form values and store in cookie
for (var i=0; i<this.fields.length; i++){
if (this.fields[i].type=="text")
this.cookiestr+=this.fields[i].fname+":"+escape(this.fields[i].value)+"#"
}
if (typeof this.togglebox!="undefined"){ //if "remember values checkbox" is defined
this.persistdays=(this.togglebox.checked)? this.persistdays : -1 //decide whether to save form values
this.cookiestr=(this.togglebox.checked)? this.cookiestr+"toggleboxid:on;" : this.cookiestr
}
else //if checkbox isn't defined, just remove final "#" from cookie string
this.cookiestr=this.cookiestr.substr(0, this.cookiestr.length-1)+";"
setCookie(this.cookiename, this.cookiestr, this.persistdays)
}

rememberForm.prototype.recallvalues=function(){ //populate form with saved values
var cookievalue=getCookie(this.cookiename)
if (cookievalue!=""){ //parse cookie, where cookie looks like: field1:value1#field2:value2...
var cookievaluepair=cookievalue.split("#")
for (var i=0; i<cookievaluepair.length; i++){
if (cookievaluepair[i].split(":")[0]!="toggleboxid" && this.getfield(cookievaluepair[i].split(":")[0]).type=="text")
this.getfield(cookievaluepair[i].split(":")[0]).value=unescape(cookievaluepair[i].split(":")[1])
else //else if name in name/value pair is "toggleboxid"
this.togglebox.checked=true
}
}
}

rememberForm.prototype.addtoggle=function(attr){
this.togglebox=this.getfield(attr)
}

//Call this function if you wish to clear the user's cookie of any saved values for this form instantly
rememberForm.prototype.clearcookie=function(){
setCookie(this.cookiename, "", -1)
}

rememberForm.dotask=function(target, functionref, tasktype){
var tasktype=(window.addEventListener)? tasktype : "on"+tasktype
if (target.addEventListener)
target.addEventListener(tasktype, functionref, false)
else if (target.attachEvent)
target.attachEvent(tasktype, functionref)
}



// prohibit enter key
function stopRKey(evt) {
  var evt = (evt) ? evt : ((event) ? event : null);
  var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
  if ((evt.keyCode == 13) && (node.type=="text"))  {return false;}
}

document.onkeypress = stopRKey;



// AutoTab | Author: Matt Kruse <matt@mattkruse.com>
// WWW: http://www.mattkruse.com/
var phone_field_length=0;
function TabNext(obj,event,len,next_field){if(event == "down"){phone_field_length=obj.value.length;}else if(event == "up"){if(obj.value.length != phone_field_length){phone_field_length=obj.value.length;if(phone_field_length == len){next_field.focus();}}}}


  // Multiple Select Lists - JavaScript
  // (c)2004 Dan Gronitz
  //
  // This code was for Programmer's Corner (http://www.programmers-corner.com/index.php)
  // and can be used freely as long as this notice remains with the code.
  //
    function fillnewlist(){
      var myindex = document.forms.atg_rfq.selectone.selectedIndex;
      var secondlist = document.forms.atg_rfq.selecttwo;

      secondlist.options.length = 0;

	   if(myindex == 1)
	  {
		secondlist.options[0] = new Option("Architectural Bronze Anodizing", "Architectural Bronze Anodizing");
        secondlist.options[1] = new Option("Chromic Acid Anodizing & Hot Water Seal");
        secondlist.options[2] = new Option("Chromic Acid Anodizing & Dichromate Seal");
        secondlist.options[3] = new Option("Sulfuric Acid Anodizing & Hot Water Seal");
		secondlist.options[4] = new Option("Sulfuric Acid Anodizing & Dichromate Sea");
        secondlist.options[5] = new Option("Sulfuric Acid Anodizing & Dye Black");
        secondlist.options[6] = new Option("Sulfuric Acid Anodizing & Dye Gold");
		secondlist.options[7] = new Option("Sulfuric Acid Anodizing & Dye Blue");
        secondlist.options[8] = new Option("Sulfuric Acid Anodizing & Dye Red");
        secondlist.options[9] = new Option("Sulfuric Acid Anodizing & Dye Gray");
		secondlist.options[10] = new Option("Chromate Conversion Coating & Gold Alodine");
        secondlist.options[11] = new Option("Chromate Conversion Coating & Clear Alodine");
      }else if(myindex == 2)
      {
      	secondlist.options[0] = new Option("Cadmium .0002");
        secondlist.options[1] = new Option("Cadmium .0002 & Clear Chromate");
        secondlist.options[2] = new Option("Cadmium .0002 & Gold Chromate");
        secondlist.options[3] = new Option("Cadmium .0002 & Olive Drab Chromate");
        secondlist.options[4] = new Option("Cadmium .0003");
        secondlist.options[5] = new Option("Cadmium .0003 & Clear Chromate");
		secondlist.options[6] = new Option("Cadmium .0003 & Gold Chromate");
		secondlist.options[7] = new Option("Cadmium .0003 & Olive Drab Chromate");
		secondlist.options[8] = new Option("Cadmium .0005");
        secondlist.options[9] = new Option("Cadmium .0005 & Clear Chromate");
        secondlist.options[10] = new Option("Cadmium .0005 & Gold Chromate");
        secondlist.options[11] = new Option("Cadmium .0005 & Olive Drab Chromate");
        secondlist.options[12] = new Option("Zinc .0002");
        secondlist.options[13] = new Option("Zinc .0002 & Clear Chromate");
        secondlist.options[14] = new Option("Zinc .0002 & Gold Chromate");
        secondlist.options[15] = new Option("Zinc .0002 & Black Chromate");
        secondlist.options[16] = new Option("Zinc .0002 & Olive Drab Chromate");
        secondlist.options[17] = new Option("Zinc .0003");
        secondlist.options[18] = new Option("Zinc .0003 & Clear Chromate");
        secondlist.options[19] = new Option("Zinc .0003 & Gold Chromate");
        secondlist.options[20] = new Option("Zinc .0003 & Black Chromate");
        secondlist.options[21] = new Option("Zinc .0003 & Olive Drab Chromate");
        secondlist.options[22] = new Option("Zinc .0005");
        secondlist.options[23] = new Option("Zinc .0005 & Clear Chromate");
        secondlist.options[24] = new Option("Zinc .0005 & Gold Chromate");
		secondlist.options[25] = new Option("Zinc .0005 & Black Chromate");
		secondlist.options[26] = new Option("Zinc .0005 & Olive Drab Chromate");
        secondlist.options[27] = new Option("Electroless Nickel Plating");
        secondlist.options[28] = new Option("Nickel Plating (QQ-N-290)");
        secondlist.options[29] = new Option("Copper Plating");
        secondlist.options[30] = new Option("Pickling & Oil Services");
        secondlist.options[31] = new Option("Zinc Phosphate");
        secondlist.options[25] = new Option("Black Oxide Finishing");
      }else if(myindex == 3){
        secondlist.options[0] = new Option("ASTM-123");
        secondlist.options[1] = new Option("ASTM-153");
       
      }else{
        secondlist.options[0] = new Option("");
      }
    }

