function isEmpty(campo) {
  return /^ *$/.test(campo);
}

function isValidDate(campo) {
  return /^\d{2}\/\d{2}\/\d{4}$/.test(campo);
}

function submitBusca(form) {
  if(isEmpty(form.busca.value)) {
    alert('Informe pelo menos uma palavra-chave.');
    form.busca.focus();
    return false;
  }
  return true;
}

function openPopup(url, windowName, width, height, resizable, scrollbars, top, left) {
    var posx = (top && top != '') ? top : (screen.width/2)-(width/2);
    var posy = (left && left != '') ? left : (screen.height/2)-(height/2);
    var resizableStr = resizable? '1': '0';
	var scrollStr = scrollbars? '1': '0';
    features="directories=0,status=0,location=0,menubar=0,toolbar=0,scrollbars=" + scrollStr + ",resizable=" + resizableStr + ",width=" + width + ",height=" + height + ",top=" + posy + ",left=" + posx;
    var wnd = window.open(url, windowName, features);
	if(wnd) wnd.focus();
}

function testDrive() {
	window.open('/wtk/sitelo/Teste.do?action=insertForm', '_self');	
	//window.open('https://' + location.host + '/wtk/sitelo/Teste.do?action=insertForm', '_self');	
}

function contratar() {
	window.open('/wtk/sitelo/Contrato.do?action=formulario', '_self');	
}

function getRadioValue(ctl) {
	for(i = 0; i < ctl.length; i++) {
		if(ctl[i].checked) return ctl[i].value;
	}
	return null;
}

var clicou = false;
function submeter(form, acao) {
	if(!clicou) {
		clicou = true;
		window.setTimeout("clicou = false;", 5000);
		if(acao) form.action.value = acao;
		form.submit();
	}
}
