<!-- Original: Richard Gorremans (xbase@volcano.net) ==>
<!-- Updates: www.spiritwolfx.com
<!-- Begin

// Check browser version
var isNav4 = false, isNav5 = false, isIE4 = false
var strSeperator = "/"; 
// If you are using any Java validation on the back side you will want to use the / because 
// Java date validations do not recognize the dash as a valid date separator.

var vDateType = 3; // Global value for type of date format
//                1 = mm/dd/yyyy
//                2 = yyyy/dd/mm  (Unable to do date check at this time)
//                3 = dd/mm/yyyy

var vYearType = 4; //Set to 2 or 4 for number of digits in the year for Netscape
var vYearLength = 2; // Set to 4 if you want to force the user to enter 4 digits for the year before validating.

var err = 0; // Set the error code to a default of zero


if(navigator.appName == "Netscape") 
{
   if (navigator.appVersion < "5")  
   {
      isNav4 = true;
      isNav5 = false;
	}
   else
   if (navigator.appVersion > "4") 
   {
      isNav4 = false;
      isNav5 = true;
	}
}
else  
{
   isIE4 = true;
}

/*função que formata Data */
function DateFormat(vDateName, vDateValue, e, dateCheck, dateType)  {
	vDateType = dateType;
	mDateValue = vDateValue;
// vDateName = object name
// vDateValue = value in the field being checked
// e = event
// dateCheck 
//       True  = Verify that the vDateValue is a valid date
//       False = Format values being entered into vDateValue only
// vDateType
//       1 = mm/dd/yyyy
//       2 = yyyy/mm/dd
//       3 = dd/mm/yyyy
   //Enter a tilde sign for the first number and you can check the variable information.
   if (vDateValue == "~")
   {
      alert("AppVersion = "+navigator.appVersion+" \nNav. 4 Version = "+isNav4+" \nNav. 5 Version = "+isNav5+" \nIE Version = "+isIE4+" \nYear Type = "+vYearType+" \nDate Type = "+vDateType+" \nSeparator = "+strSeperator);
      vDateName.value = "";
      vDateName.focus();
      return true;
   }
      
   var whichCode = (window.Event) ? e.which : e.keyCode;
 
   // Check to see if a seperator is already present.
   // bypass the date if a seperator is present and the length greater than 8
   if (vDateValue.length > 8 && isNav4)
   {
      if ((vDateValue.indexOf("-") >= 1) || (vDateValue.indexOf("/") >= 1))
         return true;
   }
   
   //Eliminate all the ASCII codes that are not valid
   var alphaCheck = " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ/-";
   if (alphaCheck.indexOf(vDateValue) >= 1)  
   {
      if (isNav4)
      {
         vDateName.value = "";
         vDateName.focus();
         vDateName.select();
         return false;
      }
      else
      {
         vDateName.value = vDateName.value.substr(0, (vDateValue.length-1));
         return false;
      } 
   }
   if (whichCode == 8) //Ignore the Netscape value for backspace. IE has no value
      return false;
   else 
   {
      //Create numeric string values for 0123456789/
      //The codes provided include both keyboard and keypad values
      
      var strCheck = '47,48,49,50,51,52,53,54,55,56,57,58,59,95,96,97,98,99,100,101,102,103,104,105';
      if (strCheck.indexOf(whichCode) != -1)  
      {
         if (isNav4)  
         {
            if (((vDateValue.length < 6 && dateCheck) || (vDateValue.length == 7 && dateCheck)) && (vDateValue.length >=1))
            {
               alert("Data Inválida\nDigite a data no formato dd/mm/aaaa");
               vDateName.value = "";
               vDateName.focus();
               vDateName.select();
               return false;
            }
            if (vDateValue.length == 6 && dateCheck)  
            {
               var mDay = vDateName.value.substr(2,2);
               var mMonth = vDateName.value.substr(0,2);
               var mYear = vDateName.value.substr(4,4)
               
               //Turn a two digit year into a 4 digit year
               if (mYear.length == 2 && vYearType == 4) 
               {
                  var mToday = new Date();
                  
                  //If the year is greater than 30 years from now use 19, otherwise use 20
                  var checkYear = mToday.getFullYear() + 30; 
                  var mCheckYear = '20' + mYear;
                  if (mCheckYear >= checkYear)
                     mYear = '19' + mYear;
                  else
                     mYear = '20' + mYear;
               }
               var vDateValueCheck = mMonth+strSeperator+mDay+strSeperator+mYear;
               
               if (!dateValid(vDateValueCheck))  
               {
                  alert("Data Inválida\nDigite a data no formato dd/mm/aaaa");
                  vDateName.value = "";
                  vDateName.focus();
                  vDateName.select();
                  return false;
		         }
               vDateName.value = vDateValueCheck;
               return true;
            
            }
            else
            {
               // Reformat the date for validation and set date type to a 1
               
               
               if (vDateValue.length >= 8  && dateCheck)  
               {
                  if (vDateType == 1) // mmddyyyy
                  {
                     var mDay = vDateName.value.substr(2,2);
                     var mMonth = vDateName.value.substr(0,2);
                     var mYear = vDateName.value.substr(4,4)
                     vDateName.value = mMonth+strSeperator+mDay+strSeperator+mYear;
                  }
                  if (vDateType == 2) // yyyymmdd
                  {
                     var mYear = vDateName.value.substr(0,4)
                     var mMonth = vDateName.value.substr(4,2);
                     var mDay = vDateName.value.substr(6,2);
                     vDateName.value = mYear+strSeperator+mMonth+strSeperator+mDay;
                  }
                  if (vDateType == 3) // ddmmyyyy
                  {
                     var mMonth = vDateName.value.substr(2,2);
                     var mDay = vDateName.value.substr(0,2);
                     var mYear = vDateName.value.substr(4,4)
                     vDateName.value = mDay+strSeperator+mMonth+strSeperator+mYear;
                  }
                  
                  //Create a temporary variable for storing the DateType and change
                  //the DateType to a 1 for validation.
                  
                  var vDateTypeTemp = vDateType;
                  vDateType = 1;
                  var vDateValueCheck = mMonth+strSeperator+mDay+strSeperator+mYear;
                  
                  if (!dateValid(vDateValueCheck))  
                  {
                     alert("Data Inválida\nDigite a data no formato dd/mm/aaaa");
                     vDateType = vDateTypeTemp;
                     vDateName.value = "";
                     vDateName.focus();
                     vDateName.select();
                     return false;
		            }
                     vDateType = vDateTypeTemp;
                     return true;
	            }
               else
               {
                  if (((vDateValue.length < 8 && dateCheck) || (vDateValue.length == 9 && dateCheck)) && (vDateValue.length >=1))
                  {
                     alert("Data Inválida\nDigite a data no formato dd/mm/aaaa");
                     vDateName.value = "";
                     vDateName.focus();
                     vDateName.select();
                     return false;
                  }
               }
            }
         }
         else  
         {
         // Non isNav Check
            if (((vDateValue.length < 8 && dateCheck) || (vDateValue.length == 9 && dateCheck)) && (vDateValue.length >=1))
            {
               alert("Data Inválida\nDigite a data no formato dd/mm/aaaa");
               vDateName.value = "";
               vDateName.focus();
               return true;
            }
            
            // Reformat date to format that can be validated. mm/dd/yyyy
            
            
            if (vDateValue.length >= 8 && dateCheck)  
            {
            
               // Additional date formats can be entered here and parsed out to
               // a valid date format that the validation routine will recognize.
               
               if (vDateType == 1) // mm/dd/yyyy
               {
                  var mMonth = vDateName.value.substr(0,2);
                  var mDay = vDateName.value.substr(3,2);
                  var mYear = vDateName.value.substr(6,4)
               }
               if (vDateType == 2) // yyyy/mm/dd
               {
                  var mYear = vDateName.value.substr(0,4)
                  var mMonth = vDateName.value.substr(5,2);
                  var mDay = vDateName.value.substr(8,2);
               }
               if (vDateType == 3) // dd/mm/yyyy
               {
                  var mDay = vDateName.value.substr(0,2);
                  var mMonth = vDateName.value.substr(3,2);
                  var mYear = vDateName.value.substr(6,4)
               }
               if (vYearLength == 4)
               {
                  if (mYear.length < 4)
                  {
                     alert("Data Inválida\nDigite a data no formato dd/mm/aaaa");
                     vDateName.value = "";
                     vDateName.focus();
                     return true;
                  }
               }
               
               // Create temp. variable for storing the current vDateType
               var vDateTypeTemp = vDateType;
               
               // Change vDateType to a 1 for standard date format for validation
               // Type will be changed back when validation is completed.
               vDateType = 1;
               
               // Store reformatted date to new variable for validation.
               var vDateValueCheck = mMonth+strSeperator+mDay+strSeperator+mYear;
               
               if (mYear.length == 2 && vYearType == 4 && dateCheck)  
               {
                  
                  //Turn a two digit year into a 4 digit year
                  var mToday = new Date();
                  
                  //If the year is greater than 30 years from now use 19, otherwise use 20
                  var checkYear = mToday.getFullYear() + 30; 
                  var mCheckYear = '20' + mYear;
                  if (mCheckYear >= checkYear)
                     mYear = '19' + mYear;
                  else
                     mYear = '20' + mYear;
                  vDateValueCheck = mMonth+strSeperator+mDay+strSeperator+mYear;
                  
                  // Store the new value back to the field.  This function will
                  // not work with date type of 2 since the year is entered first.
                  
                  if (vDateTypeTemp == 1) // mm/dd/yyyy
                     vDateName.value = mMonth+strSeperator+mDay+strSeperator+mYear;
                  if (vDateTypeTemp == 3) // dd/mm/yyyy
                     vDateName.value = mDay+strSeperator+mMonth+strSeperator+mYear;

               } 
               
               
               if (!dateValid(vDateValueCheck))  
               {
                  alert("Data Inválida\nDigite a data no formato dd/mm/aaaa");
                  vDateType = vDateTypeTemp;
                  vDateName.value = "";
                  vDateName.focus();
                  return true;
		         }
               vDateType = vDateTypeTemp;
               return true;
            
            }
            else
            {
               
               if (vDateType == 1)
               {
                  if (vDateValue.length == 2)  
                  {
                     vDateName.value = vDateValue+strSeperator;
                  }
                  if (vDateValue.length == 5)  
                  {
                     vDateName.value = vDateValue+strSeperator;
                  }
               }
               if (vDateType == 2)
               {
                  if (vDateValue.length == 4)  
                  {
                     vDateName.value = vDateValue+strSeperator;
                  }
                  if (vDateValue.length == 7)  
                  {
                     vDateName.value = vDateValue+strSeperator;
                  }
               } 
               if (vDateType == 3)
               {
                  if (vDateValue.length == 2)  
                  {
                     vDateName.value = vDateValue+strSeperator;
                  }
                  if (vDateValue.length == 5)  
                  {
                     vDateName.value = vDateValue+strSeperator;
                  }
               }
               return true;
            }
         }
         if (vDateValue.length == 10   && dateCheck)  
         {
            if (!dateValid(vDateName))  
            {
// Un-comment the next line of code for debugging the dateValid() function error messages
//               alert(err);  
               alert("Data Inválida\nDigite a data no formato dd/mm/aaaa");
               vDateName.focus();
               vDateName.select();
	         }
         }
         return false;
      }
      else  
      {
         // If the value is not in the string return the string minus the last
         // key entered.
         if (isNav4)
         {
            vDateName.value = "";
            vDateName.focus();
            vDateName.select();
            return false;
         }
         else
         {
            vDateName.value = vDateName.value.substr(0, (vDateValue.length-1));
            return false;
         }
		}
	}
}


   function dateValid(objName) {
      var strDate;
      var strDateArray;
      var strDay;
      var strMonth;
      var strYear;
      var intday;
      var intMonth;
      var intYear;
      var booFound = false;
      var datefield = objName;
      var strSeparatorArray = new Array("-"," ","/",".");
      var intElementNr;
      // var err = 0;
      var strMonthArray = new Array(12);
      strMonthArray[0] = "Jan";
      strMonthArray[1] = "Feb";
      strMonthArray[2] = "Mar";
      strMonthArray[3] = "Apr";
      strMonthArray[4] = "May";
      strMonthArray[5] = "Jun";
      strMonthArray[6] = "Jul";
      strMonthArray[7] = "Aug";
      strMonthArray[8] = "Sep";
      strMonthArray[9] = "Oct";
      strMonthArray[10] = "Nov";
      strMonthArray[11] = "Dec";
      
      //strDate = datefield.value;
      strDate = objName;
      
      if (strDate.length < 1) {
         return true;
      }
      for (intElementNr = 0; intElementNr < strSeparatorArray.length; intElementNr++) {
         if (strDate.indexOf(strSeparatorArray[intElementNr]) != -1) 
         {
            strDateArray = strDate.split(strSeparatorArray[intElementNr]);
            if (strDateArray.length != 3) 
            {
               err = 1;
               return false;
            }
            else 
            {
               strDay = strDateArray[0];
               strMonth = strDateArray[1];
               strYear = strDateArray[2];
            }
            booFound = true;
         }
      }
      if (booFound == false) {
         if (strDate.length>5) {
            strDay = strDate.substr(0, 2);
            strMonth = strDate.substr(2, 2);
            strYear = strDate.substr(4);
         }
      }
      //Adjustment for short years entered
      if (strYear.length == 2) {
         strYear = '20' + strYear;
      }
      strTemp = strDay;
      strDay = strMonth;
      strMonth = strTemp;
      intday = parseInt(strDay, 10);
      if (isNaN(intday)) {
         err = 2;
         return false;
      }
      
      intMonth = parseInt(strMonth, 10);
      if (isNaN(intMonth)) {
         for (i = 0;i<12;i++) {
            if (strMonth.toUpperCase() == strMonthArray[i].toUpperCase()) {
               intMonth = i+1;
               strMonth = strMonthArray[i];
               i = 12;
            }
         }
         if (isNaN(intMonth)) {
            err = 3;
            return false;
         }
      }
      intYear = parseInt(strYear, 10);
      if (isNaN(intYear)) {
         err = 4;
         return false;
      }
      if (intMonth>12 || intMonth<1) {
         err = 5;
         return false;
      }
      if ((intMonth == 1 || intMonth == 3 || intMonth == 5 || intMonth == 7 || intMonth == 8 || intMonth == 10 || intMonth == 12) && (intday > 31 || intday < 1)) {
         err = 6;
         return false;
      }
      if ((intMonth == 4 || intMonth == 6 || intMonth == 9 || intMonth == 11) && (intday > 30 || intday < 1)) {
         err = 7;
         return false;
      }
      if (intMonth == 2) {
         if (intday < 1) {
            err = 8;
            return false;
         }
         if (LeapYear(intYear) == true) {
            if (intday > 29) {
               err = 9;
               return false;
            }
         }
         else {
            if (intday > 28) {
               err = 10;
               return false;
            }
         }
      }
         return true;
      }

   function LeapYear(intYear) {
      if (intYear % 100 == 0) {
         if (intYear % 400 == 0) { return true; }
      }
      else {
         if ((intYear % 4) == 0) { return true; }
      }
         return false;
      }
