/**

 * Biblioteca de classes javascript para utilização nas camadas do site

 * Essa biblioteca foi programada com a utilização do framework $ (www.$.com)

 * 

 * @author Caio Teixeira FiveCom 2008

 * 

 */





/**

 * Constantes para uso utilização global

 * 

 */



//jQuery.noConflict();



//var $ = jQuery.noConflict();



Constantes = {

	URL: '/index.php?id=',	

	URL_INCLUDE: '/index.php?id=/includes',

	URL_PAGINAS: '/index.php?id=/includes/paginas',

	URL_ACAO: '/index.php?id=/includes/paginas/acoes.php',

	URL_XML: '/index.php?id=/includes/xml'

	

	

};



/**

 * Chamada para lightbox imagem / Vídeo

 */



LightBox = {

	recebeObjetoImagem: 

		function(prop) {

			var classe = "abc";

			

			var imgZoom = document.createElement('img');

			

			imgZoom.id = 'img_' +  classe;

			imgZoom.className = classe;

			imgZoom.src = prop.url;

			imgZoom.alt = prop.descricao;	

			

			return imgZoom;

			

		},

	recebeObjetoVideo:

		function(prop) {

			var _width,_height;

			

			_width  = 425;

			_height = 355;

			

			var embedZoom = document.createElement('embed');

			

			embedZoom.setAttribute("id","fivecomlv");

			embedZoom.setAttribute("name","fivecomlv");

			if (prop.ext == "wmv") {

				embedZoom.setAttribute("src", prop.url);

			} else if (prop.ext == "youtube") {

				embedZoom.setAttribute("src", "http://www.youtube.com/v/"+prop.url);

			} else if (prop.ext == "google") {

				embedZoom.setAttribute("src", "http://video.google.com/googleplayer.swf?docid="+prop.url);

			}

			embedZoom.setAttribute("uimode", "none");

			embedZoom.setAttribute("width", _width);

			embedZoom.setAttribute("height", _height);

			

			return embedZoom;

			

		//document.body.appendChild(embedZoom);

		},

		

	getImagem:

		function(imagem) {

			//imagem.descricao = "";

			openZoom(LightBox.recebeObjetoImagem(imagem),imagem.fonte,imagem.descricao);

		},

	

	getVideo:

		function(video) {

			openZoom(LightBox.recebeObjetoVideo(video), video.fonte, video.descricao, video.ext);

		},

	

	getGaleriaImagem: 

		function(imagem) {

			

			openGaleria(LightBox.recebeObjetoImagem(imagem), imagem.fonte, imagem.descricao, imagem.tipoMidia,imagem.codigoTopico,imagem.acao);

			

		},

		

	getGaleriaVideo:

		function(video) {

			openGaleria(LightBox.recebeObjetoVideo(video), video.fonte, video.descricao, video.tipoMidia, video.codigoTopico, video.acao)

		}

};









/**

 * Classe que representa as notícias em forma de pequenas notas

 * 

 * @author Caio Teixeira

 * 

 */







function WebClip() {

 	

	this.clips = new Array();

	

	this.url = null;

	

	this.container = null;

	

	this.posicaoAtual = 0;

	

	this.limite = 0;

	

	this.setContainer = 

		function (container) {

			this.container = container;

	}

	

	this.setWebClip =

		function(webClip) {

			this.clips = webClip;

	}

		

	this.setLimite = 

		function(limite) {

			this.limite = limite;	

	}

	

	this.setPosicaoAtual =

		function(pos) {



			if (pos > this.clips.length-1) {

				this.posicaoAtual = 0;

			} else if (parseInt(pos) < 0) {

				this.posicaoAtual = this.clips.length-1;

			} else {

				this.posicaoAtual = pos;

			}

			

	}

	

	this.carregarWebClip = 

		function(){ 

			

			this.getWebClip();

				

	}

	

	this.proxima =

		function() {

			this.setPosicaoAtual(this.posicaoAtual+1);

			this.getWebClip();

	}

		

	this.anterior =

		function() {

			this.setPosicaoAtual(this.posicaoAtual-1);

			this.getWebClip();

	}

		

	this.getWebClip =

		function() {

			document.getElementById(this.container).innerHTML = this.clips[this.posicaoAtual];

				

	}

	

};



