//-----------------------------------------------------------
// common/commontapjs.js
//-----------------------------------------------------------

function changeImage ( imgObjId, newSrc ) {
  var imgObj = document.getElementById(imgObjId);
  if ( imgObj ) {
  	imgObj.src = newSrc;
  }
}

function isEmpty ( x ) {
  if ( x.length == 0 ) {
    return true;
  } else {
    return false;
  }
}

function isValidEmail(emailVal){
  if (emailVal.indexOf(' ') != -1 || emailVal.indexOf('@') < 1 || emailVal.indexOf('.') == -1 ||
      (emailVal.indexOf('.')-emailVal.indexOf('@')) == 1 || emailVal.charAt(emailVal.length-1) == '.' || emailVal.charAt(emailVal.length-1) == '@') {
    return false; 
  }
  return true;
}

function trim(str) {
    return str.replace(/^\s*/, "").replace(/\s*$/, "");
}

function phoneNumberFormat(value) {
  var temp = value.toString();
  return "(" + temp.slice(0,3) + ") " + temp.slice(3,6) + "-" + temp.slice(6, temp.length);
}

/* set CSS values */
function setBgColor(thisObj, color) {
	thisObj.style.background=color;
}