//  End -->


function validEmail(email){
	invalidChars = "/:,;"
	if(email == ""){ //nao pode ser vazio
		return false
	}
	for(i=0; i<invalidChars.length; i++){ // contem algum caracter invalido?
		badChar = invalidChars.charAt(i)
		if(email.indexOf(badChar,0) > -1){
			return false
		}
	}
	atPos = email.indexOf("@", 1) //deve haver um simbolo @
	if(atPos == -1){
		return false
	}
	if(email.indexOf("@", atPos+1) != -1){	//e somente um simbolo @
		return false
	}
	periodPos = email.indexOf(".", atPos)
	if(periodPos == -1){	//e pelo menos um "." apos o @
		return false
	}
	if(periodPos+3 >email.lengh){	//deve haver pelo menos 2 caracteres apos "."
		return false
	}
	return true
}
/* 
Para usar a função do e-mail
	//verifica se o email é valido
	if(!validEmail(cadastro.form_email_simposio.value)){
		alert("Endereço de e-mail inválido !!!");
		cadastro.form_email_simposio.focus()
		cadastro.form_email_simposio.select()
		return false
	}
*/

function verifica_radio(campo){
	campo_frm = campo;
	var opcao = 0;
	for (var i = 0; i < campo_frm.length; i++) {
		if (campo_frm[i].checked) {
			opcao = campo_frm[i].value;
		}
	}
	if (opcao == ""){
		return false;
	}else {
		return true;
	}
}


