//****************************************
// Java Scripts de utilização interna
// Escrito por Mauricio Cunha
//****************************************

<!--
newbg="#6a91bf";
highlight_color = "Red";
bg = "";
lThis = "";
Obg="";
var site = "http://www.vbmania.com.br";
var description = "VBMania";
var browser = navigator.appName;
var version = navigator.appVersion.substring(0,1);
var ie = ((browser == "Microsoft Internet Explorer") && (version >= 4));
var ns = ((browser == "Netscape") && (version >= 4 && version < 5));
var True = -1;
var False = 0;
var seltext = null;
var flashlinks=new Array()

if (window.addEventListener)
{
	window.addEventListener("load", init, false);
}
else if (window.attachEvent)
{
	window.attachEvent("onload", init);
}
else if (document.all)
{
	window.onload=init;
}

 
function emailcheck(str)
{
   var at="@"
   var dot="."
   var lat=str.indexOf(at)
   var lstr=str.length
   if (str.indexOf(at)==-1) return false;
   if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr) return false;
   if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr) return false;
   if (str.indexOf(at,(lat+1))!=-1) return false;
   if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot) return false;
   if (str.indexOf(dot,(lat+2))==-1) return false;
   if (str.indexOf(" ")!=-1) return false;
   if (str.indexOf("vbmania")!=-1) return false;
   return true;
}

function openWindow(url,iHeight,iWidth)
{
  popupWin = window.open(url,'New_Page','toolbar=no,location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, left=0, top=0, height=' + iHeight + ',width=' + iWidth + '');
}

function openWindowScroll(url,iHeight,iWidth)
{
  popupWin = window.open(url,'New_Page','toolbar=no,location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, left=0, top=0, height=' + iHeight + ',width=' + iWidth + '');
}

function openWindowScrollrs(url,iHeight,iWidth)
{
  popupWin = window.open(url,'New_Page','toolbar=no,location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, left=0, top=0, height=' + iHeight + ',width=' + iWidth + '');
}

function closeWindow()
{
    var howLong = 1000;
    t = null;
    t = setTimeout("self.close()",howLong);
}


function ClipForm() 
{
  holdtext.innerText = "VBMania - www.vbmania.com.br\n\n" + copyfrm.innerText + '\n\n';
  Copied = holdtext.createTextRange();
  Copied.execCommand("RemoveFormat");      
  Copied.execCommand("Copy");
}

function setDataType(cValue)
  {
    var isDate = new Date(cValue);
    if (isDate == "NaN")
      {
        if (isNaN(cValue))
          {
            cValue = cValue.toUpperCase();
            return cValue;
          }
        else
          {
            var myNum;
            myNum = String.fromCharCode(48 + cValue.length) + cValue;
            return myNum;
          }
        }
  else
      {
        var myDate = new String();
        myDate = isDate.getFullYear() + " " ;
        myDate = myDate + isDate.getMonth() + " ";
        myDate = myDate + isDate.getDate(); + " ";
        myDate = myDate + isDate.getHours(); + " ";
        myDate = myDate + isDate.getMinutes(); + " ";
        myDate = myDate + isDate.getSeconds();
        return myDate ;
      }
  }

function startpage() 
{
      if (ie) {
        document.body.style.behavior="url(#default#homepage)";
        document.body.setHomePage(site);
      }
      else 
	    { alert("Houve um erro ao definir VBMania como sua p&aacute;gina inicial !!! "); }
}

function favorites() 
{
	if (ie) 
	{ 
		window.external.AddFavorite(site,description); 
	}
	else 
	{
		if (ns) 
		{ 
			alert("Para adicionar aos favoritos utilize as teclas CTRL+D"); 
		}
		else 
		{ 
		  	alert("Adicionado com sucesso !"); 
		}
	}
}
	

//------------------------------------------------------
//Aceita somente numeros em um campo no evento keypress
//------------------------------------------------------
function isNum( caractere ) 
{ 
	var strValidos = "0123456789" 
	if ( strValidos.indexOf( caractere ) == -1 ) return false; 
	return true; 
} 

