/*------------------------------------------------------*/
/*	VARIAVEIS GLOBAIS DO SISTEMA DE VALIDACAO DE DADOS	*/
/*------------------------------------------------------*/
var _perm = new Array();
var _mess = new Array();
var _conf = new Array();
var _gMsg = "";
var _isIE = false, _isNav = false;

/*------------------------------------------*/
/*	IDENTIFICACAO DO NAVEGADOR DO USUARIO		*/
/*------------------------------------------*/
if (navigator.appName.indexOf("Netscape") != -1) _isNav = true;
if (navigator.appName.indexOf("Microsoft") != -1 ) _isIE = true;


function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

var isNav, isIE, indVisivel
var browser = navigator.appName

// Descobre o browser
if (browser == "Microsoft Internet Explorer") { 
  isIE = true;
}
else {
  isNav = true;
} 

function validarData(oDia, oMes, oAno){
	var dia = parseInt(oDia.value,10);
	var mes = parseInt(oMes.value,10);
	var ano = parseInt(oAno.value,10);
	var teto = 0;
	var vetComp = new Array(0,3,0,3,2,3,2,3,3,2,3,2,3);

	if (isNaN(dia) || isNaN(mes) || isNaN(ano)) {
			return false;
	}

	if (ano%4 == 0 && mes == 2){
		teto = 29;
	}else{
		teto = 28+parseInt(vetComp[mes]);
	}
	if ( (dia < 1 || dia > teto) || (mes < 1 || mes > 12) ) {
			return false;
	}
	return true;		
}

/***************************/
/* Funções criadas por mim */
/***************************/


//-> Funções de data
	function cDate(){
		this.day;
		this.month;
		this.year;
		this.delimiter = "-";
		this.toYMD = toYMD;
		this.toDMY = toDMY;

	}

	function toYMD(){
		var D,M,Y,S;
		D = this.day;
		M = this.month;
		Y = this.year;
		S = this.delimiter;
		return (Y+S+M+S+D);
	}

	function toDMY(){
		var D,M,Y,S;
		D = this.day;
		M = this.month;
		Y = this.year;
		S = this.delimiter;
		return (D+S+M+S+Y);
	}



//-> Funções de data-hora
	function cDateHour(){
		this.day;
		this.month;
		this.year;
		this.hour;		
		this.delimiter = "-";
		this.delimiter1 = " ";		
		this.toYMDH = toYMDH;
		this.toDMYH = toDMYH;

	}

	function toYMDH(){
		var D,M,Y,H,S,B;
		D = this.day;
		M = this.month;
		Y = this.year;
		H = this.hour;
		B = this.delimiter;
		S = this.delimiter1;
		return (Y+B+M+B+D+S+H);
	}

	function toDMYH(){
		var D,M,Y,H,S,B;
		D = this.day;
		M = this.month;
		Y = this.year;
		H = this.hour;
		B = this.delimiter;
		S = this.delimiter1;
		return (D+B+M+B+Y+S+H);
	}


/*---------------------------------------*/
/* 		Classe de validação de Datas			 */	
/*---------------------------------------*/
function mDate(){
	this.strDay = "Favor preencha corretamente o valor do campo Dia."
	this.strMonth = "Favor preencha corretamente o valor do campo Mês."
	this.strYear = "Favor preencha corretamente o valor do campo Ano."
	this.error = false;
	this.lowerYear = 1899;
	this.day;
	this.month;
	this.year;
	this.objDay;
	this.objMonth;
	this.objYear;
	this.obr = false;
	this.sep = "/";
	this.printDate = printDMY;
	this.printDMY = printDMY;
	this.printMDY = printMDY;
	this.isYear = isYear;
	this.isMonth = isMonth;
	this.isDay = isDay;
	this.isDate = isDate;
	this.isNull = isNull;
	this.setDay = setDay;
	this.setMonth = setMonth;
	this.setYear = setYear;
	this.setDateDMY = setDateDMY;
	this.vetComp = new Array(2,4,1,4,3,4,3,4,4,3,4,3,4);
}

function printYMD(){
	var ret = "";
	with(this){
		if (isNull() && !this.obr) return ret;
		if (isDate())	ret = year+sep+month+sep+day;
	}
	return ret;
}

function printDMY(){
	var ret = "";
	with(this){
		if (isNull() && !this.obr) return ret;
		if (isDate())	ret = day+sep+month+sep+year;
	}
	return ret;
}

function printMDY(){
	var ret = "";
	with(this){
		if (isNull() && !this.obr) return ret;
		if (isDate())	ret = month+sep+day+sep+year;
	}
	return ret;
}

function isNull(){
	if (this.day == "" && this.month == "" && this.year == "") return true;
	return false;
}

function isYear(){
	if (this.year > this.lowerYear) return true;
	return false;
}

function isMonth(){
	if (this.month > 0 && this.month < 13) return true;
	return false;
}

function isDay(){
	var upperDays;
	if (Number(this.year)%Number(4) == 0 && Number(this.month) == 2){
		upperDays = Number(28)+Number(this.vetComp[0]);
	}else{
		upperDays = Number(28)+Number(this.vetComp[Number(this.month)]);
	}
	if (this.day > 0 && this.day < upperDays) return true;
	return false;
}

function isDate(){
	with(this){
		if (!isYear() ){
			objYear.focus();
			alert(strYear);
			objYear.value = "";
			error = true;
			return false;
		}
		if (!isMonth()){
			objMonth.focus();
			alert(strMonth);
			objMonth.value = "";
			error = true;
			return false;
		}
		if (!isDay()){
			objDay.focus();
			alert(strDay);
			objDay.value = "";
			error = true;
			return false;
		}
	}
	return true;
}

function setDay(objText){
	this.day = objText.value;
	this.objDay = objText;
	return;
}

function setMonth(objText){
	this.month = objText.value;
	this.objMonth = objText;
	return;
}

