function metodoDelegado( that, thatMethod )
{
	if(arguments.length > 2)
	{
	  var _params = [];
	  for(var n = 2; n < arguments.length; ++n) _params.push(arguments[n]);
	  return function() { return thatMethod.apply(that,_params); }
	}
	else
	  return function() { return thatMethod.call(that); }
}
/* Cambio de noticias de Galeria Diseño 05 */
function cambiarNotaGaleria( obj, idBotonera, avance, claseAtras, claseAmbas, claseAdelante )
{
	objBotonera = document.getElementById( idBotonera );
	if ( obj.rotarNoticiasGaleria( avance ) ){
		objBotonera.className = claseAmbas;		
	}
	else {
		if (avance < 0){
			objBotonera.className = claseAdelante;	
		}
		if (avance > 0){
			objBotonera.className = claseAtras;	
		}
	}
}

/* Funcion para carga dinámica de Javascripts, los cuales deben ser inicialmente evaluados*/
function evaluarJavascriptDePagina(url_pagina, httpRequestObject){
	//alert('url:' + url_pagina);
	if (httpRequestObject === undefined){
		httpRequestObject = crearXMLHttpRequest();
	}

	httpRequestObject.open('GET', url_pagina);
	httpRequestObject.onreadystatechange = function(){
	//alert(httpRequestObject.readyState);
		try{
			if( httpRequestObject.status == 200 && httpRequestObject.readyState == 4 ){
				eval(httpRequestObject.responseText);
				//alert('Javascript evaluado');
				//alert(httpRequestObject.responseText);
			}
		}
		catch(e){
			//alert("Error de XHR object");	
		}
	}
    httpRequestObject.send(null);
}

/* Creacion de objetos XMLHttpRequest necesarios para implementar Ajax */
function crearXMLHttpRequest()
{
  var http_request = false;
  if (typeof XMLHttpRequest != 'undefined'){
      //Para otros exploradores diferentes a IE que soportan ajax
       http_request = new XMLHttpRequest();
  }
  else {
	  try{
			 //Crea objeto para version de Javascript >= 5 en IE
			http_request = new ActiveXObject("Msxml2.XMLHttp");
			
	   }
	  catch(e){
		  try{
			  //Sino probar creacion con versiones inferiores a 5 en IE
			  http_request = new ActiveXObject("Microsoft.XMLHttp");
		  }
		  catch(e){
			 //Asignar false en señal que no se pudo crear satisfactoriamente el objeto
			 //http_request = false;
			 alert('Su navegador es muy antiguo, este sitio no podra visualizarse correctamente. Favor actualize su navegador.');
		  }
	   }//Fin de try
   }

	return http_request
}

/* Funciones para scrollbar */

/* Mensajes Ultima Hora */
var tickercontents_1;
var tickdelay_1=3000 //delay btw messages
var highlightspeed_1=10 //10 pixels at a time.

var currentmessage_1;
var clipwidth_1;
var idTickerTimeout_1;
var play_1;

function previousnext_ticker_1(step)
{
	clearTimeout(idTickerTimeout_1);
	currentmessage_1 += step;
	if (currentmessage_1 < 0)
		currentmessage_1 = tickercontents_1.length - 1;
	else if(currentmessage_1 > tickercontents_1.length - 1)
		currentmessage_1 = 0;

	changetickercontent_1();
}
function stopstart_ticker_1()
{
	play_1 = !play_1;
	clearTimeout(idTickerTimeout_1);

	if (play_1)
		previousnext_ticker_1(1);
}
function changetickercontent_1(){
	crosstick_1.style.clip="rect(0px 0px auto 0px)"
	crosstick_1.innerHTML=tickercontents_1[currentmessage_1]
	highlightmsg_1()
}
function highlightmsg_1(){
		var msgwidth_1=crosstick_1.offsetWidth
		if (clipwidth_1 < msgwidth_1){
			clipwidth_1+=highlightspeed_1
			crosstick_1.style.clip="rect(0px "+clipwidth_1+"px auto 0px)"
			beginclip_1=setTimeout("highlightmsg_1()",20)
		}
		else{
			clipwidth_1=0
			clearTimeout(beginclip_1)
			if (play_1)
				idTickerTimeout_1 = setTimeout("previousnext_ticker_1(1)", tickdelay_1)
		}
}
function start_ticking_1(){
	crosstick_1=document.getElementById? document.getElementById("highlighter1") : document.all.highlighter
	crosstick_1Parent=crosstick_1.parentNode ? crosstick_1.parentNode : crosstick_1.parentElement

	if (parseInt(crosstick_1.offsetHeight)>0)
		crosstick_1Parent.style.height=crosstick_1.offsetHeight+'px'
	else
		setTimeout("crosstick_1Parent.style.height=crosstick_1.offsetHeight+'px'",100) //delay for Mozillas sake
	previousnext_ticker_1(1);
}


