var advSearch = null;
var tmargin = 0;
var AdvTime = 0;

// EVENTOS ABRE E FECHA ID PASSADO
function Eventos_MostraBloco(id,imgName,dvName,Mostrar)
{
    if(Mostrar)
    {
        var cont = document.getElementById(imgName+id).src.indexOf('mais.gif');
        var ider = "#" + dvName+id;
        if(cont>0)
        {
            document.getElementById(imgName+id).src = '../_IMG/fileico/menos.gif';
           // document.getElementById(dvName+id).style.display = 'block';
		   $(ider).slideDown();
        }
        else
        {
            document.getElementById(imgName+id).src = '../_IMG/fileico/mais.gif';
            //document.getElementById(dvName+id).style.display = 'none';
			$(ider).slideUp();
        }
    }
}




function advHelp()
{$('#advSearchHelp').slideToggle();}

function advAlert(id){
$('.advSearchAlert div').html(id);
$('.advSearchAlert').slideToggle();
}

function advSearchStyle()
{
if($('.advSearchCat').html() != null){	
$('.advSearchCat li').addClass('advSearchFolderInit');
$('.advSeaDateFilter').click(function(){
$(".advSearch-Calendar").slideToggle("slow");
$(this).toggleClass("advSeaDateFilterMinus");});
}}


// VANTAGENS PRODUTOS
$(function(){  
      $('.vantagemProdutosItem li').hide();
	  $('.vantagemProdutosItem li:first').show();   
		 
		  
     });  
	 
	 function changeVantagem(id)
	 {
	 	 $('.vantagemProdutosItem li').hide();
	 	eleId = "#" + id;
	 	$(eleId).show();
		
		eleClass  = "." + id;
		$('.vantagemProdutosButtonStudio li').removeClass('vanProdSelected');
		$('.vantagemProdutosButtonMobile li').removeClass('vanProdSelected');
		$('.vantagemProdutosButtonSpaces li').removeClass('vanProdSelected');
		$(eleClass).addClass('vanProdSelected');
		
		//$(this).blur();
	 }
	
	
// JQUERY INIT CALLS


function initDoc()
{
	// DOCUMENTOS
	
	

	
	// CONTACTOS
	
	$(".contactUrlContent").each(function(i){
		if($(".contactUrlContent").eq(i).attr("href") == "")
	{
		$(".contactUrlName").eq(i).hide();
	}});
	
	
	
	
	$(".contactMailContent").each(function(i){
	if($(".contactMailContent").eq(i).attr("href") == "mailto:")
	{
		$(".contactMailName").eq(i).hide();
	}});
	
	$(".contactFaxContent").each(function(i){
	if($(".contactFaxContent").eq(i).html() == "")
	{
		$(".contactFaxName").eq(i).hide();
	}});
	
	$(".contactPhoneContent").each(function(i){
	if($(".contactPhoneContent").eq(i).html() == "")
	{
		$(".contactPhoneName").eq(i).hide();
	}});
	
	
	
	$(".contactAdressContent").each(function(i){
	if($(".contactAdressContent").eq(i).html().indexOf("<br>") == 0)
	{
		$(".contactAdressName").eq(i).hide();
	}});
	
	
	
	$('#doc-help a').click(function(){
									
		$('.help-content').toggle();							
	});


	
	
	

// PESQUISA AVANCADA
$('#doc-help-content').hide();
$('#doc-help').click(function(){$('#doc-help-content').toggle();});
$('#doc-help').mouseover(function (){$(this).css("cursor","pointer")}).mouseout(function (){$(this).css("cursor","default")});

$('.docTree table td a').css({fontWeight:"normal", fontSize:"11px",color:"#33383a"});
$('.docTree table td:eq(2) a').css({fontWeight:"bold", fontSize:"11px",color:"#33383a"});

$('.contentDivClass table:odd').css("background-color", "#f3f3f3");

$('.titleCat2').each(function(){
	$('.titleCat2:eq(' + tmargin +')').css('marginLeft',3*tmargin);
	tmargin = tmargin + 1;
});

if($('.titleCat').html() != null)
{
	if($('.titleCat2:last').html() != null)
	{
	$('.advSearchSubNav').html($('.advSearchSubNav').html() + ' em <i style="color:#333333">' + $('.titleCat2:last').html() + '</i>');
	$('.advSearchSubNav').insertBefore('.advSearchSubCat');
	$('.advSearchSubNav').css({display:"block"});
	}
	else{
		$('.advSearchSubNav').insertBefore('.advSearchSubCat');
		$('.advSearchSubNav').css({display:"block"});
		$('.advSearchSubNav').html($('.advSearchSubNav').html() + ' em <i style="color:#333333">' + $('.titleCat').html() + '</i>');
	}
	
	$('.advSeaDateFilter').css({display:"block"});
}else{
	$('.advSearchCat li').addClass('advSearchFolderInit');
}


$('.advSeaDateFilter').addClass('advSeaDateFilterPlus');

$('.advSeaDateFilter').click(function(){	
	 $(".advSearch-Calendar").slideToggle("slow");
	  $(this).toggleClass("advSeaDateFilterMinus"); 
	});

//$('.advSearchSubCat a:first').html('<b>Ficheiros da Categoria</a>');
$('.advSearchSubCat li').addClass('advSearchFolderInit');
if($('.advSearchSubCat a:first').html() == 'Ficheiros da Categoria')
{
	$('.advSearchSubCat li:first').addClass('advSearchFiles');
}

$('#ctl00_masterContentPlaceHolder_pesqAvancadaLink').click(function(){
	advSearchStyle();
	});

if($('#ctl00_masterContentPlaceHolder_dateInTxt').val() != "" || $('#ctl00_masterContentPlaceHolder_dateEndTxt').val() !="")
{
	$('.advSearch-Calendar').slideToggle('slow');
	$('.advSeaDateFilter').toggleClass('advSeaDateFilterMinus'); 
}


}


