/*****************************************************************************
 *
 * My JS uTools
 * Author: Madjoudj Athmane <madjoudj_a@kdconcept.net>
 * 
 *****************************************************************************/

function _( obj ) { 
    //return document.getElementById( element );
    var el = document.getElementById( obj );
    return el;
}


function toggle(obj) {
    var el = document.getElementById(obj);
    el.style.display = (el.style.display != 'none' ? 'none' : '' );
}

function show(obj) {
    var el = document.getElementById(obj);
	el.style.display = "block";
}

function hide(obj) {
    var el = document.getElementById(obj);
	el.style.display = "none";
}

// returns true if the string is empty
function isEmpty(str){
  return (str == null) || (str.length == 0);
}
  // returns true if the string is a valid email
function isEmail(str){
  if(isEmpty(str)) return false;
  var re = /^[^\s()<>@,;:\/]+@\w[\w\.-]+\.[a-z]{2,}$/i
  return re.test(str);
}
// returns true if the string only contains characters A-Z or a-z
function isAlpha(str){
  var re = /[^a-zA-Z]/g
  if (re.test(str)) return false;
  return true;
}
// returns true if the string only contains characters 0-9
function isNumeric(str){
  var re = /[\D]/g
  if (re.test(str)) return false;
  return true;
}
// returns true if the string only contains characters A-Z, a-z or 0-9
function isAlphaNumeric(str){
  var re = /[^a-zA-Z0-9]/g
  if (re.test(str)) return false;
  return true;
}