function isEmpty(inputStr){
	if(inputStr == "" || inputStr == null){
		return true;
	}
	return false;
}

function inRange(inputStr, lo, hi){
	var num = parseInt(inputStr, 10);
	if(num < lo || num > hi){
		return false;
	}
	return true;
}


function isNum(valor, tipo){
//	alert("estou aki");
	if(isEmpty(valor)){
		return false;
		//alert("estou aki");
	}else{

		/*if(valor == "01"){
			valor = "1";
		}
		if(valor == "02"){
			valor = "2";
		}
		if(valor == "03"){
			valor = "3";
		}
		if(valor == "04"){
			valor = "4";
		}
		if(valor == "05"){
			valor = "5";
		}
		if(valor == "06"){
			valor = "6";
		}
		if(valor == "07"){
			valor = "7";
		}
		if(valor == "08"){
			valor = "8";
		}
		if(valor == "09"){
			valor = "9";
		}*/
		valor = parseInt(valor, 10);
		if(isNaN(valor)){
			return false;
		}else{
			if(tipo == "dia"){
				if(!inRange(valor, 1, 31)){
					return false;
				}
			}
			if(tipo == "mes"){
				if(!inRange(valor, 1, 12)){
					return false;
				}
			}
			if(tipo == "ano"){
				v_ano_min = 1970;
				if(valor < v_ano_min){
					return false;
				}
			}
			if(tipo == "ano_nasc"){
				v_ano_min_nasc = 1900;
				if(valor < v_ano_min_nasc){
					return false;
				}
			}
			if((tipo == "hora") && (valor > 24)){
					return false;
			}
			if((tipo == "minuto") && (valor > 59)){
					return false;
			}
			if((tipo == "segundo") && (valor > 59)){
					return false;
			}
			
		}
	}

	return true;	
}

/*
Para usar a funçao isNum
	//verifica se o dia é valido
	if(!isNum(cadastro.form_dia_ini.value, "dia")){
		alert("Dia inválido !!!");
		cadastro.form_dia_ini.focus()
		cadastro.form_dia_ini.select()
		return false
	}
*/


function isNumData(valor, tipo){
//	alert("estou aki");
	if(isEmpty(valor)){
		return false;
		//alert("estou aki");
	}else{
		valor = parseInt(valor, 10);
		if(isNaN(valor)){
			return false;
		}else{
			if(tipo == "dia"){
				if(!inRange(valor, 1, 31)){
					return false;
				}
			}
			if(tipo == "mes"){
				if(!inRange(valor, 1, 12)){
					return false;
				}
			}
			if(tipo == "ano"){
				v_ano_min = 1900;
				if(valor < v_ano_min){
					return false;
				}
			}
			if((tipo == "hora") && (valor > 24)){
					return false;
			}
			if((tipo == "minuto") && (valor > 59)){
					return false;
			}
			if((tipo == "segundo") && (valor > 59)){
					return false;
			}
			
		}
	}
	return true;	
}

function isData(dia, mes, ano){
	anomod = ano % 4; 
	if((mes == 2) && ((dia == 30) || (dia == 31))){
		return false;
	}
	if((mes == 2) && (dia == 29) && (anomod != 0)){  //verifica se é bissexto
		return false;
	}
	if((dia == 31) && ((mes == 4) || (mes == 6) || (mes == 9) || (mes == 11))){
		return false;
	}
	return true;	
}