//------------------------------------------------------
// Teclas validas para digitacao de numeros
//------------------------------------------------------  
function validaTecla(campo, event) 
{ 
	var BACKSPACE = 8; 
	var SEPPOINT = 46; 
	var key; 
	var tecla; 
	CheckTAB=true; 
	  
	if(navigator.appName.indexOf("Netscape")!= -1) 
	{
		tecla= event.which; 
	}
	else 
	{
		tecla= event.keyCode;
	}
	key = String.fromCharCode(tecla); 
	if ( tecla == 13 ) return false; 
	if ( tecla == 0 ) return true;
	if ( tecla == BACKSPACE ) return true; 
	if ( tecla == SEPPOINT ) return true; 
	return (isNum(key)); 
} 


//-------------------------------------------------------------------------------------------------------------
//Retira acentos e caracteres estranhos do campo
//-------------------------------------------------------------------------------------------------------------
function troca(campo)
{ 
	var estranha = "ÁÉÍÓÚÀÈÌÒÙÂÊÎÔÛÃÕÇç;$%^&*()<>+=~`'"; 
	var correta  = "AEIOUAEIOUAEIOUAOCC               "; 
	var retorno = ""; 
	  
	campo.value = campo.value.toUpperCase(); 
	  
	for(i=0;i<estranha.length;i++) 
	 { 
	  for(j=0;j<campo.value.length;j++) 
	  { 
	   retorno = campo.value.replace(estranha.substr(i,1),correta.substr(i,1)); 
	   campo.value = retorno; 
	  } 
	 } 
} 

//-------------------------------------------------------------------------------------------------------------
//Limpa um campo caso nume tenha o valor igual ao valor default
//-------------------------------------------------------------------------------------------------------------
function clearFromDefault(finumd) 
{
   if(finumd.defaultValue == finumd.value) finumd.value = "";
}


//-------------------------------------------------------------------------------------------------------------
//Força o preenchimento de zero caso o campo seja nulo
//-------------------------------------------------------------------------------------------------------------
function forceZero(finumd)
{
  if(finumd.value == "") finumd.value = "0";
}


//-------------------------------------------------------------------------------------------------------------
//Formata um campo para numerico a partir de um valor currency
//-------------------------------------------------------------------------------------------------------------
function formatToNumber(num)
{
	var rep1 = /[.]/gi
	num = num.toString().replace(rep1, "");
	var rep2 = /[$,.]/gi
	num = num.toString().replace(rep2, "")/100;
	return num
}


//-------------------------------------------------------------------------------------------------------------
//Formata um campo para moeda
//-------------------------------------------------------------------------------------------------------------
function formatCurrency(num)
{
	num = num.toString().replace(/\$|\,/g, '');
	if (isNaN(num)) 
	{
		num = "0";
		sign = (num == (num = Math.abs(num)));
		num = Math.floor(num * 100 + 0.50000000001);
		cents = num % 100;
		num = Math.floor(num / 100).toString();
		if (cents < 10) 
		{
			cents = "0" + cents;
			for (var i = 0; i < Math.floor((num.length - (1 + i)) / 3); i++) {
				num = num.substring(0, num.length - (4 * i + 3)) + '.' +
				num.substring(num.length - (4 * i + 3));
			}
		}
		return (((sign)?'':'-') + num + ',' + cents);
	}
}

//------------------------------------------------------
//Formata uma data em dd/mm/yyyy
//------------------------------------------------------
function formatDia(vData)
{
	if(vData=="")return "";
	if(vData.indexOf('/')<0)
	 {
	  var vDia=vData.substring(0,2);
	  var vMes=vData.substring(2,4);
	  var vAno=vData.substring(4,8);
	 }
	else
	{
	  var vDia=vData.substring(0,2);
	  var vMes=vData.substring(3,5);
	  var vAno=vData.substring(6,10);
	}
	return vDia + "/" + vMes + "/" + vAno;
}

//------------------------------------------------------
//Valida uma data
//------------------------------------------------------
function isDate(dateStr) 
{
	var datePat = /^(\d{1,2})(\/|-)(\d{1,2})(\/|-)(\d{4})$/;
	var matchArray = dateStr.match(datePat); 
	
	if (matchArray == null) 
	{
	 return false;
	}
	
	day = matchArray[1];
	month = matchArray[3]; 
	year = matchArray[5];
	
	if (month < 1 || month > 12) 
	{
	 return false;
	}
	
	if (day < 1 || day > 31) 
	{
	 return false;
	}
	
	if ((month==4 || month==6 || month==9 || month==11) && day==31) 
	{
	 return false;
	}
	
	if (month == 2) 
	{
	 var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
	 if (day > 29 || (day==29 && !isleap)) 
	 {
	  return false;
	 }
	}
	return true
}