function setYear(objText){
	this.year = objText.value;
	this.objYear = objText;
	return;
}

function setDateDMY(objDay, objMonth, objYear){
	this.day = objDay.value;
	this.objDay = objDay;
	this.month = objMonth.value;
	this.objMonth = objMonth;
	this.year = objYear.value;
	this.objYear = objYear;
	return;
}


//-> Funções de string

	function estarVazio(objText){
	 	return !objText.value.match(/[a-zA-Z0-9]/g);
	}

	function serNumero(objText){
	 	return objText.value.match(/[0-9]/g);
	}
	
//-> Funções de conteudo

    function verInformacao(lcodArea, lcodItem){
      with(document.formConteudo){
				method = "get";
        action = "conteudo.php";
        codArea.value = lcodArea;
        codItem.value = lcodItem;
        if ( (lcodArea == 0 || lcodArea == -1) && (lcodItem == 0) ) {
          location.href='inicial.php'
        }else{
          submit();
        }
      }
      return;
    }


//-> Funções de conteudo

    function alterarMural(lcodArea){
      with(document.formConteudo){
        action='alterar_mural.php';
        codArea.value = lcodArea;
        submit();
      }
      return;
    }    
    
    function inserirItem(lcodArea){
      with(document.formConteudo){
        action='administracao/conteudo/principal.php';
        codArea.value = lcodArea;
        submit();
      }
      return;
    }        

//-> Função usada na gerencia das aplicações de conteudo

	function selecionarArea(strPaginaDestino, codAreaArg){
		with(document.form){
			codArea.value = codAreaArg;
			action = strPaginaDestino;
			submit();
		}
		return;
	}

