function $(v)
{
	return document.getElementById(v);
}

function CheckForm(Fields, Labels)
{
	var fReff;

	// Percorre campos a serem validados
	for(var i=0; i<Fields.length; i++)
	{
		// Cria referencia para o objeto
		fReff = document.getElementById(Fields[i]);

		// Testa se o objeto existe
		if(fReff != null)
		{
			// Validacao de data
			if((/^[0-9]{1,2}\/[0-9]{1,2}\/[0-9]{4}$/).test(fReff.value))
			{
				 var numbers = fReff.value.split("/");
			 	 if(!DateValidate(numbers[0], numbers[1], numbers[2])){
					alert("A data informada no campo \""+Labels[i]+"\" não é válida!");
					try{
						fReff.focus();
					}catch(e){
						return false;
					}

					return false;
				 }
			}
			else
			{
				// Testa valor do campo
				if( fReff.value.length == 0 )
				{
					alert("O campo \""+Labels[i]+"\" é de preenchimento obrigatório!");
					try
					{
						fReff.focus();
					}catch(e)
					{
						return false;
					}
					return false;
				}
				else
				{
					if (Fields[i]=="email" && (fReff.value.indexOf("@") == -1 || fReff.value.indexOf(".") == -1))
					{
						alert("O e-mail informado não é válido!");
						fReff.focus();
						return false;
					}
				}
			}
		}
	}
	return true;
}

function confirma(x){
  a = window.location.search;if (a == ""){a = "?";};
  if (a!="?"){
    posa = a.indexOf("=");posb = a.indexOf("&");b = a.substring(0,posa+1)+x;c = a.substring(posb,a.length);d = b + c + "&acao=excluir";
  }else{
    d = "?id="+x+ "&acao=excluir";
  }
  if (confirm('VocÃª deseja apagar?')){
    window.location=d;
  }else{
    window.location="#";
  }
}

function chatOpen()
{
	window.open('/chat', '', 'width=400, height=330');
	hideConvite("");
}

function hideConvite(content)
{
	/*document.getElementById("LayerConvite").style.display = 'none';*/
}

function showDescricao(id)
{
	document.getElementById(id).className = 'descricaoVisivel';
}

function hideDescricao(id)
{
	document.getElementById(id).className = 'descricaoOculta';
}
function showVideo(c)
{
	window.open("/video.php/"+c,"Video","width=240, height=200");
}
function hidePro(id)
{
	if(document.getElementById('produto_'+id).style.display=='none')
		document.getElementById('produto_'+id).style.display = '';
	else
		document.getElementById('produto_'+id).style.display = 'none';
}
function hideLeg(id)
{
	if(document.getElementById('legenda_'+id).style.display=='none')
		document.getElementById('legenda_'+id).style.display = '';
	else
		document.getElementById('legenda_'+id).style.display = 'none';
}
function showList(id)
{
	document.getElementById(id).style.width='auto';
}
function hideList(id,s)
{
	document.getElementById(id).style.width=s;
}