/**

 * Classe para criar abas na aplicação

 * 

 * @example 

 *  var nomAba = new Array('aba01','aba02'); // ID's referentes aos objetos de ação nas abas

 *  var urlAba = new Array('pagina01.html','pagina02.html'); // páginas que serão carregadas

 *  var abaEx = new Aba();

 *  abaEx.setClasseAtiva('ativo'); // Classe CSS que representa uma aba ativa

 *  abaEx.setContainer('resultado'); // objeto que vai receber o código resposta das páginas

 *  abaEx.addAba(nomAba,urlAba); // Criando as abas

 *  abaEx.observer(); // tornando as abas ativas.

 *  

 *  @author Caio Teixeira - FIVECOM 2008

 */



function Aba() {

	

	this.aba = new Array();

	

	this.url = new Array();

	

	this.classeAbaAtiva = null;

	

	this.container = null;

	

	this.addAba = 

		function(abas,paginas) {    	

		    this.aba = abas;

			this.url = paginas;

	},

	

	this.setClasseAbaAtiva = 

		function(classe) {

			this.classeAbaAtiva = classe;

	},

	

	this.setContainer = function(container) {

		this.container = container;

	},

	



	

	this.addAction = 

		function() {

			var caminho = Constantes.URL_PAGINAS;

			var container = this.container;

			var urlAtual;

			var numeroAba = this.aba.length;

			var classeAbaAtiva = this.classeAbaAtiva;

			for (var ite in this.aba) {

				

				urlAtual = caminho + "/" + this.url[ite];



				$("#" + this.aba[ite]).attr("id","aba_" + (parseInt(ite)+1));

				$("#aba_" + (parseInt(ite)+1)).attr("url",urlAtual);



			



				$("#aba_" + (parseInt(ite)+1)).click( 

									function(){ 

										for (var i=1;i<=numeroAba;i++) {

											$("#aba_"+i).removeClass(classeAbaAtiva);

										}

										

										$(this).addClass(classeAbaAtiva);

										

										$("#"+container).load($(this).attr("url"),{ cache:false});

										

									} 

				);

		

		}

	},

	

	this.cargaAba = 

		function(idAba) {

			$("#"+idAba).addClass(this.classeAbaAtiva);

	},

	

	this.observer = 

		function() {

		   this.addAction();

		}



};



/**

 * Classe responsável por criar o menu do topo

 * 

 * @example 

 * 

 * var menuTopo = new Menu();

 * menuTopo.setMenuAtivo('menu_noticia'); // id menu a ser carregado

 * menuTopo.setSubMenuAtivo('submenu_noticias'); id submenu a ser carregado

 * menuTopo.carregarMenu();	

 * 

 * @author Caio Teixeira - FIVECOM 2008

 * 

 */



function Menu() {	



		this.menuAtivo  = null;

		

		this.subMenuAtivo = null;

		

		this.classeMenuAtivo = 'menu_ativo';

		

		this.delayMenuAtual = 3000;

		

		this.setMenuAtivo = 

			function(menuId) {

				this.menuAtivo = menuId;

		},

		

		this.setSubMenuAtivo = 

			function(subMenuId) {

				this.subMenuAtivo = subMenuId;

		},

		

		this.setDelayMenu = 

			function(delay) {

				this.delayMenuAtual = delay;

		},

			

		this.ativaMenu = 

			function(menuId,subMenuId) {

				

				var spans = document.getElementsByTagName("span");

				for (var i=0;i<spans.length;i++) {

					if (spans[i].className == this.classeMenuAtivo) {

						spans[i].className = "";

					}

				}

				document.getElementById(menuId).className = this.classeMenuAtivo;

				

				//$("span[@class*="+this.classeMenuAtivo+"]").removeClass(this.classeMenuAtivo);

				

				//$("#"+menuId).addClass(this.classeMenuAtivo);

				if (document.getElementById(subMenuId) != null) {

					document.getElementById("submenu").innerHTML = document.getElementById(subMenuId).innerHTML;

					//$("#submenu").html($("#" + subMenuId).html());

				} else {

					//$("#"+menuId).css("cursor: hand;");

					//$("#submenu").html("");

					document.getElementById("submenu").innerHTML = "";

				}

			

		},

		



		this.inativa =

			function(evt,menuId,subMenuId) {

				var trajeto = evt.toElement || evt.relatedTarget;

				if (trajeto.id.indexOf("menu") == -1) {

					//this.ativaMenu(this.menuAtivo, this.subMenuAtivo);

				} 

		},



		this.inativaMenu =

			function(evt,menuId,subMenuId) {

				this.inativa(evt,menuId,subMenuId);

		},



		this.carregarMenu =

			function() {

				this.ativaMenu(this.menuAtivo, this.subMenuAtivo);

			},

			

		this.abrirLink =

			function(url) {

				//$("."+this.classeMenuAtivo).css(

				//	{ cursor: "default" } );

				

				eval("location.href='"+url+"'");

			}

};



