// JavaScript Document


  function confirmbeforesubmit() {
    if (isantique) {
      if (document.getElementById("_confirmbox").checked) {
        document.forms[0]._confirmbox=null;
        return true;
      } else {
        alert("You must check the 'I Agree' box. To confirm your agreement to the terms and\nconditions for returning antique items before you can add this item to your cart.");
        return false;
      }
    } else {
      return true;
    }
  }

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 printThisPage() {
    window.print();
}

function retOptCode(valName) {
 var i;
 var on = new String("");
 var vn = new String("");

 for (i = 1; i <= optCnt; i++) 
 {
 on = aOptName[i];
 vn = valName;
 if (on.toUpperCase() == vn.toUpperCase())
  {
   return(aOptCode[i]);
//alert optcnt + ": " + on;
  }
 }
}

function retOptName(valName) {
 var i;
 var on = new String("");
 var vn = new String("");
 

 for (i = 1; i <= optCnt; i++) 
 {
 on = aOptCode[i];
 vn = valName;
 if (on.toUpperCase() == vn.toUpperCase())
  {
//   alert (aOptName[i]);
   return(aOptName[i]);
  }
 }
}

function retOptPrice(pasCode, pasItem) {
 var i;

 for (i = 1; i <= priceCnt; i++) 
 {
  if (aOptions[i] == pasCode && aItem[i] == pasItem)
  {
   imageArrayIndex = i;
if (aPrice[i] == 9999.99) {
      return('Call for Quote');
    } else {
    return(aPrice[i]);
      }
  }
 }
 return(-1);
}

QueryString.keys = new Array();
QueryString.values = new Array();

function QueryString(key) {
    var value = null;
    for (var i=0;i<QueryString.keys.length;i++) {
        if (QueryString.keys[i]==key) {
            value = QueryString.values[i];
            break;
        }
    }
    return value;
}

function QueryString_Parse() {
    var query = window.location.search.substring(1);
    var pairs = query.split("&");

    for (var i=0;i<pairs.length;i++) {
        var pos = pairs[i].indexOf('=');
        if (pos >= 0) {
            var argname = pairs[i].substring(0,pos);
            var value = pairs[i].substring(pos+1);
            QueryString.keys[QueryString.keys.length] = argname;
            QueryString.values[QueryString.values.length] = value;
        }
    }
}

QueryString_Parse();

IMAGEPLACEHOLDER = new String("ImageMain");

function MM_swapImage() { //v3.0
  var i;
  var j=0;
  var x;
  var 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];
    }
}

function MM_findObj(n, d) { //v4.01
    var p;
    var i;
    var 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 && d.getElementById) {
        x=d.getElementById(n);
    }
    return x;
}

var fname = new String();
var att1 = new String("");
var att2 = new String("");
var att3 = new String("");
var itemid = new String(QueryString("itemid"));
//var fna = new Array();
var imgFile = new String("");
var imgFileFull = new String("");
var imgName = new String("");
var tryi = 0;
var img = new Image();
var imageArrayIndex=0;
var aImage = new Array();
var newWin;
var fullImgHeight;
var fullImgWidth;

function doit() {

    var frm = document._ItemOrder;
    var v=0;
    
    img.onabort = imgError;
    img.onerror = imgError;
    img.onload = displayImg;


    imgName = aImage[imageArrayIndex];
    
    if (imgName.indexOf("1x1") >= 0) {
        for (var q=1; q<=priceCnt;q++) {
            if (aImage[q].indexOf("1x1") < 0) {
                imgName = aImage[q];
            }
        }
    }

    //alert ("Imagename: " + imgName);

    
    
    imgFile = "/_item_images/" + imgName;
    
    var s1 = new String(imgFile.substring(0, imgFile.indexOf(".jp") -2));
    var s2 = new String(imgFile.substring(imgFile.indexOf(".jp"), imgFile.length));
                  
                  
    imgFileFull = s1 + "_g" + s2 ; 
    
    img.src = imgFile;
    
}

