/*------------------------------------------------------------
	Document Text Sizer- Copyright 2003 - Taewook Kang.  All rights reserved.
	Coded by: Taewook Kang (txkang.REMOVETHIS@hotmail.com)
	Web Site: http://txkang.com
	Script featured on Dynamic Drive (http://www.dynamicdrive.com)
	
	Please retain this copyright notice in the script.
	License is granted to user to reuse this code on 
	their own website if, and only if, 
	this entire copyright notice is included.
--------------------------------------------------------------*/

//Specify affected tags. Add or remove from list:
var tgs = new Array( 'div','td','tr');

//Specify spectrum of different font sizes:
var szs = new Array( 'xx-small','x-small','small','medium','large','x-large','xx-large' );
var startSz = 2;

function ts( trgt,inc ) {
	if (!document.getElementById) return
	var d = document,cEl = null,sz = startSz,i,j,cTags;
	
	sz += inc;
	if ( sz < 0 ) sz = 0;
	if ( sz > 6 ) sz = 6;
	startSz = sz;
		
	if ( !( cEl = d.getElementById( trgt ) ) ) cEl = d.getElementsByTagName( trgt )[ 0 ];

	cEl.style.fontSize = szs[ sz ];

	for ( i = 0 ; i < tgs.length ; i++ ) {
		cTags = cEl.getElementsByTagName( tgs[ i ] );
		for ( j = 0 ; j < cTags.length ; j++ ) cTags[ j ].style.fontSize = szs[ sz ];
	}
}

function uptext(){
	ts('titular_articulo',1);
	ts('sumario_articulo',1);
	ts('texto1',1);
	ts('crecer_hora',1);
}

function downtext(){
	ts('titular_articulo',-1);
	ts('sumario_articulo',-1);
	ts('texto1',-1);
	ts('crecer_hora',-1);
}

function uptextVideo(){
	ts('titular_noticia2',1);
	ts('texto_contenido2',1);
	ts('hora2',1);
}

function downtextVideo(){
	ts('titular_noticia2',-1);
	ts('texto_contenido2',-1);
	ts('hora2',-1);
}

function printer(quien,id){
 	//window.open(''); 
	window.open ('imprimirArticulo.php?id='+id+'&quien='+quien+'');

}

function regresar(){
	history.back(-1);	
}

function verificar(direccion){
	if(confirm('żEsta seguro de desea eliminarlo?')){
		location.href = direccion;
	}	
}

function agregar_enviar(quien,id){
		document.getElementById("enviar_recomendar_id").innerHTML = "<div id='inner_enviar'><form name='form2' method='post'><table width='395' height='230' border='0'><tr><td width='165' height='33'><span class='texto_mail_form'>Email destino:</span> </td><td width='220'><label><input type='text' name='email_destino' /><span class='asterisco'> * </span></label></td></tr><tr><td height='31'><span class='texto_mail_form'>Nombre remitente: </span></td><td><input type='text' name='nombre_remitente' /><span class='asterisco'> * </span></td></tr><tr><td height='31'><span class='texto_mail_form'>Email remitente: </span></td><td><input type='text' name='email_remitente' /><span class='asterisco'> * </span></td></tr><tr><td height='37'><span class='texto_mail_form'>Comentarios: </span></td><td>&nbsp;</td></tr><tr><td colspan='2'><label><textarea name='comentarios' cols='60' rows='4'></textarea></label></td></tr>  <tr><td align='center'><label><input id='enviar_mail' type='button' name='Submit' class='boton' value='Enviar' onclick=\"send('"+quien+"','"+id+"');\" onmouseover=\"encima_boton('enviar_mail');\" onmouseout=\"no_encima_boton('enviar_mail');\" /></label></td><td align='center'><label><input id='cancelar_mail' type='button' name='Submit2' value='Cancelar' class='boton' onclick='quitar_enviar();' onmouseover=\"encima_boton('cancelar_mail');\" onmouseout=\"no_encima_boton('cancelar_mail');\"/></label></td></tr></table></form></div>";
}

function quitar_enviar(){
	document.getElementById('inner_enviar').parentNode.removeChild(document.getElementById('inner_enviar'));
	//document.getElementById("hola").innerHTML = "<input name='fichier[]' type='FILE' class='Forms'>";
}

