﻿
      
   var ACTUAL_FONTSIZE = 0;
   var ArrayFontSize = new Array('','14px','16px','18px','20px', '22px');
   var ArrayFontSizeSummary = new Array('','18px','20px','22px','24px', '26px');
   var ArrayFontSizeSummaryContent = new Array('','18px','20px','22px','24px', '26px');
   //pagina programas
   var ArrayFontSizeSummaryContentVideo = new Array('','16px','18px','20px','22px', '24px');
      var ArrayFontSizeSummaryContentSinopse = new Array('','14px','16px','18px','20px', '22px');
      
       
   function MagnifyText(iDirection)
   {
   
   if (ACTUAL_FONTSIZE == null || (1*ACTUAL_FONTSIZE).toString() == 'NaN') ACTUAL_FONTSIZE = 0;
  
   var BtmAumentar = document.getElementById('BtnAumentar');
    var BtmDiminuir = document.getElementById('BtnDiminuir');
   
      
      if (iDirection > 0 && ACTUAL_FONTSIZE < ArrayFontSize.length-1) 
      
      ACTUAL_FONTSIZE++;
      
      	 
      else if (iDirection < 0 && ACTUAL_FONTSIZE > 0) 
			 ACTUAL_FONTSIZE--;
      
      
      
    
	   
	   SaveCookie("tsfFontSize",ACTUAL_FONTSIZE, true);
	   
	   
	   
	  
	   
	   	   
	  
	  
      var oNewsMain = document.getElementById("Article");
      if (oNewsMain) oNewsMain.style.fontSize = ArrayFontSize[ACTUAL_FONTSIZE];     
      
      
      /*
      var oSummaryContent = document.getElementById("SummaryContent");
      if (oSummaryContent) oSummaryContent.style.fontSize = ArrayFontSizeSummaryContent[ACTUAL_FONTSIZE];  
      */
      
       var oSummaryContentVideo = document.getElementById("SummaryContentVideo");
      if (oSummaryContentVideo) oSummaryContentVideo.style.fontSize = ArrayFontSizeSummaryContentVideo[ACTUAL_FONTSIZE];     
      
      
      
      var oSummaryContentSinopse = document.getElementById("SummaryContentSinopse");
      if (oSummaryContentSinopse) {
       oSummaryContentSinopse.style.fontSize = ArrayFontSizeSummaryContentSinopse[ACTUAL_FONTSIZE];  
       /*
       var k, arrChildren = oSummaryContentSinopse.childNodes;
		 if (arrChildren) {
			 for (k=0; k<arrChildren.length; k++)
				if ( arrChildren[k].nodeName.toString().toLowerCase() != "#text" ) {
				  arrChildren[k].style.fontSize = ArrayFontSizeSummaryContentSinopse[ACTUAL_FONTSIZE];  
				 
				} 
		  }*/
		}
		  else {
			 var oNewsSummary = document.getElementById("NewsSummary");
			 if (oNewsSummary) oNewsSummary.style.fontSize = ArrayFontSizeSummary[ACTUAL_FONTSIZE];  
		}
      
   }
   
     
     
   
      
   var sDivHeight = 0;
   function ShowMaisUltimas() 
   {
      var oDiv1 = document.getElementById("maisultimas");
    
      if (oDiv1)
      {
        if(oDiv1.style.display == "")
          oDiv1.style.display = "none";
        else
          oDiv1.style.display = "";
      }
   }

   function ChangeLayerPais(Layerid, obj, parentname, elementname, elementname2) 
   {
   
    var parentobj = GetAncestor(obj,parentname);
    var element = GetDescendant(parentobj,elementname,"div");
    var element2 = GetDescendant(parentobj,elementname2,"div");
    if ( element && element2)   
      if (Layerid==1)
      {
        element.style.display = "";
        element2.style.display = "none";
      }
      else if (Layerid==2)
      {
        element.style.display = "none";
        element2.style.display = "";
      }
   }

function empty(){}
   
var NewsArgs;
function PrintNews()
{
   var id = GetQueryStringValue("content_id");
   if ( id ) {
       var sFeatures = "height=560px,width=600px,status=no,toolbar=no,menubar=no,location=yes,scrollbars=yes";
       window.open("/Common/print.aspx?content_id=" + id, "Print", sFeatures);
   }
}