function loadFullImage(item) {

    var frm = document._ItemOrder;
    var v=0;
    
    img.onabort = imgError;
    img.onerror = imgError;
    img.onload = setHW;
    
    fullImgHeight = 550;
    fullImgWidth = 550;
    img.src = imgFileFull;
                                                                                             
    displayPopupImg(item);
}

function setHW() {
    fullImgHeight = img.height + 50;
    fullImgWidth = img.width + 50;
}    

function displayPopupImg(item) {

    
    newWin = window.open("","LargeImage","height=" + fullImgHeight + ", width=" + fullImgWidth + ", top=50, left=100, menubar=no, location=no,resizable=yes,titlebar=no,toolbar=no,scrollbars=yes");
    if (newWin != null) {
        newWin.document.writeln("<html><head><title>" + item + "</title></head><body><img src='" + imgFileFull + "' alt='Large Image' ></body></html>");
        newWin.document.close();
        newWin.focus();
    } else {
        alert ("The larger image is displayed in a pop up window and your pop up blocker has stopped the image from displaying.  Please hold the Control (Ctrl) key when clicking the View Larger Image link to properly display the image.");
    }
}

function displayAntiqueTaC() {

    
    newWin = window.open("","AntiqueTaC","height=260, width=420, top=50, left=100, menubar=no, location=no,resizable=no,titlebar=no,toolbar=no,scrollbars=no");
    if (newWin != null) {
        newWin.document.writeln("<html><head><title>Restoration.Com - Terms and Conditions for Antique Items</title><link href='/site_styles.css' rel='stylesheet' type='text/css'></head><body background='#FFFFFF' LINK='000000' ALINK='000000' VLINK='000000' ><div class='DetailBigText'><strong><center>Antique Collection Terms and Conditions</center></strong></div><br/><div class='DetailText'><center>Crown City Hardware has put a lot of effort in selecting these antique pieces for sale. They are actual antiques and in most cases many decades old. Although they have been extensively refurbished, they are likely to show some wear, imperfections, and blemishes consistent with their age. They are not guaranteed in any way and the buyer should be aware of the risk at the time of purchase. Once an antique piece has been bought, it is non-returnable and non-refundable. This is a standard policy with antique items, and there are no exceptions. If you have questions regarding an item, please don’t hesitate to contact us directly before making your purchase.</center></div><br/><center><a href='javascript:window.close();'>Close</a></center></body></html>");
        newWin.document.close();
        newWin.focus();
    } else {
        alert ("The Terms & Conditions are displayed in a pop up window and your pop up blocker has stopped the window from displaying.  Please hold the Control (Ctrl) key when clicking the link to properly display the window.");
    }
}


function displayImg() {

    MM_swapImage(IMAGEPLACEHOLDER,"",imgFile,1);

}

function imgError() {

    img.src = "/_item_images/1x1.gif";

}

