var aTags = new Array( 'div','td','tr');
var aFontSizes = new Array( 'xx-small','x-small','small','medium','large','x-large','xx-large' );
var aIDs = Array('txtArticle');
var nStartSize = 2;

function jsTextSize( nInc ) {

  if (!document.getElementById) return;
  
  var cElement = null, nSize = nStartSize, a, n, i, cTags;

  nSize += nInc;
  if ( nSize < 0 ) nSize = 0;
  if ( nSize > 4 ) nSize = 4;  //tamaņo maximo permitido
  nStartSize = nSize;

  for(a = 0; a < aIDs.length; a++ ) {

    if (document.getElementById(aIDs[a]) != null) {
     if ( !( cElement = document.getElementById(aIDs[a]))) {
       cElement = document.getElementsByTagName(aIDs[a])[0];        
     }
     cElement.style.fontSize = aFontSizes[nSize];

       for ( n = 0; n < aTags.length; n++ ) {
         cTags = cElement.getElementsByTagName( aTags[n] );
         for (i=0; i < cTags.length; i++ ) {
	      cTags[i].style.fontSize = aFontSizes[nSize];
         }
       }
  	 }
  }
}

function jsPrintPreview(nID) {
	window.open("/noticias/imprimir.aspx?ix=" + nID) ;
}

function jsPrint() {
    var oDivPrint = document.getElementById("divPrint");
    oDivPrint.style.display="none";
	var x = window.print();
	oDivPrint.style.display="";
}

function jsSend() {
    var divobj = document.getElementById('divSend');
 
	if(document.getElementById("divSend").style.display == "none") {
	   document.getElementById("divSend").style.display = "block" ;
	   DivCenter(divobj);
	}
}

function jsSendMail() {

  var cEmailTo = document.getElementById("txtEmailTo").value;
  var cEmailFrom = document.getElementById("txtEmailFrom").value;
  var cNameFrom = document.getElementById("txtFrom").value;
  var cComment = document.getElementById("txtComment").value;
  var nIx = document.getElementById("txtIx").value;
  var cTitle = document.getElementById("txtTitle").value;
  
  if(cEmailTo.length == 0) {
     alert('Por favor, verifique el email del destinatario'); 
     return;
  }
  
  else if(cEmailFrom.length == 0) {
     alert('Por favor, verifique el email del remitente');
     return;
  }
  
  else if(cNameFrom.length == 0) {
     alert('Por favor, ingrese el nombre del remitente');
     return;
  }
     
  var oXmlHttp = new XHConn();
  if (!oXmlHttp) {
     alert("Your browser doesn't support this feature");
	 return;
  }
  var cParameters;
  cParameters = 'from=' + cEmailFrom + '&fromname=' + cNameFrom + '&to=' + cEmailTo + '&comment=' + cComment + '&ix=' + nIx + '&title=' + cTitle;
 
  var fnOnReady = function (oXML) { 
      if(oXML.responseText.length > 0) {
         alert("Ha ocurrido un error al enviar la nota. Verifique que el email del destinatario sea correcto");
      }    
      else {
      alert("La nota ha sido enviada a " + cEmailTo);
      jsSendClose();
      }
  }
    oXmlHttp.connect("/inc/x_enviar_nota.aspx", "POST", cParameters, fnOnReady);
}

function jsSendClose() {
  document.getElementById("divSend").style.display = "none";
}