/**
 * @author rnogueira@uolinc.com
 * @projectDescription Exibir um layer com informações sobre a estação para o usuário que veio de um determinado endereço
 */
 
 
 
layerAssineJS = {

  HTML_HEAD : document.getElementsByTagName('head')[0],
  HTML_DIV : document.createElement("div"),
  textoSel : "",
  texto : {
    assine :  "\
        <div class=\"texto\"><p>\
		Para assinar UOL Ligue 0800 703 3000\
        </p></div>\
    "
  },
  
  init : function(){
   	this.textoSel = this.texto.assine;
    this.importarDependencias();
	this.createElements();
    this.show();
  },

  importarDependencias : function(){
    if (typeof FullOpacity == "undefined") {
      var HTML_SCRIPT = document.createElement("script");
      HTML_SCRIPT.src="http://assinebandalarga.uol.com.br/_js/fullopacity.js";
      this.HTML_HEAD.appendChild(HTML_SCRIPT);
    }
  },
  
  createElements : function(){
    this.HTML_DIV.id="layerInfoAssine";
    this.HTML_DIV.innerHTML="\
      <div class=\"layerInfoAssineConteudo\">\
        <a href=\"javascript:FullOpacity.hide();\" class=\"btFechar\"><img src=\"https://simg.uol.com.br/bandalarga/new/btn-fechar-layer.gif\" border=\"0\" /></a>"+this.textoSel+"\
		<div class=\"suporte\"><a href=\"https://sac.uol.com.br/info/suporte/uol_suporte.jhtm\" target=\"_blank\" onclick=\"javascript:FullOpacity.hide()\"><img src=\"https://simg.uol.com.br/bandalarga/new/btn-suporte-pop.gif\" width=\"321\" height=\"34\" border=\"0\"></a></div>\
      </div>";
    this.append();
  },
  
  
  /**
   * Insere após ter carregado o primeiro node dentro do elemento body, feito para evitar bug no IE
   */
  append : function(){
    if(document.getElementsByTagName("body").length>0 && document.getElementsByTagName("body")[0].childNodes[0].parentNode)
      document.getElementsByTagName("body")[0].childNodes[0].parentNode.insertBefore(this.HTML_DIV,document.getElementsByTagName("body")[0].childNodes[0]);
    else
      setTimeout(function(){
        layerInfoAssineJS.append();
      },1000);
  },
  
  /**
   * Exibe o layer utilizando o FullOpacity apenas se o script "FullOpacity" e o elemento de id "layerInfoAssine" existirem
   */
  show : function(){
    if (typeof FullOpacity != "undefined" && document.getElementById("layerInfoAssine"))
       FullOpacity.show("layerInfoAssine");
    else
       setTimeout(function(){
         layerAssineJS.show();
       },100);
  }

}
//layerInfoAssineJS.init();