function loadup() {

    
    var frm = document._ItemOrder;
    
    
    //     var priceCnt = 4;  aOptions[1] = '00AB00000000'; aPrice[1] = 5.50; aItem[1] = '113A'; aImage[1] = '1x1.gif'; aOptions[2] = '00OB00000000'; aPrice[2] = 5.50; aItem[2] = '113A'; aImage[2] = '1x1.gif'; aOptions[3] = '00PB00000000'; aPrice[3] = 4.60; aItem[3] = '113A'; aImage[3] = '1x1.gif'; aOptions[4] = '00PC00000000'; aPrice[4] = 5.50; aItem[4] = '113A'; aImage[4] = '113a_pc_x_x_f.jpg';
    
    var lowPriceIndex = 1;
    var work1=999999;
    
    for (var i1=1; i1<=priceCnt;i1++) {
      if (aPrice[i1] < work1) {
        work1 = aPrice[i1];
        lowPriceIndex = i1;
      }       
    }
    
    var attrs = new String();    
    var lowAttr1, lowAttr2, lowAttr3;
    
    attrs = aOptions[lowPriceIndex];
    lowAttr1 = attrs.substring(0,4);
    lowAttr2 = attrs.substring(4,8);
    lowAttr3 = attrs.substring(8,12);

    
 //   alert (lowAttr1 + " : " + lowAttr2 + " : " + lowAttr3);

    if (lowAttr1 != "0000") {
      frm.Option_Value_1.value = retOptName(lowAttr1);
    }

    if (lowAttr2 != "0000") {
      frm.Option_Value_2.value = retOptName(lowAttr2);
    }

    if (lowAttr3 != "0000") {
      frm.Option_Value_3.value = retOptName(lowAttr3);
    }


    if (QueryString("att1")!=null) { 
        frm.Option_Value_1.value = QueryString("att1").toUpperCase();
    }
    
    if (QueryString("att2")!=null) { 
        frm.Option_Value_2.value = QueryString("att2").toUpperCase();
    }
    
    if (QueryString("att3")!=null) {
        frm.Option_Value_3.value = QueryString("att3").toUpperCase();
    }
    
    totalme(frm);

}

function removeLeadingZeros(str) {

  for (var ii=0;ii<str.length;ii++) {
    if (str.substring(ii, ii+1) != "0") {
      return(str.substring(ii));
    }
  }  
  
}


function preloadimages() {

    var selObj1 = document._ItemOrder.Option_Value_1;
    var selObj2 = document._ItemOrder.Option_Value_2;
    var selObj3 = document._ItemOrder.Option_Value_3;
    var msg = new String();
    var p1 = new String();
    var p2 = new String();
    var p3 = new String();
    var pimg = new Array();
    var tcnt = 0;
    
    document.writeln("Tried to preload these images: <br>");

alert (selObj2.length + "\n" + selObj1.length + "\n" + selObj3.length);

    for (var j2=0; j2<=selObj2.length;j2++) {
        if (j2 == selObj2.length) {
            p1 = "/_item_images/" + itemid + "_X";
        } else {
            p1 = "/_item_images/" + itemid + "_" + retOptCode(selObj2.options[j2].value);
        }
        for (var j1=0; j1<=selObj1.length;j1++) {
            if (j1 == selObj1.length) {
                p2 = "_X";
            } else {
                p2 = "_" + retOptCode(selObj1.options[j1].value);
            }
            for (var j3=0; j3<=selObj3.length;j3++) {
                if (j3 == selObj3.length) {
                    p3 = "_X";
                } else {
                    p3 = "_" + retOptCode(selObj3.options[j3].value);
                }
                tcnt++;
                document.writeln(tcnt + ":  " + p1 + p2 + p3 + "_f.jpg<br>");
                pimg[tcnt] = new Image();
                pimg[tcnt].src = p1 + p2 + p3 + "_f.jpg\t";
            }
        }
    }
}

function customOnLoad() {
    loadup();
//    preloadimages();
}

function AddressList() {
var rstring;
  rstring = '&' + escape(new Date());
  window.open(document.forms[0].baseurl.value +'orders.nsf/wCustomerAddress?Open&login'+rstring, 'CustomerAddress', 'width=450,height=600,resizable=0,status=1,menubar=0,scrollbars=1')
}
// these are the common cookie handling functions

function SetCookie (name,value,expires,path,domain,secure) {
   document.cookie = name + "=" + escape (value) +
     ((expires) ? "; expires=" + expires.toGMTString() : "") +
     ((path) ? "; path=" + path : "") +
     ((domain) ? "; domain=" + domain : "") +
     ((secure) ? "; secure" : ""); 
}