/**

 * Classe que cria as estrelas de votação

 * 

 * @example

 * 

 *  estrelas = new StarRating();

 *  estrelas.cargaEstrela(2,false); // 2 é o número da estrela a ser carregada. true/false. Caso o sistema esteja recebendo votações ou não

 *

 * @author Caio Teixeira - FIVECOM

 *

 */



function StarRating() {

	

	this.URL = Constantes.URL_ACAO;

	this.container = "container_estrelas";

	this.starId = "estrela";

	

	this.imagemOn = "/imagens/estrela.gif";

	this.imagemOff = "/imagens/estrela_off.gif";

	

	this.estrelas = new Array(1,2,3,4,5);

	this.estrelaPadrao = null;

	this.lock = false;

	

	

	this.starUp = 

		function(estrela) {

			if (this.lock) 

				return;

			else {

				estrelaArr = this.estrelas;

				

				try {

					for (i in estrelaArr) {

					

						//document.images[this.starId + "_" + estrelaArr[item]].title = this.tip[item];

						if (i >= estrela) {

							document.images[this.starId + "_" + estrelaArr[i]].src = this.imagemOff;

						}

						else {

							document.images[this.starId + "_" + estrelaArr[i]].src = this.imagemOn;

						}

					}

				} 

				catch (e) {

				}

				

			}

	},

	

	this.starDown = 

		function(evt,estrela) {

			if (this.lock) {

				return;

			}

			else {

				var trajeto = evt.toElement || evt.relatedTarget;

				estrelaArr = this.estrelas;

				if (trajeto.id.indexOf(this.container) == -1) {

					for (i in estrelaArr) {

					

						if (i == estrela) {

							break;

						}

						else {

							document.images[this.starId + "_" + estrelaArr[i]].src = this.imagemOff;

						}

					}

				}

				

				if (trajeto.id.indexOf(this.starId) == -1) {

					this.starUp(this.estrelaPadrao);

				}

			}

			

	},

		

	this.cargaEstrela = 

		function(quantidade,estado) {

				

				this.estrelaPadrao = quantidade;

				

				this.starUp(quantidade);

				

				if (estado) {

					this.lockStar();

				}

		},

		

		

	this.votaEstrela =

		function(materia,estrela) {

			if (this.lock) {

				return;

			}

			else {

				$.ajax({

					url: "/index.php?id=/barraFerramenta.php",

					data: "acao=votar&cd_matia=" + materia + "&estrela=" + estrela,

					type: "POST",

					cache: false,

					success: function(html){

						$("#numero_voto").html(html);

					}

				});

				

				this.cargaEstrela(estrela);

				this.lockStar();

			}

		},



	this.votaBlogEstrela =

		function(materia,estrela) {

			if (this.lock) {

				return;

			}

			else {

				$.ajax({

					url: "/index.php?id=/barraFerramenta.php",

					data: "acao=votarBlog&cd_matia=" + materia + "&estrela=" + estrela,

					type: "POST",

					cache: false,

					success: function(html){

						$("#numero_voto").html(html);

					}

				});

				

				this.cargaEstrela(estrela);

				this.lockStar();

			}

		},



	this.lockStar =

		function() {

				this.lock = true;

				var estrelaArr = this.estrelas;

				for (i in estrelaArr) {

					//alert("link_" + this.starId + "_" + estrelaArr[i]);

					document.getElementById("link_" + this.starId + "_" + estrelaArr[i]).removeAttribute("href");

					

				}

		},

				

	this.unLockStar =

		function() {

			this.lock = false;

	},

	

	this.calculaMediaVoto =

		function(numeroVoto) {

			

		}

};