extArray = new Array(".gif", ".jpg", ".jpeg");
function LimitAttach(form, file) {
	allowSubmit = false;
	if (!file) return;
	while (file.indexOf("\\") != -1){
		file = file.slice(file.indexOf("\\") + 1);
	}
	ext = file.slice(file.indexOf(".")).toLowerCase();
	for (var i = 0; i < extArray.length; i++) {
		if (extArray[i] == ext) { 
			allowSubmit = true; 
			break; 
		}
	}
	if (allowSubmit) {
		return true;
	}else{
		alert("Somente são aceitos arquivos do tipo:  " + (extArray.join("  ")) + "\nPor favor selecione um outro arquivo.");
		return false;
	}
}

extArrayDoc = new Array(".pdf", ".doc", "xls", ".pps", ".rtf", ".txt");
function LimitAttachDoc(form, file) {
	allowSubmit = false;
	if (!file) return;
	while (file.indexOf("\\") != -1){
		file = file.slice(file.indexOf("\\") + 1);
	}
	ext = file.slice(file.indexOf(".")).toLowerCase();
	for (var i = 0; i < extArrayDoc.length; i++) {
		if (extArrayDoc[i] == ext) { 
			allowSubmit = true; 
			break; 
		}
	}
	if (allowSubmit) {
		return true;
	}else{
		alert("Somente são aceitos arquivos do tipo:  " + (extArrayDoc.join("  ")) + "\nPor favor selecione um outro arquivo.");
		return false;
	}
}

extArrayCompactada = new Array(".zip", ".rar", ".arj");
function LimitAttachCompactada(form, file) {
	allowSubmit = false;
	if (!file) return;
	while (file.indexOf("\\") != -1){
		file = file.slice(file.indexOf("\\") + 1);
	}
	ext = file.slice(file.indexOf(".")).toLowerCase();
	for (var i = 0; i < extArrayCompactada.length; i++) {
		if (extArrayCompactada[i] == ext) { 
			allowSubmit = true; 
			break; 
		}
	}
	if (allowSubmit) {
		return true;
	}else{
		alert("Somente são aceitos arquivos do tipo:  " + (extArrayCompactada.join("  ")) + "\nPor favor selecione um outro arquivo.");
		return false;
	}
}

extArrayJPG = new Array(".jpg", ".jpeg");
function LimitAttachJPG(form, file) {
	allowSubmit = false;
	if (!file) return;
	while (file.indexOf("\\") != -1){
		file = file.slice(file.indexOf("\\") + 1);
	}
	ext = file.slice(file.indexOf(".")).toLowerCase();
	for (var i = 0; i < extArrayJPG.length; i++) {
		if (extArrayJPG[i] == ext) { 
			allowSubmit = true; 
			break; 
		}
	}
	if (allowSubmit) {
		return true;
	}else{
		alert("Somente são aceitos arquivos do tipo:  " + (extArrayJPG.join("  ")) + "\nPor favor selecione um outro arquivo.");
		return false;
	}
}

extArrayPDF = new Array(".pdf");
function LimitAttachPDF(form, file) {
	allowSubmit = false;
	if (!file) return;
	while (file.indexOf("\\") != -1){
		file = file.slice(file.indexOf("\\") + 1);
	}
	ext = file.slice(file.indexOf(".")).toLowerCase();
	for (var i = 0; i < extArrayPDF.length; i++) {
		if (extArrayPDF[i] == ext) { 
			allowSubmit = true; 
			break; 
		}
	}
	if (allowSubmit) {
		return true;
	}else{
		alert("Somente são aceitos arquivos do tipo:  " + (extArrayPDF.join("  ")) + "\nPor favor selecione um outro arquivo.");
		return false;
	}
}

extArrayAudio = new Array(".mp3", ".wav", ".wma");
function LimitAttachAudio(form, file) {
	allowSubmit = false;
	if (!file) return;
	while (file.indexOf("\\") != -1){
		file = file.slice(file.indexOf("\\") + 1);
	}
	ext = file.slice(file.indexOf(".")).toLowerCase();
	for (var i = 0; i < extArrayAudio.length; i++) {
		if (extArrayAudio[i] == ext) { 
			allowSubmit = true; 
			break; 
		}
	}
	if (allowSubmit) {
		return true;
	}else{
		alert("Somente são aceitos arquivos do tipo:  " + (extArrayAudio.join("  ")) + "\nPor favor selecione um outro arquivo.");
		return false;
	}
}

extArrayVideo = new Array(".mov", ".wmv", ".avi", ".mpg", ".asf", ".flv");
function LimitAttachVideo(form, file) {
	allowSubmit = false;
	if (!file) return;
	while (file.indexOf("\\") != -1){
		file = file.slice(file.indexOf("\\") + 1);
	}
	ext = file.slice(file.indexOf(".")).toLowerCase();
	for (var i = 0; i < extArrayVideo.length; i++) {
		if (extArrayVideo[i] == ext) { 
			allowSubmit = true; 
			break; 
		}
	}
	if (allowSubmit) {
		return true;
	}else{
		alert("Somente são aceitos arquivos do tipo:  " + (extArrayVideo.join("  ")) + "\nPor favor selecione um outro arquivo.");
		return false;
	}
}

extArrayVideoFlash = new Array(".flv");
function LimitAttachVideoFlash(form, file) {
	allowSubmit = false;
	if (!file) return;
	while (file.indexOf("\\") != -1){
		file = file.slice(file.indexOf("\\") + 1);
	}
	ext = file.slice(file.indexOf(".")).toLowerCase();
	for (var i = 0; i < extArrayVideoFlash.length; i++) {
		if (extArrayVideoFlash[i] == ext) { 
			allowSubmit = true; 
			break; 
		}
	}
	if (allowSubmit) {
		return true;
	}else{
		alert("Somente são aceitos arquivos do tipo:  " + (extArrayVideoFlash.join("  ")) + "\nPor favor selecione um outro arquivo.");
		return false;
	}
}


extArrayBiblioteca = new Array(".pdf", ".doc", ".xls", ".pps", ".ppt", ".rtf", ".txt", ".vsd",".vss",".vst",".vdx",".vsx",".vtx");
function LimitAttachBiblioteca(form, file) {
	allowSubmit = false;
	if (!file) return;
	while (file.indexOf("\\") != -1){
		file = file.slice(file.indexOf("\\") + 1);
	}
	ext = file.slice(file.indexOf(".")).toLowerCase();
	for (var i = 0; i < extArrayBiblioteca.length; i++) {
		if (extArrayBiblioteca[i] == ext) { 
			allowSubmit = true; 
			break; 
		}
	}
	if (allowSubmit) {
		return true;
	}else{
		alert("Somente são aceitos arquivos do tipo:  " + (extArrayBiblioteca.join("  ")) + "\nPor favor selecione um outro arquivo.");
		return false;
	}
}

