// JavaScript Document
function isEmail(xemail) {
    var addressPattern = /^[^\s\n]+\@[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,4}$/;
    return addressPattern.test(xemail);
}

function validateForm(xform) {
	var xerro="";

	if (xerro=="" && xform.txtEmail.value=="") {
		xerro="Por favor preencha o campo \"E-Mail\".";
	}

	if (xerro=="" && !isEmail(xform.txtEmail.value)) {
		xerro="Por favor digite um e-mail válido.";
	}

/*
	if (xerro=="" && xform.contact.value=="") {
		xerro="Por favor preencha o campo 'Nome'.";
	}

	if (xerro=="" && xform.company.value=="") {
		xerro="Por favor preencha o campo 'Empresa'.";
	}
*/

	if (xerro!="") alert(xerro);

	return (xerro=="");
}

// agenda rotator
/*
$(document).ready(function(){
  rotatePics(1);
});
*/

function rotatePics(currentPhoto) {
  var numberOfPhotos = $('#agenda img').length;
  currentPhoto = currentPhoto % numberOfPhotos;
	
  $('#agenda img').eq(currentPhoto).fadeOut(function() {
		// re-order the z-index
    $('#agenda img').each(function(i) {
      $(this).css(
        'zIndex', ((numberOfPhotos - i) + currentPhoto) % numberOfPhotos
      );
    });
    $(this).show();
    setTimeout(function() {rotatePics(++currentPhoto);}, 4000);
  });
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

