n01off=new Image(49,53);
n01off.src="i/n-01-off.jpg";
n01on=new Image(49,53);
n01on.src="i/n-01-on.jpg";
n02off=new Image(48,53);
n02off.src="i/n-02-off.jpg";
n02on=new Image(48,53);
n02on.src="i/n-02-on.jpg";
n03off=new Image(49,53);
n03off.src="i/n-03-off.jpg";
n03on=new Image(49,53);
n03on.src="i/n-03-on.jpg";
n04off=new Image(49,53);
n04off.src="i/n-04-off.jpg";
n04on=new Image(49,53);
n04on.src="i/n-04-on.jpg";


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


function money(value) {
    result="\$"+Math.floor(value)+".";
    var cents=100*(value-Math.floor(value))+0.5;
    result += Math.floor(cents/10);
    result += Math.floor(cents%10);
    return result;
}
function pricer(){
    var ornament = document.contact.ornamentname.value.length;
    var price = ornament * 1.5;
    var total = price + 5;
    document.contact.ornamentprice.value = money(price);
    document.contact.ornamenttotal.value = money(total);
}


/* begin spam killer */


function CedarockKS(JC0,handler) {  /* "KS" = kill spam */
    var JC1 = "ornaments4u"         /* 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+"\">")
    }
    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 = "i/submitted2.gif"

/* DISABLE THE SUBMIT BUTTON AFTER FIRST CLICK */
function Localize(NewText){
    return NewText;
}
var ButtonText = Localize("Submitting...");
var submissions=0;
function Submitting(f){
    f.go.value=ButtonText;
    f.go.disabled=true;
    if (submissions==0)f.submit();
    submissions++;
    /* SHOW "STAND BY" IMAGE */
    flipper('sub1','subon')
    return true
}

function CedarockValidate(f) {

    /* VALIDATE REQUIRED FIELDS */
    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}
        Submitting(f)
    }
    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}
        Submitting(f)
    }
    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}
                Submitting(f)
            }
        }
        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}
        Submitting(f)
    }
    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}
        Submitting(f)
    }
    if (len<2) {
        var errStr="Email address seems incorrect (missing a complete hostname). Submit anyway?"
        var JC6 = confirm(errStr)
        if (!JC6) {return false}
        Submitting(f)
    }
    /* SET COOKIE FOR EMAIL TEST */
    document.contact.emailtest.value = "valid"
    document.cookie = "CedarockValidate=valid"
    Submitting(f)
}

/* 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 */