/* Mensajes Promocionales ON */
var tickercontents_2=new Array()
tickercontents_2[0]='Con&eacute;ctate a trav&eacute;s del m&oacute;vil al 9849-6396';
tickercontents_2[1]='Manda tus mensajes de texto al 6396';
tickercontents_2[2]='Llámanos a (504) 558-1273, 508-3345';
tickercontents_2[3]='Escr&iacute;benos a nexos@laprensa.hn';

var tickdelay_2=3000 //delay btw messages
var highlightspeed_2=10 //10 pixels at a time.

////Do not edit pass this line////////////////

var currentmessage_2=-1
var clipwidth_2=0
var idTickerTimeout_2;
var play_2 = true;

function previousnext_ticker_2(step)
{
	clearTimeout(idTickerTimeout_2);
	currentmessage_2 += step;
	if (currentmessage_2 < 0)
		currentmessage_2 = tickercontents_2.length - 1;
	else if(currentmessage_2 > tickercontents_2.length - 1)
		currentmessage_2 = 0;

	changetickercontent_2();
}
function stopstart_ticker_2()
{
	play_2 = !play_2;
	clearTimeout(idTickerTimeout_2);

	if (play_2)
		previousnext_ticker_2(1);
}
function changetickercontent_2(){
	crosstick_2.style.clip="rect(0px 0px auto 0px)"
	crosstick_2.innerHTML=tickercontents_2[currentmessage_2]
	highlightmsg_2()
}
function highlightmsg_2(){
		var msgwidth_2=crosstick_2.offsetWidth
		if (clipwidth_2 < msgwidth_2){
			clipwidth_2+=highlightspeed_2
			crosstick_2.style.clip="rect(0px "+clipwidth_2+"px auto 0px)"
			beginclip_2=setTimeout("highlightmsg_2()",20)
		}
		else{
			clipwidth_2=0
			clearTimeout(beginclip_2)
			if (play_2)
				idTickerTimeout_2 = setTimeout("previousnext_ticker_2(1)", tickdelay_2)
		}
}
function start_ticking_2(){
	crosstick_2=document.getElementById? document.getElementById("highlighter2") : document.all.highlighter
	crosstick_2Parent=crosstick_2.parentNode ? crosstick_2.parentNode : crosstick_2.parentElement

	if (parseInt(crosstick_2.offsetHeight)>0)
		crosstick_2Parent.style.height=crosstick_2.offsetHeight+'px'
	else
		setTimeout("crosstick_2Parent.style.height=crosstick_2.offsetHeight+'px'",100) //delay for Mozillas sake
	previousnext_ticker_2(1);
}

/* Buzon de mensajes ON*/
var tickercontents_3=new Array();
var tickdelay_3=3000 //delay btw messages
var highlightspeed_3=10 //10 pixels at a time.

////Do not edit pass this line////////////////

var currentmessage_3=-1
var clipwidth_3=0
var idTickerTimeout_3;
var play_3 = true;

function previousnext_ticker_3(step)
{
	clearTimeout(idTickerTimeout_3);
	currentmessage_3 += step;
	if (currentmessage_3 < 0)
		currentmessage_3 = tickercontents_3.length - 1;
	else if(currentmessage_3 > tickercontents_3.length - 1)
		currentmessage_3 = 0;

	changetickercontent_3();
}
function stopstart_ticker_3()
{
	play_3 = !play_3;
	clearTimeout(idTickerTimeout_3);

	if (play_3)
		previousnext_ticker_3(1);
}
function changetickercontent_3(){
	crosstick_3.style.clip="rect(0px 0px auto 0px)"
	crosstick_3.innerHTML=tickercontents_3[currentmessage_3]
	highlightmsg_3()
}
function highlightmsg_3(){
		var msgwidth_3=crosstick_3.offsetWidth
		if (clipwidth_3 < msgwidth_3){
			clipwidth_3+=highlightspeed_3
			crosstick_3.style.clip="rect(0px "+clipwidth_3+"px auto 0px)"
			beginclip_3=setTimeout("highlightmsg_3()",20)
		}
		else{
			clipwidth_3=0
			clearTimeout(beginclip_3)
			if (play_3)
				idTickerTimeout_3 = setTimeout("previousnext_ticker_3(1)", tickdelay_3)
		}
}
function start_ticking_3(){
	crosstick_3=document.getElementById? document.getElementById("highlighter3") : document.all.highlighter
	crosstick_3Parent=crosstick_3.parentNode ? crosstick_3.parentNode : crosstick_3.parentElement

	if (parseInt(crosstick_3.offsetHeight)>0)
		crosstick_3Parent.style.height=crosstick_3.offsetHeight+'px'
	else
		setTimeout("crosstick_3Parent.style.height=crosstick_3.offsetHeight+'px'",100) //delay for Mozillas sake
	previousnext_ticker_3(1);
}


/* Funcion que inicializa banner con movimiento vertical */
function initStatLyr() {
	// args: id, left, top, w, h, duration of glide to location onscroll, acceleration factor
 	// acceleration factor should be -1 to 1. -1 is full deceleration

	var statLyr = new Glider("glideDiv",0,0,null,null,1000,-1);
  	statLyr.show();
}

