function subTitlehighlight() {
	var moduleSelect = window.location.hash.slice(1).split('/');
	if(moduleSelect[1] != undefined && moduleSelect[1] != '' && moduleSelect[1] != moduleSelect[0]){
		if($("div[id$="+moduleSelect[1]+"]")){
			$('.smBtn').css('fontWeight', 'normal');
			$("div[id$="+moduleSelect[1]+"]").css('fontWeight', 'bold');
			$('#pageMainTitle').css('color', '#000000');
			$('#pageSubTitle').html("");
			if(!$("div[id$="+moduleSelect[1]+"]").parent().is(':first-child')){
				$('#pageMainTitle').css('color', '#C0C0C0');
				$('#pageSubTitle').html($("div[id$="+moduleSelect[1]+"]").attr("title"));
			}
		}
	}
}

function hashModuleUpdate(){
	if(ajaxBusy == "0"){
		var noCacheKey2 = Math.random();
		$('#mainHolder').fadeOut('slow', function (){
			if (window.location.hash == '' ){
				$.get("./modules/inicio/inicio.php", {nck: noCacheKey2}, function(data){
					$('#mainHolder').html(data);
					$('#mainHolder').fadeIn('slow');
				});
			}else{
				var module = window.location.hash.slice(1).split('/');
				if(module[1] != undefined && module[1] != '' && module[1] != module[0]){
					var modulePath = "./modules/"+module[0]+"/"+module[0]+".php";
					$.get(modulePath, {nck: noCacheKey2}, function(data){
						$('#mainHolder').html(data);
						var modulePath2 = "./modules/"+module[0]+"/"+module[1]+".php";
						subTitlehighlight();
						$.get(modulePath2, {nck: noCacheKey2}, function(data){
							$('#pageMainContent').html(data);
							$('#mainHolder').fadeIn('slow');
						});
					});
				}else{
					var modulePath = "./modules/"+module[0]+"/"+module[0]+".php";
					$.get(modulePath, {nck: noCacheKey2}, function (data) {
						$('#mainHolder').html(data);
						$('#mainHolder').fadeIn('slow');
						//currentMainPage = module;
						var noCacheKey = Math.random();
						
						switch (module[0]){
							case 'formacaoContinua':
								$.get("./modules/formacaoContinua/descricao.php", {nck: noCacheKey}, function (data) {
									$('#pageMainContent').html(data);
									$('#pageMainContent').fadeIn('slow');
								});
							break;
							case 'formacaoProfissional':
								$.get("./modules/formacaoProfissional/descricao.php", {nck: noCacheKey}, function (data) {
									$('#pageMainContent').html(data);
									$('#pageMainContent').fadeIn('slow');
								});
								break;
							case 'formacaoFormadores':
								$.get("./modules/formacaoFormadores/descricao.php", {nck: noCacheKey}, function (data) {
									$('#pageMainContent').html(data);
									$('#pageMainContent').fadeIn('slow');
								});
								break;
							case 'contactos':
								$.get("./modules/contactos/priorVelho.php", {nck: noCacheKey}, function (data) {
									$('#pageMainContent').html(data);
									$('#pageMainContent').fadeIn('slow');
								});
								break;
							case 'empresas':
								$.get("./modules/empresas/descricao.php", {nck: noCacheKey}, function (data) {
									$('#pageMainContent').html(data);
									$('#pageMainContent').fadeIn('slow');
								});
								break;
							case 'cno':
								$.get("./modules/cno/oQueE.php", {nck: noCacheKey}, function (data) {
									$('#pageMainContent').html(data);
									$('#pageMainContent').fadeIn('slow');
								});
								break;
							case 'noticias':
								$.get("./modules/noticias/todas.php", {nck: noCacheKey}, function (data) {
									$('#pageMainContent').html(data);
									$('#pageMainContent').fadeIn('slow');
								});
								break;
							case 'areaReservada':
								$.get("./modules/areaReservada/ficheirosInternos.php", {nck: noCacheKey}, function (data) {
									$('#pageMainContent').html(data);
									$('#mainHolder').fadeIn('slow');
								});
								break;
							default:
								break;
						};
					});
				}
			}
		});
		
	}
}

function actualizarCabecalho(){
	$("#headerSlideShow > img:eq("+headerImg+")").fadeOut("slow", function(){
		headerImg ++;
		if (headerImg>7){headerImg = 0;}
		$("#headerSlideShow > img:eq("+headerImg+")").fadeIn("slow");
	});
}

function manualHashCheck(){
	
	/*currentPage = window.location.hash.slice(1);
	if (currentPage != previousPage){
		hashModuleUpdate();
		previousPage = currentPage;
	}*/
}



function popupRedirect(place){
	ajaxBusy = "1";
	
	/*if(place=='llFormEmpresasPriorVelho'){pageTracker._trackPageview("/popup/priorVelho");}
	if(place=='llFormEmpresasGrandola'){pageTracker._trackPageview("/popup/grandola");}
	if(place=='llFormEmpresasSobral'){pageTracker._trackPageview("/popup/sobral");}
	if(place=='llFormEmpresasLousa'){pageTracker._trackPageview("/popup/lousa");}*/
	window.location.hash = "inscricoes/"+place;
	var noCacheKey = Math.random();
	var modulePath = "modules/inscricoes/inscricoes.php";
	$.get(modulePath+'?noCacheKey=', function(data){
		$('#mainHolder').html(data);
		$('#mainHolder').fadeIn('slow');
		var noCacheKey = Math.random();
		var modulePath2 = "modules/inscricoes/"+place+".php";
		$.get(modulePath2, {nck: noCacheKey}, function(data){
			$('#pageMainContent').html(data);
			$('#pageMainContent').fadeIn('slow');
			ajaxBusy = "0";
		});
	});
	TINY.box.hide();

	
	
}