function saltarCampo(campo_atual, event, tamanho_maximo, campo_proximo){
    var tecla;
    var vr;

    if (isNav)
        tecla = event.which;
    else
        tecla = event.keyCode;

    vr = campo_atual.value;
    tam = vr.length;

    if (tam >= tamanho_maximo && tecla >= 48)
        campo_proximo.focus();
}

	function retirarEspeciais(strEntrada){
		return strEntrada.replace(/\||;|'/g,"");
	}


 	function filtrarMaiusculas(evt){
	  if (isNav)
	    tecla = evt.which;
		else
	    tecla = evt.keyCode;
		if (tecla < 65){tecla = 0;}
		if (tecla > 123){tecla = 0;}
		if (tecla > 89 && tecla < 97){tecla = 0;}
		if (tecla > 96 && tecla < 123){tecla -= 32;}
	  if (isNav)
	    evt.which = tecla;
		else
	    evt.keyCode = tecla;
		return;
	}

 	function selecionarList(objList, numValor){
		var i;
		for(i=0; i < objList.length; i++){
			if(objList.options[i].value == numValor){
				objList.selectedIndex = i;
				return;
			}
		}
		return;
	}

	function filtrarNumeros(evt){
		var key;
		if (isNav || isIE){
			key = (isNav)? evt.which: evt.keyCode;
			return (key > 47 && key < 58) || key == 8 || key == 0 ? true: false;
		}
		return true;
	}


	function isEmpty(obj){
		var re;
		re = new RegExp("\\w+", "g");
		return !re.test(obj.value);
	}

	function isBetween(lower, upper, value){
		if (value >= lower && value <= upper)
		{
			return true;
		}
		else
		{
			return false;
		}
	}

	function validarHoraNow(obj, msg){
		var hora;
		hora = parseInt(obj.value, 10);
		if (!isEmpty(obj)){
			if (!isBetween(0, 23, hora)){
				alert(msg);
				obj.focus();
				return false;
			}
			else
			{
				return true;
			}
		}
		return false;
	}
	
	function validarMinutoNow(obj, msg){
		var min;
		min = parseInt(obj.value, 10);
		if (!isEmpty(obj)){
			if (!isBetween(0, 59, min)){
				alert(msg);
				obj.focus();
				return false;
			}
			else
			{
				return true;
			}
		}
		return false;
	}

	function validarDiaNow(obj, msg){
		var dia;
		dia = parseInt(obj.value, 10);
		if (!isEmpty(obj)){
			if (!isBetween(1, 31, dia)){
				alert(msg);
				obj.focus();
				return false;
			}
			else
			{
				return true;
			}
		}
		return false;
	}

	function validarMesNow(obj, msg){
		var mes;
		mes = parseInt(obj.value, 10);
		if (!isEmpty(obj)){
			if (!isBetween(1, 12, mes)){
				alert(msg);
				obj.focus();
				return false;
			}
			else
			{
				return true;
			}
		}
		return false;
	}
	
	function validarAnoNow(obj, msg){
		var ano;
		ano = parseInt(obj.value, 10);
		if (!isEmpty(obj)){
			if (ano < 1900 || isNaN(ano)){
				obj.focus();
				alert(msg);
				return false;
			}
			else
			{
				return true;
			}
		}
		return false;
	}

	function isIntervaloData(vetDataInicial, vetDataFinal, msg)
	{
		var msg_errodat = 'Favor preencher a data inicial corretamente';
		
		//Inicia variaveis
		objDiaI = vetDataInicial[0];
		objMesI = vetDataInicial[1];
		objAnoI = vetDataInicial[2];

		objDiaF = vetDataFinal[0];
		objMesF = vetDataFinal[1];
		objAnoF = vetDataFinal[2];

		//Valida as datas
		if (
			validarDiaNow(objDiaI, msg_errodat)
			&& validarMesNow(objMesI, msg_errodat)
			&& validarAnoNow(objAnoI, msg_errodat)
			&& validarDiaNow(objDiaF, msg_errodat)
			&& validarMesNow(objMesF, msg_errodat)
			&& validarAnoNow(objAnoF, msg_errodat)
		   )
		{
/*
			//Cria os obj de data
			var dat_inicial = new Date(objAnoI.value, objMesI.value, objDiaI.value);
			var dat_final = new Date(objAnoF.value, objMesF.value, objDiaF.value);

			if( dat_inicial.getTime() <= dat_final.getTime() )
			{
				return true;
			}
			else
			{
				alert(msg);
				return false;
			}
*/
			return true;
		}
		else
		{
			return false;
		}
		return false;
	}


   	function baixarArquivo(strIn){
		with(formConteudo){
			strNomeArquivo.value = strIn;
			action = "download.php"
			submit();
		}
		return;
	}
	
	function Item(name, subItens){
    	this.name = name;
    	this.subItens = subItens;
    }
    
    function subItem(value, name){
    	this.name = name;
    	this.value = value;
	}

	function trocarCombos2(strForm ,strListPai, strListFilho, arrDados)
    {
    	var i;
    	objListPai = eval("document."+ strForm +"."+ strListPai);
    	objListFilho = eval("document."+ strForm +"."+ strListFilho);
    	objListFilho.length = 0;
    	for(i = 0; i < arrDados[objListPai.value].subItens.length; i++){
    		tmpOption = new Option ();
    		tmpOption.text = arrDados[objListPai.value].subItens[i].name;
    		tmpOption.value = arrDados[objListPai.value].subItens[i].value;
    		objListFilho.options[i] = tmpOption;
    	}
    	objListFilho.selectedIndex = 0;
    	return;
    }
	
	function trocarCombos(strForm ,strListPai, strListFilho, arrDados)
    {
    	var i;
    	objListPai = eval("document."+ strForm +"."+ strListPai);
    	objListFilho = eval("document."+ strForm +"."+ strListFilho);
    	objListFilho.length = 0;
		//alert (arrDados.length);
    	for(i = 0; i < arrDados[objListPai.value].length; i++){
    		tmpOption = new Option ();
    		tmpOption.text = arrDados[objListPai.value][i].name;
    		tmpOption.value = arrDados[objListPai.value][i].value;
    		objListFilho.options[i] = tmpOption;
    	}
    	objListFilho.selectedIndex = 0;
    	return;
    }

function check_email (emailStr)
{
	var emailPat = /^(.+)@(.+)$/
	var specialChars = "\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
	var validChars = "\[^\\s" + specialChars + "\]"
	var quotedUser = "(\"[^\"]*\")"
	var ipDomainPat = /^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
	var atom = validChars + '+'
	var word = "(" + atom + "|" + quotedUser + ")"
	var userPat = new RegExp("^" + word + "(\\." + word + ")*$")
	var domainPat = new RegExp("^" + atom + "(\\." + atom +")*$")

	var matchArray = emailStr.match(emailPat)
	if (matchArray == null)
	{
		return false;
	}

	var user = matchArray[1]
	var domain = matchArray[2]

	if (user.match(userPat) == null)
	{
		return false;
	}

	var IPArray = domain.match(ipDomainPat)

	if (IPArray != null)
	{
		for (var i=1;i<=4;i++)
		{
			if (IPArray[i]>255)
			{
			return false;
			}
		}
		return true;
	}

	var domainArray = domain.match(domainPat)

	if (domainArray == null)
	{
		return false;
	}

	var atomPat = new RegExp(atom,"g")
	var domArr = domain.match(atomPat)
	var len = domArr.length
	
	if (domArr[domArr.length-1].length < 2 || domArr[domArr.length-1].length>3)
	{
  		return false;
	}

	if (len < 2)
	{
  		return false;
	}
	return true;
}

function filtrarNumero(evt){
	var key;
	if (_isNav || _isIE){
		key = (_isNav)? evt.which: evt.keyCode;
		return (key > 47 && key < 58) || key == 8 || key == 0 ? true: false;
	}
	return true;
}

function checarCPF(StrCPF)
{
	x = 0;
	soma = 0;
	dig1 = 0;
	dig2 = 0;
	texto = "";
	StrCPF1="";
	len = StrCPF.length; 
	x = len -1;
	for (var i=0; i <= len - 3; i++)
	{
		y = StrCPF.substring(i,i+1);
		soma = soma + ( y * x);
		x = x - 1;
		texto = texto + y;
	}
	dig1 = 11 - (soma % 11);
	if (dig1 == 10) dig1=0 ;
	if (dig1 == 11) dig1=0 ;
	StrCPF1 = StrCPF.substring(0,len - 2) + dig1 ;
	x = 11; soma=0;
	for (var i=0; i <= len - 2; i++)
	{
		soma = soma + (StrCPF1.substring(i,i+1) * x);
		x = x - 1;
	}
	dig2= 11 - (soma % 11);
	if (dig2 == 10) dig2=0;
	if (dig2 == 11) dig2=0;
	if ((dig1 + "" + dig2) == StrCPF.substring(len,len-2))
	{
		if (StrCPF != "00000000000" && StrCPF != "11111111111" && StrCPF != "22222222222" && StrCPF != "33333333333" && StrCPF != "44444444444" && StrCPF != "55555555555" && StrCPF != "66666666666" && StrCPF != "77777777777" && StrCPF != "88888888888" && StrCPF != "99999999999")
		{
			return true;
		}
	}
	return false;
}


function checarCNPJ(objeto) 
{
	var i, idx; 
	idx = _getIndiceCampo(objeto); 
	msg = "CNPJ Inválido"; 
	
	if(!isEmpty(objeto))
	{ 
		s = objeto.value; 
		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) 
		{ 
			_perm[idx] = 0; 
			_mess[idx] = msg; 
			return false; 
		}
		d1 = 11 - (d1 % 11); 
		if (d1 > 9) 
		{ 
			d1 = 0; 
		} 
		if (dv.charAt(0) != d1) 
		{ 
			_perm[idx] = 0; 
			_mess[idx] = msg; 
			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) 
		{ 
			_perm[idx] = 0; 
			_mess[idx] = msg; 
			return false; 
		} 
		return true; 
	} 
	else 
	{ 
		return true; 
	} 
}