//------------------------------------------------------
// Retira textos estranhos
//------------------------------------------------------
function clearAllTags(fromobj)
{
	var tmpreturn = "";
	for (var i = 0; i < fromobj.length; i++) 
	 {
	  switch (fromobj.charAt(i))
	  {
	   case "/": 
	    tmpreturn += "";
	    break;
	   case "-": 
	    tmpreturn += "";
	    break;
	   case ".": 
	    tmpreturn += "";
	    break;
	   case ",": 
	    tmpreturn += "";
	    break;
	   default:  
	    tmpreturn += fromobj.charAt(i); 
	  }  
	 }
	return tmpreturn;
}

//------------------------------------------------------
//Conta caracteres de um campo do form em outro
//------------------------------------------------------
function textCounter(field, countfield, maxlimit)
{
	if (field.value.length > maxlimit) 
	{
		field.value = field.value.substring(0, maxlimit);
	}
	else 
	{
		countfield.value = maxlimit - field.value.length;
	}
}

//------------------------------------------------------
//Abri um link com base em um listbox
//------------------------------------------------------
function jumpTo(URL_List)
{
   var URL = URL_List.options[URL_List.selectedIndex].value;
   window.location.href = URL;
}

//------------------------------------------------------
//Muda a caption do button...
//------------------------------------------------------
function ChangeCaption(Botao)
{
	var tmpreturn = "";
	var tmpposicao = 0;
	
	tmpposicao = Botao.indexOf("/");
	if (tmpposicao == -1)
	{
		tmpreturn = Botao.replace("[","[/"); 
	}
	else  
	{
		tmpreturn = Botao.replace("[/","["); 
	}
	return tmpreturn;
}

//------------------------------------------------------
//Tags do forum
//------------------------------------------------------
function TagIt(input, tag, opcao, textasopcao) 
{
  var clientPC = navigator.userAgent.toLowerCase(); 
  var clientVer = parseInt(navigator.appVersion); 
  var is_ie = ((clientPC.indexOf("msie") != -1) && (clientPC.indexOf("opera") == -1));
  var is_nav = ((clientPC.indexOf('firefox')!=-1) && (clientPC.indexOf('mozilla')!=-1) && (clientPC.indexOf('spoofer')==-1) && (clientPC.indexOf('compatible') == -1) && (clientPC.indexOf('opera')==-1) && (clientPC.indexOf('webtv')==-1) && (clientPC.indexOf('hotjava')==-1));
  var is_moz = 0;
  var is_win = ((clientPC.indexOf("win")!=-1) || (clientPC.indexOf("16bit") != -1));
  var is_mac = (clientPC.indexOf("mac")!=-1);
  var seltext;
  var selit;
  var mode_moz = 0;
  var subtagini = "";
  var subtagfim = "";
  
  if (window.getSelection)
  {
      seltext = window.getSelection;
      selit = window.getSelection;
  }
  else if (document.getSelection)
  {
      seltext = document.getSelection();
      selit = document.getSelection();
  }
  
  if (tag == "table")
  {
   subtagini = "[th][td]Cabecalho[/td][/th][tr][td]";
   subtagfim = "[/td][/tr]";
  }

  if ((clientVer >= 4) && is_ie && is_win)
  {
    seltext = (document.all)? document.selection.createRange() : document.getSelection();
    selit = (document.all)? document.selection.createRange().text : document.getSelection();
  }
  else 
  {
   if (input.selectionEnd && (input.selectionEnd - input.selectionStart > 0)) mode_moz = 1;
  }
  if ((mode_moz == 1) && (is_moz == 0)) is_moz = 1;
   
  if (selit.length >=1)
  {
    if (seltext) 
    {
      if (textasopcao) opcao = seltext.text;
      if (tag=="*")
      {
        if (mode_moz == 0) seltext.text = "[*]" + seltext.text;  
        if (mode_moz == 1) mozWrap(input, "[*]", "");
      }
      else
      {
        if (opcao=="")
        { 
          if (mode_moz == 0) seltext.text = "[" + tag + "]" + subtagini + seltext.text + subtagfim +"[/" + tag + "]";
          if (mode_moz == 1) mozWrap(input, "[" + tag + "]" + subtagini, subtagfim + "[/" + tag + "]");
        }
        else
        {
          if (mode_moz == 0) seltext.text = "[" + tag + "=" + opcao + "]" + seltext.text + "[/" + tag + "]";
          if (mode_moz == 1) mozWrap(input, "[" + tag + "=" + opcao + "]", "[/" + tag + "]");
        }
      }
    }
    setCaretToEnd(input);
  }
  else 
  {
    if (tag=="*")
    {
      if (mode_moz == 0) input.value = input.value + "[*]";
      if (mode_moz == 1) mozWrap(input, "[*]", "");
    }
    else
    {
      if (opcao=="")
      { 
        if (mode_moz == 0) input.value = input.value + "[" + tag + "]" + subtagini + "   " + subtagfim + "[/" + tag + "]";
        if (mode_moz == 1) mozWrap(input, "[" + tag + "]" + subtagini, subtagfim + "[/" + tag + "]");
      }
      else
      {
        if (mode_moz == 0) input.value = input.value + "[" + tag + "=" + opcao + "]  [/" + tag + "]";
        if (mode_moz == 1) mozWrap(input, "[" + tag + "=" + opcao + "]", "[/" + tag + "]");
      }
    }
    
    if (input != null && input.value != null)
    {
  		setCaretToPos(input,input.value.length - tag.length - 4);
  	}
  }
  if (input != null) input.focus();
}


