// JavaScript Document
window.onload = function(){
  try{
	  Shadowbox.init();	
  }catch(e){}
  mostraMsg();
}

function mostraMsg(){
  var overlay = document.createElement("div")
  overlay.id = "overlay";
  
  var msg = document.createElement("div");
  msg.className = "msg_corpo"
  msg.id = "msg_corpo"
  
  var titulo = document.createElement("h1");
  titulo.innerHTML = "Mudamos de Endere&Ccedil;o";
  
  var p1 = document.createElement("p");
  p1.innerHTML = "<img src=\"images/erro/icone_aviso.png\" width=\"96\" height=\"85\" style=\"float:right\" />Ol&aacute;, muito obrigado por visitar o site da Decornat Decora&ccedil;&otilde;es.";
  var p2 = document.createElement("p");
  p2.innerHTML = "Estamos sempre buscando meios de melhorar nossos servi&ccedil;os e essa mudan&ccedil;a chegou ao nosso Web Site.";
  var p3 = document.createElement("p");
  p3.innerHTML = "Acesse nosso novo endere&ccedil;o clicando aqui ou se preferir digite o endere&ccedil;o:";
  var p4 = document.createElement("p");
  p4.innerHTML = "<a href=\"http://www.persianasdecornat.com.br\" title=\"Decornat Persianas\">www.persianasdecornat.com.br</a>";
  
  var btn = document.createElement("span");
  btn.innerHTML = "Continuar navegando";
  btn.onclick = function(){ocultaMsg();}


  msg.appendChild(titulo);
  msg.appendChild(p1);
  msg.appendChild(p2);
  msg.appendChild(p3);
  msg.appendChild(p4);
  msg.appendChild(btn);
  
  document.body.appendChild(overlay);
  document.body.appendChild(msg);
  posicionaMsg();
}

function ocultaMsg(){
  try{
	var overlay =  document.getElementById("overlay");
	var msg_corpo =  document.getElementById("msg_corpo");
  }catch(e){}
  if(overlay){
	document.body.removeChild(overlay);
	document.body.removeChild(msg_corpo);
	window.onresize = null;
	window.onscroll = null;
  }
}

function posicionaMsg(){
	window.onresize = function(){posicionaMsg();};
	window.onscroll = function(){posicionaMsg();};
	var obj = document.getElementById("msg_corpo");
	var ScrollTop;
	if (window.pageYOffset){
	  ScrollTop = window.pageYOffset;
	}
	else{
	  ScrollTop = (document.body.parentElement) ? document.body.parentElement.scrollTop : 0;
	}
	var tamJanela = getTamanhoJanela();
	obj.style.left = ((tamJanela[0] - obj.offsetWidth)/2)+"px";
	obj.style.top = (((tamJanela[1] - obj.offsetHeight)/2)+ScrollTop)+"px";
	try{
	  document.getElementById("overlay").style.height = getTamanhoPagina()[1]+"px";
	}catch(e){}
}

function getTamanhoJanela(){
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  return [myWidth,myHeight];
}

function getTamanhoPagina(){
  var altura = 0; largura = 0; 
  var tjan = getTamanhoJanela()
  if (window.innerHeight && window.scrollMaxY) {// Firefox
	altura = window.innerHeight + window.scrollMaxY;
	largura = window.innerWidth + window.scrollMaxX;
	if(altura <= 0) altura = window.innerHeight;
  } else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac 
	altura = document.body.scrollHeight;  
	largura = document.body.scrollWidth;  
  } else { // works in Explorer 6 Strict, Mozilla (not FF) and Safari    
	altura = document.body.offsetHeight;    
	largura = document.body.offsetWidth;
	if(largura<tjan[0])largura = tjan[0];
	if(altura<tjan[1])altura = tjan[1];
  }   
  return [largura,altura];
}