function _getIndiceCampo(obj){
		var i = 0;
		var form = obj.form;
		while (form.elements[i].name != obj.name && i < form.elements.length) i++;
		return i;
}

function concatenarOption(objLista){
	var i, strResultado;
	strResultado = "";
	for(i=0; i<objLista.length; i++)
	{
		strResultado += objLista.options[i].value+";";
	}
	return strResultado.substr(0,strResultado.length-1);
}

function criarOption(arr){
	var i, strValue = "", strText = "", strAux = "";
	var objOption, idx;
	var vetAux;
	var band;
	for(i=0; i<arr.length; i++)
	{
		if(typeof arr[i] == "string")
		{
			if(arr[i] == "checkBox")
			{
				band = false;
				strText += "(";
				for(k=0; k < document.formAula.elements.length; k++)
				{					
					if (document.formAula.elements[k].type == "checkbox")
					{
						if (document.formAula.elements[k].checked)
						{
							strAux = document.formAula.elements[k].value;
							vetAux = strAux.split(";"); // (posição 0 - codigo , 1 - strNome)
							if (!band)
							{
								strText += retirarEspeciais(vetAux[1]);
								band = true;
							}
							else
							{
								strText += " | " + retirarEspeciais(vetAux[1]);
							}
							strValue += (!strValue) ? retirarEspeciais(vetAux[0]) : "|"+retirarEspeciais(vetAux[0]);


							//Eliminar horarios duplicados
							document.formAula.elements[k].checked = false;
							document.formAula.elements[k].disabled = true;

							strAux = document.formAula.elements[k].id;
							vetAux = strAux.split("_"); // (posição 0 - codigo , 1 - linha)

							if( 'undefined' == typeof(vetSalas[document.formAula.codSala.value]) )
							{
								vetSalas[document.formAula.codSala.value] = new Array();
							}

							vetSalas[document.formAula.codSala.value][document.formAula.elements[k].id] = true;
						}
					}
				}
				strText += ")";
			}
			else
			{
				strText += arr[i];
			}
		}
		else
		{
			switch(arr[i].type)
			{
				case "text":
					strText += retirarEspeciais(arr[i].value);
					strValue += (!strValue) ? retirarEspeciais(arr[i].value) : "|"+retirarEspeciais(arr[i].value);
					break;

				case "checkbox":
					strText += retirarEspeciais(' ' + arr[i].title);
					if(arr[i].checked == true)
					{
						tmpText = arr[i].value;
					}
					else
					{
						tmpText = arr[i].id;
					}

					strValue += (!strValue) ? retirarEspeciais(tmpText) : "|"+retirarEspeciais(tmpText);
					break;

				case "hidden":
					strText += retirarEspeciais(arr[i].value);
					strValue += (!strValue) ? retirarEspeciais(arr[i].value) : "|"+retirarEspeciais(arr[i].value);
					break;
					
				case "select-one":
					idx = arr[i].selectedIndex;
					strText += retirarEspeciais(arr[i].options[idx].text);
					strValue += (!strValue) ? retirarEspeciais(arr[i].options[idx].value) : "|"+retirarEspeciais(arr[i].options[idx].value);
					break;

				case "responsavel":
					strText += retirarEspeciais(arr[i].text);
					strValue += (!strValue) ? retirarEspeciais(arr[i].value) : "|"+retirarEspeciais(arr[i].value);
					break;
					
				default:
					strText += retirarEspeciais(arr[i].value);
					strValue += (!strValue) ? retirarEspeciais(arr[i].value) : "|"+retirarEspeciais(arr[i].value);
					break;

			}
		}
	}
	objOption = new Option();
	objOption.value = strValue;
	objOption.text = strText;
	return objOption;
}

function inserirItem(objListTarget, objOption){
	if (!objListTarget){
		alert("Lista de destino fornecida não existe.");
		return null;
	}
	if (!objOption) return objListTarget;
	objListTarget.options[objListTarget.length] = objOption;
	objListTarget.options[objListTarget.length -1].selected = true;
	return objListTarget;
}

function validarObjeto(arr){
	var i;
	for(i=0; i<arr.length; i++){
		if(typeof arr[i] != "string"){
			switch(arr[i].type){
				case "text":
					if (isEmpty(arr[i])){
						alert("Campo(s) necessário(s) não preenchido(s).");
						arr[i].focus();
						return false;
					}	
					break;
				case "select-one":
					if (notSelected(arr[i])){
						alert("Por favor selecione um item da lista.");
						arr[i].focus();
						return false;
					}	
					break;
			}
		}
	}
	return true;
}

function notSelected(obj){
	if (obj.selectedIndex == -1)
		return true;
	else
		return false;
}

function retirarItem(objListSource){
	if (!objListSource){
		alert("Lista de origem fornecida não existe.");
		return null;
	}
	if (!objListSource.length){
		alert("Lista de origem fornecida não possui elementos.");
		return null;
	}
	if (objListSource.selectedIndex == -1){
		alert("Selecione algum elemento na lista de origem.");
		return null;
	}
	return _buscarItem(objListSource, "r");
}

function _buscarItem(objListSource, inst){
	var objOption;
	objOption = new Option();
	objOption.value = objListSource.options[objListSource.selectedIndex].value;
	objOption.text = objListSource.options[objListSource.selectedIndex].text;
	if(inst == "r") objListSource.options[objListSource.selectedIndex] = null;
	return objOption;
}

function reunirValue(objListSource){
	var str="", i;
	if (!objListSource)return null;
	for(i=0; i<objListSource.length; i++)
		str += (!i)? objListSource.options[i].value: "#"+objListSource.options[i].value;
	return str;
}

/*	LIMPEZA DE UM CONJUNTO DE OBJETOS		*/
function limparObjeto(arr){
	var i;
	for(i=0; i<arr.length; i++){
		if(typeof arr[i] != "string"){
			switch(arr[i].type){
				case "text":
					arr[i].value = "";	
					break;
				case "select-one":
					if (arr[i].length >0) arr[i].selectedIndex = -1;	
					break;
				case "checkbox":
					arr[i].checked = false;
					break;
			}
		}
	}
	return;
}