function GetCookie (name) {
   var arg = name + "=";
   var alen = arg.length;
   var clen = document.cookie.length;
   var i = 0;
   while (i < clen) {
     var j = i + alen;
     if (document.cookie.substring(i, j) == arg)
       return getCookieVal (j);
     i = document.cookie.indexOf(" ", i) + 1;
     if (i == 0) break;
    }
   return null;
}

function getCookieVal (offset) {
   var endstr = document.cookie.indexOf (";", offset);
   if (endstr == -1)
     endstr = document.cookie.length;
   return unescape(document.cookie.substring(offset, endstr));
}

function DeleteCookie (name,path,domain) {
   if (GetCookie(name)) {
     document.cookie = name + "=" +
       ((path) ? "; path=" + path : "") +
       ((domain) ? "; domain=" + domain : "") +
       "; expires=Thu, 01-Jan-70 00:00:01 GMT";
   }
}

function SCSubmit(key) { 
//    document.forms[0].SameAsBillTo.value = "";
  if (document.forms[0].SubmitAction.value != "*") {
      alert("Only one SubmitAction can be processed.\n Click OK to continue.");
      location.reload();
      return;
  }
  if (key == "EmptyCart") {
    if (!(confirm("Would you like to remove all items from your cart?"))) { return };
  }
  if (key == "ContinueCheckout") {
    if (!(Validate(document.forms[0]))) { return };  // old
//    if (!(Validate(document.forms[0]))) {
//        return;
//    } else {
//        if (!(Validate3(document.forms[0]))) { 
//            return;
//        }
//    }

  }
  if (key == "CompleteOrder") {
    if (!(Validate3(document.forms[0]))) { return };  // old

  }
//  if (key == "Checkout") {
//        document.forms[0].PaymentType.value=1;
//  }
  document.forms[0].SubmitAction.value=key;
  if (window.name == "") {document.forms[0].InFrame.value = "_top"} else {document.forms[0].InFrame.value=window.name};


  document.forms[0].submit();


}

function wShoppingCartLoad() {
  var f = document.forms[0];
  if (f.BackBuster && f.BackBuster.value == "Y") {
       window.location.replace(f.baseurl.value + 'orders.nsf/(ShoppingCart)');
       return;
  };
  if (document.forms[0].OrderPlaced.value =="Yes") {
    if (document.forms[0].RememberMyOrder.value =="Remember My Order") {
       DeleteCookie("btordernum","/");
       var exp = new Date();
       exp.setTime(exp.getTime() + (90*24*60*60*1000));
       SetCookie("btordernum",document.forms[0].OrderUniqueID.value,exp,"/");
    }
  }
}


function IsCreditCard (s) {
  validChars = "1234567890";
  var st = "";

  sum = 0;
  mul = 1;
  
  if (s){
    s = s.value ;
    l = s.length;
    // strip all characters that are not valid numbers
    for (i = 0; i < l; i++) {
      var c = s.charAt(i);
      if (validChars.indexOf(c) != -1) {
      st += c;
    }
  }

  if (st.length == 0) {
	return false;
  } else {
  mul = 1;
  l = st.length;

  // validate credit card number using Luhn Mod-10 test
  for (i = 0; i < l; i++) {
    digit = st.substring(l-i-1,l-i);
    tproduct = parseInt(digit ,10)*mul;
    if (tproduct >= 10)
      sum += (tproduct % 10) + 1;
    else
      sum += tproduct;
    if (mul == 1)
      mul++;
    else
      mul--;
  }

  if ((sum % 10) == 0) { return true; }
  else { return false; }

 }
 } else {
  return true;
 }
}

function IsNameOnCard(btName) {

  var l;
  var s = new String("");
  s = btName.value;

  if (s){

    l = s.length;
    if (l) {
        if (l == 0) { 

            return false;
        }
    } else {
        return false;
    }


  } else {                 

	return false;
  }
    
  return true;
}

