function scrambleIt(b,a){
	var c = ".com";
	document.write('<a href="mailto:'+a+'@'+b+c+'">'+a+'@'+b+c+'</a>');
}

function checkForm(f){
	var isValid = true;
	if(f.password.value == ""){
		document.getElementById("pwErr").innerHTML = "Required";
		f.password.focus();
		isValid = false;
	}
	if(f.Email.value == ""){
		eErr = document.getElementById("eErr").innerHTML = "Required";
		f.Email.focus();
		isValid = false;
	}
	if(!isValid){
		f.hasErrs.value="yes";
	}
	return isValid;
}

function CheckPost(f){
	var isValid = true;
	if(f.Price.value == ""){
		document.getElementById("pErr").innerHTML = "Required";
		//f.Price.focus();
		isValid = false;
	}
	if(f.Category.selectedIndex == 0){
		document.getElementById("cErr").innerHTML = "Required";
		//f.Category.focus();
		isValid = false;
	}
	if(f.ItemName.value == ""){
		document.getElementById("iErr").innerHTML = "Required";
		//f.ItemName.focus();
		isValid = false;
	}
	if(!isValid){
		f.hasErrs.value="yes";
	}
	//return isValid;
	return isValid;
}

function CheckAddCat(f){
	var isValid = true;
	if(f.CategoryName.value == ""){
		document.getElementById("cErr").innerHTML = "Required";
		//f.Category.focus();
		isValid = false;
	}
	if(!isValid){
		f.hasErrs.value="yes";
	}
	//return isValid;
	return isValid;
}

function CheckImageSave(f){
	var isValid = true;
	if(f.Item.selectedIndex == 0){
		document.getElementById("iErr").innerHTML = "Required";
		//f.Category.focus();
		isValid = false;
	}
	if(f.Image1.value === ""){
		document.getElementById("p1Err").innerHTML = "Required";
		//f.Category.focus();
		isValid = false;
	}
	if(!isValid){
		f.hasErrs.value="yes";
	}
	//return isValid;
	return isValid;
}

function checkFields(f,fld,errFld,em){
	var nb = "&nbsp;";
	var Err = document.getElementById(errFld);
	if(f.hasErrs.value=="yes"){
		if(fld == ""){
			Err.innerHTML = "Required";
		}else{
			if(em){
				Err.innerHTML = validateEmail(fld,fld.value);
			}else{
				Err.innerHTML = nb;
			}
		}
	}
}

function checkDropDown(f,fld,errFld){
	var nb = "&nbsp;";
	var Err = document.getElementById(errFld);
	if(f.hasErrs.value=="yes"){
		if(fld.selectedIndex == 0){
			Err.innerHTML = "Required";
		}else{
			Err.innerHTML = nb;
		}
	}
}

String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g,"");
}

function validateEmail(fldName, fldValue){
    var emRegxp = /(^[a-zA-Z0-9]([a-zA-Z0-9_\.\-]*)@([a-zA-Z0-9_\.\-]*)([.][a-z]{3})$)|(^[a-zA-Z0-9]([a-zA-Z0-9_\.\-]*)@([a-zA-Z0-9_\.\-]*)(\.[a-z]{3})(\.[a-z]{2})*$)/i;
    var error = "";
	if(! emRegxp.test(fldValue)){
		error = "Invalid Email Address";   
	}
    return error;
}

function UploadOnly(e){
	var key = window.event ? e.keyCode : e.which;
	var isValid;
	//check to see if the user has clicked the tab key, the backspace key or the delete key 
	//if so allow them and block all other keys
	if ((e.keyCode == 8)||(e.keyCode == 9)||(e.keyCode == 46)){
		isValid = true;
	}else{
		isValid = false;
	}
	return isValid;
}

//hide and show various elements as needed
function show(o){
	var e = document.getElementById(o);
	e.style.display = 'block';
}
function hide(o){
	var e = document.getElementById(o);
	e.style.display = 'none';
}