function TagItByID(id, tag, opcao, textasopcao) 
{
  var clientPC = navigator.userAgent.toLowerCase(); 
  var clientVer = parseInt(navigator.appVersion); 
  var is_ie = ((clientPC.indexOf("msie") != -1) && (clientPC.indexOf("opera") == -1));
  var is_nav = ((clientPC.indexOf('firefox')!=-1) && (clientPC.indexOf('mozilla')!=-1) && (clientPC.indexOf('spoofer')==-1) && (clientPC.indexOf('compatible') == -1) && (clientPC.indexOf('opera')==-1) && (clientPC.indexOf('webtv')==-1) && (clientPC.indexOf('hotjava')==-1));
  var is_moz = 0;
  var is_win = ((clientPC.indexOf("win")!=-1) || (clientPC.indexOf("16bit") != -1));
  var is_mac = (clientPC.indexOf("mac")!=-1);
  var seltext;
  var selit;
  var mode_moz = 0;
  var subtagini = "";
  var subtagfim = "";
  var input = document.getElementById(id);
  
  if (window.getSelection)
  {
      seltext = window.getSelection;
      selit = window.getSelection;
  }
  else if (document.getSelection)
  {
      seltext = document.getSelection();
      selit = document.getSelection();
  }
  
  if (tag == "table")
  {
   subtagini = "[th][td]Cabecalho[/td][/th][tr][td]";
   subtagfim = "[/td][/tr]";
  }

  if ((clientVer >= 4) && is_ie && is_win)
  {
    seltext = (document.all)? document.selection.createRange() : document.getSelection();
    selit = (document.all)? document.selection.createRange().text : document.getSelection();
  }
  else 
  {
   if (input.selectionEnd && (input.selectionEnd - input.selectionStart > 0)) mode_moz = 1;
  }
  if ((mode_moz == 1) && (is_moz == 0)) is_moz = 1;
   
  if (selit.length >=1)
  {
    if (seltext) 
    {
      if (textasopcao) opcao = seltext.text;
      if (tag=="*")
      {
        if (mode_moz == 0) seltext.text = "[*]" + seltext.text;  
        if (mode_moz == 1) mozWrap(input, "[*]", "");
      }
      else
      {
        if (opcao=="")
        { 
          if (mode_moz == 0) seltext.text = "[" + tag + "]" + subtagini + seltext.text + subtagfim +"[/" + tag + "]";
          if (mode_moz == 1) mozWrap(input, "[" + tag + "]" + subtagini, subtagfim + "[/" + tag + "]");
        }
        else
        {
          if (mode_moz == 0) seltext.text = "[" + tag + "=" + opcao + "]" + seltext.text + "[/" + tag + "]";
          if (mode_moz == 1) mozWrap(input, "[" + tag + "=" + opcao + "]", "[/" + tag + "]");
        }
      }
    }
    setCaretToEnd(input);
  }
  else 
  {
    if (tag=="*")
    {
      if (mode_moz == 0) input.value = input.value + "[*]";
      if (mode_moz == 1) mozWrap(input, "[*]", "");
    }
    else
    {
      if (opcao=="")
      { 
        if (mode_moz == 0) input.value = input.value + "[" + tag + "]" + subtagini + "   " + subtagfim + "[/" + tag + "]";
        if (mode_moz == 1) mozWrap(input, "[" + tag + "]" + subtagini, subtagfim + "[/" + tag + "]");
      }
      else
      {
        if (mode_moz == 0) input.value = input.value + "[" + tag + "=" + opcao + "]  [/" + tag + "]";
        if (mode_moz == 1) mozWrap(input, "[" + tag + "=" + opcao + "]", "[/" + tag + "]");
      }
    }
  setCaretToPos(input,input.value.length - tag.length - 4);
  }
  input.focus();
}


