function mask(f)
{
tel=''; 
var val = removeNonNumeric(f.value).split(''); 
    for(var i=0;i<val.length;i++){ 
    if(i==0){val[i]='('+val[i]} 
    if(i==2){val[i]=val[i]+')'} 
    if(i==5){val[i]=val[i]+'-'} 
    tel=tel+val[i] 
    } 
f.value=tel; 
} 

function removeNonNumeric(s)
{
val=s.split('');
var t='';
    for(var i=0;i<val.length;i++)
    {
        if(val[i] >= '0' && val[i] <= '9')
        {
        t=t+val[i];
        }
    }
return t;
}


function numeric(o,e)
{
var unicode=e.charCode? e.charCode : e.keyCode //cross browser
if(unicode == 13){calculate()}
if(unicode == 46 && o.value.indexOf(".") != -1){return false} //only 1 dot
if(unicode != 46){
if (unicode!=8 && unicode!=9){ //allow backspace
if (unicode<48||unicode>57) //a number
return false //disable key press
}
}
}

function Left(str, n){
	if (n <= 0)
	    return "";
	else if (n > String(str).length)
	    return str;
	else
	    return String(str).substring(0,n);
}
function check(o) {
    if (o.checked == true) {
        nm = o.name;
        nl = document.forms["editor"].elements[nm].length;
        for (var i = 0; i < nl; i++) {
            if (document.forms["editor"].elements[nm][i] != o) {
                document.forms["editor"].elements[nm][i].checked = false;
            }
        }
    }
}
function vcheck(nm) {
    var v = "";
    nl = document.forms["editor"].elements[nm].length;
    for (var i = 0; i < nl; i++) {
        if (document.forms["editor"].elements[nm][i].checked == true) {
            v = document.forms["editor"].elements[nm][i].value;
        }
    }
    return v;
}

String.prototype.trim = function() {
    return this.replace(/^\s+|\s+$/g, "");
}
String.prototype.ltrim = function() {
    return this.replace(/^\s+/, "");
}
String.prototype.rtrim = function() {
    return this.replace(/\s+$/, "");
}
function validEmail(id) {
    var parts = document.getElementById(id).value.split("@");
    if (parts.length == 2) {
        var dom = parts[1].split(".");
        if (dom.length > 1 && dom.length < 4) {
            return true;
        }
    }
    return false;
}

