function isBlank(val) {
	if (val == null) { return true; }
	for (var i=0; i < val.length; i++) {
		if ((val.charAt(i) != ' ') && (val.charAt(i) != "\t") && (val.charAt(i) != "\n")) { return false; }
		}
	return true;
	}


function cColor(element, color){
	element.style.backgroundColor=color;
}


function isMail( mail ){ 
  arroba = "@";
  if (mail == "") {
	alert("E-mail inválido!");
	return true;
  }

  A1 = mail.indexOf(arroba);
  if (A1 < 0) {
     alert("E-mail inválido!");
	 return false;
  }

  cliente = mail.substring(0,A1);  
  provedor = mail.substring(A1+1,mail.length);  
  ponto = ".";
  P1 = provedor.indexOf(ponto);

  if (P1 < 0) {
	alert("E-mail inválido!");
    return false;
  }
  return true;
}

function OpenWindow(url, h, w) {
	var posx, posy;

	posx = (screen.width/2)-(w/2);
	posy = (screen.height/2)-(h/2);

	janela = window.open (url, 'Preview', "screenX=" + posx + ",screenY=" + posy + ",top=" + posy + ",left=" + posx + ",toolbar=0,location=0,directories=0,status=0,scrollbars=1,resizable=0,width=" + w + ",height="+ h)
}

function chg(field, cor){
	var rgb;
	switch(cor){
		case '2':
			rgb = "#f6f6f6";
			break;
	}
	field.style.backgroundColor = rgb;
}