function IsInteger(s) {
   var validChars = "1234567890";
   
   if (s) {
     s = s.value;
     if (s.length == 0) {
              return false;
	} else {
		// make sure all characters are valid
		for (i=0; i <= s.length; i++) {
			var c = s.charAt(i);
			if (validChars.indexOf(c) == -1) {
				return false;
			}
		}
	}
     return true;
    } else {
     return true;
    }
}


function IsChar(s) {
  if (s) {
    s = s.value;
    if (s == "") { return false; }
  }
  return true;
}

function IsEmail(s){
  if (s) {
       s = s.value;
	// should be of format MyAcct@MyDomain.com
	if ((s.indexOf('@') >0 ) && (s.indexOf('.', s.indexOf('@')) > 0)) {
		return true;
	} else {
		return false;
	}
  } else {
       return true;
  }
}

function IsPhoneNumber (s) {
  validChars = "1234567890";
  var st = "";

  sum = 0;
  mul = 1;
  
  if (s){
    s = s.value ;
    l = s.length;
    // strip all characters that are not valid numbers
    for (i = 0; i < l; i++) {
      var c = s.charAt(i);
      if (validChars.indexOf(c) != -1) {
        st += c;
      }
    }
  }

  if (st.length != 10) {
	return false;
  } else {
  return true;
 }
}



  var msgText = "";
  var setFocusTo = "";

function ValidatePhone (ph)
{
  if (ph) 
  {
    if (ph.value != "") 
    {
      if (!IsPhoneNumber(ph))
      {
        msgText = "Please enter your telephone number with areacode.\n" + msgText; setFocusTo = ph;
      };
    }
    else
    {
      msgText = "Please enter your telephone number with areacode.\n" + msgText; setFocusTo = ph;
    };
  };
}

