a01off=new Image(15,20);
a01off.src="http://www.atprecision.com/atprecision/i/arrow-off.gif";
a01on=new Image(15,20);
a01on.src="http://www.atprecision.com/atprecision/i/arrow-on.gif";


function flipper(ExistingImageName,NewImageName){
    if (document.images)
    document.images[ExistingImageName].src=eval(NewImageName+".src")
}


function FileSubmission(){
    win3=window.open("http://www.atprecision.com/atprecision/file-popup.html","","width=400,height=400,toolbar,scrollbars,")
    win3.moveTo(0,0)
}


/* begin spam killer */


function CedarockKS(JC0,handler) {  /* "KS" = kill spam */
    var JC1 = "atprecision"         /* this is the "do" in "do.us" */
    var JC2 = "com"                 /* this is the "us" in "do.us" */
    if (handler=="mto") {           /* write mail to only */
        document.write("<A HREF=\"mai")
        document.write("lto:"+JC0+"@")
        document.write(JC1+"."+JC2+"\">")
        document.write("</A>")
    }
    if (handler=="add") {           /* write address only */
        document.write(JC0+"@")
        document.write(JC1+"."+JC2)
    }
    if (handler=="all") {           /* write mail to and address */
        document.write("<A HREF=\"mai")
        document.write("lto:"+JC0+"@")
        document.write(JC1+"."+JC2+"\">")
        document.write(JC0+"@")
        document.write(JC1+"."+JC2)
        document.write("</A>")
    }
    return true
}


/* end of spam killer */
/* start of CedarockValidate */


subon = new Image(130,25)
subon.src = "http://www.atprecision.com/atprecision/i/submitted2.gif"
function CedarockValidate() {

    /* VALIDATE REQUIRED FIELDS */
        if (document.contact.quantity.value==""){
            alert("Please enter the quantity you need.")
            return false
        }
        if (document.contact.delivery.value==""){
            alert("Please enter the expected delivery date.")
            return false
        }
        if (document.contact.firstname.value==""){
            alert("Please enter your first name.")
            return false
        }
        if (document.contact.lastname.value==""){
            alert("Please enter your last name.")
            return false
        }
        if (document.contact.company.value==""){
            alert("Please enter your company name.")
            return false
        }
    var emailStr=document.contact.email.value

    /* VERIFY EMAIL ADDRESS IS VALID */
    var emailPat=/^(.+)@(.+)$/
    var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
    var validChars="\[^\\s" + specialChars + "\]"
    var quotedUser="(\"[^\"]*\")"
    var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
    var atom=validChars + '+'
    var word="(" + atom + "|" + quotedUser + ")"
    var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
    var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")
    var matchArray=emailStr.match(emailPat)
    if (matchArray==null) {
        var JC1 = confirm("Email address seems incorrect (check @ and .'s). Submit anyway?")
        if (!JC1) {return false}
    }
    var user=matchArray[1]
    var domain=matchArray[2]
    if (user.match(userPat)==null) {
        var JC2 = confirm("Email address seems incorrect (username doesn't seem to be valid). Submit anyway?")
        if (!JC2) {return false}
    }
    var IPArray=domain.match(ipDomainPat)
    if (IPArray!=null) {
        for (var i=1;i<=4;i++) {
            if (IPArray[i]>255) {
                var JC3 = confirm("Email address seems incorrect (destination IP address is invalid). Submit anyway?")
                if (!JC3) {return false}
            }
        }
        return true
    }
    var domainArray=domain.match(domainPat)
    if (domainArray==null) {
        var JC4 = confirm("Email address seems incorrect (domain name doesn't seem to be valid). Submit anyway?")
        if (!JC4) {return false}
    }
    var atomPat=new RegExp(atom,"g")
    var domArr=domain.match(atomPat)
    var len=domArr.length
    if (domArr[domArr.length-1].length<2 || 
        domArr[domArr.length-1].length>4) {
        var JC5 = confirm("Email address seems incorrect (address must end in a two, three, or four letter domain). Submit anyway?")
        if (!JC5) {return false}
    }
    if (len<2) {
        var errStr="Email address seems incorrect (missing a complete hostname). Submit anyway?"
        var JC6 = confirm(errStr)
        if (!JC6) {return false}
    }
    document.contact.emailtest.value = "valid"
    document.cookie = "CedarockValidate=valid"

    /* SHOW "STAND BY" IMAGE */
    flipper('sub1','subon')
    return true
}

/* end of CedarockValidate */
/* start of ThankYou */

function cookieVal(cookieName) {
thisCookie = document.cookie.split("; ")
for (i=0; i<thisCookie.length; i++){
	if (cookieName == thisCookie[i].split("=")[0]){
		return thisCookie[i].split("=")[1]
	}
}
return 0
}


function ThankYou() {
    if (cookieVal("CedarockValidate") == "valid") {document.write("Our server has emailed a copy of your request to you for your records, and we will reply&nbsp;soon.")}
    else {document.write("We will reply&nbsp;soon.")}
}

/* end of ThankYou */