//------------------------------------------------------
//Suporte do forum...
//------------------------------------------------------
function mozWrap(txtarea, tagOpen, tagClose)
{
   var selStart = txtarea.selectionStart;
   var selEnd = txtarea.selectionEnd;
   var selLength = txtarea.textLength;
   if (selEnd == 1 || selEnd == 2) selEnd = selLength;
   var s1 = (txtarea.value).substring(0,selStart);
   var s2 = (txtarea.value).substring(selStart, selEnd)
   var s3 = (txtarea.value).substring(selEnd, selLength);
   
   if (tagOpen.indexOf("url")!=-1)
   {
     tagOpen = tagOpen.replace("]", s2 + "]");
     if (s2.indexOf("http://") != -1)
     {
        tagOpen = tagOpen.replace("http://","");
     }
   }  
   txtarea.value = s1 + tagOpen + s2 + tagClose + s3;
   return;
}

function ColorIt(input, cor) 
{
  TagIt(input, 'txt-color', cor, False);
}

function BackColorIt(input, cor) 
{
  TagIt(input, 'txt-backcolor', cor, False);
}

function SizeIt(input, tamanho) 
{
  TagIt(input,'txt-size', tamanho, False);
}

function setSelectionRange(input, selectionStart, selectionEnd) 
{
  if (input.setSelectionRange) 
  {
    input.focus();
    input.setSelectionRange(selectionStart, selectionEnd);
  }
  else if (input.createTextRange) 
  {
    var range = input.createTextRange();
    range.collapse(true);
    range.moveEnd('character', selectionEnd);
    range.moveStart('character', selectionStart);
    range.select();
  }
}

function setCaretToEnd (input) 
{
  setSelectionRange(input, input.value.length, input.value.length);
}

function setCaretToBegin (input) 
{
  setSelectionRange(input, 0, 0);
}

function setCaretToPos (input, pos) 
{
  setSelectionRange(input, pos, pos);
}

//------------------------------------------------------
//Ocultar/Exibir tabelas
//------------------------------------------------------
function HideTableColumn (colIndex) 
{
 var table = document.all ? document.all.aTable :
 document.getElementById('aTable');
 for (var r = 0; r < table.rows.length; r++)
 table.rows[r].cells[colIndex].style.display = 'none';
}

function ShowTableColumn (colIndex) 
{
 var table = document.all ? document.all.aTable :
 document.getElementById('aTable');
 for (var r = 0; r < table.rows.length; r++)
 table.rows[r].cells[colIndex].style.display = '';
}