/**

 * Classe de comportamentos comuns à interface

 * 

 * @author Caio Teixeira - FIVECOM 2008

 * 

 */



Comportamento = {

		

	zoomLetra: 

	

		function(classe, tipo){

			

			var tags = Array("p","h1","h2","a","");

			

			for (tag in tags) {

				size = new String($("."+classe+ " " + tags[tag]).css("font-size"));

				var fonte = size.replace('px', '');

				

				if (fonte == "") {

					fonte = "11";

				}

				

				fonte = parseInt(fonte);

				

				if ((tipo == "+") && (fonte < 16) && (tags[tag] == "p")) {

					fonte += 1;

					$(".texto_materia p").css("font-size",fonte+"px");

					$(".texto_materia p").css("line-height","1.4em");

				} else if ((tipo == "+") && (fonte < 27) && (tags[tag] != "p")) {

					fonte += 1;

					$(".texto_materia "+tags[tag]).css("font-size",fonte+"px");

					$(".texto_materia "+tags[tag]).css("line-height","1.4em");

				}

				

				if ((tipo == "-") && (fonte > 11) && (tags[tag] == "p")) {

					fonte -= 1;

					$(".texto_materia p").css("font-size",fonte+"px");

					$(".texto_materia p").css("line-height","1.4em");

				} else if ((tipo == "-") && (fonte > 22) && (tags[tag] != "p")) {

					fonte -= 1;

					$(".texto_materia "+tags[tag]).css("font-size",fonte+"px");

					$(".texto_materia "+tags[tag]).css("line-height","1.4em");

				}

				

			}

	},





	exibeComentario: 

		function (matia) {	

			FivecomUtil.loadHtml("/index.php?id=/barraFerramenta.php&cd_matia="+matia+"&acao=listar_comentario", "#comentarios");

			$("#comentarios").show();

			

	},



	exibeComentarioBlog: 

		function (matia) {	

			FivecomUtil.loadHtml("/index.php?id=/barraFerramenta.php&cd_matia="+matia+"&acao=listar_comentario_blog", "#comentarios"+matia);

			$("#comentarios"+matia).show();

			

	},





	exibeBloco: 

		function (bloco, matia) {

			FivecomUtil.loadHtml("/index.php?id=/includes/paginas/" + bloco.toLowerCase() + ".php&cd_matia=" + matia, "#box_ferramenta");

	},

	

	exibeMais:

		function(obj,evt,matia, view) {



			var barra = new Array();

			

			barra[0]="<a href=\"javascript:Comportamento.exibeBloco('comunicar_erro', " + matia + ")\"><img alt=\"\" src=\"/imagens/icon_erro.gif\" /> comunicar erro</a>";

			//barra[1]="<a href=\"javascript:Comportamento.exibeBloco('estatisticas', " + matia + ")\"><img alt=\"\" src=\"/imagens/icon_estatisticas.gif\" /> estat&iacute;sticas</a>";

			//barra[2]="<a href=\"javascript:Comportamento.exibeBloco('tag_blog', " + matia + ")\"><img alt=\"\" src=\"/imagens/icon_blog.gif\" /> tag para blog</a>";

			//barra[3]="<a href=\"javascript:Comportamento.exibeBloco('celular', " + matia + ")\"><img alt=\"\" src=\"/imagens/icon_celular.gif\" /> celular</a>";

			//barra[4]="<a href=\"javascript:Comportamento.exibeBloco('newsletter', " + matia + ")\"><img alt=\"\" src=\"/imagens/icon_news.gif\" /> newsletter</a>";

			

			barra[5]="<a href=\"javascript:Util.linkUrl('http://del.icio.us/post?url=" + view + "');\"><img alt=\"\" src=\"/imagens/delicious.16px.gif\" /> Del.icio.us</a>";

			barra[6]="<a href=\"javascript:Util.linkUrl('http://digg.com/submit?phase=2&url=" + view + "');\"><img alt=\"\" src=\"/imagens/blog_digg.gif\" /> Digg</a>";

			barra[7]="<a href=\"javascript:Util.linkUrl('http://www.technorati.com/search/" + view + "');\"><img alt=\"\" src=\"/imagens/blog_technorati.gif\" /> Technorati</a>";

			barra[8]="<a href=\"javascript:Util.linkUrl('http://myweb2.search.yahoo.com/myresults/bookmarklet?u=" + view + "');\"><img alt=\"\" src=\"/imagens/blog_yahoo.gif\" /> Yahoo</a>";

			barra[9]="<a href=\"javascript:Util.linkUrl('http://www.google.com.br/bookmarks/mark?op=edit&bkmk=" + view + "');\"><img alt=\"\" src=\"/imagens/blog_google.gif\" /> Google</a>";

			barra[10]="<a href=\"javascript:Util.linkUrl('http://www.twitthis.com/twit?url=" + view + "');\"><img alt=\"\" src=\"/imagens/blog_twitthis.gif\" /> Twitthis</a>";

			barra[11]="<a href=\"javascript:Util.linkUrl('http://www.linkk.com.br/submit.php?url=" + view + "');\"><img alt=\"\" src=\"/imagens/blog_linkk.gif\" /> Linkk</a>";

			barra[12]="<a href=\"javascript:Util.linkUrl('http://www.facebook.com/share.php?u=" + view + "');\"><img alt=\"\" src=\"/imagens/blog_facebook.gif\" /> Facebook</a>";

	

			return dropdownmenu(obj, evt, barra, '180px');

	},

	

	escondeMais: 

		function() {

			return delayhidemenu();

		},

		

	bookmarkSite: 

	

		function(titulo, url) {

	

			if (window.sidebar) // firefox

				window.sidebar.addPanel(title, url, "");

			else 

				if (window.opera && window.print) { // opera

					var elem = document.createElement('a');

					elem.setAttribute('href', url);

					elem.setAttribute('title', titulo);

					elem.setAttribute('rel', 'sidebar');

					elem.click();

				}

				else 

					if (document.all)// ie

						window.external.AddFavorite(url, title);

	},

		

	mudaAbaNoticiaRelacionada: 

		function(novaAba,bloco) {

		   var abas = new Array('aba_noticia_relacionada_leia_tambem', 'aba_noticia_relacionada_mais_lidas', 'aba_noticia_relacionada_mais_comentadas');

		   

		   for (var aba in abas) {

			   	$("#"+abas[aba]).removeClass("ativo");

		   }

		  

		   $("#"+novaAba).addClass("ativo");

		   

		   

		   $.ajax({

					url: Constantes.URL_PAGINAS + '/' + bloco.toLowerCase() + '.php',

					cache: false,

				    success: 

						function(html) {

					 	   $("#noticiasRelacionadasMateria").html(html);	

					    }	

					});	

	},

	

	exibeObjeto:

		function(item) {

			$("#"+item).css("display","block");

	},



	escondeObjeto:

		function(obj) {

			$("#"+item).css("display","none");

		},

	

	

	cargaMenu:

		function(menu,submenu) {

			cargaMenu = new Menu();

			cargaMenu.setMenuAtivo(menu);

			cargaMenu.setSubMenuAtivo(submenu);

			cargaMenu.carregarMenu();

		},	

	

	exibeToolTip:

		function(texto,tamanho) {

			return ddrivetip(texto, tamanho);

	},

	escondeToolTip:

		function() {

			return  hideddrivetip();

	},

		

	exibeHotWords:

		function(texto,tamanho,cor, urlImg, descricao) {

			return ddrivetip_hot(texto,tamanho,cor, urlImg, descricao);

	},

	escondeHotWords:

		function() {

			return  hideddrivetip();

		},

		

	submitForm:

		function(form, div) {

			var data = $(form).serialize();

			$.ajax( {

				url: $(form).attr("action"),

				type: $(form).attr("method"),

				data: data,

				cache: false,

				async: true,

				beforeSend: function(xmlhttprequest){

					

				},

				complete: function(xmlhttprequest){

					

				},

				success: function(html){

					$(div).html(html);

				}

			});

		},



	loadHtml:

		function(Url, div) {

			//alert(Url);

			$.ajax({

				url: Url,

				type: "GET",

				cache: false,

				async: false,

				beforeSend: function(xmlhttprequest){

					//$('#loading').show();

				},

				error: function (XMLHttpRequest, textStatus, errorThrown) {

				  alert('Erro: ' + textStatus);

				},

				complete: function(xmlhttprequest){

					//$('#loading').hide();

				},

				success: function(html){

					//alert(html);

					$(div).html(html);

				}

			});

		},





	formatCampo:

		function (src, mask) {

			var i = src.value.length;

			var saida = mask.substring(0,1);

			var texto = mask.substring(i)

		

			if (texto.substring(0,1) != saida) {

				src.value += texto.substring(0,1);

			}

		},

		

	comentar:

		function() {

			var form = window.document.frmComentar;

			

			if (form.ds_comma.value == "") {	

				alert("O campo descrição deve ser preenchido!");

				form.ds_comma.select();



			} else if (form.ds_usuin_email.value == "") {

				alert("O campo email deve ser preenchido!");

				form.ds_usuin_email.select();

			} else if (form.ds_usuin_senha.value == "") {

				alert("O Campo senha deve ser preenchido!");

				form.ds_usuin_senha.select();

			} else if (form.id_politica.checked == false) {

				alert("Você deve aceitar as clausulas da politica de privacidade!");

				form.ds_usuin_senha.select();

			} else {
				this.submitForm("#frmComentar", "#comentarios");
			}

		},





	comentarBlog:

		function(id) {

			var form = window.document.getElementById("frmComentar"+id);

			

			if (form.ds_comma.value == "") {	

				alert("O campo descrição deve ser preenchido!");

				form.ds_comma.select();



			} else if (form.ds_usuin_email.value == "") {

				alert("O campo email deve ser preenchido!");

				form.ds_usuin_email.select();

			} else if (form.ds_usuin_senha.value == "") {

				alert("O Campo senha deve ser preenchido!");

				form.ds_usuin_senha.select();

			} else if (form.id_politica.checked == false) {

				alert("Você deve aceitar as clausulas da politica de privacidade!");

				form.ds_usuin_senha.select();

			} else {

				this.submitForm("#frmComentar"+id, "#comentarios"+id);

			}

		},









	indicar: 

		function(form) {

			var form = window.document.frmIndicar;

			

			if (form.nome_indicar_materia.value == "") {

				

				alert("Campo nome deve ser preechido!");

				form.nome_indicar_materia.select();

								

			} else if (form.email_indicar_materia.value == "") {				

				

				alert("O campo email deve ser preenchido!");

				form.email_indicar_materia.select();			

			

			} else if (!Util.checaEmail(form.email_indicar_materia.value)) {

				

				alert("O email digitado é inválido!");

				form.email_indicar_materia.select();

				

			} else {

				this.submitForm("#frmIndicar", "#box_ferramenta");

			}

		},



	// Validação BOX COMUNICAR ERRO

	comunicarErro:

		function(form) {

			var form = window.document.frmComunicarErro;

			

			if (form.email_comunicar_erro.value == "") {				

				alert("O Campo email deve ser preenchido!");

				form.email_comunicar_erro.select();

			} else if (!Util.checaEmail(form.email_comunicar_erro.value)) {			

				alert("O email digitado não é válido");

				form.email_comunicar_erro.select();

			} else if (form.descricao_comunicar_erro.value == "") {

				alert("O campo descrição deve ser preenchido");

				form.descricao_comunicar_erro.select();

			} else {

				

				this.submitForm("#frmComunicarErro", "#box_ferramenta");

			}

		}

	



};