function limpa_string(S){
	// Deixa so' os digitos no numero
	var Digitos = "0123456789";
	var temp = "";
	var digito = "";

	for (var i=0; i<S.length; i++)	{
		digito = S.charAt(i);
		if (Digitos.indexOf(digito)>=0)	{
			temp=temp+digito	}
	} //for

	return temp
}

function valida_CGC(s)
{
	var i;
	s = limpa_string(s);
	var c = s.substr(0,12);
	var dv = s.substr(12,2);
	var d1 = 0;
	for (i = 0; i < 12; i++)
	{
		d1 += c.charAt(11-i)*(2+(i % 8));
	}
        if (d1 == 0) return false;
        d1 = 11 - (d1 % 11);
	if (d1 > 9) d1 = 0;
	if (dv.charAt(0) != d1)
	{
		return false;
	}

	d1 *= 2;
	for (i = 0; i < 12; i++)
	{
		d1 += c.charAt(11-i)*(2+((i+1) % 8));
	}
	d1 = 11 - (d1 % 11);
	if (d1 > 9) d1 = 0;
	if (dv.charAt(1) != d1)
	{
		return false;
	}
	return true;
}

function valida_CPF(s)	{
	var i;
	s = limpa_string(s);
	var c = s.substr(0,9);
	var dv = s.substr(9,2);
	var d1 = 0;
	for (i = 0; i < 9; i++)
	{
		d1 += c.charAt(i)*(10-i);
	}
        if (d1 == 0) return false;
	d1 = 11 - (d1 % 11);
	if (d1 > 9) d1 = 0;
	if (dv.charAt(0) != d1)
	{
		return false;
	}

	d1 *= 2;
	for (i = 0; i < 9; i++)
	{
		d1 += c.charAt(i)*(11-i);
	}
	d1 = 11 - (d1 % 11);
	if (d1 > 9) d1 = 0;
	if (dv.charAt(1) != d1)
	{
		return false;
	}
        return true;
}



function isNUMB(c) 
 { 
 if((cx=c.indexOf(","))!=-1) 
  { 
  c = c.substring(0,cx)+"."+c.substring(cx+1); 
  } 
 if((parseFloat(c) / c != 1)) 
  { 
  if(parseFloat(c) * c == 0) 
   { 
   return(1); 
   } 
  else 
   { 
   return(0); 
   } 
  } 
 else 
  { 
  return(1); 
  } 
 } 

function LIMP(c) 
 { 
 while((cx=c.indexOf("-"))!=-1) 
  { 
  c = c.substring(0,cx)+c.substring(cx+1); 
  } 
 while((cx=c.indexOf("/"))!=-1) 
  { 
  c = c.substring(0,cx)+c.substring(cx+1); 
  } 
 while((cx=c.indexOf(","))!=-1) 
  { 
  c = c.substring(0,cx)+c.substring(cx+1); 
  } 
 while((cx=c.indexOf("."))!=-1) 
  { 
  c = c.substring(0,cx)+c.substring(cx+1); 
  } 
 while((cx=c.indexOf("("))!=-1) 
  { 
  c = c.substring(0,cx)+c.substring(cx+1); 
  } 
 while((cx=c.indexOf(")"))!=-1) 
  { 
  c = c.substring(0,cx)+c.substring(cx+1); 
  } 
 while((cx=c.indexOf(" "))!=-1) 
  { 
  c = c.substring(0,cx)+c.substring(cx+1); 
  } 
 return(c); 
 } 

function VerifyCNPJ(CNPJ) 
 { 
 CNPJ = LIMP(CNPJ); 
 if(isNUMB(CNPJ) != 1) 
  { 
  return(0); 
  } 
 else 
  { 
  if(CNPJ == 0) 
   { 
   return(0); 
   } 
  else 
   { 
   g=CNPJ.length-2; 
   if(RealTestaCNPJ(CNPJ,g) == 1) 
    { 
    g=CNPJ.length-1; 
    if(RealTestaCNPJ(CNPJ,g) == 1) 
     { 
     return(1); 
     } 
    else 
     { 
     return(0); 
     } 
    } 
   else 
    { 
    return(0); 
    } 
   } 
  } 
 } 
function RealTestaCNPJ(CNPJ,g) 
 { 
 var VerCNPJ=0; 
 var ind=2; 
 var tam; 
 for(f=g;f>0;f--) 
  { 
  VerCNPJ+=parseInt(CNPJ.charAt(f-1))*ind; 
  if(ind>8) 
   { 
   ind=2; 
   } 
  else 
   { 
   ind++; 
   } 
  } 
  VerCNPJ%=11; 
  if(VerCNPJ==0 || VerCNPJ==1) 
   { 
   VerCNPJ=0; 
   } 
  else 
   { 
   VerCNPJ=11-VerCNPJ; 
   } 
 if(VerCNPJ!=parseInt(CNPJ.charAt(g))) 
  { 
  return(0); 
  } 
 else 
  { 
  return(1); 
  } 
 } 
  

function FormataCGC(Formulario, Campo, TeclaPres)
  {
    var tecla = TeclaPres.keyCode;
    var strCampo;
    var vr;
    var tam;
    var TamanhoMaximo = 14;
 
    eval("strCampo = document." + Formulario + "." + Campo);
 
    vr = strCampo.value;
    vr = vr.replace("/", "");
    vr = vr.replace("/", "");
    vr = vr.replace("/", "");
    vr = vr.replace(",", "");
    vr = vr.replace(".", "");
    vr = vr.replace(".", "");
    vr = vr.replace(".", "");
    vr = vr.replace(".", "");
    vr = vr.replace(".", "");
    vr = vr.replace(".", "");
    vr = vr.replace(".", "");
    vr = vr.replace("-", "");
    vr = vr.replace("-", "");
    vr = vr.replace("-", "");
    vr = vr.replace("-", "");
    vr = vr.replace("-", "");
    tam = vr.length;

    if (tam < TamanhoMaximo && tecla != 8)
    {
      tam = vr.length + 1;
    }

    if (tecla == 8)
    {
      tam = tam - 1;
    }

    if (tecla == 8 || tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105)
    {
      if (tam <= 2)
      {
        strCampo.value = vr;
      }
       if ((tam > 2) && (tam <= 6))
       {
         strCampo.value = vr.substr(0, tam - 2) + '-' + vr.substr(tam - 2, tam);
       }
       if ((tam >= 7) && (tam <= 9))
       {
         strCampo.value = vr.substr(0, tam - 6) + '/' + vr.substr(tam - 6, 4) + '-' + vr.substr(tam - 2, tam);
      }
       if ((tam >= 10) && (tam <= 12))
       {
         strCampo.value = vr.substr(0, tam - 9) + '.' + vr.substr(tam - 9, 3) + '/' + vr.substr(tam - 6, 4) + '-' + vr.substr(tam - 2, tam);
      }
       if ((tam >= 13) && (tam <= 14))
       {
         strCampo.value = vr.substr(0, tam - 12) + '.' + vr.substr(tam - 12, 3) + '.' + vr.substr(tam - 9, 3) + '/' + vr.substr(tam - 6, 4) + '-' + vr.substr(tam - 2, tam);
      }
       if ((tam >= 15) && (tam <= 17))
       {
         strCampo.value = vr.substr(0, tam - 14) + '.' + vr.substr(tam - 14, 3) + '.' + vr.substr(tam - 11, 3) + '.' + vr.substr(tam - 8, 3) + '.' + vr.substr(tam - 5, 3) + '-' + vr.substr(tam - 2, tam);
      }
    }
  } 
  
