function addSWF (URL, WIDTH, HEIGHT, TRANSPARENTE, SEMMENU)
{
	document.write (' <embed src="'+ URL +'" quality="high" ');
	if ( TRANSPARENTE ) {
		document.write (' wmode = "transparent" ');
	}
	if ( SEMMENU ) {
		document.write (' menu = "false" ');
	}
	document.write (' pluginspage="http://www.macromedia.com/go/getflashplayer" ');
	document.write (' type="application/x-shockwave-flash" width="'+ WIDTH +'" height="'+ HEIGHT +'"></embed> ');
}
/*<script language='JavaScript' src='addswf.js'></script>*/
/*<script>addSWF('exemplo.swf', 125, 100, true, true);</script>*/

function cidades(){
	if(document.getElementById('cidade_select').value!=''){
		if(document.getElementById('cidade_select').value==95){
			document.getElementById('convenios_select').style.display="inline";
			document.getElementById('convenios_select').value="";
		}else{
			document.getElementById('convenios_select').style.display="none";
			document.conveniados.submit();
		}
	}else{
		document.getElementById('convenios_select').style.display="none";
		//document.getElementById('convenios_select').value="";
	}
}

function conv(){
	if(document.getElementById('convenios_select').value!=''){
		document.conveniados.submit();
	}
}

function selectSubmit(campo, form){
	if(document.getElementById(campo).value!=''){
		document.getElementById(form).submit();
	}
}

function flutuante(idObjeto)
{
	if(document.getElementById(idObjeto+'_flutuante').style.display=="block"){
		document.getElementById(idObjeto+'_flutuante').style.display="none";
	}else{
		
		larguraJanela= document.documentElement.scrollWidth;
		larguraConteiner=550;
		/*
		esquerdaJanela=document.documentElement.scrollLeft;
		diferenca=((larguraJanela-larguraConteiner)/2)-esquerdaJanela;
		esquerdaConteiner=document.getElementById('conteiner').scrollLeft;
		mouseX=event.clientX;
		*/
		
		xMaximo=((larguraJanela-larguraConteiner)/2) + 550;
		xObjeto=document.getElementById(idObjeto+'_flutuante').style.left + 140;
		if(xObjeto >= xMaximo){
			resultado = xObjeto - xMaximo;
			//document.getElementById(idObjeto+'_flutuante').style.left -= resultado;
		}
		document.getElementById(idObjeto+'_flutuante').style.display="block";
	}
}

function galeriasScroll(acao){
	if(acao=='esquerda'){
		intervalo=window.setInterval('scrollEsquerda()', 1);
	}
	if(acao=='direita'){
		intervalo=window.setInterval('scrollDireita()', 1);
	}
	if(acao=='parar'){
		clearInterval(intervalo);
	}
}
function scrollEsquerda(){
	document.getElementById('conteiner').scrollLeft-=3;
}
function scrollDireita(){
	document.getElementById('conteiner').scrollLeft+=3;
}
function validaForm( NomeForm )
{
	if (NomeForm == 'frm')
	{
		if (document.forms[NomeForm].elements['nome'].value == "" || document.forms[NomeForm].elements['nome'].value == "Nome:")
		{
			alert("O campo NOME deve ser preenchido!");
			document.forms[NomeForm].elements['nome'].focus();
			return false;
		}
		
		if(document.forms[NomeForm].elements['email_novo'].value == "" || document.forms[NomeForm].elements['email_novo'].value == "E-mail:"){
			alert("O campo E-MAIL deve ser preenchido!");
			document.forms[NomeForm].elements['email_novo'].focus();
			return false;
		}else{
				if(!(validaEmail(document.forms[NomeForm].elements['email_novo'].value))){
					alert("O campo E-MAIL não está com um e-mail válido!");
					document.forms[NomeForm].elements['email_novo'].focus();
					return false;
				}
		}
		/*if (document.forms[NomeForm].elements['telefone'].value == "" || document.forms[NomeForm].elements['telefone'].value == "Telefone:")
		{
			alert("O campo TELEFONE deve ser preenchido!");
			document.forms[NomeForm].elements['telefone'].focus();
			return false;
		}*/
		if (document.forms[NomeForm].elements['cidade'].value == "" || document.forms[NomeForm].elements['cidade'].value == "Cidade:")
		{
			alert("O campo CIDADE deve ser preenchido!");
			document.forms[NomeForm].elements['cidade'].focus();
			return false;
		}
		if (document.forms[NomeForm].elements['titulotexto'].value == "" || document.forms[NomeForm].elements['titulotexto'].value == "tituloTexto:")
		{
			alert("O campo TÍTULO deve ser preenchido!");
			document.forms[NomeForm].elements['titulotexto'].focus();
			return false;
		}
		/*
		if (document.forms[NomeForm].elements['video'].value == "" || document.forms[NomeForm].elements['video'].value == "Video:")
		{
			alert("O campo VÍDEO deve ser preenchido!");
			document.forms[NomeForm].elements['video'].focus();
			return false;
		}
		if (document.forms[NomeForm].elements['legendavideo'].value == "" || document.forms[NomeForm].elements['legendavideo'].value == "legendavideo:")
		{
			alert("O campo LEGENDA DO VÍDEO deve ser preenchido!");
			document.forms[NomeForm].elements['legendavideo'].focus();
			return false;
		}
		*/
		if(document.forms[NomeForm].elements['auth'].checked != true)
		{
			alert("Favor Autorizar a veiculação do conteúdo enviado!");
			document.forms[NomeForm].elements['auth'].focus();
			return false;
		}
		
		return true;
	} //Fim frmContato
	
	if (NomeForm == 'frmQueroVerNaTv')
	{
		if (document.forms[NomeForm].elements['nome'].value == "" || document.forms[NomeForm].elements['nome'].value == "Nome:")
		{
			alert("O campo NOME deve ser preenchido!");
			document.forms[NomeForm].elements['nome'].focus();
			return false;
		}
		
		if(document.forms[NomeForm].elements['email_novo'].value == "" || document.forms[NomeForm].elements['email_novo'].value == "E-mail:"){
			alert("O campo E-MAIL deve ser preenchido!");
			document.forms[NomeForm].elements['email_novo'].focus();
			return false;
		}else{
				if(!(validaEmail(document.forms[NomeForm].elements['email_novo'].value))){
					alert("O campo E-MAIL não está com um e-mail válido!");
					document.forms[NomeForm].elements['email_novo'].focus();
					return false;
				}
		}
		if (document.forms[NomeForm].elements['cidade'].value == "" || document.forms[NomeForm].elements['cidade'].value == "Cidade:")
		{
			alert("O campo CIDADE deve ser preenchido!");
			document.forms[NomeForm].elements['cidade'].focus();
			return false;
		}
		if (document.forms[NomeForm].elements['sugestao'].value == "")
		{
			alert("O campo SUGESTÃO deve ser preenchido!");
			document.forms[NomeForm].elements['sugestao'].focus();
			return false;
		}
		return true;
	}
	return false;
}
function validaEmail(email)
{
	if(email.length < 6)
	{
		return false;
	}
	var x=0;
	for(var c=0;c<email.length;c++)
	{
		if(email.substring(c,c+1)=='@')
		{
			x=c;
		}
	}
	var y=0;
	if(x > 0)
	{
		for(c=x;c<email.length;c++)
		{
			if(email.substring(c,c+1)=='.')
			{
				y=c;
				var valida=1;
			}
		}					
	}
	else
		{
			return false;
		}

	if(y<=x+2)
	{
		return false;
	}

	if(valida==1)
	{
		return true;
	}
	return true;
}