//------------------------------------------------------
//Faz o label piscar
//------------------------------------------------------
function changelinkcolor()
{
  for (i=0; i< flashlinks.length; i++)
   {
    var flashtype = document.getElementById? flashlinks[i].getAttribute("flashtype")*1 : flashlinks[i].flashtype * 1
    var flashcolor = document.getElementById? flashlinks[i].getAttribute("flashcolor") : flashlinks[i].flashcolor
    if (flashtype==0)
     {
      if (flashlinks[i].style.color != flashcolor.toString()) 
	  {
	  	flashlinks[i].style.color = flashcolor.toString()
	  }
	  else 
	  {
	  	flashlinks[i].style.color = ''
	  }
     }
     else if (flashtype==1)
     {
         if (flashlinks[i].style.backgroundColor!=flashcolor.toString())
		 {
		 	flashlinks[i].style.backgroundColor=flashcolor.toString()
		 }
         else
		 {
		 	flashlinks[i].style.backgroundColor=''
		 }
     }
  }
}

function init()
{
	var i=0
	if (document.all)
	{
		while (eval("document.all.flashlink"+i)!=null)
		{
		  flashlinks[i]= eval("document.all.flashlink"+i);
		  i++;
		} 
	}
	else if (document.getElementById)
	{
		while (document.getElementById("flashlink"+i)!=null)
		{
			 flashlinks[i]= document.getElementById("flashlink"+i);
			 i++;
		}
	}
	setInterval("changelinkcolor()", 1000);
}


//------------------------------------------------------
//Gerenciamento de options em um select 
//------------------------------------------------------
var NS4 = (navigator.appName == "Netscape" && parseInt(navigator.appVersion) < 5);
function addOption(theSel, theText, theValue)
{
	var newOpt = new Option(theText, theValue);
	var selLength = theSel.length;
	theSel.options[selLength] = newOpt;
}

function deleteOption(theSel, theIndex)
{	
	var selLength = theSel.length;
	if(selLength>0)
	{
		theSel.options[theIndex] = null;
	}
}

function moveOptions(theSelFrom, theSelTo)
{
	var i;
	var selLength = theSelFrom.length;
	var selectedText = new Array();
	var selectedValues = new Array();
	var selectedCount = 0;
	
	for(i=selLength-1; i>=0; i--)
	{
		if(theSelFrom.options[i].selected)
		{
			selectedText[selectedCount] = theSelFrom.options[i].text;
			selectedValues[selectedCount] = theSelFrom.options[i].value;
			deleteOption(theSelFrom, i);
			selectedCount++;
		}
	}
	
	for(i=selectedCount-1; i>=0; i--)
	{
		addOptionNoPrompt(theSelTo, selectedText[i], selectedValues[i]);
	}
	
	if(NS4) history.go(0);
}


function addOption(objSelect,intUcase)
{
  var theDD = eval(objSelect);
  var newOption;
  var newDialog;
  var name;
  var value;
  newDialog = prompt('Informe o texto à adicionar para a listagem', '');
  if ( (newDialog == ' ') || (newDialog == null))
  {
   return false;
  }
  
  if ( intUcase == 1 )
  {
   name = newDialog.toUpperCase();
   value = newDialog.toUpperCase();
  } 
  else
  {
   name = newDialog;
   value = newDialog;
  }
  
  newOption= new Option (name,value);
  var insertAt = theDD.options.length;
  theDD.options.length=theDD.options.length + 1;
  theDD.options[insertAt] = newOption;
} 

function addOptionNoPrompt(objSelect,strText,strValue)
{
  var theDD = eval(objSelect);
  var newOption;
  var name;
  var value;

  newOption= new Option (strText,strValue);
  var insertAt = theDD.options.length;
  theDD.options.length=theDD.options.length + 1;
  theDD.options[insertAt] = newOption;
} 

function removeOptionSelected(objSelect)
{
  var i;
  for (i = objSelect.length - 1; i>=0; i--) 
  {
    if (objSelect.options[i].selected) {
      objSelect.remove(i);
    }
  }
}

//------------------------------------------------------
//Clona um objeto listbox para um listbox oculto
//------------------------------------------------------
function CloneListBoxToHiddenBox(oListBox,oTextBox)
{
  var lent = oListBox.length ;
  oTextBox.value = "";
  for (var i=0; i<lent; i++)
  { 
   oTextBox.value = oTextBox.value + oListBox.options[i].value + ";"; 
  }
 return true;
} 


tms=new Array()
function menu_over(n)
{
	if(typeof(tms[n])!="undefined")clearTimeout(tms[n])
	document.getElementById("s"+n).style.visibility="visible"
}

