
  var Destaque = 
  {   
        list: Array(),
        
		init: function (codigo, desc, image)
        {
           var d = new Object();
           d.codigo = codigo;
		   d.desc = desc;
		   d.image = image;
		   this.list.push(d); 
		},
		
		show: function (idx)
		{
		   var link;
		   
		   idx = idx == undefined ? 0 : idx;
		   
		   link = "conteudo.php?id="+this.list[idx].codigo;
		   
		   $("#corpo-central-centro #destaques").css('background-image', 'url("'+this.list[idx].image+'")');
		   $("#leads p").html("<a href= '"+link+"'>" + this.list[idx].desc + "</a>");
		   
		   var btnOpac = $("#botoes p img").get(idx);
		   $("#botoes p img").css("opacity", 1);
		   $(btnOpac).css("opacity", .5);
		   
		   return this.list[idx];		   
		}
  }

  var jLoginBox = 
	{			
		check: function(formObj)
		{
			var login = formObj.login;
			var senha = formObj.senha;
			var loginOptions = { dataType: 'json', success: this.success };
					
			if (fcForm.trim(login.value) == "")
			{
				login.focus();
				return false;
			} else if (fcForm.trim(senha.value) == "")
			{
				senha.focus();
				return false;
			}
			
			$(formObj).hide();
			$("#loginLoading").show();																										
			$(formObj).ajaxSubmit(loginOptions);
			
			return false;
		},

		success: function(ret)
		{
			$("#loginLoading").hide();
			
			if (!ret.success)
			{
				$("#frmUserLogin").show();
				alert("Login ou senha incorreta!\nPor favor verifique os dados e tente novamente.");
			} else
			{
			    $("#tit-area-restrita").append("<h4 style='margin-top: 20px'>Sucesso! Aguarde Enquanto Recarregamos a Página...</h4>");
			    
			    setTimeout(function () {
 					 window.location.reload();
			    }, 1500);
			    
			}
		}
  }

  if (typeof search != "object")
	search =
	{
	
	 selType: function(idType) {
	 	
	 	$('#ajaxLoaded').css('display', 'inline');
	  $("#newSearch").load('pages/search.php?type=' + idType, function() { $('#ajaxLoaded').hide() });
	  
    $("." + idType).css('font-weight', 'bold');
	  
    if (idType == 1)
      $(".2").css('font-weight', 'normal');
      
    else
      $(".1").css('font-weight', 'normal');
	   
	 
	 }
	
	}

  if (typeof conteudo != "object")
  conteudo =
  {
	  
		doMural: function(formObj) {
			
			var tLen = document.getElementById('texto').value.length;
			
			if (tLen == "" || tLen == 0)
				return false;
			
			$(formObj).ajaxSubmit({success: function(receivedText){ 
			   if (!receivedText.match(/<script>alert\(/))
					 $('#sendComment').hide(); 
				 
				 $('#sendComm').fadeOut();
				 $('#sendComm').html(receivedText).fadeIn(); 
				 $('#muralForm').resetForm(); 
			}});				
			
			return false;
		},
	  
		doComment: function(formObj, idCont) {
		  
			textValue = fcForm.trim(formObj.texto.value);
			
		  if (textValue.length > 1024) {
		    alert('Você só pode escrever até 1024 caracteres! Você digitou ' + textValue.length + ' caracteres.');
		    return false;
		  }
		    

			if (textValue == "") {
				alert('Por favor, digite algum comentário.');
				return false;
			}
			
			$('#ajaxSuccess').hide();
			$('#ajaxLoading').show();		
			
			$('#enviar').attr('disabled', 'disabled');
			
			$(formObj).ajaxSubmit({success: function(receivedText){ 
					$('#ajaxSuccess').html(receivedText).fadeIn();
					
					if (receivedText.match(/Seu comentário/)) {
						$('#formColab').resetForm(); 
						$("#counterHtml").html('1024');
					}
					
					else 
						$('#enviar').attr('disabled', false);
						
			}});
				
			$(formObj).ajaxStop(function() {
			 $('#ajaxLoading').hide();
      });
			
			setTimeout(function() { $("#comentarios").load('pages/conteudo.comments.php?limitCom=2') }, 400);
			
			return false;
		
		},
		
		showAllComments: function(listAll) {		
		 
      $("#ajaxCommLoading").show();
			$("#comentarios").load('pages/conteudo.comments.php?limitCom=' + listAll, function() { 
				$("#ajaxCommLoading").hide();
		 });
		 
		},
	
	  countChar: function(thisObj) 
		{
			var limit = 1024;
			
      if (thisObj.value.length >= limit)
        thisObj.value = thisObj.value.substr(0, (limit-1));
    
      setTimeout(function () {
       document.getElementById('counterHtml').innerHTML = thisObj.value.length <= limit ? (limit - thisObj.value.length) : 0;        
      }, 30);
    
    },
    
    removeComm: function(idCol, limitCom) {
    
      $("#comentarios").load('pages/conteudo.comments.php?delCom=' + idCol + '&limitCom=' + limitCom);
    
    },
		
		changeType: function(changeDesc, idArea, thiz, area) {
			
			$("#nAjax").hide();
			$("#areaLoading").show();
			
			newLink = "pages/subarea.list.php?id=";
			
			if (area == true)
				newLink = "pages/area.list.php?id=";
			
			$("#nAjax").load(newLink + idArea + '&type=' + changeDesc, function() { $("#areaLoading").hide(); $(this).show() } );
			
			$('.orderNum').removeClass('orderSel');
			$(thiz).parent().addClass('orderSel');
		
		}
		
	}

  if (typeof enq != "object")
  enq =
  {

   sendVote: function (itemObj, cod_enq, base_url) {

      var i = 0;
      
      if (itemObj.option.length == undefined && itemObj.option && itemObj.option.checked == true)
      {
        itens = 1;
        i++;
      }
      else
      {
        itens = itemObj.option.length;
        
        for (var x = 0; x < itens; x++)   {
            if (itemObj.option[x].checked == true && itemObj.option[x]) 
            i++; 
        }
        
      }
      if (i == 0) { alert('Por favor, selecione uma opção.'); return false; }

      $(itemObj).ajaxSubmit({success: function(receivedText){ 
      	
				recArr = receivedText.match('^x\{(.+)');
				if (recArr)
					alert(recArr[1]);
		
				else {
					$('#dataInfo').html(receivedText);
					$('#dataInfo').fadeIn(600);
					enq.showResults(cod_enq, base_url);
				}
					
			}});
      
      return false;
    },
    
    showResults: function (cod, base_url) {
    
     $('#newAjax').hide();
 			
 		 $('#loadingAjax').show();
		 $('#showResults').load(base_url + 'action/do.vote.php?showResult=' + cod, function() { $('#loadingAjax').hide(); $(this).show() });
		
    },
    
    back2Vote: function() {
      $('#showResults').hide();
      $('#newAjax').show(); 
    }    
  }
  	
  if (typeof fcForm != "object")
  fcForm = 
  {

    setFocus: function(myInput, message)
    {
      if (this.trim(myInput.value) == message)
        myInput.value = '';
    },
    
    setBlur: function(myInput, message)
    {
      if (this.trim(myInput.value) == '')
        myInput.value = message;
    },

    trim: function(val) 
    { 
      return val.replace(/^\s+|\s+$/, ''); 
    },
    
    isBlank: function(elementId)
    {
        var element = typeof(elementId) != "object" ? document.getElementById(elementId) : elementId;
        var value   = element.value;
        var originalMsg = element.getAttribute('val');
        
        if (this.trim(value) == '' || this.trim(value) == originalMsg)
    		return true;
    		
    	return false;
    },
  
    fix: function(formName)
    {
      var formElement = document.getElementById(formName);
      for (var i = 0; i < formElement.length; i++)
      {
        var myValue = formElement[i].getAttribute('value');
        formElement[i].setAttribute('val', myValue);
      }
    }
  }
    		  
  function openURL(url, name, opts)
  {
     window.open(url, name, opts);
  }
 
  $(document).ready(function ()
  {
     $("#corpo-central-menu h1.sub").click(function ()
     {
        if ($(this).next().css("display") == "none")
           $(this).next().fadeIn();
        else
           $(this).next().fadeOut();
   	 });
  });
  
	var sizes = new Array('xx-small','x-small','small','medium','large');
	var atualSize = 2;
			
	function fontSize(type) {
		var newSize = atualSize
		newSize += type;
		
		if (newSize < 0) newSize = 0;
		if (newSize > 4) newSize = 4;
		
		atualSize = newSize;
		
		$("#conteudo p").css("font-size", sizes[newSize]);
		
	}
	
	function stripAccents(str) {
    
    var replaceChars = new Array(
    /[áàâãª]/ig,
    /[éèê]/ig,
    /[ìîí]/ig,
    /[óòôõº]/ig,
    /[ùûú]/ig,
    /[ç]/ig
    );
    
    var newChars = new Array(
     "a", "e", "i", "o", "u", "c"
    );
    
    for (var i = 0; i < replaceChars.length; i++) {
      str = str.replace(replaceChars[i], newChars[i]);
    } 
    
    return str;
	}
	
	function fix_next_form(form) {
    new_value = form.value;
    if(new_value.match(/^Contabilista$/))
      $(form.parentNode).next().show();
    else
      $(form.parentNode).next().hide()
  }
  
  function open_webradio()
	{
		window.open('webradio.php', 'webradio', 'width=910, height=543, top=150, left=150, scrollbars=no, status=no, toolbar=no, location=no, directories=no, menubar=no, resizable=no, favoritos=no, fullscreen=no')
	}