/* início função que abre / fecha texto */
function toggleRow(link, msg_abre, msg_fecha) {
    var row = link;
    while (row.nodeName != "TR") {
        row = row.parentNode;
    }

    var table = row;
    while (table.nodeName != "TABLE") {
        table = table.parentNode;
    }
    
    row = table.rows.item(row.rowIndex + 1);

    var display = row.style.display;

    if (display == "none") {
        if (window.navigator.userAgent.indexOf("Gecko") >= 0) {
            row.style.display = "table-row";
        } else {
            row.style.display = "block";
        }

        link.innerHTML = msg_fecha;
    } else {
        row.style.display = "none";
        link.innerHTML = msg_abre;
    }
}
/* fim função que abre / fecha texto */

/* inicio da funcao que abre uma janela */
var popupWindow;
function abrir_popup(arg, nomepopup, largura, altura, barra_scroll) {
	var valor = 20;
	var val_alt = parseInt(altura) + valor;
	var val_larg = parseInt(largura) + valor;
	var pos_left = screen.width/2 - parseInt(largura)/2;
//	var pos_top = screen.height/2 - parseInt(altura)/2;
	var pos_top = 0;
	if(barra_scroll == 1){
		var tipo_barra_scroll = "yes";
	}else{
		var tipo_barra_scroll = "no";
	}
	if(popupWindow){
		popupWindow.close();
		popupWindow = null;
	}
	popupWindow = window.open(arg, nomepopup,'toolbar=no,location=no,menubar=no,status=no,width='+largura+',height='+altura+',scrollbars='+tipo_barra_scroll+', left='+pos_left+', top='+pos_top+''); 
	popupWindow.focus();
	return;
}
/* fim da funcao que abre uma janela */


/* inicio da funcao que abre uma janela redimensionavel*/
var popupWindowRedim;
function abrir_popup_redim(arg, nomepopup, largura, altura, barra_scroll) {
	var valor = 20;
	var val_alt = parseInt(altura) + valor;
	var val_larg = parseInt(largura) + valor;
	var pos_left = screen.width/2 - parseInt(largura)/2;
//	var pos_top = screen.height/2 - parseInt(altura)/2;
	var pos_top = 0;
	if(barra_scroll == 1){
		var tipo_barra_scroll = "yes";
	}else{
		var tipo_barra_scroll = "no";
	}
	if(popupWindowRedim){
		popupWindowRedim.close();
		popupWindowRedim = null;
	}
	popupWindowRedim = window.open(arg, nomepopup,'resizable=yes,toolbar=no,location=no,menubar=no,status=no,width='+largura+',height='+altura+',scrollbars='+tipo_barra_scroll+', left='+pos_left+', top='+pos_top+''); 
	popupWindowRedim.focus();
	return;
}
/* fim da funcao que abre uma janela */


/* inicio da funcão q formata CPF */
function mascara_cpf(cpf){ // Esta eh a funcao que formata o cpf. 
	var mycpf = ''; 
    mycpf = mycpf + cpf; 
    if (mycpf.length == 3){ 
    	mycpf = mycpf + '.'; 
        document.forms[0].cpf.value = mycpf; 
	} 
    if (mycpf.length == 7){ 
    	mycpf = mycpf + '.'; 
        document.forms[0].cpf.value = mycpf; 
	} 
    if (mycpf.length == 11){ 
    	mycpf = mycpf + '-'; 
        document.forms[0].cpf.value = mycpf; 
	} 
    if (mycpf.length == 14){ } 
} 
/* fim da funcão q formata CPF */


/* funcao q formata numeros de telefone*/
function TelefoneFormat(Campo, e) { 
    var key = ''; 
    var len = 0; 
    var strCheck = '0123456789'; 
    var aux = ''; 
    var whichCode = (window.Event) ? e.which : e.keyCode; 
     
    if (whichCode == 13 || whichCode == 8 || whichCode == 0) 
    { 
        return true;  // Enter backspace ou FN qualquer um que não seja alfa numerico 
    } 
    key = String.fromCharCode(whichCode); 
    if (strCheck.indexOf(key) == -1){ 
        return false;  //NÃO E VALIDO 
    } 
     
    aux =  Telefone_Remove_Format(Campo.value); 
     
    len = aux.length; 
    if(len>=10) 
    { 
        return false;    //impede de digitar um telefone maior que 10 
    } 
    aux += key; 
     
    Campo.value = Telefone_Mont_Format(aux); 
    return false; 
} 

function  Telefone_Mont_Format(Telefone) 
{ 
    var aux = len = ''; 
     
    len = Telefone.length; 
    if(len<=9) 
    { 
        tmp = 5; 
    } 
    else 
    { 
        tmp = 6; 
    } 
     
    aux = ''; 
    for(i = 0; i < len; i++) 
    { 
        if(i==0) 
        { 
            aux = '('; 
        } 
        aux += Telefone.charAt(i); 
        if(i+1==2) 
        { 
            aux += ')'; 
        } 
         
        if(i+1==tmp) 
        { 
            aux += '-'; 
        } 
    } 
    return aux ; 
} 

function  Telefone_Remove_Format(Telefone) 
{ 
    var strCheck = '0123456789'; 
    var len = i = aux = ''; 
    len = Telefone.length; 
    for(i = 0; i < len; i++) 
    { 
        if (strCheck.indexOf(Telefone.charAt(i))!=-1) 
        { 
            aux += Telefone.charAt(i); 
        } 
    } 
    return aux; 
} 
/* fim da funcao q formata numeros de telefone*/

