var newsaberto = 0;
function ApareceConteudoNews(a,range){
  if (newsaberto != a){
    for (x=1; x<=range; x++){
	  document.getElementById('news'+x).setAttribute("class","esconde");
	  document.getElementById('news'+x).setAttribute("className","esconde");	
	}
	document.getElementById('news'+a).setAttribute("class","aparece");
	document.getElementById('news'+a).setAttribute("className","aparece");	
	newsaberto = a;
  }else{
	for (x=1; x<=range; x++){
	  document.getElementById('news'+x).setAttribute("class","esconde");
	  document.getElementById('news'+x).setAttribute("className","esconde");
	}		
	newsaberto = 0;
  }
  location.hash = "#blocoNews"+a;
}

function urlSite(){
  var url = window.location;
  url = url.toString()
  a = url.length;
  b = url.indexOf("?news");
  if(b == -1){
  	b = url.indexOf("#news");	
  }
  id = "";
  for (c=b+5; c<=a; c++){
    id += url.charAt(c);
  }
  return (id);
}

function IsNumeric(value){
  var er = /^[0-9]+$/;
  return (er.test(value)) ? true : false;
}

var arrayPageSize;
function getPageSize(){
    
    var xScroll, yScroll;
    
    if (window.innerHeight && window.scrollMaxY) {  
      xScroll = document.body.scrollWidth;
      yScroll = window.innerHeight + window.scrollMaxY;
    } else if (document.body.scrollHeight > document.body.offsetHeight){ 
      xScroll = document.body.scrollWidth;
      yScroll = document.body.scrollHeight;
    } else { 
      xScroll = document.body.offsetWidth;
      yScroll = document.body.offsetHeight;
    }
    
    var windowWidth, windowHeight;
    if (self.innerHeight) {
      windowWidth = self.innerWidth;
      windowHeight = self.innerHeight;
    } else if (document.documentElement && document.documentElement.clientHeight) { 
      windowWidth = document.documentElement.clientWidth;
      windowHeight = document.documentElement.clientHeight;
    } else if (document.body) { 
      windowWidth = document.body.clientWidth;
      windowHeight = document.body.clientHeight;
    } 
    
    
    if(yScroll < windowHeight){
      pageHeight = windowHeight;
    } else { 
      pageHeight = yScroll;
    }

    // for small pages with total width less then width of the viewport
    if(xScroll < windowWidth){  
      pageWidth = windowWidth;
    } else {
      pageWidth = xScroll;
    }
    arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight);
}