function SendNewsAudio (nomeId, commentId, destinationId, isSinopse, originNameId, originMailId, programTitleId, commentQS)
{
  
    var oTitle = document.getElementById("NewsTitle");
    var oSummary = document.getElementById("NewsSummary");
    var sFeatures, sLoc = document.location.toString().toLowerCase();
    var id = GetQueryStringValue("content_id");
    if ( (commentId!=null && destinationId!=null && sLoc.indexOf("programa.aspx")<0 ) ) {
        var objId = document.getElementById("AudioVideoId");
        if (objId) id = objId.value;
        var oLoc = document.getElementById("AudioVideoLink");
        if (oLoc && oLoc.value) sLoc = oLoc.value.toLowerCase();
    }
    
  
    NewsArgs = Array((oTitle ? oTitle.innerHTML : ""), (oSummary ? oSummary.innerHTML:""), sLoc);
    var url = "";
    var sFeatures = "height=340px,width=700px,status=no,toolbar=no,menubar=no,location=yes,scrollbars=yes";
    if ( id ) {
         var url = "/Common/send.aspx?content_id=" + id;
         if (nomeId) {
           var nome = document.getElementById(nomeId);
           url += "&nome=" + ( nome && nome.value!=nome.title ? escape(nome.value) : "" );
         }
         if (commentId) {
           var comment = document.getElementById(commentId);
           url += "&comment=" + ( comment && comment.value!=comment.title ? escape(comment.value) : "" );
         }
         if (destinationId) { 
           var destination = document.getElementById(destinationId);
           url += "&destination=" + ( destination && destination.value!=destination.title ? escape(destination.value) : "" ) + "&url=" + escape(sLoc);
         }
         if (originMailId) { 
           var origin_mail = document.getElementById(originMailId);
           url += "&origin_mail=" + ( origin_mail ? escape(origin_mail.value) : "" );
         }
         if (originNameId) { 
           var origin_name = document.getElementById(originNameId);
           url += "&origin_name=" + ( origin_name ? escape(origin_name.value) : "" );
         }
         if (programTitleId) { 
           var program = document.getElementById(programTitleId);
           url += "&program=" + ( program ? escape(program.value) : "" );
           
          
         }
         if (commentQS) {
           url += commentQS;
         }
        
         window.open(url, "Send", sFeatures);
    }
}


function SendNews(commentId, destinationId, isSinopse, originNameId, originMailId, programTitleId, commentQS)
{
    var oTitle = document.getElementById("NewsTitle");
    var oSummary = document.getElementById("NewsSummary");
    var sFeatures, sLoc = document.location.toString().toLowerCase();
    var id = GetQueryStringValue("content_id");
    if ( (commentId!=null && destinationId!=null && sLoc.indexOf("programa.aspx")<0 ) ) {
        var objId = document.getElementById("AudioVideoId");
        if (objId) id = objId.value;
        var oLoc = document.getElementById("AudioVideoLink");
        if (oLoc && oLoc.value) sLoc = oLoc.value.toLowerCase();
    }
  
    NewsArgs = Array((oTitle ? oTitle.innerHTML : ""), (oSummary ? oSummary.innerHTML:""), sLoc);
    var url = "";
    var sFeatures = "height=340px,width=700px,status=no,toolbar=no,menubar=no,location=yes,scrollbars=yes";
    if ( id ) {
         var url = "/Common/send.aspx?content_id=" + id;
         if (commentId) {
           var comment = document.getElementById(commentId);
           url += "&comment=" + ( comment && comment.value!=comment.title ? escape(comment.value) : "" );
         }
         if (destinationId) { 
           var destination = document.getElementById(destinationId);
           url += "&destination=" + ( destination && destination.value!=destination.title ? escape(destination.value) : "" ) + "&url=" + escape(sLoc);
         }
         if (originMailId) { 
           var origin_mail = document.getElementById(originMailId);
           url += "&origin_mail=" + ( origin_mail ? escape(origin_mail.value) : "" );
         }
         if (originNameId) { 
           var origin_name = document.getElementById(originNameId);
           url += "&origin_name=" + ( origin_name ? escape(origin_name.value) : "" );
         }
         if (programTitleId) { 
           var program = document.getElementById(programTitleId);
           url += "&program=" + ( program ? escape(program.value) : "" );
         }
         if (commentQS) {
           url += commentQS;
         }
         window.open(url, "Send", sFeatures);
    }
}