/**
* Oculta ou exibe um item atraves de um checkbox
* @input: id_do_campo, id_do_check
**/
function ocultarItem(idCampo, idCheck)
{
    objCheck = document.forms[0].elements[idCheck];
    objCampo = document.forms[0].elements[idCampo];

    objCheck.blur(); //retirando o foco
    if( objCheck.checked == true )
    {
        objCampo.style.display = '';
    }
    else
    {
        objCampo.style.display = 'none';
    }
    
    objCheck.blur();

}


/*------------------------------------------------------
	Funções que fazem interfaceamento com campos lisbox		
--------------------------------------------------------*/
function inserirItem(oLista, oOpt){
	with(oLista){
		for (i=0; i<length; i++){
			if (options[i].text > oOpt.text){
				oOptAux = options[i];
				options[i] = oOpt;
				oOpt = oOptAux;
			}
		}
		options[i] = oOpt;
	}
	return;
}

function removerItem(oLista){
	if (oLista.selectedIndex == -1){
		alert("Selecione algum elemento na lista de origem.");
		return null;
	}
	opt = oLista.options[oLista.selectedIndex];
	oLista.options[oLista.selectedIndex] = null;
	sText = opt.text;
	sValue = opt.value;
	return new Option(sText, sValue);
}

function juntarCodigos(oLista){
	var sRes = "";
	with(oLista){
		for(i=0; i<length; i++){
			if (i!=0) sRes += ";";
			sRes += options[i].value;
		}
	}
	return sRes;
}

<!--###############################################################################################-->

function popup_ampliar(img){
	pagina = 'amplia_produto.php?img='+ img;
	targ = 0;
	largura = 500;
	altura = 300;
	esquerda = (screen.width - largura - 10)/2;
	topo = screen.height - 59;
	topo = (topo - altura)/2;
	param = "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=" + largura + ",height=" + altura + ",top=" + topo + ",left=" + esquerda;
	window.open(pagina,targ,param);
}

function popup_pedido(produto){
	pagina = 'pedido.php?produto='+ produto;
	targ = 0;
	largura = 500;
	altura = 400;
	esquerda = (screen.width - largura - 10)/2;
	topo = screen.height - 59;
	topo = (topo - altura)/2;
	param = "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=" + largura + ",height=" + altura + ",top=" + topo + ",left=" + esquerda;
	window.open(pagina,targ,param);
}

function Money_2_Java(num){
	novo_num = num;
	for(z=0;novo_num.lastIndexOf(".")>-1;z++){
		ult_ponto = novo_num.lastIndexOf(".");
		novo_num = novo_num.substring(0,ult_ponto) + novo_num.substring(ult_ponto+1,novo_num.length);
	}
	ult_virg = novo_num.lastIndexOf(",");
	if (ult_virg > -1){
		novo_num = novo_num.substring(0,ult_virg) + "." + novo_num.substring(ult_virg+1,novo_num.length);
	}
	return novo_num
}

function NumJava_2_Money(num){
	virg = false;
	novo_num = "";
	num = "" + num
	if (num.lastIndexOf(".") == -1){
		virg = true;
		ponto = 0
	}
	for(i=0;i<num.length;i++){
		if(num.substring(num.length-i-1,num.length-i) == "."){
			if (!virg){
				virg = true;
				ponto = 0;
				novo_num = "," + novo_num;
			}
		}else{
			if(virg){
				if (ponto == 3 && num.substring(num.length-i-1,num.length-i) != "-"){
					ponto = 0
					novo_num = "." + novo_num
				}
				ponto = ponto + 1
			}
			novo_num = num.substring(num.length-i-1,num.length-i) + novo_num;
		}
	}
	if (novo_num.lastIndexOf(",") == -1){
		novo_num = novo_num + ",00";
	}else if(novo_num.lastIndexOf(",") == novo_num.length - 2){
		novo_num = novo_num + "0";
//	}else{
//		novo_num = novo_num.substring(0,novo_num.lastIndexOf(",")) + novo_num.substring(novo_num.lastIndexOf(",") + 1,2);
	}
	return novo_num
}

function mascaradata(S,campo){
	var Digitos = "0123456789";
	var temp = "";
	var digito = "";
	var dig = "";
	var espaco;
	var numero;
	numero = 0;
	espaco = 0;
	S = limpa_string(S);	
   	for (var i=0; i<S.length; i++){
	  	numero = numero + 1;
	  	digito = S.charAt(i);
  		if (i<=8) {
			if (Digitos.indexOf(digito)>=0){temp = temp + digito}
			if (numero == 4 ){if (Digitos.indexOf(digito)>=0){temp = "/"+ S.charAt(0) + S.charAt(1) + S.charAt(2) + S.charAt(3)}}
			if (numero == 5 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) +"/"+ S.charAt(1) + S.charAt(2) + S.charAt(3) + S.charAt(4)}}
			if (numero == 6 ){if (Digitos.indexOf(digito)>=0){temp = "/"+ S.charAt(0) + S.charAt(1) +"/"+ S.charAt(2) + S.charAt(3) + S.charAt(4) + S.charAt(5)}}
			if (numero == 7 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) +"/"+ S.charAt(1) + S.charAt(2) +"/"+ S.charAt(3) + S.charAt(4) + S.charAt(5)+ S.charAt(6)}}
			if (numero == 8 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + S.charAt(1) +"/"+ S.charAt(2) + S.charAt(3) +"/"+ S.charAt(4) + S.charAt(5) + S.charAt(6)+ S.charAt(7)}}
		}
	}
    campo.value = temp;
}

