
	function postage(one,two,three,subj,style){
   		sVal = one+'&#64;'+two+'&#46;'+three;
   		sFull = '<a class=\"'+style+'\" href=\"m&#97;&#105;&#108;&#116;o:'+sVal+'?subject='+subj+'\">'+sVal+'</a>';
   		document.write(sFull);
   	}


	function BookmarkThisPage(domain, title){
		//window.external.AddFavorite(location.href,document.title)
		//window.external.AddFavorite("http://www.qmaxvision.com","QmaxVision - ISO Quality Management Consulting")
		window.external.AddFavorite(domain,title)
	}


/**
 * Changes all the required fields status
 *
 */
function changeAll(theForm) {

	// get this to work
	for (i=0; i < theForm.elements; i++) {
	changed(document.forms["main"].elements[i]);
	}
}

/**
 * Displays "Required" status for required fields when
 * user doesn't enter any values.
 */
function changed(inp) {
	span = document.getElementById("req_" + inp);
	input = document.forms["contactForm"][inp];
	if (input.value == '') {
	span.innerHTML = '<font size="2" color="red"><b>&nbsp;Required.</b></font>';
	} else {
	span.innerHTML = "";
	}
}

/**
 * Validates the accont setup form
 *
 */
function validate()
{
	why ="";

	if(document.infoForm.Email.value=="")
		why += "* Email addrss is required.\n";
	else
		why += checkEmail(document.infoForm.Email.value);

	why += checkPassword(document.infoForm.Password.value);

	if(document.infoForm.ConfirmPassword.value=="")
		why += "* Password confirmation is required.\n";

	if(document.infoForm.Password.value!=document.infoForm.ConfirmPassword.value)
		why += "* Confirmation password does not match the password entered.\n";

	if(document.infoForm.FirstName.value=="")
		why += "* First name is required.\n";

	if(document.infoForm.LastName.value=="")
		why += "* Last name is required.\n";

	if(document.infoForm.Address1.value=="")
		why += "* Adress is required.\n";

	if(document.infoForm.City.value=="")
		why += "* City is required.\n";

	if(document.infoForm.Province.value=="")
		why += "* Province is required.\n";

	if(document.infoForm.PostalCode.value=="")
		why += "* Postal Code/zip is required.\n";

	if(document.infoForm.Country.value=="")
		why += "* Country is required.\n";

	if(document.infoForm.Phone.value=="")
		why += "* Phone number is required.\n";
	else
		why += checkPhone(document.infoForm.Phone.value);

   if (why != "") {
   	error ="The following form field(s) were incomplete or incorrect:\n\n";
   	error += why;
   	error += "\nPlease complete or correct the form and submit again.";
		alert(error);
		return false;
	}
	return true;

}

/**
 * Validates contact info form
 *
 */
function contactInfo()
{
	why ="";

	if(document.contactForm.Name.value=="")
		why += "* Your name is required.\n";

	if(document.contactForm.email.value=="")
		why += "* Email addrss is required.\n";
	else
		why += checkEmail(document.contactForm.email.value);

	if(document.contactForm.Comments.value=="")
		why += "* Please add your Comments/Questions.\n";

   if (why != "") {
   	error ="The following form field(s) were incomplete or incorrect:\n\n";
   	error += why;
   	error += "\nPlease complete or correct the form and submit again.";
		alert(error);
		return false;
	}
	return true;
}

/**
 * Checks if email is valid.
 *
 */
function checkEmail(strng) {

	var emailFilter=/^.+@.+\..{2,3}$/;
	var error = "";
	if (!(emailFilter.test(strng))) {
		error = "* Please enter a valid email address.\n";
	}

	var illegalChars= /[\(\)\<\>\,\;\:\\\/\"\[\]]/
	if (strng.match(illegalChars)) {
		error = "* The email address contains illegal characters.\n";
	}

	return(error)
}

/**
 * Checks if phone contains illigal chars.
 * Only accept numbers.
 */
function checkPhone(strng) {

	var stripped = strng.replace(/[\(\)\.\-\ ]/g, '');
	var error = "";
	//strip out acceptable non-numeric characters
	if (isNaN(parseInt(stripped))) {
   	error = "* The phone number contains illegal characters.\n";
	}

	if (!(stripped.length == 10)) {
		error = "* The phone number is the wrong length.  Make sure you included an area code.\n";
	}
	return(error)
}

/**
 * Checks password
 *
 */
function checkPassword (strng) {

	var error = "";
 	if (strng == "") {
    	error = "* You didn't enter a password.\n";
    	return(error)
 	}
	var illegalChars = /[\W_]/; // allow only letters and numbers
	//if ((strng.length < 6) || (strng.length > 8)) {
	if (strng.length < 4) {
		error = "* The password must contain at least four characters.\n";
	}
	//else if (illegalChars.test(strng)) {
	//	error = "* The password contains illegal characters.\n";
	//}
	//else if (!((strng.search(/(a-z)+/))
  	//		&& (strng.search(/(A-Z)+/))
  	//		&& (strng.search(/(0-9)+/)))) {
  	//	error = "The password must contain at least one uppercase letter, one lowercase letter, and one numeral.\n";
  	//}
  	return(error)
}


/**
 *
 *
 */
function checkUsername (strng) {
	var error = "";
 	if (strng == "") {
    	error = "You didn't enter a username.\n";
 	}

	if ((strng.length < 4) || (strng.length > 10)) {
    	error = "The username is the wrong length.\n";
	}

	var illegalChars = /\W/;
  	// allow only letters, numbers, and underscores
	if (illegalChars.test(strng)) {
		error = "The username contains illegal characters.\n";
	}
}






/**
 *
 *
 */
function isDifferent(strng) {
  var error = "";
  if (strng != "Can\'t touch this!") {
     error = "You altered the inviolate text area.\n";
  }
}

/**
 *
 *
 */
function checkRadio() {

	for (i=0, n=theForm.radios.length; i<n; i++) {
   	if (theForm.radios[i].checked) {
			var checkvalue = theForm.radios[i].value;
			break;
   	}
	}
	why += checkRadio(checkvalue);

}

/**
 *
 *
 */
function checkRadio(checkvalue) {

	var error = "";
   if (!(checkvalue)) {
		error = "Please check a radio button.\n";
	}
	return error;
}

/**
 *
 *
 */
function checkDropdown(choice) {
	var error = "";
	if (choice == 0) {
		error = "You didn't choose an option from the drop-down list.\n";
	}
	return error;
}

