$(document).ready(function(){
if(PopMv=="sim"){$("#flutuante").easydrag();}
	function popUP(){
	if(PopPos=="centro"){
	Xtop=(document.body.clientHeight - AltImgPop)/2 - 150;
	Xleft=(document.body.clientWidth - LarImgPop)/2 ; 
	$('#flutuante').css({'top': Xtop,'left':Xleft})
	}}
	popUP();
	 window.onresize = function () {popUP();}

$(function() {$('#enquete').ajaxForm({ beforeSubmit: cad,success:retorno1});});
	function cad(formData, jqForm){
	var f = jqForm[0]; 
 var resposta = false;
	 $('input[@type=radio]').each(function() {
	if ( $(this).is(':checked') ) {
		resposta = true;
	}
										   })
	 if($.cookie('votou')){ alert('Seu voto já foi inserido em nosso sistema !');return false;}
	else  if(!resposta){alert('Uma opção de resposta deve ser escolhida');return false;}
	else{
	return true;
	}
	}
	function retorno1(responseText)  {
	$('#sis_enquete').empty().append(responseText);
	$.cookie('votou', 'sim',{expires: 0.0277777776});
	};
	
function ab(i,v,p,xx){$(i).click(function(){$(v).load(p,{time: (new Date()).getTime() },xx);return false});}


var e=/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/;
var mensagem = "<option>Carregando ...</option>";
var mensagem1 = "<center><span style=\"color:#cc4444\">Aguarde...</span></center>";
var mensagem2 = "<center><span style=\"color:#cc4444\">Desconectando...</span></center>";

function forgot(){alert('Este módulo esta desabilitado.');return false;}

$(function() {$('#lg').ajaxForm({beforeSubmit: valida3});});
function valida3(formData, jqForm) { 
    var f = jqForm[0]; 
$('#bob').hide();$('#boa').show();
if(slider1timer>0){
clearTimeout(slider1timer);
}
			
$("div#meio").load('construcao.php',{time: (new Date()).getTime() });
$('#boa').hide();
$('#bob').show();
    return false; 
	}	

function contatos(){
	
$('#contactar').ajaxForm({target: '#oi',beforeSubmit: validacontatos,success: retorno });	
	function validacontatos(formData, jqForm)
		{$('input,textarea').removeClass('vermei');
		var f = jqForm[0];
			if (!$.trim(f.nome.value)) {$('#oi').html('Preencha o campo Nome');f.nome.focus();$('#nome').addClass('vermei');return false; }
			else if (!$.trim(f.emailx.value)) {$('#oi').html('O campo E-mail não pode ficar em branco');f.emailx.focus();$('#emailx').addClass('vermei');return false; }
			else if (e.test($.trim(f.emailx.value))== false) {$('#oi').html('Endereço de Email inválido');f.emailx.focus();$('#emailx').addClass('vermei');return false;}
			else if (!$.trim(f.msgx.value)) {$('#oi').html('O campo Mensagem não pode ficar em branco');f.msgx.focus();$('#msgx').addClass('vermei');return false; }
			else{return true; }
	}
				function retorno(responseText)  {
					$('#contactar').remove();
					if($('#voltacontato').html() == 1){
					redir=setTimeout("window.location = 'index.php'",3000);
				}
			}		
		}
		
$(function() {$('#cadastranews').ajaxForm({beforeSubmit: validanews,success:voltanews });});
function validanews(formData, jqForm) { 
var f = jqForm[0]; 
if (!$.trim(f.emailnews.value)) {alert("O campo E-mail não pode ficar em branco");f.emailnews.focus();return false; }
else if (e.test(f.emailnews.value) == false) {alert("Endereço de E-mail inválido.");f.emailnews.focus();return false;}
else{ return true}
}
function voltanews(responseText)  {
alert(responseText);$('#emailnews').get(0).focus();
			if(responseText.indexOf("sucesso")>=0){$('form#cadastranews').resetForm();return false}
	}

	



function pageload(hash) {
		
			
		var X = {forgot:'forgot.php',registerphysics:'construcao.php',YourAccount:'construcao.php',registerlegal:'construcao.php',registerphysics:'construcao.php',contact:'contato.php',comofunciona:'bs.php?type=init',direction:'fx.php?type=direction',advice:'fx.php?type=advice',rss:'rss.php',register:'construcao.php',periodical:'jn.php',notice:'noticias.php',licitations:'licitacoes.php',escolageral:'sites.php?action=geral',links:'links.php',legislation:'legislacao.php',jobs:'vagas.php',mapa:'mapa.php',downloads:'downloads.php'};
		
		
		
		
		if(hash.match('crq') != null){	
		if(slider1timer>0){
			clearTimeout(slider1timer);
			}
			
			$("#meio").load('fixo.php?'+hash,{time: (new Date()).getTime() },function(){
								if(hash=="crqlegislation"){$.getScript('estilo/thickbox.js')};														   
								if(hash=="crqprofessionals"){$.getScript('estilo/crqprofessionals.js')};												   
								if(hash=="crqrtmenu"){
							if($.browser.msie){
							$('a[@secao=crqrtabout]').click(function(){pageload('crqrtabout')});
							$('a[@secao=crqrtauto]').click(function(){pageload('crqrtauto')});
							}
						};
						
								});return false;
		}
		else if(hash.match('site') != null){	
		if(slider1timer>0){clearTimeout(slider1timer);	}
		$("#meio").load('sites.php?'+hash,{time: (new Date()).getTime() })
		
		}
		else if(hash.match('\ler+') != null){
			var numero  = hash.replace(/[^0-9]+/g, '');
			if(slider1timer>0){
			clearTimeout(slider1timer);
			}
			
			
			$("div#meio").load('noticias.php?acao=read&id='+numero,{time: (new Date()).getTime() });
			 $('#topo').ScrollTo(800);
			//	window.scrollTo(0,0);
				return false;
		}
		else if(hash){
		
			if(slider1timer>0){
			clearTimeout(slider1timer);
			}
		$("div#meio").load(X[hash],{time: (new Date()).getTime() },
		//inicio estrutura de reatachamento
					function(){
						if(hash=="comofunciona"){$.getScript('estilo/accordion.js')};
						if(hash=="legislation"){$.getScript('estilo/thickbox.js')};	
						if(hash=="forgot"){forgot()};
						if(hash=="contact"){contatos()};
						if(hash=="mapa"){
							if($.browser.msie){
								$('a').click(function(){pageload($(this).attr('href').replace(/^.*#/, ''))})
							}
							};


					 // if(hash=="registerphysics"){pessoafisica()};
					//	if(hash=="registerlegal"){pessoajuridica()};
						if(hash=="YourAccount"){if(emailatual){suaconta()}};
						if(hash=="notice"){
						if($.browser.msie){
				
				$('a[@secao=ler]').click(function(){pageload($(this).attr('name'));});
			}
							
							};
						if(hash=="register"){
							if($.browser.msie){
							$('a[@secao=registerlegal]').click(function(){pageload('registerlegal')});
							$('a[@secao=registerphysics]').click(function(){pageload('registerphysics')});
							}
						};
					
				//FINAL estrutura de reatachamento										
													
															 }
													 
															 );
				
		}
		else{
			$("div#meio").load('principal.php',{time: (new Date()).getTime() },
			function(){$('div#descricao').border('fancy-');
			if($.browser.msie){
				
				$('a').click(function(){if($(this).attr('href').match('\ler+') != null){pageload($(this).attr('href').replace(/^.*#/, ''))}})
			}
			}
												
																		
							
							
																													);return false;
			}	
		// fim pageload
}
		$.historyInit(pageload);
		$("*[@rel='history']").click(function(){
			var hash = this.href;
			hash = hash.replace(/^.*#/, '');
			$.historyLoad(hash);
			return false;
		});	
		
		// fecha o ready do jquery
						   });
function vvoid(sURL,sNome,iWidth,iHeight)
{var page = "view.php?id=" +sURL;
 window.open(page,sNome,"status=no,menubar=no,toolbar=no,width="+ iWidth +",height="+ iHeight +",scrollbars=yes, top="+ (screen.height - iHeight)/2 +",left="+(screen.width - iWidth)/2 + "directories=no");
}