function menu_out(n)
{
	tms[n]=setTimeout('document.getElementById("s'+n+'").style.visibility="hidden"',200)
}

//------------------------------------------------------
//Confirma submissao de formulario genericamente
//------------------------------------------------------
function confirmSubmit()
{
  //Para chamar: onsubmit="return confirmSubmit()"
  var agree = confirm("Voce tem certeza absoluta que deseja continuar ?");
  if (agree)
  	return true ;
  else
  	return false ;
}

//------------------------------------------------------
//Muda a cor de uma linha em um table
//------------------------------------------------------
function highglightrowcheckbox(checkbox,ocolor,ohighcolor) 
{
    var nome = checkbox.name;
    var tmp = "";
    var indice = 0;
    for (var i = 0; i < nome.length; i++)
    {
      if (!isNaN(nome.substr(i))) tmp += nome.substr(i);
    }
    indice = parseInt(tmp);
    var obj = "TR" + indice;
    var tr = document.getElementById(obj);
    if (tr == null) return;
    if (checkbox.checked) 
    {
        tr.className = ohighcolor;
    } 
    else 
    {
       tr.className = ocolor;
    }
}


function Add_BBTags_To_Text(objTextArea)
   {
     var linhas = objTextArea.value.split("\n");
     var linha = 0;
     var texto = "";
     var textocheck = "";
     var textofinal = "";
     var criterio = "";
     var add_ini = 0;
     var add_fim = 0;
     var ult_ini = 0;
     var ult_end = 0;
     var iniciou = 0;

     while (linha < linhas.length)
     {
       texto = linhas[linha];
       add_ini = 0;
       add_fim = 0;

       if (Trim(texto) != "")
       {
         textocheck = LTrim(texto.toLowerCase());
         criterio = "sub ";              if ((textocheck.indexOf("[c]") == -1) && (textocheck.substr(0,criterio.length) == criterio)) add_ini = 1;
         criterio = "private sub ";      if ((textocheck.indexOf("[c]") == -1) && (textocheck.substr(0,criterio.length) == criterio)) add_ini = 1;
         criterio = "public sub ";       if ((textocheck.indexOf("[c]") == -1) && (textocheck.substr(0,criterio.length) == criterio)) add_ini = 1;
         criterio = "function ";         if ((textocheck.indexOf("[c]") == -1) && (textocheck.substr(0,criterio.length) == criterio)) add_ini = 1;
         criterio = "private function "; if ((textocheck.indexOf("[c]") == -1) && (textocheck.substr(0,criterio.length) == criterio)) add_ini = 1;
         criterio = "public function ";  if ((textocheck.indexOf("[c]") == -1) && (textocheck.substr(0,criterio.length) == criterio)) add_ini = 1;
         criterio = "public class ";     if ((textocheck.indexOf("[c]") == -1) && (textocheck.substr(0,criterio.length) == criterio)) add_ini = 1;

         criterio = "end sub";           if ((textocheck.indexOf("[/c]") == -1) && (textocheck.substr(0,criterio.length) == criterio)) add_fim = 1;         
         criterio = "end function";      if ((textocheck.indexOf("[/c]") == -1) && (textocheck.substr(0,criterio.length) == criterio)) add_fim = 1;
         criterio = "end class";         if ((textocheck.indexOf("[/c]") == -1) && (textocheck.substr(0,criterio.length) == criterio)) add_fim = 1;         
         
         if ((linha - ult_ini) <= 1) add_ini = 0;

         if (add_ini == 1) 
         {
            texto = "[c]" + texto;
            ult_ini = linha;
            iniciou = 1;
         }
         
         if (add_fim == 1 && iniciou == 1)
          {
            texto = texto.replace("Sub", "Sub[/c]");
            texto = texto.replace("sub", "Sub[/c]");
            texto = texto.replace("Function", "Function[/c]");
            texto = texto.replace("function", "Function[/c]");
            ult_fim = linha;
            iniciou = 0;
          }
       }
       textofinal += texto + "\n";
       linha +=1;
     }
     if (iniciou == 1) 
     {
       textofinal += "[/c]";
       iniciou = 0;
     }
     objTextArea.value = textofinal;
   }

function LTrim(value)
{
   var re = /\s*((\S+\s*)*)/;
   return value.replace(re, "$1");
}