function Validate(me) {

//  if (me.Shipping)  {if (me.Shipping.options[me.Shipping.selectedIndex].value == "Select --->"){ msgText = "Best Way is UPS or USPS Priority.  Please call customer service for more shipping options.\n" + msgText; setFocusTo = me.Shipping;}};

    var checkBillTo = !me.elements[25].checked;
//    
//    msgText = checkBillTo;
//
//(checkBillTo) && 
//

//   var msgWindow=window.open("");
//   for (var i = 0; i < me.elements.length; i++) {
//          msgWindow.document.write(i + " - " + me.elements[i].name + " is type: " + me.elements[i].type + "<BR>");
//   }
//
//

  if (me.ExpirateDate) { if (me.ExpirateDate.value != "") { 

 }; };

  if (me.CreditCardNumber) { if (me.CreditCardNumber.value != "") {if (!IsCreditCard(me.CreditCardNumber))  {msgText = "Please enter a valid credit card number.\n" + msgText; setFocusTo = me.CreditCardNumber;}; }; };

  if (me.Payment)  {if (me.Payment.options[me.Payment.selectedIndex].value == "Select --->"){ msgText = "You must select a payment type." + msgText; setFocusTo = me.Payment;}};

  if (!IsChar(me.ST_Opt2))  {msgText = "Please enter the last name of the ship to recipient\n" +  msgText; setFocusTo = me.ST_Opt2;};

  if (!IsChar(me.ST_Opt1))  {msgText = "Please enter the first name of the ship to recipient\n" +  msgText; setFocusTo = me.ST_Opt1;};

  ValidatePhone(me.ST_Phone2);
  ValidatePhone(me.ST_Phone1);

//  if (me.ST_Country)  {if (me.ST_Country.options[me.ST_Country.selectedIndex].value == "Select --->"){ msgText = "Country is required for delivery.\n" + msgText; setFocusTo = me.ST_Country;}};

  if (me.ST_Zip) { if (!IsChar(me.ST_Zip)) {msgText = "Zip is required for delivery.\n" +  msgText; setFocusTo = me.ST_Zip;}else{if (me.ST_Zip.value.length != 5){msgText = "Please enter a 5 digit ship-to zip code.\n" +  msgText; setFocusTo = me.ST_Zip;};};};

  if (me.ST_State)  {if (me.ST_State.options[me.ST_State.selectedIndex].value == "Select --->"){ msgText = "State is required for delivery.\n" + msgText; setFocusTo = me.ST_State;}};

  if (!IsChar(me.ST_City))  {msgText = "City is required for delivery.\n" +  msgText; setFocusTo = me.ST_City;};

  if (me.ST_Address2) { if (me.ST_Address2.value != "") { 

    if (!IsChar(me.ST_Address2))  {msgText = "\n" +  msgText; setFocusTo = me.ST_Address2;};

 }; };

  if (!IsChar(me.ST_Address1))  {msgText = "Street Address is required for delivery.\n" +  msgText; setFocusTo = me.ST_Address1;};

  if (me.ST_CompanyName) { if (me.ST_CompanyName.value != "") { 

    if (!IsChar(me.ST_CompanyName))  {msgText = "\n" +  msgText; setFocusTo = me.ST_CompanyName;};

 }; };

  if (me.ST_Name) { if (me.ST_Name.value != "") { 

    if (!IsChar(me.ST_Name))  {msgText = "\n" +  msgText; setFocusTo = me.ST_Name;};

 }; };

  ValidatePhone(me.BT_Phone2);
  ValidatePhone(me.BT_Phone1);

//  if (me.BT_Country)  {if (me.BT_Country.options[me.BT_Country.selectedIndex].value == "Select --->"){ msgText = "Country is required for delivery.\n" + msgText; setFocusTo = me.BT_Country;}};

  if ((checkBillTo) && !IsChar(me.BT_Zip)) {msgText = "Zip is required for delivery.\n" +  msgText; setFocusTo = me.BT_Zip;}else{if (me.BT_Zip.value.length != 5){msgText = "Please enter a 5 digit zip code.\n" +  msgText; setFocusTo = me.BT_Zip;};};
//  if (!IsChar(me.BT_Zip))  {msgText = "Zip is required for delivery.\n" +  msgText; setFocusTo = me.BT_Zip;};

  if ((checkBillTo) && me.BT_State)  {if (me.BT_State.options[me.BT_State.selectedIndex].value == "Select --->"){ msgText = "State is required for delivery.\n" + msgText; setFocusTo = me.BT_State;}};

  if ((checkBillTo) && !IsChar(me.BT_City))  {msgText = "City is required for delivery.\n" +  msgText; setFocusTo = me.BT_City;};

  if ((checkBillTo) && me.BT_Address2) { if (me.BT_Address2.value != "") { 

    if ((checkBillTo) && !IsChar(me.BT_Address2))  {msgText = "\n" +  msgText; setFocusTo = me.BT_Address2;};

 }; };

  if ((checkBillTo) && !IsChar(me.BT_Address1))  {msgText = "Street Address is required for delivery.\n" +  msgText; setFocusTo = me.BT_Address1;};

  if ((checkBillTo) && me.BT_CompanyName) { if (me.BT_CompanyName.value != "") { 

    if ((checkBillTo) && !IsChar(me.BT_CompanyName))  {msgText = "\n" +  msgText; setFocusTo = me.BT_CompanyName;};

 }; };

  if ((checkBillTo) && !IsChar(me.BT_Name))  {msgText = "\n" +  msgText; setFocusTo = me.BT_Name;};

  if (!IsChar(me.ConfirmPassword))  {msgText = "A confirmation of the password is required.\n" +  msgText; setFocusTo = me.ConfirmPassword;};

  if (!IsChar(me.Password))  {msgText = "A password is required.\n" +  msgText; setFocusTo = me.Password;};

  if (!IsChar(me.UserID))  {msgText = "A unique User ID is required for identifciation.\n" +  msgText; setFocusTo = me.UserID;};

  if ((checkBillTo) && !IsEmail(me.BT_Email))  {msgText = "Please enter your internet email address.\n" + msgText; setFocusTo = me.BT_Email;};

  if (!IsChar(me.LastName))  {msgText = "Last Name is a required field.\n" +  msgText; setFocusTo = me.LastName;};

  if (!IsChar(me.FirstName))  {msgText = "First Name is a required field.\n" +  msgText; setFocusTo = me.FirstName;};


  if (msgText != "")  {
    alert(msgText);
    msgText = "";
    setFocusTo.focus();
    return false;
  }
  else {
     return true;
  }
}