function mascaracep(S,campo){
	var Digitos = "0123456789";
	var temp = "";
	var digito = "";
	var dig = "";
	var espaco;
	var numero;
	numero = 0;
	espaco = 0;
	S = limpa_string(S);	
   	for (var i=0; i<S.length; i++){
	  	numero = numero + 1;
	  	digito = S.charAt(i);
  		if (i<=6) {
			if (Digitos.indexOf(digito)>=0){temp = temp + digito}
			if (numero == 3 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + "-" + S.charAt(1) + S.charAt(2) + S.charAt(3)}}
			if (numero == 4 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + S.charAt(1) + "-" + S.charAt(2) + S.charAt(3) + S.charAt(4)}}
			if (numero == 5 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + S.charAt(1) + S.charAt(2) + "-" + S.charAt(3) + S.charAt(4) + S.charAt(5)}}
			if (numero == 6 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + "." + S.charAt(1) + S.charAt(2) + S.charAt(3) + "-" + S.charAt(4) + S.charAt(5) + S.charAt(6)}}
			if (numero == 7 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + S.charAt(1) + "." + S.charAt(2) + S.charAt(3) + S.charAt(4) + "-" + S.charAt(5) + S.charAt(6) + S.charAt(7)}}
		}
	}
//	document.formulario.CGC.value = temp;
    campo.value = temp;
}

function mascarafone(S,campo){
	var Digitos = "0123456789";
	var temp = "";
	var digito = "";
	var dig = "";
	var espaco;
	var numero;
	numero = 0;
	espaco = 0;
	S = limpa_string(S);	
   	for (var i=0; i<S.length; i++){
	  	numero = numero + 1;
	  	digito = S.charAt(i);
  		if (i<=10) {
			if (Digitos.indexOf(digito)>=0){temp = temp + digito}
			if (numero == 5 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) +"-"+ S.charAt(1) + S.charAt(2) + S.charAt(3) + S.charAt(4)}}
			if (numero == 6 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + S.charAt(1) +"-"+ S.charAt(2) + S.charAt(3) + S.charAt(4) + S.charAt(5)}}
			if (numero == 7 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + S.charAt(1) + S.charAt(2) +"-"+ S.charAt(3) + S.charAt(4) + S.charAt(5)+ S.charAt(6)}}
			if (numero == 8 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + S.charAt(1) + S.charAt(2) + S.charAt(3) +"-"+ S.charAt(4) + S.charAt(5) + S.charAt(6) + S.charAt(7)}}
			if (numero == 9 ){if (Digitos.indexOf(digito)>=0){temp = "(" + S.charAt(0) + ") " + S.charAt(1) + S.charAt(2) + S.charAt(3) + S.charAt(4) +"-"+ S.charAt(5) + S.charAt(6) + S.charAt(7)+ S.charAt(8)}}
			if (numero == 10 ){if (Digitos.indexOf(digito)>=0){temp = "(" + S.charAt(0) + S.charAt(1) + ") " + S.charAt(2) + S.charAt(3) + S.charAt(4) + S.charAt(5) +"-"+ S.charAt(6) + S.charAt(7) + S.charAt(8)+ S.charAt(9)}}
		}
	}
//	document.formulario.CGC.value = temp;
    campo.value = temp;
}

function mascaranumero(S,campo){
	var Digitos = "0123456789";
	S = limpa_string(Money_2_Java(S));
	ini_z = false
	sem_zero = ""
	for (var i=0; i<S.length; i++){
		if (ini_z == true || S.charAt(i) != "0" || S.length == 1){
			ini_z = true;
			sem_zero = sem_zero + S.charAt(i);
		}
	}
	S = sem_zero;
	a_virg = "";
	numero = 0;
   	for (var i=0; i<S.length - 2; i++){
	  	numero = numero + 1;
	  	digito = S.charAt(i);
		if (Digitos.indexOf(digito)>=0){
			a_virg = a_virg + digito
		}
	}
	if (S.length == 1){
		temp = "0.0" + S
		temp = NumJava_2_Money(temp);
	}else if (S.length == 2){
		temp = "0." + S
		temp = NumJava_2_Money(temp);
	}else if (S.length > 2){
		temp = a_virg + "." + S.charAt(S.length-2) + S.charAt(S.length-1);
		temp = NumJava_2_Money(temp);
	}else{
		temp = S;
	}
//	if (eval(Money_2_Java(temp)) == 0){temp = "";}
    campo.value = temp;
}

function mascaranumero2(S,campo){
	var Digitos = "0123456789";
	S = limpa_string(Money_2_Java(S));
	ini_z = false
	sem_zero = ""
	for (var i=0; i<S.length; i++){
		if (ini_z == true || S.charAt(i) != "0"){
			ini_z = true;
			sem_zero = sem_zero + S.charAt(i);
		}
	}
	S = sem_zero;
	a_virg = "";
	numero = 0;
   	for (var i=0; i<S.length - 2; i++){
	  	numero = numero + 1;
	  	digito = S.charAt(i);
		if (Digitos.indexOf(digito)>=0){a_virg = a_virg + digito}
	}
	temp = S;
	if (eval(Money_2_Java(temp)) == 0){temp = "";}
    campo.value = temp;
}