function SendNewsM(commentId, destinationId, commentQS)
{
    var oTitle = document.getElementById("NewsTitle");
    var oSummary = document.getElementById("NewsSummary");
    var sFeatures, sLoc = document.location.toString().toLowerCase();
    var oLoc = document.getElementById("AudioVideoLink");
    if (oLoc && oLoc.value) sLoc = oLoc.value.toLowerCase();
    NewsArgs = Array((oTitle ? oTitle.innerHTML : ""), (oSummary ? oSummary.innerHTML:""), sLoc);
    var id = GetQueryStringValue("content_id");
    if (!id) {
      var objId = document.getElementById("AudioVideoId");
      if (objId) 
      {
        id = objId.value;
      }
      else
      {
        var objId2 = document.getElementById("NewsId");
        if (objId2) id = objId2.innerHTML;
      }
    }
    if ( id ) {
         var sFeatures = "height=360px,width=700px,status=no,toolbar=no,menubar=no,location=yes,scrollbars=yes";
         var url = "/Common/send.aspx?content_id=" + id;
         if (commentId) {
           var comment = document.getElementById(commentId);
           url += "&comment=" + ( comment && comment.value!=comment.title ? escape(comment.value) : "" );
         }
         if (destinationId) {
           var destination = document.getElementById(destinationId);
           url += "&destination=" + ( destination && destination.value!=destination.title ? escape(destination.value) : "" );
         }
         
         
         
         if (commentQS) {
           url += commentQS;
           
         }
         window.open(url, "Send", sFeatures);
    }
}




function SendComment(commentId, destinationId, isSinopse, originNameId, originMailId, programTitleId, commentQS, user, data, Comentario)
{
  
    var oTitle = document.getElementById("NewsTitle");
    var oSummary = document.getElementById("NewsSummary");
    var sFeatures, sLoc = document.location.toString().toLowerCase();
    var id = GetQueryStringValue("content_id");
    if ( (commentId!=null && destinationId!=null && sLoc.indexOf("programa.aspx")<0 ) ) {
        var objId = document.getElementById("AudioVideoId");
        if (objId) id = objId.value;
        var oLoc = document.getElementById("AudioVideoLink");
        if (oLoc && oLoc.value) sLoc = oLoc.value.toLowerCase();
    }
    NewsArgs = Array((oTitle ? oTitle.innerHTML : ""), (oSummary ? oSummary.innerHTML:""), sLoc);
    var url = "";
    var sFeatures = "height=340px,width=700px,status=no,toolbar=no,menubar=no,location=yes,scrollbars=yes";
    if ( id ) {
         var url = "/Common/sendComment.aspx?content_id=" + id + user + data + Comentario;
         if (commentId) {
           var comment = document.getElementById(commentId);
           url += "&comment=" + ( comment && comment.value!=comment.title ? escape(comment.value) : "" );
         }
         if (destinationId) { 
           var destination = document.getElementById(destinationId);
           url += "&destination=" + ( destination && destination.value!=destination.title ? escape(destination.value) : "" ) + "&url=" + escape(sLoc);
         }
         if (originMailId) { 
           var origin_mail = document.getElementById(originMailId);
           url += "&origin_mail=" + ( origin_mail ? escape(origin_mail.value) : "" );
         }
         if (originNameId) { 
           var origin_name = document.getElementById(originNameId);
           url += "&origin_name=" + ( origin_name ? escape(origin_name.value) : "" );
         }
         if (programTitleId) { 
           var program = document.getElementById(programTitleId);
           url += "&program=" + ( program ? escape(program.value) : "" );
           
          
         }
         if (commentQS) {
           url += commentQS;
         }
        
         window.open(url, "Send", sFeatures);
    }
}

var statsComments = 0, statsVisits = 0, statsPrint = 0, statsSend = 0, statsVideo = 0,statsVideoSend = 0, statsAvailable = false;

function ShowStats(visible, hasComments, texttodisplay)
{
  var sText = texttodisplay ? texttodisplay : "";
  
  if (statsAvailable) {
    var statsWrapper = document.getElementById("StatsWrapper");

    if (statsWrapper) {
      //if (!visible && statsWrapper.style.display == "inline") alert(window.event);
      statsWrapper.style.display = visible ? "inline" : "none";
      var hbq = document.getElementById("EstatisticasLink");
      if(hbq)
      {
       var hbqx = getXCoord(hbq);
       //statsWrapper.style.marginTop = "-10px";
       statsWrapper.style.marginLeft = hbqx+"px";
      }
      var stats = document.getElementById("Stats");
      if (stats) {
			 var commentsWrapper = document.getElementById("PagerNumCommentsTotalContainer");
			 if (commentsWrapper){
			 
				var aux = commentsWrapper.innerHTML.toString();
				
				statsComments = ( aux.indexOf(' ')>0 ? aux.substr(0, aux.indexOf(' ')) : aux );
			 }
			 /*
			 stats.innerHTML = "" +
          sText + "&nbsp;" + statsVisits + "&nbsp;" + ( 1*statsVisits == 1 ? "Visualiazação" : "Visualizações" ) + "<br clear='all'/>" +
          ( 1*statsComments ? "&nbsp;" + statsComments + "&nbsp;Comentário" + ( 1*statsComments == 1 ? "" : "s" ) + "<br clear='all'/>" : "" ) +
          ( 1*statsSend ? "&nbsp;" + statsSend + "&nbsp;Envio" + ( 1*statsSend == 1 ? "" : "s" ) + "<br clear='all'/>" : "" ) +
          ( 1*statsPrint ? "&nbsp;" + statsPrint + "&nbsp;" + ( 1*statsPrint == 1 ? "Impressão" : "Impressões" ) + "<br clear='all'/>" : "" );
      */
      
     
      
      stats.innerHTML = "<table id='statsTable' class='statsdata'><tr>" 
        + sText + "<td style='font-weight:bold; text-align:right;'>" + statsVisits + "</td>" + "<td>" + "&nbsp;" +( 1*statsVisits == 1 ? "Visualiazação" : "Visualizações" ) + "</td></tr>" +
        "<tr><td style='font-weight:bold; text-align:right;'>" + statsComments + "</td>" + "<td>" + "&nbsp;" + ( 1*statsComments == 1 ? "Comentário" : "Comentários" ) + "</td></tr>" +        
        "<tr><td style='font-weight:bold; text-align:right;'>" + statsSend + "</td>" + "<td>" + "&nbsp;" + ( 1*statsSend == 1 ? "Envio" : "Envios" ) + "</td></tr>" +  
        "<tr><td style='font-weight:bold; text-align:right;'>" + statsPrint + "</td>" + "<td>" + "&nbsp;" + ( 1*statsPrint == 1 ? "Impressão" : "Impressões" ) + "</td>" +  
        "</tr></table>";
      
      
      }
    }
  }
}


