function validate_form ( ) {
    
	var valid = true;

	if ( ( document.agreeform.agree.checked == false ) ) {
		alert ( "You must agree to the terms and conditions to proceed." );
		valid = false;
	}
	
	return valid;
}

function enableField(id,enable)
{
	var e = document.getElementById(id);
	if (e.disabled && enable) {
		e.disabled=false;
	} else if (!e.disabled && !enable) {
		e.disabled=true;
	}
}

function copy_fields (checkbox,from,to) {
   var suffixes = new Array('first_name','last_name','org_name','address1',
   'address2','address3','city','state','country','postal_code','phone',
   'fax','email');
   var chk = checkbox.checked;
   var al = suffixes.length;
   if (from == to) {
   	from = from + 'cache';
   }
   for (i=0; i<al; i++) {
	var fname = from + "_" + suffixes[i];
	var tname = to + "_" + suffixes[i];
	var f = document.getElementById(fname);
	var t = document.getElementById(tname);
	if (f && t) {
	  	if ( (f.type == 'select') && (t.type == 'select') ) {
			var fidx = f.selectedIndex;
			if (!chk) {
				fidx = 0;
			}
			t.selectedIndex = fidx;
		} else {
			var fval = f.value;
			if (!chk) {
				fval = "";
			}
		 	t.value = fval;
		}
	}
   } 
   return;
}

function noSpace(obj) {
     obj.value = obj.value.replace (/\s/g, "");
}



/* code from qodo.co.uk */
// create as many regular expressions here as you need:
var digitsOnly = /[1234567890]/g;
var integerOnly = /[0-9\.]/g;
var alphaOnly = /[A-Z]/g;
var emailUser = /[a-zA-Z0-9_-]/g;

function restrictCharacters(myfield, e, restrictionType, ignorePeriod) {
	if (!e) var e = window.event;
	if (e.keyCode) code = e.keyCode;
	else if (e.which) code = e.which;
	var character = String.fromCharCode(code);

	// if they pressed esc... remove focus from field...
	if (code==27) { this.blur(); return false; }

	// ignore if they are press other keys
	// strange because code: 39 is the down key AND ' key...
	// and DEL also equals .
	if (!e.ctrlKey && code!=9 && code!=8 && code!=36 && code!=37 && code!=38 && (code!=39 || (code==39 && character=="'")) && code!=40) {
		if (character.match(restrictionType)) {
			return true;
                } else {
			return false;
		}

	}
}



