// JavaScript Document

//Restrict to whole numbers on input	
function isWholeNumber(e){
	var unicode=e.charCode? e.charCode : e.keyCode
	if (unicode!=8 && unicode!=45){ 
		if (unicode<48||unicode>57) 
		return false 
	}
}

//Restrict to decimal numbers on input	
function isDeclNumber(e){
	var unicode=e.charCode? e.charCode : e.keyCode
	if (unicode!=8){ 
		if (unicode<46||unicode>57) 
		return false 
	}
}

//format to d decimal places
function toDecl(obj,a,d) {
		if (!isNaN(a)) {
		a = a / 1;
		a = a.toFixed(d); 
		document.getElementById(obj).value = a;
	}
}

function alltrim(value) {
   var temp = value;
   var obj = /^(\s*)([\W\w]*)(\b\s*$)/;
   if (obj.test(temp)) { temp = temp.replace(obj, '$2'); }
   var obj = / +/g;
   temp = temp.replace(obj, " ");
   if (temp == " ") { temp = ""; }
   return temp;
}


function checkemail(q) {
	if (isValidEmail(q)) {
		alert("OK");
	}
	else {
		alert("Email invalid");
	}
}

toCamelCase.exp = / ([a-z])/;
function toCamelCase(s) {
	s = ' '+s.toLowerCase();
	for(var exp = toCamelCase.exp; 
		exp.test(s); 
		s = s.replace(exp, ' '+RegExp.$1.toUpperCase()) );
	return alltrim(s);
}

function passwordTrim(value) {
	var obj=/\W/g;
		value = value.replace(obj, "");
		return value;
}


function isValidEmail(emailAddress) {
    var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[(2([0-4]\d|5[0-5])|1?\d{1,2})(\.(2([0-4]\d|5[0-5])|1?\d{1,2})){3} \])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
    return re.test(emailAddress);
}

//function noSpecials(value) {
//	var obj=/[&/=:#?*\\'\\"<>%$]/g;
//		value = value.replace(obj, " ");
//		return value;
//}
//

function noSpecials(value) {
	var obj=/[&/=:#?*\\'\\"<>%$]/g;
	var obj = /&nbsp;|\*picture\*|\f|\n|\r|\t|[&/=:#?*<>%$\\"\\'\.\,\)\(]/g;
		value = value.replace(obj, " ");
		return value;
}


