function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function popDireitosReservados() {
	window.open ("politica.asp", "Direitos","location=no,status=0,scrollbars=1,width=600,height=600,resizable=no","titlebar=no"); 
}

function reconhecerNavegador(){
	var navegador = navigator.appName;
	var versao = navigator.appVersion;
	if ((navegador.indexOf("Microsoft") > -1) && (versao < 7)){
		setActiveStyleSheet('ie6');		
	}else{
		setActiveStyleSheet('ie7');
	}
	return false;
}


function jwsInstalled() {
  // Para Internet Explorer.
  if (navigator.userAgent.indexOf('MSIE') > -1) { 
      try {
          var jws = new ActiveXObject('JavaWebStart.isInstalled'); 
          return true; 
      }
      catch (e) {
          return false; 
      }
  } 

	// No Firefox é verificado o "x-java-jnlp-file". 
	// Já no Por Chrome e Safari, isso não funciona, em vez é buscado o "x-java-vm"
	// Se eles têm uma JVM recente instalado, eles geralmente têm também um Java instalado WebStart.

  return navigator.mimeTypes && 
         navigator.mimeTypes.length &&
              (navigator.mimeTypes['application/x-java-jnlp-file'] != null ||
               navigator.mimeTypes['application/x-java-vm'] != null);
}

function jwsApplet(pagina){
	ajax = Ajax();
	if(ajax){
		ajax.open("GET", pagina, true);
		ajax.onreadystatechange = function() {
			if(ajax.readyState == 4){
				if(ajax.status == 200){
					document.getElementById("applet").innerHTML = ajax.responseText;
					validaRetorno(pagina);
				}else{
					document.getElementById("applet").innerHTML = ajax.responseText;
				}
			}
		}
		ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=iso-8859-1");
		ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=UTF-8");
		ajax.setRequestHeader("Cache-Control", "no-store, no-cache, must-revalidate");
		ajax.setRequestHeader("Cache-Control", "post-check=0, pre-check=0");
		ajax.setRequestHeader("encoding", "ISO-8859-1"); 
		ajax.setRequestHeader("Pragma", "no-cache");
		ajax.send(null);
	}
}

function validaRetorno(p){
	var applet = document.infomac.getRetorno(document.fLogin.fid.value);
	//alert(applet);
	if (applet.indexOf("registrada") > -1){
		document.fLogin.submit();
	}if (applet.indexOf("bloqueada") > -1){
		alert(applet);
	}
}

//---------------------------------------------------------------------------------------------------
function ispunct(c){
		if ((c == '.') || (c == ',') || (c == '-') || (c == '+') || 
			(c == '@') || (c == '_') || (c == '"') || (c == '\'') ||
			(c == '$') || (c == '#') || (c == '!') || (c == '\´') ||
			(c == '%') || (c == '&') || (c == '*') || (c == '(') ||
			(c == ')') || (c == '=') || (c == '{') || (c == '}') ||
			(c == '[') || (c == ']') || (c == '/') || (c == '\\') ||
			(c == ':') || (c == ';') || (c == '>') || (c == '<') || 
			(c == '\`') || (escape(c) == '%20') )
			return true;
		else
			return false;
}
//---------------------------------------------------------------------------------------------------
function isalpha(c){
		if (((c >= 'a') && (c <= 'z')) || ((c >= 'A') && (c <= 'Z')))
 			return true;
		else  
 			return false;
}
//---------------------------------------------------------------------------------------------------
function isdigit(c){
		if ((c >= '0') && (c <= '9'))
		 	return true;
		else
			return false;
}
//---------------------------------------------------------------------------------------------------
function ValidaTexto(s) {
		var i; var c;
		for (var i=0;i<s.length;i++) {	
				c = s.substring(i,i+1); 
				if (!( isalpha(c) || isdigit(c) || !ispunct(c) ) ) return false;
				 }						
return true;
}
//---------------------------------------------------------------------------------------------------
function validatelogin(){
	with (document.fLogin) {
		//id
		if (fid.value == "") {
			alert("Entre com o nome do usuário (e-mail).");
			fid.focus();
			return false;
		}
		else if (fsenha.value == "") {
			alert("Entre com a Senha.");
			fsenha.focus();
			return false;
		}else{
			return true;
		}
	}
}
//---------------------------------------------------------------------------------------------------
function postlogin(){
	if (validatelogin()){
document.fLogin.submit();
/*

		if (jwsInstalled()) {
			var p = "mac/mac.asp";
			//alert(p);
			jwsApplet(p);
		}else{
			document.fLogin.submit();
		}
*/
	}
	
	return false;
}