function mascaracpfcnpj(S,campo){
	var Digitos = "0123456789";
	var temp = "";
	var digito = "";
	var dig = "";
	var espaco;
	var numero;
	numero = 0;
	espaco = 0;
	S = limpa_string(S);	
   	for (var i=0; i<S.length; i++){
	  	numero = numero + 1;
	  	digito = S.charAt(i);
  		if (i<=13) {
			if (Digitos.indexOf(digito)>=0){temp = temp + digito}
			if (numero == 2 ){temp = "-" + S.substring(S.length-2,S.length)}
			if (numero == 3 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) +"-"+ S.charAt(1) + S.charAt(2)}}
			if (numero == 4 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + S.charAt(1) + "-" + S.charAt(2) + S.charAt(3)}}
			if (numero == 5 ){if (Digitos.indexOf(digito)>=0){temp = "."+S.charAt(0) + S.charAt(1) + S.charAt(2) + "-" + S.charAt(3) + S.charAt(4)}}
			if (numero == 6 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) +"."+ S.charAt(1) + S.charAt(2) + S.charAt(3) + "-" + S.charAt(4) + S.charAt(5)}}
			if (numero == 7 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + S.charAt(1) +"."+ S.charAt(2) + S.charAt(3) + S.charAt(4) + "-" + S.charAt(5)+ S.charAt(6)}}
			if (numero == 8 ){if (Digitos.indexOf(digito)>=0){temp = "."+S.charAt(0) + S.charAt(1) + S.charAt(2) +"."+ S.charAt(3) + S.charAt(4) + S.charAt(5) + "-" + S.charAt(6)+ S.charAt(7)}}
			if (numero == 9 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) +"."+ S.charAt(1) + S.charAt(2) + S.charAt(3) +"."+ S.charAt(4) + S.charAt(5) + S.charAt(6) + "-" + S.charAt(7)+ S.charAt(8)}}
			if (numero == 10){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + S.charAt(1) +"."+ S.charAt(2) + S.charAt(3) + S.charAt(4) +"."+ S.charAt(5) + S.charAt(6) + S.charAt(7) + "-" + S.charAt(8)+ S.charAt(9)}}
			if (numero == 11){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + S.charAt(1) + S.charAt(2) +"."+ S.charAt(3) + S.charAt(4) + S.charAt(5) +"."+ S.charAt(6) + S.charAt(7) + S.charAt(8) + "-" + S.charAt(9) + S.charAt(10)}}
			if (numero == 12){if (Digitos.indexOf(digito)>=0){temp = "." + S.charAt(0) + S.charAt(1) + S.charAt(2) + "." + S.charAt(3) + S.charAt(4) + S.charAt(5) + "/" +  S.charAt(6) + S.charAt(7) + S.charAt(8) + S.charAt(9) + "-" + S.charAt(10) + S.charAt(11)}}
			if (numero == 13){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + "." +  S.charAt(1) + S.charAt(2) + S.charAt(3) +"."+ S.charAt(4) + S.charAt(5) + S.charAt(6) +"/"+ S.charAt(7) + S.charAt(8) + S.charAt(9) + S.charAt(10) +"-"+ S.charAt(11) + S.charAt(12)}}
			if (numero == 14){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + S.charAt(1) + "." + S.charAt(2) + S.charAt(3) + S.charAt(4) + "." + S.charAt(5) + S.charAt(6) + S.charAt(7) + "/" + S.charAt(8) + S.charAt(9) + S.charAt(10) + S.charAt(11) +"-"+ S.charAt(12) + S.charAt(13)}}
		}
	}
//	document.formulario.CGC.value = temp;
    campo.value = temp;
}

function mascaracnpjcol(S,campo){
	var Digitos = "0123456789";
	var temp = "";
	var digito = "";
	var dig = "";
	var espaco;
	var numero;
	numero = 0;
	espaco = 0;
	S = limpa_string(S);	
   	for (var i=0; i<S.length; i++){
	  	numero = numero + 1;
	  	digito = S.charAt(i);
  		if (i<=11) {
			if (Digitos.indexOf(digito)>=0){temp = temp + digito}
			if (numero == 2 ){temp = "-" + S.substring(S.length-2,S.length)}
			if (numero == 3 ){if (Digitos.indexOf(digito)>=0){temp = "." + S.charAt(0) + S.charAt(1) + S.charAt(2)}}
			if (numero == 4 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) +"."+ S.charAt(1) + S.charAt(2) + S.charAt(3)}}
			if (numero == 5 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + S.charAt(1) +"."+ S.charAt(2) + S.charAt(3) + S.charAt(4)}}
			if (numero == 6 ){if (Digitos.indexOf(digito)>=0){temp = "."+S.charAt(0) + S.charAt(1) + S.charAt(2) +"."+ S.charAt(3) + S.charAt(4) + S.charAt(5)}}
			if (numero == 7 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) +"."+ S.charAt(1) + S.charAt(2) + S.charAt(3) +"."+ S.charAt(4) + S.charAt(5) + S.charAt(6)}}
			if (numero == 8){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + S.charAt(1) +"."+ S.charAt(2) + S.charAt(3) + S.charAt(4) +"."+ S.charAt(5) + S.charAt(6) + S.charAt(7)}}
			if (numero == 9){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + S.charAt(1) + S.charAt(2) +"."+ S.charAt(3) + S.charAt(4) + S.charAt(5) +"."+ S.charAt(6) + S.charAt(7) + S.charAt(8)}}
			if (numero == 10){if (Digitos.indexOf(digito)>=0){temp = "." + S.charAt(0) + S.charAt(1) + S.charAt(2) + "." + S.charAt(3) + S.charAt(4) + S.charAt(5) + "/" +  S.charAt(6) + S.charAt(7) + S.charAt(8) + S.charAt(9)}}
			if (numero == 11){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + "." +  S.charAt(1) + S.charAt(2) + S.charAt(3) +"."+ S.charAt(4) + S.charAt(5) + S.charAt(6) +"/"+ S.charAt(7) + S.charAt(8) + S.charAt(9) + S.charAt(10)}}
			if (numero == 12){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + S.charAt(1) + "." + S.charAt(2) + S.charAt(3) + S.charAt(4) + "." + S.charAt(5) + S.charAt(6) + S.charAt(7) + "/" + S.charAt(8) + S.charAt(9) + S.charAt(10) + S.charAt(11)}}
		}
	}
//	document.formulario.CGC.value = temp;
    campo.value = temp;
}

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}
   	}
   return temp
}

function limpa_string2(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}
   	}
   return temp
}

