/*  
  Modulo  jQuery Assec SIM 2010     v1.1  
  jQuery coder: ppires@assec.pt  
  
  */
 
  
  
var resizeTimer = null;
var posRedimPagAlt = null;
var posRedimPagLarg = null;
var posRedimPagfim = null;
var ixLoadingOffCallback = null;

var  sfNoticia =false 
 
var isLoading =  false;

var av = 0;
var bv = 0;
var hv = 0;

(function($){
		
    $.fn.xDbg =function(v){
		return this.each(function(){
			 return;
			if (!console) return;
			console.info(v); 
			});
		};	
	})(jQuery);  
 

$(function (){ $.ixLoading(); });
$(window).bind("load", function() { 
	$.redimensionaPag(); 
	$.ixLoadingOff();});

$(document).ready(function () {
	//$.redimensionaPag();
	
	} );
 	
$(window).bind('resize', function() {
	if (resizeTimer) clearTimeout(resizeTimer);
	resizeTimer = setTimeout(redimensionaPag, 100);
});
	
function redimensionaPag (){
	//$.ixLoading();  
	$.redimensionaPag();  
	//$.ixLoadingOff(1); 
	if (jQuery.isFunction(posRedimPagAlt)) posRedimPagAlt();
	}
	

function redimensionaPagLargura(){ 
	av = 0;
	bv = 0;
	var w = $(window).width();  
	if (  w > 1001   ) { 
		av =  parseInt((w  - 2*$('#assecesquerda').width()  - $('#assecdireita').width()))  ;
		bv = $('#assecesquerda').width()  - $('#assecdireita').width(); 
		if ( av <810 ) { av=810; bv=0;} 
		$('#asseccentro').css( { width: av+'px','padding-right': bv+'px'}); 
				  
		} else $('#asseccentro').css( { 'margin-left':'0px', width:'810px','padding-right':'0px'});
	}
 
 function redimensionaPagAltura(){
	var h =  $(window).height(); 
	hv =0;
	if (h > 732 ){
		 
		hv = h  - $('#asseccentro').height()- 175;  
		if (hv < 1) hv =0;
		if ($('#assecbottom #bottom1' ).css('display') == 'none') hv = hv+44;
		$('#fundo0').css( {top: (520 + hv)+'px'});
		$('#asseccentro').css( {'padding-top': hv+'px'}); 
		}
	else { 
		$('#fundo0').css( {top: '520px'});
		$('#asseccentro').css( {'margin-top': '0px'});
		} 
	}

	
// 
function tabNoticias(v){ 
	if (sfNoticia) return;
	sfNoticia = true;
	$('#noticiadetalhe').html('');
	$('#noticiadetalhe').html( $(v).html() );
	
	$('#noticiadetalhe').show('fast', function (){ sfNoticia = false;} );
	 
	
	}	
	
 $.redimensionaPag  = function (){	
	//$('#asseccentro').css({'visibility': 'hidden'});

 
	if (jQuery.isFunction(posRedimPagfim)) posRedimPagfim();
	redimensionaPagLargura();  
	if (jQuery.isFunction(posRedimPagLarg)) posRedimPagLarg();	
	redimensionaPagAltura();  
	if (jQuery.isFunction(posRedimPagAlt)) posRedimPagAlt();
	
	$('#asseccentro').css({'visibility': 'visible'});
	
	}

 $.ixLoading = function (){
	if (isLoading) return;
	isLoading = true;
	if (jQuery.isFunction(ixLoadingOffCallback)) ixLoadingOnCallback();
	$('body').append('<div id="ixpane"><div class="nuvem"></div><div class="bloco"><img src="'+base_url+'loading.gif" /></div></div>');
	$('#ixpane div.nuvem').css({'height':parseInt($(window).height() -1)+'px'})
	}

 $.ixLoadingOff = function (p){	
    isLoading = false;
	if (p ==1)  return $('#ixpane').remove();
	$('#ixpane').fadeOut(1000, function (){ $(this).remove(); 
		if (jQuery.isFunction(ixLoadingOffCallback)) ixLoadingOffCallback();
		});
	}
	
	
 // objectos desenvolvidos
 $.ppirexDbg = function(v){
	return;
	if (!console) return;
	console.info(v);
	}

 $.xDG = function(v){return this.each(function(){if (!console) return;console.info(v);});}
	
 
 