/**

 * Classe de validação dos formulários do sistema. É utilizado requisição AJAX para alguns forms.

 * 

 * @param {Object} form Objeto de formulário

 * 

 */



Validacao = {

	

	// Validação BOX NEWSLETTER

	

	newsletter: 

		function(form) {

			if (form.login_newsletter.value == "") {

				alert("O campo login deve ser preenchido!");

				form.login_newsletter.select();	

			} else if (form.senha_newsletter.value == "") {				

				alert("O campo senha deve ser preenchido!");

				form.senha_newsletter.select();

			} else {

								

				$.ajax( {

						url: Constantes.URL_ACAO,

						data: $(form.id).serialize() + "&acao=newsletter",

						type: "POST",

						cache: false,

						success: 

							function(html) {

								 ("#box_ferramenta").html(html);	

							}	

					 } );	

			}

		},

	

	// Validação BOX CELULAR

	

	celular:

		function(form) {

			

			if (form.ddd_celular.value == "") {

				

				alert("O campo DDD deve ser preenchido!");

				form.ddd_celular.select();

				

			} else if (form.numero_celular.value == "") {

				

				alert("O campo celular deve ser preenchido!");

				form.numero_celular.select();

			

			

			} else {

				

				$.ajax( {

						url: Constantes.URL_ACAO,

						data:  $(form.id).serialize()+ "&acao=celular",

						type: "POST",

						cache: false,

						success: 

							function(html) {

								 alert(html);	

							}	

					 } );		

			}

		}

	

	

};