/* funcao para formatar cep */
function completaCEP(campo) 
{ 
      qtdcaracteres = (campo.value).length; 

      if(qtdcaracteres == 5) 
        campo.value = campo.value + "-"; 
}
/* fim da funcao para formatar cep */

/* funcao para checar varios tipos de campos */
function checar(tipo,obj){ 
    var str; 

    if(tipo == 'num') // campos numéricos 
        str = " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZçÇáéíóúÁÉÍÓÚàÀâêîôûÂÊÎÔÛãõÃÕäëïöüÄËÏÖÜ@*.,;:~!?/|\\'\"<>()[]{}&%#-_=+¨^§º¢£¬ª°"; 
    if(tipo == 'numdifzero') // campos numéricos diferentes de zero
        str = " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZçÇáéíóúÁÉÍÓÚàÀâêîôûÂÊÎÔÛãõÃÕäëïöüÄËÏÖÜ@*.,;:~!?/|\\'\"<>()[]{}&%#-_=+¨^§º¢£¬ª°0"; 
    if(tipo == 'numd') // campos com números fracionados 
        str = " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZçÇáéíóúÁÉÍÓÚàÀâêîôûÂÊÎÔÛãõÃÕäëïöüÄËÏÖÜ@*;:~!?/|\\'\"<>()[]{}&%#-_=+¨^§º¢£¬ª°"; 
	else if(tipo == 'numdponto') // campos com números fracionados somente com ponto (.)
        str = " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZçÇáéíóúÁÉÍÓÚàÀâêîôûÂÊÎÔÛãõÃÕäëïöüÄËÏÖÜ@*;:~!?/|\\'\"<>()[]{}&%#-_=+¨^§º¢£¬ª°,"; 
    else if(tipo == 'data') // campos de data 
        str = " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZçÇáéíóúÁÉÍÓÚàÀâêîôûÂÊÎÔÛãõÃÕäëïöüÄËÏÖÜ@*.,;:~!?|\\'\"<>()[]{}&%#-_=+¨^§º¢£¬ª°"; 
    else if(tipo == 'cep') // campos de cep 
        str = " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZçÇáéíóúÁÉÍÓÚàÀâêîôûÂÊÎÔÛãõÃÕäëïöüÄËÏÖÜ@*,;:~!?/|\\'\"<>()[]{}&%#_=+¨^§º¢£¬ª°"; 
    else if(tipo == 'cpfcnpj') // campos de cnpj e cpf 
        str = " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZçÇáéíóúÁÉÍÓÚàÀâêîôûÂÊÎÔÛãõÃÕäëïöüÄËÏÖÜ@*,;:~!?|\\'\"<>()[]{}&$%#_=+¨^§º¢£¬ª°`´"; 
    else if(tipo == 'fone') // campos de telefone 
        str = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZçÇáéíóúÁÉÍÓÚàÀâêîôûÂÊÎÔÛãõÃÕäëïöüÄËÏÖÜ@*.,;:~!?/|\\'\"<>[]{}&%#_=+¨^§º¢£¬ª°"; 
    else if(tipo == 'letra') // campos alfabéticos 
        str = "1234567890äëïöüÄËÏÖÜ@*;:~!?/|\\'\"<>[]{}&$%#_=+¨^§º¢£¬ª°"; 

    else if(tipo == 'letranumpontuacao') // campos alfabéticos com números, pontos e pontuação
        str = "äëïöüÄËÏÖÜ@*:~/|\\'<>[]{}&$%#_=+¨^§º¢£¬ª°"; 

    else if(tipo == 'letranum') // campos alfabéticos com numeros e pontos
        str = "äëïöüÄËÏÖÜ@*;:~!?/|\\'\"<>[]{}&$%#_=+¨^§º¢£¬ª°"; 

    else if(tipo == 'letranumcaract') // campos alfabéticos com numeros e pontos
        str = "äëïöüÄËÏÖÜ@*;~!?|\\'\"<>[]{}&$%#=+¨^§º¢£¬ª°"; 

    else if(tipo == 'email') // campos alfabéticos com caracteres usados em email como ._@
        str = "äëïöüÄËÏÖÜ*,;:~!?/|\\'\"<>[]{}&$%#=+¨^§º¢£¬ª°"; 
    
	if(obj.value != ''){ 
        tam = str.length; 
        for(x=0;x<tam;x++){ 
            if(obj.value.indexOf(str.substr(x,1)) != -1){ 
                obj.value = obj.value.substr(0,obj.value.length-1) 
                break; 
            } 
        } 
    } 
} 

/* Ex.:
<input type="text" name="textbox" onFocus="checar('letra',this);" onKeyDown="checar('letra',this);" onKeyUp="checar('letra',this);"> */
/* fim da funcao para checar varios tipos de campos */

/* inicio da função que formata campo monetario */
function currencyFormat(fld, milSep, decSep, e) {
	var sep = 0;
	var key = '';
	var i = j = 0;
	var len = len2 = 0;
	var strCheck = '0123456789';
	var aux = aux2 = '';
	var whichCode = (window.Event) ? e.which : e.keyCode;
	if (whichCode == 13) return true;  // Enter
	if (whichCode == 8) return true;  // Delete (Bug fixed)
	key = String.fromCharCode(whichCode);  // Get key value from key code
	if (strCheck.indexOf(key) == -1) return false;  // Not a valid key
	len = fld.value.length;
	for(i = 0; i < len; i++)
		if ((fld.value.charAt(i) != '0') && (fld.value.charAt(i) != decSep)) break;
	aux = '';
	for(; i < len; i++)
		if (strCheck.indexOf(fld.value.charAt(i))!=-1) aux += fld.value.charAt(i);
	aux += key;
	len = aux.length;
	if (len == 0) fld.value = '';
	if (len == 1) fld.value = '0'+ decSep + '0' + aux;
	if (len == 2) fld.value = '0'+ decSep + aux;
	if (len > 2) {
		aux2 = '';
		for (j = 0, i = len - 3; i >= 0; i--) {
			if (j == 3) {
				aux2 += milSep;
				j = 0;
			}
			aux2 += aux.charAt(i);
			j++;
		}
		fld.value = '';
		len2 = aux2.length;
		for (i = len2 - 1; i >= 0; i--)
			fld.value += aux2.charAt(i);
		fld.value += decSep + aux.substr(len - 2, len);
	}
	return false;
}
/*
Ex de uso:
<input type=text name=test length=15 onKeyPress="return(currencyFormat(this,',','.',event))">
*/
/* fim da função que formata campo monetario */


/* função que adiciona url aos Favoritos */
function bookmark(url,title){
  if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4)) {
  window.external.AddFavorite(url,title);
  } else if (navigator.appName == "Netscape") {
    window.sidebar.addPanel(title,url,"");
  } else {
    alert("Pressione CTRL-D (Netscape) ou CTRL-T (Opera) para Adicionar nos Favoritos");
  }
}
/* fim da função que adiciona url aos Favoritos */