/* Funciones obtencion de posicionamiento cartesiando de un objeto */
function obtenerPosX(objID){
	var obj = document.getElementById(objID);
	var posX = 0;

	if (obj.offsetParent){
		while(obj.offsetParent){
			posX += obj.offsetLeft;
			obj = obj.offsetParent;
		}
	} else if (obj.x){
			posX += obj.x;
	}

	return posX;
}

function obtenerPosY(objID){
	var obj = document.getElementById(objID);
	var posY = 0;

	if (obj.offsetParent){
		while(obj.offsetParent){
			posY += obj.offsetTop;
			obj = obj.offsetParent;
		}
	} else if (obj.y){
			posY += obj.y;
	}

	return posY;
}

/* Procesamiento de formularios */
function obtenerValoresDeFormulario(formulario)
{
	var str = "";
	for(var i = 0; i < formulario.elements.length; i++){
		str += formulario.elements[i].name + "=" + escape(formulario.elements[i].value) + "&";
	}
	return str;
}

function cargarPagina(contenedor, url_pagina, srcImgCargando, httpRequestObject, metodo, qString, redirectURL){
	if (httpRequestObject === undefined)
		httpRequestObject = crearXMLHttpRequest();

	//Por default el metodo a enviar contenido es get
	if (metodo === undefined) {
		metodo = 'get';
	}

	if (metodo == 'get') {
		httpRequestObject.open('GET', url_pagina);
		httpRequestObject.onreadystatechange = function(){
			try{
				if( httpRequestObject.status == 200 && httpRequestObject.readyState == 4 ){
					document.getElementById(contenedor).innerHTML = httpRequestObject.responseText;
				}
			}
			catch(e){
				//alert("Error: XHR object access");	
			}
		}
	    httpRequestObject.send(null);
		insertarImagenCargando(srcImgCargando, contenedor, 0);

	}
	else if (metodo == 'post') {
		httpRequestObject.open('POST', url_pagina, true);
		httpRequestObject.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		httpRequestObject.setRequestHeader("Content-length", qString.length);

		httpRequestObject.onreadystatechange = function(){
			try{
				if( httpRequestObject.status == 200 && httpRequestObject.readyState == 4 ){
					if ( redirectURL === undefined ){
						document.getElementById(contenedor).innerHTML = httpRequestObject.responseText;
					}
					else {
						location.href = redirectURL;	
					}
				}
			
			}
			catch(e){
				//alert("Error: Try accessing XHR object property");		
			}
		}
		httpRequestObject.send(qString);
	}
}

/* Carga de contenido de página mediante Ajax */
function cargarPaginaOptimizado(contenedor, url_pagina, srcImgCargando, contenido_noticias, httpRequestObject){
	//alert('Contenedor: ' + contenedor + '; URL' + url_pagina);
	if (contenido_noticias[url_pagina] === undefined){
		if (httpRequestObject === undefined)
			httpRequestObject = crearXMLHttpRequest();

		httpRequestObject.open('GET', url_pagina);
		httpRequestObject.onreadystatechange = function(){
			try{
				if( httpRequestObject.status == 200 && httpRequestObject.readyState == 4 ){
						document.getElementById(contenedor).innerHTML = httpRequestObject.responseText;
						contenido_noticias[url_pagina] = httpRequestObject.responseText;
						//alert(contenido_noticias[url_pagina]);
				}
			}
			catch(e){
				//alert("Error: Try accessing XHR object property");			
			}
		
		}
		httpRequestObject.send(null);
		insertarImagenCargando(srcImgCargando, contenedor, 0);
	}
	else{
		document.getElementById(contenedor).innerHTML = contenido_noticias[url_pagina];
		//alert('Sin uso de Ajax');
	}
}

function insertarImagenCargando(srcImagen, idContenedor, ubicacion){
	var imagenLoading = new Image();
	imagenLoading.src = srcImagen;
	//alert('Contenedor:' + idContenedor);
	switch(ubicacion){
		case 0:
			document.getElementById(idContenedor).innerHTML = '<div style="position:absolute; top: 50%; left: 50%; margin-top:'+ (-imagenLoading.height/2) + '; margin-left:' + (-imagenLoading.width/2) + ';"><img src="' + srcImagen + '"/></div>';
		break;

		case 1:
			document.getElementById(idContenedor).innerHTML = '<img src="' + srcImagen + '"/>';
		break;
	}
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

/*Limitacion de caracteres en comentarios*/
var charLimit = 400;
function onKeyDownTextComment(sender, keyEventArgs)
{
	var backSpaceCode = 8;
	if(window.event)
	{
	  var keynum = keyEventArgs.keyCode;
	}
	else if(keyEventArgs.which)
	{
	  var keynum = keyEventArgs.which;
	}

	//alert(keynum);
	if ( sender.value.length <= charLimit || keynum == backSpaceCode )
	{
		//alert('return true');
		return true;
	}
	else {
		//alert('return false');
		return false;
	}
}