/**

 * Classe de métodos estáticos comuns ao sistema. 

 *  

 */



Util = {

	

	getFlash :	

		function(arquivo, largura, altura, bgcolor, id, qualidade, alinhamento, transparente, pgphp) {

			obj = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="'+largura+'" height="'+altura+'" id="'+id+'" align="'+alinhamento+'">';

			obj+= '<param name="allowScriptAccess" value="sameDomain" />';

			obj+= '<param name="movie" value="'+arquivo+'" />';

			obj+= '<param name="quality" value="'+qualidade+'" />';

			if(transparente == true) {

				obj+= '<param name="wmode" value="transparent" />';

			}

			obj+= '<param name="bgcolor" value="'+bgcolor+'" />';

			obj+= '<param name="FlashVars" value="pais='+pgphp+'" />';

			obj+= '<embed src="'+arquivo+'" '+((transparente==true)?'wmode="transparent"':'')+'" quality="'+qualidade+'" bgcolor="'+bgcolor+'" FlashVars="pais='+pgphp+'" width="'+largura+'" height="'+altura+'" name="'+id+'" align="'+alinhamento+'" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';

			obj+= '</object>';

			document.write(obj);

		},

	underline:

		function (obj){

			if(obj.style.textDecoration == "underline")

				obj.style.textDecoration = "none";	

			else

				obj.style.textDecoration = "underline";

		},



	imgRollover:

		function (id, imagem){

				window.document.getElementById(id).src=imagem;

		},



	popup :

		function(Url, Titulo, Width, Height, Scrollbar) {

	    	window.open(Url, Titulo, 'width='+Width+', height='+Height+', scrollbars='+Scrollbar+', status=no, resizable, top='+((screen.availHeight/2)-(Height/2))+', left='+((screen.availWidth/2)-(Width/2)))

		},

	

	formatar :

		function(src, mask) {

			var i = src.value.length;

			var saida = mask.substring(0,1);

			var texto = mask.substring(i)



			if (texto.substring(0,1) != saida) {

				src.value += texto.substring(0,1);

			}

		},

	

	validaBusca :

		function() {

			if (window.document.Busca.ds_busca.value == "")	{

				alert("Digite uma palavra-chave para realizar a busca.");

				return false;

			} else {

				window.document.Busca.submit();

			}

		},	

	

	underline :

		function(obj) {

			if(obj.style.textDecoration == "underline")

				obj.style.textDecoration = "none";	

			else

				obj.style.textDecoration = "underline";

		},

	 

	imprimir :

		function(pagina) {

			Popup("/index.php?id=/includes/paginas/imprimir.php&cd_matia="+pagina, "imprimir", 700, 500, "yes");

		},

	checaEmail : 

		function(email) {

		   var expreMail = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;

		   if (expreMail.test(email))

		     return true;

 		   else

			return false;

		},

		

	apenasNumerico: 

		function(caracter) {

        	if(document.all) { // Internet Explorer

       		 	 var tecla = event.keyCode;

       		 } else {

		        var tecla = caracter.which;

		     }

       

	   		if(tecla > 47 && tecla < 58) { // numeros de 0 a 9

        		 return true;

        	} else {

		         if (tecla != 8) { // backspace

        			  return false;

         		} else {

			           return true;

         		  }

      	 	 }

		},		

		

	include : 

		function(arquivo) {

			//By Fabrício Magri e Micox

			//http://elmicox.blogspot.com/2006/12/include-em-javascript.html

			 var novo = document.createElement('script');

			 novo.setAttribute('type', 'text/javascript');

			 novo.setAttribute('src', arquivo);

			 document.getElementsByTagName('head')[0].appendChild(novo);

 			//apos a linha acima o navegador inicia o carregamento do arquivo

			 //portanto aguarde um pouco até o navegador baixá-lo. :)

		},

	

	capitalize:

		function(form) {

			var pars = "";

			for (var i=0;i<form.length;i++) {

				pars += form.elements[i].name + "=" + form.elements[i].value + "&";

			}

			

			return pars.substr(0,pars.length-1);

		},

		

	imgRollover: 

		function(id, imagem){

			window.document.getElementById(id).src=imagem;

	},

	

	loadHtml:

		function(Url, div) {

			//alert(Url);

			$.ajax({

				url: Url,

				type: "GET",

				cache: false,

				async: false,

				beforeSend: function(xmlhttprequest){

					//$('#loading').show();

				},

				error: function (XMLHttpRequest, textStatus, errorThrown) {

				  alert('Erro: ' + textStatus);

				},

				complete: function(xmlhttprequest){

					//$('#loading').hide();

				},

				success: function(html){

					//alert(html);

					$(div).html(html);

				}

			});

		},

		

	linkUrl:

		function (url, var1, var2, var3, var4, var5, var6) {

			 

			 if(typeof var1 != "undefined")

			 	url = url+'&'+var1;

			 if(typeof var2 != "undefined")

			 	url = url+'&'+var2;

			 if(typeof var3 != "undefined")

				url = url+'&'+var3;

			 if(typeof var4 != "undefined")

			 	url = url+'&'+var4;

			 if(typeof var5 != "undefined")

			 	url = url+'&'+var5;

			 if(typeof var6 != "undefined")

			 	url = url+'&'+var6;

			 window.document.location.href = url;

			 

		}			

 



};