/* função que formata e valida CPF */
function campo_numerico (){
	if (event.keyCode < 45 || event.keyCode > 57) event.returnValue = false;
}
	function mascara_cpf (campo,documento,f){
		var mydata = '';
		mydata = mydata + documento;

		if (mydata.length == 3){
			mydata   = mydata + '.';

			ct_campo = eval("document."+f+"."+campo+".value = mydata");
			ct_campo;
		}

		if (mydata.length == 7){
					mydata   = mydata + '.';

					ct_campo = eval("document."+f+"."+campo+".value = mydata");
					ct_campo;
		}

		if (mydata.length == 11){
			mydata 	  = mydata + '-';

			ct_campo1 = eval("document."+f+"."+campo+".value = mydata");
			ct_campo1;
		}

		if (mydata.length == 14){

			valida_cpf(f,campo);
		}

	}
	
	function valida_cpf(f,campo){
		pri = eval("document."+f+"."+campo+".value.substring(0,3)");
		seg = eval("document."+f+"."+campo+".value.substring(4,7)");
		ter = eval("document."+f+"."+campo+".value.substring(8,11)");
		qua = eval("document."+f+"."+campo+".value.substring(12,14)");

		var i;
		var numero;

		numero = (pri+seg+ter+qua);

		s = numero;
		c = s.substr(0,9);
		var dv = s.substr(9,2);
		var d1 = 0;

		for (i = 0; i < 9; i++){
			d1 += c.charAt(i)*(10-i);
		}

		if (d1 == 0){
			var result = "falso";
		}

		d1 = 11 - (d1 % 11);
		if (d1 > 9) d1 = 0;

		if (dv.charAt(0) != d1){
			var result = "falso";
		}

		d1 *= 2;
		for (i = 0; i < 9; i++){
			d1 += c.charAt(i)*(11-i);
		}

		d1 = 11 - (d1 % 11);
		if (d1 > 9) d1 = 0;

		if (dv.charAt(1) != d1){
			var result = "falso";
		}


		if (result == "falso") {
			alert("CPF inválido!");
			aux1 = eval("document."+f+"."+campo+".focus");
			aux2 = eval("document."+f+"."+campo+".value = ''");

		}
	}


function campo_focus(campo_completo){
	campo_completo.focus();
}

function campo_select(campo_completo){
	campo_completo.select();
}


function selectContent( element, lock, only_once ) {
    if ( only_once && only_once_elements[element.name] ) {
        return;
    }

    only_once_elements[element.name] = true;

    if ( lock  ) {
        return;
    }

    element.select();
}

function emdesenvolvimento(){
	alert("Esta área está em desenvolvimento!\n\nAguarde...");
	return false;
}

function resize_tela(largura, altura) {
	var vl = 10;
	var va = 50;
 	window.resizeTo(largura + vl, altura + va);
}

function checar_caps_lock(ev) {
	var e = ev || window.event;
	codigo_tecla = e.keyCode?e.keyCode:e.which;
	tecla_shift = e.shiftKey?e.shiftKey:((codigo_tecla == 16)?true:false);
	if(((codigo_tecla >= 65 && codigo_tecla <= 90) && !tecla_shift) || ((codigo_tecla >= 97 && codigo_tecla <= 122) && tecla_shift)) {
		document.getElementById('aviso_caps_lock').style.display = "block";
	}
	else {
		document.getElementById('aviso_caps_lock').style.display = "none";
	}
}

function msg_alerta(mensagem){
	alert(mensagem);
	return false;
}


function mostra_div(div,valor){
	if(valor == 1){
		document.getElementById(div).style.display = "block";
	}else{
		document.getElementById(div).style.display = "none";
	}
}

function checar_caps_lock_novo(ev) {
	var e = ev || window.event;
	codigo_tecla = e.keyCode?e.keyCode:e.which;
	tecla_shift = e.shiftKey?e.shiftKey:((codigo_tecla == 16)?true:false);
	if(((codigo_tecla >= 65 && codigo_tecla <= 90) && !tecla_shift) || ((codigo_tecla >= 97 && codigo_tecla <= 122) && tecla_shift)) {
		document.getElementById('aviso_caps_lock').style.display = "block";
	}
	else {
		document.getElementById('aviso_caps_lock').style.display = "block";
	}
}

function confere_campos() {
        form = document.forms.form1;
        for (i = 0; i < form.elements.length; i++) {
                if (form.elements[i].type == "text") {
                        if (form.elements[i].value == '') {
                                document.form1.elements[i].className = "destaca";
                        }
                        else {
                                document.form1.elements[i].className = "normal";
                        }
                }
        }
}

function checar_caps_lock_div(ev, nmdiv) {
	var e = ev || window.event;
	codigo_tecla = e.keyCode?e.keyCode:e.which;
	tecla_shift = e.shiftKey?e.shiftKey:((codigo_tecla == 16)?true:false);
	if(((codigo_tecla >= 65 && codigo_tecla <= 90) && !tecla_shift) || ((codigo_tecla >= 97 && codigo_tecla <= 122) && tecla_shift)) {
		document.getElementById(nmdiv).style.visibility = 'visible';
	}
	else {
		document.getElementById(nmdiv).style.visibility = 'hidden';
	}
}

function abrefecha_div(id_div) {
	if (document.getElementById(id_div).style.display == 'none'){
		document.getElementById(id_div).style.display = 'block';
	}else{
		document.getElementById(id_div).style.display = 'none';
	}
}

/* inicio - função para jogar o valor hexa da cor no campo de texto determinado */
function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}
function MM_changeProp(objName,x,theProp,posicao,theValue) { //v3.0
	var obj = MM_findObj(objName);
	if (obj && (theProp.indexOf("style.")==-1 || obj.style)){
		nm_campo = "cpick_" + objName;
		var nm_campo_obj = MM_findObj(nm_campo);
  		if(theValue=="transparent"){
			eval("obj."+theProp+"='transparent'");
			nm_campo_obj.bgColor="transparent";
		}else{
			eval("obj."+theProp+"='#"+theValue+"'");
			nm_campo_obj.bgColor="#"+theValue;
		}
	}
}
/* 
MM_changeProp('<?=$campo_cor;?>','','value','FF0000','INPUT/TEXT')
function MM_changeProp(objName,x,theProp,theValue, posicao) { //v3.0

MM_changeProp('<?=$nm_campo;?>','','value','INPUT/TEXT','ffffff')"
function MM_changeProp(objName,x,theProp, posicao,theValue) { //v3.0

fim - função para jogar o valor hexa da cor no campo de texto determinado */
