function allstepsloader() {
	$$('#main input.numonly').each(function(ni, i) {
		ni.onkeypress = function(e) {
			var e = new Event(e);
			return ((e.key.search(/[0-9]/)==-1) && (![0,8,9,13,27,37,39,46].test(e.code)) && (e.key!=null)) ? false : true;
		};
	});
}
window.addEvent('domready', allstepsloader);

function step1loader() {

}
function step2loader() {
	
}
function step3loader() {
	s3rowFX = new Array();
	$$('.removelink').each(function(rl, i) {
		var tr = rl.getParent().getParent();
		var startcolor;
		startcolor = (tr.hasClass('warning')) ? '#ED2' : '#FFF';
		s3rowFX[i] = new Fx.Elements($ES('td',tr), { transition: Fx.Transitions.Quad.easeOut }).set({
			'0': { 'backgroundColor': startcolor },
			'1': { 'backgroundColor': startcolor },
			'2': { 'backgroundColor': startcolor }
		});
		rl.addEvent('mouseenter', function() {
			// fade tr background to red to emphasize deletion
			s3rowFX[i].stop();
			s3rowFX[i].start({
				'0': { 'backgroundColor': '#B00' },
				'1': { 'backgroundColor': '#B00' },
				'2': { 'backgroundColor': '#B00' }
			});
		});
		rl.addEvent('mouseleave', function() {
			s3rowFX[i].stop();
			s3rowFX[i].start({
				'0': { 'backgroundColor': startcolor },
				'1': { 'backgroundColor': startcolor },
				'2': { 'backgroundColor': startcolor }
			});
		});
	});
}
function step4loader() {
	
}
function step5loader() {
	
}
function step6loader() {
	
}
function step7loader() {
	
}
function step8loader() {
	
}

function step2helmetupdate() {
	var s = $('s2helmetseries').getValue();
	if (s=='**' || s=='') {
		$('s2helmetmodel').options.length = 0;
		$('s2helmetmodel').options[0] = new Option('- Select Your Series Above -', '***');
		$('s2helmetmodel').disabled = 'disabled';
		return false;
	} else {
		$('s2helmetmodel').options.length = 0;
		$('s2helmetmodel').options[0] = new Option('Please wait, loading...');
		$('s2helmetmodel').disabled = 'disabled';
		new Ajax('/product-registration/', {
			method: 'post',
			postBody: 'ajax=1&series=' + s,
			onComplete: function(r) {
				var v;
				$('s2helmetmodel').options.length = 0;
				$('s2helmetmodel').options[0] = new Option('- Select Your Design -', '**');
				r = r.split("\n");
				for (var i=0; i<r.length; i++) {
					if (r[i]>'') {
						v = r[i].split("\t");
						$('s2helmetmodel').options[$('s2helmetmodel').options.length] = new Option(v[1], v[0]);
					}
				}
				$('s2helmetmodel').disabled = '';
			}
		}).request();
	}
}
function checkStep2WKS(f) {
	if ($(f.s2workstation).getValue()=='**') {
		alert('Please select an ArcStation Model.');
		return false;
	} else if ($(f.s2workstation).getValue()=='**' || $(f.s2workstation).getValue()=='') {
		alert('Please select an ArcStation Model.');
		return false;
	}
	
	if(f.wks_lot_code.value != ''){
        str = f.wks_lot_code.value;
        str = str.replace(/[^\d]/g, "");
        //console.log(str);
        if(str.length != 6){
            alert("Lot code should be in the format ####-##.");
            return false;
        }
    }
}
function checkStep1(f) {
	if ($('prodtype_wc').checked==false 
		&& $('prodtype_helmet').checked==false
		&& $('prodtype_workstation').checked==false
	) {
		alert('Please select a product type to register.');
		return false;
	}
}
function checkStep2SN(f) {
	if (f.serno.value=='') {
		alert('Please enter your serial number to continue.');
		return false;
	}
}
function checkStep2HSG(f) {
	if ($(f.helmetseries).getValue()=='**') {
		alert('Please select a helmet series.');
		return false;
	} else if ($(f.helmetmodel).getValue()=='**' || $(f.helmetmodel).getValue()=='***' || $(f.helmetmodel).getValue()=='') {
		alert('Please select the helmet model you wish to register.');
		return false;
	}
}

function checkRadios(rs) {
	var ok = false;
	for (var i=0; i<rs.length; i++) {
		if (rs[i].checked) return rs[i].value;
	}
	return false;
}
function checkStep5(f) {
	if ($(f.month).getValue()=='**' || $(f.year).getValue()=='**') {
		alert('Please enter your purchase date.');
		return false;
	}
	var pf = checkRadios(f.purchfor);
	if (!pf) {
		alert('Please select the use this product was purchased for.');
		return false;
	}
	if ((pf=='professional' || pf=='both') && !checkRadios(f.industry)) {
		alert('Please select the industry you will use your new Miller product in.');
		return false;
	}
	if ((pf=='personal' || pf=='both') && !checkRadios(f['hobby[]'])) {
		alert('Please select the application(s) you will use your new Miller product in at home.');
		return false;
	}
	if ($(f.fname).getValue()=='') {
		alert('Please enter your first name.');
		return false;
	} else if ($(f.lname).getValue()=='') {
		alert('Please enter your last name.');
		return false;
	} else if ($(f.address).getValue()=='') {
		alert('Please enter your address.');
		return false;
	} else if ($(f.city).getValue()=='') {
		alert('Please enter your city name.');
		return false;
	} else if ($(f.state).getValue()=='**') {
		alert('Please select your state.');
		return false;
	} else if ($(f.zip).getValue()=='') {
		alert('Please enter your postal code.');
		return false;
	} else if ($(f.email).getValue()=='') {
		alert('Please enter your email address.');
		return false;
	} else if ($(f.email).getValue().search(/^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i)==-1) {
		alert('Please enter a valid email address.');
		return false;
	} else if ($(f.email).getValue()!=$(f.cemail).getValue()) {
		alert('Please confirm your email address.');
		return false;
	} else if ($(f.phone).getValue()=='') {
		alert('Please enter your phone number.');
		return false;
	} else if (!checkRadios(f.infotype)) {
		alert('Please select if the address information you provided is for your business or home.');
		return false;
	}
	return true;
}
function checkStep6(f) {
	return true;
}
function checkStep7(f) {
	return true;
}