function send(quien,id){
	enviar_mail_ajax("enviarUnAmigo.php",quien,id,document.form2.email_destino.value,document.form2.nombre_remitente.value,document.form2.email_remitente.value,document.form2.comentarios.value);
	document.getElementById('inner_enviar').parentNode.removeChild(document.getElementById('inner_enviar'));
	document.getElementById("enviar_recomendar_id").innerHTML = "<div id='inner_enviar'><span class='mail_enviado'>Email enviado con exito</span></div>";
}


function resize(width,height,elem){
	var percents = .01;
	var percent = 100;
	var temp = 1;
	var img = document.getElementById(elem);
	var i = 1;
	
	while((img.width > width) || (img.height > height)){
		percent -= i;
		temp = percent * percents;
		img.width = img.width * temp;
		img.height = img.height * temp;
		i += 1;
	}
}

function redimImage(inImg, inMW, inMH)
{
  // Cette function recoit 3 parametres
  // inImg : Chemin relatif de l'image
  // inMW  : Largeur maximale
  // inMH   : Hauteur maximale
  var maxWidth = inMW;
  var maxHeight = inMH;
  // Declarations des variables "Nouvelle Taille"
  var dW = 0;
  var dH = 0;
  // Declaration d'un objet Image
  var oImg = new Image();
  // Affectation du chemin de l'image a l'objet
  oImg.src = inImg;
  // On recupere les tailles reelles
  var h = dH = oImg.height;
  var w = dW = oImg.width;
  // Si la largeur ou la hauteur depasse la taille maximale
  if ((h >= maxHeight) || (w >= maxWidth)) {
    // Si la largeur et la hauteur depasse la taille maximale
    if ((h >= maxHeight) && (w >= maxWidth)) {
      // On cherche la plus grande valeur
      if (h > w) {
        dH = maxHeight;
        // On recalcule la taille proportionnellement
        dW = parseInt((w * dH) / h, 10);
      } else {
        dW = maxWidth;
        // On recalcule la taille proportionnellement
        dH = parseInt((h * dW) / w, 10);
      }
    } else if ((h > maxHeight) && (w < maxWidth)) {
      // Si la hauteur depasse la taille maximale
      dH = maxHeight;
        // On recalcule la taille proportionnellement
      dW = parseInt((w * dH) / h, 10);
    } else if ((h < maxHeight) && (w > maxWidth)) {
      // Si la largeur depasse la taille maximale
      dW = maxWidth;
        // On recalcule la taille proportionnellement
      dH = parseInt((h * dW) / w, 10);
    }
  }
  // On ecrit l'image dans le document
  document.writeln("<img src=\"" + inImg + "\" width=\"" + dW + "\" height=\"" + dH + "\" border=\"0\">");
};

function redimImageWithClass(inImg, inMW, inMH, classe)
{
  // Cette function recoit 3 parametres
  // inImg : Chemin relatif de l'image
  // inMW  : Largeur maximale
  // inMH   : Hauteur maximale
  var maxWidth = inMW;
  var maxHeight = inMH;
  // Declarations des variables "Nouvelle Taille"
  var dW = 0;
  var dH = 0;
  // Declaration d'un objet Image
  var oImg = new Image();
  // Affectation du chemin de l'image a l'objet
  oImg.src = inImg;
  // On recupere les tailles reelles
  var h = dH = oImg.height;
  var w = dW = oImg.width;
  // Si la largeur ou la hauteur depasse la taille maximale
  if ((h >= maxHeight) || (w >= maxWidth)) {
    // Si la largeur et la hauteur depasse la taille maximale
    if ((h >= maxHeight) && (w >= maxWidth)) {
      // On cherche la plus grande valeur
      if (h > w) {
        dH = maxHeight;
        // On recalcule la taille proportionnellement
        dW = parseInt((w * dH) / h, 10);
      } else {
        dW = maxWidth;
        // On recalcule la taille proportionnellement
        dH = parseInt((h * dW) / w, 10);
      }
    } else if ((h > maxHeight) && (w < maxWidth)) {
      // Si la hauteur depasse la taille maximale
      dH = maxHeight;
        // On recalcule la taille proportionnellement
      dW = parseInt((w * dH) / h, 10);
    } else if ((h < maxHeight) && (w > maxWidth)) {
      // Si la largeur depasse la taille maximale
      dW = maxWidth;
        // On recalcule la taille proportionnellement
      dH = parseInt((h * dW) / w, 10);
    }
  }
  // On ecrit l'image dans le document
  document.writeln("<img src=\"" + inImg + "\" width=\"" + dW + "\" height=\"" + dH + "\" class=\"" + classe +"\" border=\"0\">");
};