function Validate3(form) {
  failMsg = "";
  failField = "";

  if (form.PaymentType.value != "0") {
    if (form.CreditCardNumber.value == "") {
      failMsg += "The payment type you have selected requires additional information to process the order.\n";
    }
    if (form.PaymentType.value == "1" && !(IsCreditCard(form.CreditCardNumber)) ) {
      failMsg += "Credit Card number is not valid\n";
    }
    if (form.PaymentType.value == "1" && !(IsNameOnCard(form.BT_Name)) ) {
      failMsg += "Please enter the name as it apears on the credit card.\n";
    }
    if (failMsg.length > 0){
       alert(failMsg);
       form.CreditCardNumber.focus();
       return false;
    }
  }
  if (form.ConfirmPassword) {
    if (form.ConfirmPassword.value == "") {
      failMsg += "Enter something into the required field confirm password\n";
      failField = form.ConfirmPassword;
    }
  }
  if (form.Password) {
    if (form.Password.value == "") {
      failMsg += "Enter something into the required field password\n";
      failField = form.Password;
    }
  }
  if (form.UserID) {
    if (form.UserID.value == "") {
      failMsg += "Enter something into the required field User ID\n";
      failField = form.UserID;
    }
  }
  if (failMsg.length > 0){
       alert(failMsg);
       failField.focus();
       return false;
  } else {
       return true;
  }

}

function copySTInfo() {
    
    
    var f = document.forms[0];
    
    
    f.ST_Opt1.value      = f.FirstName.value  ;
    f.ST_Opt2.value      = f.LastName.value   ;
    f.ST_Address1.value  = f.BT_Address1.value;
    f.ST_City.value      = f.BT_City.value    ;
    f.ST_State.value     = f.BT_State.value   ;
    f.ST_State[f.BT_State.selectedIndex].selected = true;
    f.ST_Zip.value       = f.BT_Zip.value     ;
    f.ST_Phone1.value    = f.BT_Phone1.value  ;
    
}

function cropOptions(opt) {

    var s = new String(opt);

    var opt1 = new String("");
    var opt2 = new String("");
    var opt3 = new String("");

    var opt1s = new String("");
    var opt2s = new String("");
    

    var str1 = s.indexOf("Finish<br>=") + 11;
    var end1 = s.indexOf("<br>", str1 + 1);
    if (s.indexOf("Finish<br>=") >= 0)    
        opt1 = s.substring(str1, end1);

    var str2 = s.indexOf("Configuration<br>=") + 18;
    var end2 = s.indexOf("<br>", str2 + 1);
    if (s.indexOf("Configuration<br>=") >= 0)    
        opt2 = s.substring(str2, end2);

    var str3 = s.indexOf("Color<br>=") + 10;
    var end3 = s.indexOf("<br>", str3 + 1);
    if (s.indexOf("Color<br>=") >= 0)
        opt3 = s.substring(str3, end3);

    if ((opt2.length > 0 && opt1.length > 0) ||
        (opt2.length > 0 && opt3.length > 0))
        opt2s = ", <br>";
    else
        opt2s = "";
        
    if (opt1.length > 0 && opt3.length > 0)
        opt1s = ", <br>";
    else
        opt1s = "";
        

    document.write(opt2 + opt2s + opt1 + opt1s + opt3);    
    

}

 
 

 
 
 
 
 