function limpa_string_virg(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}
   	}
   return temp
}

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 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 ltrim(string){
	inicio = false;
	nova_string = "";
	for (x=0;x<string.length;x++){
		if (string.charAt(x) != " "){
			inicio = true;
			nova_string = nova_string + string.charAt(x);
		}else if(inicio){
			nova_string = nova_string + string.charAt(x);
		}
	}
	return nova_string
}

function rtrim(string){
	inicio = false;
	nova_string = "";
	for (x = string.length - 1;x>=0;x--){
		if (string.charAt(x) != " "){
			inicio = true;
			nova_string = string.charAt(x) + nova_string;
		}else if(inicio){
			nova_string = string.charAt(x) + nova_string;
		}
	}
	return nova_string
}

function trim(string){
	return ltrim(rtrim(string))
}
function logout() {
	if(confirm('Deseja sair e fazer logout do HelpDesk Online?')){
		popup_up('logout.asp?x=unload','logout',50,10)
	}
}
function checa(nform) {
	msg = "";
	if (nform.dcrUsuario.value == "") {
		msg = "Informe a empresa.";
		nform.dcrUsuario.focus();
		nform.dcrUsuario.select();
	}
	if (nform.DcrContato.value == "") {
		msg += "\nInforme o contato.";
		nform.DcrContato.focus();
		nform.DcrContato.select();
	}
	if (nform.Endereco.value == "") {
		msg += "\nInforme o endereço.";
		nform.Endereco.focus();
		nform.Endereco.select();
	}
	if (nform.Cidade.value == "") {
		msg += "\nInforme a cidade.";
		nform.Cidade.focus();
		nform.Cidade.select();
	}
	if (nform.CPFCNPJ.value == "") {
		msg += "\nInforme o CPF/CGC.";
		nform.CPFCNPJ.focus();
		nform.CPFCNPJ.select();
	}
	if (nform.email.value == "") {
		msg += "\nInforme seu e-mail.";
		nform.email.focus();
		nform.email.select();
	} else {
		prim = nform.email.value.indexOf("@")
		if(prim < 2) {
			msg += "Favor verificar se o email foi digitado corretamente.";
			nform.email.focus();
			nform.email.select();
		}
		if(nform.email.value.indexOf("@",prim + 1) != -1) {
			msg +="Favor verificar se o email foi digitado corretamente.";
			nform.email.focus();
			nform.email.select();
		}
		if(nform.email.value.indexOf(".") < 1) {
			msg +="Favor verificar se o email foi digitado corretamente.";
			nform.email.focus();
			nform.email.select();
		}
		if(nform.email.value.indexOf(" ") != -1) {
			msg +="Favor verificar se o email foi digitado corretamente.";
			nform.email.focus();
			nform.email.select();
		}
		if(nform.email.value.indexOf("zipmeil.com") > 0) {
			msg +="Favor verificar se o email foi digitado corretamente.";
			nform.email.focus();
			nform.email.select();
		}
		if(nform.email.value.indexOf("hotmeil.com") > 0) {
			msg +="Favor verificar se o email foi digitado corretamente.";
			nform.email.focus();
			nform.email.select();
		}
		if(nform.email.value.indexOf(".@") > 0) {
			msg +="Favor verificar se o email foi digitado corretamente.";
			nform.email.focus();
			nform.email.select();
		}
		if(nform.email.value.indexOf("@.") > 0) {
			msg +="Favor verificar se o email foi digitado corretamente.";
			nform.email.focus();
			nform.email.select();
		}
		if(nform.email.value.indexOf(".com.br.") > 0) {
			msg +="Favor verificar se o email foi digitado corretamente.";
			nform.email.focus();
			nform.email.select();
		}
		if(nform.email.value.indexOf("/") > 0) {
			msg +="Favor verificar se o email foi digitado corretamente.";
			nform.email.focus();
			nform.email.select();
		}
		if(nform.email.value.indexOf("[") > 0) {
			msg +="Favor verificar se o email foi digitado corretamente.";
			nform.email.focus();
			nform.email.select();
		}
		if(nform.email.value.indexOf("]") > 0) {
			msg +="Favor verificar se o email foi digitado corretamente.";
			nform.email.focus();
			nform.email.select();
		}
		if(nform.email.value.indexOf("(") > 0) {
			msg +="Favor verificar se o email foi digitado corretamente.";
			nform.email.focus();
			nform.email.select();
		}
		if(nform.email.value.indexOf(")") > 0) {
			msg +="Favor verificar se o email foi digitado corretamente.";
			nform.email.focus();
			nform.email.select();
		}
		if(nform.email.value.indexOf("..") > 0) {
			msg +="Favor verificar se o email foi digitado corretamente.";
			nform.email.focus();
			nform.email.select();
		}
	}
	if(msg==''){
			return true;
	} else {
		alert(msg);
		return false;
	}
}

function veri(){
	if(informativo.nome.value.length==0){
		alert("Preencha corretamente o campo Nome")
		informativo.nome.focus()
		return false
	}else if(informativo.nome.value == "nome"){
		alert("Preencha corretamente o campo Nome")
		informativo.nome.focus()
		return false
	}else if(informativo.email.value.length==0){
		alert("Preencha corretamente o campo E-mail")
		informativo.email.focus()
		return false
	}else if(informativo.email.value == "e-mail"){
		alert("Preencha corretamente o campo E-mail")
		informativo.email.focus()
		return false
	}else if(informativo.email.value.indexOf("@")==-1 || informativo.email.value.indexOf(".")==-1){ 
		alert("O campo email não está preenchido corretamente!"); 
		informativo.email.focus(); 
		return false; 
	}
}	

function limpar_nome(){
	if(informativo.nome.value == "nome"){
		informativo.nome.value = "";
	}
}
function limpar_email(){
	if(informativo.email.value == "e-mail"){
		informativo.email.value = "";
	}
}
function nao_limpar_nome(){
	if(informativo.nome.value == ""){
		informativo.nome.value = "nome";
	}
}
function nao_limpar_email(){
	if(informativo.email.value == ""){
		informativo.email.value = "e-mail";
	}
}