function RTrim(value)
{
   var re = /((\s*\S+)*)\s*/;
   return value.replace(re, "$1");
}

function Trim( value )
{
   return LTrim(RTrim(value));
}

function openPreview(value)
{
  if (value == null)
  {
   return;
  }
  else
  {
    var newvalue = new String(value);
    newvalue = newvalue.replace("#","¢");
    window.open("vbmtextpreview.php?ocultar=1&TxtMensagem=" + newvalue,'Preview','toolbar=no,location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, left=0, top=0, height=320,width=480');
  }  
}

//-----------------------------------------
//Copia o valor de um text para a area de
//transferencia, 
//copy(document.formtocopy.texttocopy);"
//--------------------------------------
function copyText(n) 
{
  copyme = n;
  if (document.selection)
  {
    textRange = document.body.createTextRange();
    textRange.moveToElementText(copyme);
    textRange.execCommand("Copy");
    alert("Conteudo copiado com sucesso !");
  }
  else
  {
    alert("Atencao:\n\nEsta funcao esta habilitada somente no Internet Explorer");
  }
}

function Minusculo(objID)
{
  var obj = document.getElementById(objID);
  obj.value = obj.value.toLowerCase();
}

function Maiusculo(objID)
{
  var obj = document.getElementById(objID);
  obj.value = obj.value.toUpperCase();
}



//popup window em css...
var popupStatus = 0;
function loadPopup()
{
  if(popupStatus==0)
    {
      $("#backgroundPopup").css({"opacity": "0.7"});
      $("#backgroundPopup").fadeIn("slow");
      $("#foregroundPopup").fadeIn("slow");
      popupStatus = 1;
    }
}

function disablePopup()
{
  if(popupStatus==1)
  {
    $("#backgroundPopup").fadeOut("slow");
    $("#foregroundPopup").fadeOut("slow");
    popupStatus = 0;
  }
}

function centerPopup()
{
  var posx = 0;
  var posy = 0;
  var e = window.event;
  if (!(e==null))
  {
    var targ = e.target ? e.target : e.srcElement;
    
    if(e.pageX||e.pageY)
    {
      posx = e.pageX;
      posy = e.pageY;
    }
    else if(e.clientX||e.clientY)
    {
      posx = e.clientX;
      posy = e.clientY;
    }
  }

  var windowWidth = document.documentElement.clientWidth;
  var windowHeight = document.documentElement.clientHeight;
  var popupHeight = $("#foregroundPopup").height();
  var popupWidth = $("#foregroundPopup").width();
  //$("#foregroundPopup").css({"position": "absolute","top": windowHeight/2-popupHeight/2,"left": windowWidth/2-popupWidth/2});
  $("#foregroundPopup").css({"position": "absolute","top": posy,"left": windowWidth/2-popupWidth/2});
  $("#backgroundPopup").css({"height": windowHeight});
}

function PopupShowSmiles()
{
  DisplayPopup("../pages/popsmiles.php");
}


function DisplayPopup(link)
{
  centerPopup();
  loadPopup();
  
  var obj = document.getElementById("popupContent");
  obj.innerHTML = "<p align='center'>Carregando, aguarde...<BR><img src='../images/popup/loading.gif' border='0'></p>";
  
  $.ajax({type: "GET",url: link, dataType: "html", 
      error: function()
      {
        obj.innerHTML = "<div class='msgbox-error'>Erro ao carregar " + link + "</div>";
      },
      success: function(data)
      {
        obj.innerHTML = data;
      }
      });
  
}

function submitonEnter(evt)
{
	var charCode = (evt.which) ? evt.which : event.keyCode
	if(charCode == "13")
	{
		document.form1.submit();
	}
}

function CheckInboxMessages()
{
    var elementos;
    elementos = document.getElementById("FrmCaixaPostal");
    for (i = 0; i < elementos.elements.length; i++)
    {
	elementos.elements[i].checked = document.FrmCaixaPostal.ChkCheckAll.checked;
    }
}

function CheckAllItems(idform,idcheckboxall)
{
    var elementos;
    elementos = document.getElementById(idform);
    for (i = 0; i < elementos.elements.length; i++)
    {
	elementos.elements[i].checked = document.getElementById(idcheckboxall).checked;
    }
}




-->