window.onload = 

	function() {

	

		

		arrayUrlAbaNoticia = new Array('noticia_relacionada_leia_tambem.php','noticia_relacionada_mais_lidas.php','noticia_relacionada_mais_comentadas.php');		

		

		arrayAbaNoticia = new Array('link_local','link_nacional','link_internacional','link_esportes','link_enviadas');

			

		//abaVideo = new Aba();

			

		//abaVideo.setContainer('noticiaCollDestaqueMateria');

			

		//abaVideo.setClasseAbaAtiva("ativo");

			

		//abaVideo.addAba(arrayAbaNoticia, arrayUrlAbaNoticia);

		

		//abaVideo.observer();

		

		if (document.getElementById("container_estrelas") != null) {

		

			arrayUrlAbaNoticia = new Array('noticia_relacionada_leia_tambem.php','noticia_relacionada_mais_lidas.php','noticia_relacionada_mais_comentadas.php');

			arrayAbaNoticia = new Array('link_aba_leia_tambem','link_aba_mais_lidas','link_aba_mais_comentadas');

			

			abaNoticia = new Aba();

			abaNoticia.setClasseAbaAtiva('ativo');

			abaNoticia.setContainer('noticiasRelacionadasMateria');

			abaNoticia.addAba(arrayAbaNoticia, arrayUrlAbaNoticia);

			abaNoticia.cargaAba('link_aba_leia_tambem');

			abaNoticia.observer();

		}

		

		//Comportamento.getLightBox('conteudo');

		

		if (document.getElementById("container_estrelas") != null) {

			

			//estrelas = new StarRating();

			//estrelas.cargaEstrela(2,false);

		}

		

		/*

		menuTopo = new Menu();

		menuTopo.setMenuAtivo('menu_noticia');

		menuTopo.setSubMenuAtivo('submenu_noticias');

		menuTopo.carregarMenu();	

		*/



};