function InitStats()
{

  var visitsObj = document.getElementById("AreaVisitas");
  if (visitsObj) {
    statsVisits = GetFirstChild(GetFirstChild(visitsObj)).innerHTML; 
    var printObj = GetDescendant(visitsObj, "AreaImpressoes", "div");
    if (printObj) statsPrint = printObj.innerHTML;
    var sendObj = GetDescendant(visitsObj, "AreaEnvios", "div");
    if (sendObj) statsSend = sendObj.innerHTML;
    var videoObj = GetDescendant(visitsObj, "AreaPlayerVisits", "div");
    if (videoObj) statsVideo = videoObj.innerHTML;
    var videosendObj = GetDescendant(visitsObj, "AreaPlayerSend", "div");
    if (videosendObj) statsVideoSend = videosendObj.innerHTML;
  }
  
  //alert(visitsObj);
  //alert(visitsObj.innerHTML);
  //alert(GetFirstChild(GetFirstChild(visitsObj)).outerHTML)
  //alert(statsVisits);
  if (IsNumeric(statsVisits) && statsVisits>0) {
    statsAvailable = true;
    var showStatsobj = document.getElementById("StatsWrapper");
    //alert(showStatsobj);
    if (showStatsobj) showStatsobj.style.display = "";
    if (IsNumeric(statsVideo) && statsVideo && statsVideo*1)
    {
      var showVideoStats = document.getElementById("ShowVideoStats");
      if (showVideoStats) showVideoStats.style.display = "";
    }
    var commentsWrapper = document.getElementById("AreaComentariosWrapper");
    if (commentsWrapper){
      var totalCommentsObj = GetDescendantByPartialId(commentsWrapper, "totalComments", "div");
      if (totalCommentsObj) {
        var aux = totalCommentsObj.innerHTML.toString();
        statsComments = ( aux.indexOf(' ')>0 ? aux.substr(0, aux.indexOf(' ')) : aux );
      }
    }
  }
}

function ShowVideoStats()
{

  if (statsAvailable) {

      var statsObj = document.getElementById("VideoStats");
      if (statsObj) {
        //var stats = ( statsprogram  ? statsprogram : statsVisits );
        statsObj.innerHTML = "" +
          statsVideo + "&nbsp;vez" + ( 1*statsVideo == 1 ? "" : "es" ) + 
          (1*statsVideoSend ? "&nbsp;|&nbsp;enviado&nbsp;" + statsVideoSend + "&nbsp;vez" + ( 1*statsVideoSend == 1 ? "" : "es" ) : "");
          
           //+ ( 1*statsVideoSend ? "&nbsp;|&nbsp;enviado&nbsp;" + statsVideoSend + "&nbsp;vez" + ( 1*statsVideoSend == 1 ? "" : "es" ) : "" ) +
          
      }

  }
}


function GetPreviousAfterArticle()
{
 var docid = GetQueryStringValue("content_id");
 var sLoc = document.location.toString().toLowerCase();

 var ifr = document.getElementById("BAIfr");
 if (ifr) {
   var loc = "" +
     "/Common/Services/beforeafter_article.aspx" +
       "?content_id=" + docid + 
       "&url=" + escape("'" + sLoc + "'");
   ifr.src = loc;
 }
}
