		function gE(ID) {
		
			return document.getElementById(ID);
		
		}
		function GeraSelectBox(ElementoDestino, Sql, ColunaTexto, ColunaChave, PrimeiraOpcaoVazia) {
				document.getElementById(ElementoDestino).innerHTML = "";
				$.get("includes/GeraSelectBox.php", { Sql: Sql, ColunaTexto: ColunaTexto, ColunaChave: ColunaChave, PrimeiraOpcaoVazia: PrimeiraOpcaoVazia }, function(data) {
					document.getElementById(ElementoDestino).innerHTML = data;
				});				
		}
		
		
		function SelecionarVideo(Index) {
			$(".VideoImagePlaying").each(function(intIndex) {
					$(this).hide();
			});
			$("#VideoImagePlaying_"+Index).fadeIn("slow");
			var value = document.getElementById("Video_"+Index).value;
			var Element = document.getElementById("VideoSelecionado");
			Element.innerHTML = '<embed height="250" width="382" src="http://www.iteia.com.br/FlowPlayerDark.swf" bgcolor="#ffffff" allowfullscreen="true" allowscriptaccess="always" quality="high" wmode="opaque" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/go/getflashplayer" flashvars="config={\'videoFile\':\''+value+'\',\'autoRewind\':true,\'autoPlay\':true,\'autoBuffering\':true,\'initialScale\':\'scale\',\'loop\':false,\'usePlayOverlay\':true,\'initialVolumePercentage\':80}"/>';	
		}		
		/*function SelecionarVideo(Index) {
			$(".VideoImagePlaying").each(function(intIndex) {
					$(this).hide();
			});
			$("#VideoImagePlaying_"+Index).fadeIn("slow");
			var value = fixEmbeddedVideo(document.getElementById("Video_"+Index).value);
			var Element = document.getElementById("VideoSelecionado");
			Element.innerHTML = value;			
		}*/
		
		
		
		
		function SelecionarAudio(Index) {
			document.getElementById("AudioSelecionado").innerHTML = "";
			$("AudioSelecionado").html("");
			$(".AudioImagePlaying").each(function(intIndex) {
					$(this).hide();
			});
			$("#AudioImagePlaying_"+Index).fadeIn("slow");
			//var value = fixEmbeddedVideo(document.getElementById("Audio_"+Index).value);
			var value = document.getElementById("Audio_"+Index).value;
			var Element = document.getElementById("AudioSelecionado");
			Element.innerHTML = '<embed height="28" width="382" src="http://www.iteia.com.br/FlowPlayerDark.swf" bgcolor="#ffffff" allowfullscreen="true" allowscriptaccess="always" quality="high" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/go/getflashplayer" flashvars="config={\'videoFile\':\''+value+'\',\'autoRewind\':true,\'autoPlay\':true,\'autoBuffering\':true,\'initialScale\':\'scale\',\'loop\':false,\'usePlayOverlay\':true,\'initialVolumePercentage\':80}"/>';
		}		
		/*function SelecionarAudio(Index) {
			document.getElementById("AudioSelecionado").innerHTML = "";
			$("AudioSelecionado").html("");
			$(".AudioImagePlaying").each(function(intIndex) {
					$(this).hide();
			});
			$("#AudioImagePlaying_"+Index).fadeIn("slow");
			var value = fixEmbeddedVideo(document.getElementById("Audio_"+Index).value);
			var Element = document.getElementById("AudioSelecionado");
			Element.innerHTML = value;
		}*/
		function SelecionarTexto(Index) {
			 
			//$("#Texto_"+Index).jqmShow(); 
			var api = $("#Texto_"+Index).overlay();
			api.load();			
		}		
		function SelectElementInGroup(ElementId, GroupClassToHide) {
			$("."+GroupClassToHide).each(function(intIndex) {
					$(this).hide();
			});			
			$("#"+ElementId).fadeIn("slow");			
		}
		function Pesquisar(PesquisaInicial, Value, Key, TipoPesquisa, Midia, Categoria, Cidade, Edicao) {
			if(PesquisaInicial == 1) {
				if(Key == 13) {
					window.location = "index.php?pid=5&pesquisa="+Value+"&tipo_pesquisa=1&midia="+Midia+"&categoria="+Categoria+"&cidade="+Cidade+"&edicao="+Edicao;	
				}				
			} else {
				window.location = "index.php?pid=5&pesquisa="+Value+"&tipo_pesquisa="+TipoPesquisa+"&midia="+Midia+"&categoria="+Categoria+"&cidade="+Cidade+"&edicao="+Edicao;	
			}
		}
		function SelectBox(Id) {			
			$(".zindexbox").each(function(intIndex) {
					$(this).css("z-index", "1");
			});	
			$(".hiddenzindexbox").each(function(intIndex) {
					$(this).hide();
			});			
			$("#"+Id).css("z-index", "3");
			//$("#Hidden"+Id).show();
			$("#Conteudo"+Id).fadeIn("slow");
		}
		function MudaDestaqueLoop() {
			var DestaqueSelecionado =  parseInt(document.getElementById("DestaqueSelecionado").value);
			var CountDestaques =  parseInt(document.getElementById("CountDestaques").value);
			if(document.getElementById("LoopDestaques").value == 1) {
					DestaqueSelecionado = DestaqueSelecionado + 1;
					if(DestaqueSelecionado > CountDestaques) {
						document.getElementById("DestaqueSelecionado").value = 1;
						DestaqueSelecionado = 1;
					}
					MudaFotoDestaque(DestaqueSelecionado);
					setTimeout("MudaDestaqueLoop()", 8000);	
			}
		}
		function MudaFotoDestaque(Index) {
			$(".MenuFotosDestaque").each(function(intIndex) {
					$(this).removeClass("MenuFotosDestaqueActive");
			});			
			$("#FotoDestaque"+Index).addClass("MenuFotosDestaqueActive");
			$("#FotoDestaque").hide();
			//$("#DivDestaques").addClass("ImageLoading");
			document.getElementById("FotoDestaque").src = document.getElementById("SrcFotoDestaque_"+Index).value;
			$("#BackgroundImageLoader").image(document.getElementById("SrcFotoDestaque_"+Index).value,function(){
				document.getElementById("FotoDestaque").src = document.getElementById("SrcFotoDestaque_"+Index).value;
				document.getElementById("DestaqueSelecionado").value = Index;
				//$("#DivDestaques").removeClass("ImageLoading");
				$("#FotoDestaque").fadeIn("slow");																													
			},function(e){
				alert(e);
			});				
			

		}
		function EntrarDestaque() {
			var Index = document.getElementById("DestaqueSelecionado").value;
			var Link = document.getElementById("LinkFotoDestaque_"+Index).value;
			window.location = Link;
		}
		function ToogleBox(BoxToHide, BoxToShow) {
			
			$("#"+BoxToHide).hide();
			$("#"+BoxToShow).fadeIn("slow");
			$("#Zindex"+BoxToHide).css("z-index", "1");
			$("#Zindex"+BoxToShow).css("z-index", "2");
			
		}
		function FecharOlverLayCadastro() {
			api = $("#Cadastro_overlay").overlay();	
			api.close();
		}
		function AbreOlverLayCadastro(Email) {
			document.getElementById("Cadastro_ReceberNoticias").checked = true;
			document.getElementById("Cadastro_QuerSerColaborador").checked = false;
			document.getElementById("Cadastro_Nome").value = "";
			document.getElementById("Cadastro_Email").value = "";
			document.getElementById("Cadastro_OutraCidade").value = "";
			document.getElementById("Cadastro_SobreCadastro").value = "";
			document.getElementById("Cadastro_Cidade").options[0].selected = true;
			$("#OutraCidadeDiv").hide();
			if(Email) {
				document.getElementById("Cadastro_Email").value = Email;
			}
			api = $("#Cadastro_overlay").overlay();	
			api.load();
		}
		function EnviarRecado() {
			var Erro = "";
			var Email = trimAll(document.getElementById('Recados_Email').value);
			var Recado = trimAll(document.getElementById('Recados_Recado').value);
			if(Email == "" || Recado == "") {
				Erro += "Preencha todos os campos!\n";
			} else {
				if(echeck(Email) == false) {
					Erro += "Email inválido!\n";
				}
			}			
			if(Erro == "") {
				$.get("includes/VerificarJaCadastrado.php", { Email: Email }, function(data) {
						if(parseInt(data) == 0) {
							alert("Este e-mail ainda não foi cadastrado.\n\nPara deixar um recado você deve se cadastrar.\n\nClique OK para abrir a página de cadastro.");
							AbreOlverLayCadastro(Email);
						} else {
							$.get("includes/EnviarRecado.php", { Email: Email, Recado: Recado }, function(data) {
								alert("Seu recado foi cadastrado e será liberado em breve.\n\nObrigado por participar!");
							});							
						}
				});					
			} else {
				alert(Erro);
			}
		}
		function CadastrarPessoa() {
			var Erro = "";
			var Cidade = "";
			var ReceberNoticias = "";
			var Nome = trimAll(document.getElementById('Cadastro_Nome').value);
			var Email = trimAll(document.getElementById('Cadastro_Email').value);
			var SobreCadastro = trimAll(document.getElementById('Cadastro_SobreCadastro').value);
			var Recado = trimAll(document.getElementById('Recados_Recado').value);
			if(document.getElementById("Cadastro_ReceberNoticias").checked) {
				ReceberNoticias = 1;
			} else {
				ReceberNoticias = 0;
			}
			if(document.getElementById("Cadastro_QuerSerColaborador").checked) {
				QuerSerColaborador = 1;
			} else {
				QuerSerColaborador = 0;
			}			
			if(document.getElementById("Cadastro_Cidade").value == "Outra") {
				Cidade = trimAll(document.getElementById("Cadastro_OutraCidade").value);
			} else {
				Cidade = document.getElementById("Cadastro_Cidade").value;
			}			
			if(Nome == "" || Email == "" || Cidade == "") {
				Erro += "Preencha os campos com *!\n";
			} else {
				if(echeck(Email) == false) {
					Erro += "Email inválido!\n";
				}
			}			
			if(Erro == "") {
				$.get("includes/CadastrarPessoa.php", { Nome: Nome, Email: Email, Cidade: Cidade, ReceberNoticias: ReceberNoticias, QuerSerColaborador: QuerSerColaborador, SobreCadastro: SobreCadastro }, function(data) {
						if(Recado == "") {																													   
							alert(data);
						} else {
							EnviarRecado();
							document.getElementById('Recados_Recado').value = "";							
							ToogleBox('BoxDeixarRecado','BoxRecados');
						}
						FecharOlverLayCadastro();
				});	
			} else {
				alert(Erro);
			}
		}	
		function VerificaCidade(Cidade) {
			if(Cidade == "Outra") {
				$("#OutraCidadeDiv").fadeIn("slow");
			} else {
				$("#OutraCidadeDiv").hide();
			}
		}
		function trimAll(sString) {
			while (sString.substring(0,1) == ' ') {
				sString = sString.substring(1, sString.length);
			}
			while (sString.substring(sString.length-1, sString.length) == ' ') {
				sString = sString.substring(0,sString.length-1);
			}
			return sString;
		}		
		function echeck(str) {
		
				var at="@"
				var dot="."
				var lat=str.indexOf(at)
				var lstr=str.length
				var ldot=str.indexOf(dot)
				if (str.indexOf(at)==-1){
				   //alert("Invalid E-mail ID")
				   return false
				}
		
				if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
				   //alert("Invalid E-mail ID")
				   return false
				}
		
				if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
					//alert("Invalid E-mail ID")
					return false
				}
		
				 if (str.indexOf(at,(lat+1))!=-1){
					//alert("Invalid E-mail ID")
					return false
				 }
		
				 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
					//alert("Invalid E-mail ID")
					return false
				 }
		
				 if (str.indexOf(dot,(lat+2))==-1){
					//alert("Invalid E-mail ID")
					return false
				 }
				
				 if (str.indexOf(" ")!=-1){
					//alert("Invalid E-mail ID")
					return false
				 }
		
				 return true					
			}		
