/*
n10on=new Image(126,19);
n10on.src="http://www.kcmach.com/kcmach/i/b-customers-red.gif";
*/
	function centerscreen(){
	var width = screen.width
	var height = screen.height
	if(width>800)
		border = (width-800)/2 + "px";
	else
		border = "0px";
	document.getElementById("screenborder").style.left = border;
	}

function flipper(ExistingImageName,NewImageName){
    if (document.images)
    document.images[ExistingImageName].src=eval(NewImageName+".src")
}

/* Rotate Part Pictures*/
function partname(loc){
	var np = 4
	if (loc == "top" ) {np = 11;}
	var randomnumber=Math.floor(Math.random()*np)+1;
	var pname = ".jpg";
	pname = randomnumber + pname;
	if (loc == "top" ) {
		if (pname.length == 5) {
			pname = "p-00"+ pname;}
		else { pname = "p-0"+pname;}
	}	
	else {pname = "pic-00"+pname;}
	return (pname);
}

/* begin spam killer */


function CedarockKS(JC0,handler) {  /* "KS" = kill spam */
    var JC1 = "kcmach"          /* 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 = "http://www.kcmach.com/Common/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 */

<!-- 
// This is the function that will open the
// new window when the mouse is moved over the link

// check the browser...we're looking for ie/win
function showbigimage(NewImageName,TopLeft) {
	var width = screen.width;
		if(window.createPopup()) {
			open_popup(NewImageName,TopLeft)}
		else {
			open_new_window(NewImageName,TopLeft);}
	}

function open_popup(NewImageName,TopLeft) {
	var width = screen.width
	var height = screen.height
	var oPopup = window.createPopup();
    var oPopupBody = oPopup.document.body;
	oPopupBody.style.backgroundColor = "lightyellow";
	oPopupBody.style.border = "solid black 1px";   
    oPopupBody.innerHTML = ('<img src="'+NewImageName+'" width="400" height="305">'); 
		if(width>800)
		border = (width-800)/2 ;
	else
		border = 0;
    oPopup.show(border, TopLeft, 400, 305, document.body);}

function open_new_window(NewImageName,TopLeft) 
{	new_window = open("","hoverwindow","width=400,height=305,left=200,top="+TopLeft+",titlebar=0,status=0");
	
	// open new document 
	new_window.document.open();
	
	// Text of the new document
	// Replace your " with ' or \" or your document.write statements will fail
	new_window.document.write("<html><title>K & C Machining, Inc.</title>");
	//new_window.document.write("<body bgcolor=\"#FFFFFF\">");
	new_window.document.write('<img src="'+NewImageName+'" width="450" height="300">');
	//new_window.document.write("Test");
	new_window.document.write("<br>");
	new_window.document.write("</body></html>");
	
	// close the document
	new_window.document.close(); 
}

// This is the function that will close the
// new window when the mouse is moved off the link
function close_window() 
	{
	new_window.close();
	}

// Fills out the textarea with the form text
function updateoutput()
{	    var output=document.contact.output.value;
	document.contact.quantity.value = "TEST";
}


// -->



