// JavaScript Document

function cardlength(form){
	if (form.paymenttype[2].checked) {
		form.cardnum1.disabled = true
		form.cardnum2.disabled = true
		form.cardnum3.disabled = true
		form.cardnum4.disabled = true
		form.amexnum1.disabled = false
		form.amexnum2.disabled = false
		form.amexnum3.disabled = false
	} else {
		form.cardnum1.disabled = false
		form.cardnum2.disabled = false
		form.cardnum3.disabled = false
		form.cardnum4.disabled = false
		form.amexnum1.disabled = true
		form.amexnum2.disabled = true
		form.amexnum3.disabled = true
	}
	
}

function format(expr, decplaces) {
	var str = "" + Math.round (eval(expr) * Math.pow(10,decplaces))
	while (str.length <= decplaces) {
		str = "0" + str
	}
	var decpoint = str.length - decplaces
	if (decplaces == "0"){
		return str.substring(0,decpoint);
	} else {
		return str.substring(0,decpoint) + "." + str.substring(decpoint,str.length);
	}
}

function dollarize(expr) {
	return format(expr,2)
}

function compareLengths(length,longest) {
	if (length > longest) {
		return length
	} else {
		return longest
	}
}

hideTreatedAlert = 0;
function showTreatedAlert(form)
{
	if (form.cuts && form.cuts[1].checked && !hideTreatedAlert) {
		if (order_form['id'] == "specialty-ano")
		{
			alert('Pressure Treated needs 18.8 St. Steel to not corrode.\nSelect the 3rd item in appropriate -- Fastener Area --\nSelect #12x2" SS Screw & Washer - Bag 250 No Paint')
		}
		else if (order_form['id'] == "Corrugated" || order_form['id'] == "Trim")
		{
			alert('Pressure Treated needs 18.8 St. Steel to not corrode.\nSelect the 5th item in -- Wood Fastener Area --\n#12x2" SS Screw & Washer - Bag 250 No Paint')
		}
		else
		{
			alert('Pressure Treated needs 18.8 St. Steel to not corrode.\nSelect the 3rd item in -- Wood Fastener Area --\n#12x2" SS Screw & Washer - Bag 250 No Paint')
		}
		hideTreatedAlert = 1;
	} 
}

hideAluminumAlert = 0;
function showAluminumAlert(form)
{
	if (form.cuts && form.cuts[3].checked && !hideAluminumAlert) {
		if (order_form['id'] == "specialty-ano")
		{
			alert('Aluminum Frame requires  St. Steel Screws.\nSelect the last item in appropriate -- Fastener Area --\n#12x1.5 or 2 self drill screws, bag-250 "SS SILVER"')
		}
		hideAluminumAlert = 1;
	} 
}