//---------------------------------------------------------------------------------------//
function validaEvento(e){
//---------------------------------------------------------------------------------------//
	var keynum;
	if(window.event){ 
		keynum = e.keyCode;
	}
	else if(e.which){ 
		keynum = e.which;
	}
	return keynum;
}


function validaBotonEnter(evento,fecha,aniox){//permite digitar solo numeros y el punto 
//---------------------------------------------------------------------------------------//
	//window.event.keyCode valor ascii de tecla pulsada
		
		var key = validaEvento(evento);
		if (key==13){
			//alert("evento: "+ evento);
			//alert("pagina: "+ pagina);
			//alert("fecha: "+ fecha);
			//alert("anio: "+aniox);
			
			//if (pagina===undefined){				
				page=$('txt_pagina').value;	
			/*	if(parseInt(page)>parseInt(toppages)){
					page=toppages;
				}//end if
			}else{
				page=pagina;
			}	*/
			
			
			cargarListadoNoticias(page,fecha,aniox);				
			
			elemento.blur();
			
			return true;
		}else{
			return false;
		}
	
    	
}//end function validaBotonEnter

//---------------------------------------------------------------------------------------//
function validaSoloLosNumeros(evento){	
//---------------------------------------------------------------------------------------//
	var key = validaEvento(evento);
	//alert(key);
	if(key == 8){ return true; }	
	if (key < 48 || key > 57){
        if(window.event){ 
			evento.keyCode = 0;
			respuesta = false;
		}
		else if(evento.which){			
			return false;
		}
    }	
}//end function validaNumero


//------------------------------------------------------------------------------------------------------------------//		
	var winNoticiaVentana = null;
	function VentanaNoticia(idNoticia,formato){
//------------------------------------------------------------------------------------------------------------------//		
		var  titulo = '' ; 
		var  ancho  =  760 ; 
		var  largo  =  440 ;

		winOfertaVentana = new Window({className: "alphacube", title: titulo, 
						  width:ancho, height:largo, maxWidth:ancho, maxHeight:largo,
						  maximizable: false, resizable: false, minimizable: true, destroyOnClose: true,
						  url: 'noticias_ventana.asp?idNoticia='+idNoticia+'&formato='+formato, 						  
						  showEffectOptions: {duration:0.5}});		
		winOfertaVentana.setZIndex(100)
		winOfertaVentana.showCenter(false);
	}//end function VentanaOfertas
//------------------------------------------------------------------------------------------------------------------//

//------------------------------------------------------------------------------------------------------------------//
function cargarListadoNoticias(pagina,fecha,anio){	//Carga el submenú
//------------------------------------------------------------------------------------------------------------------//
            window.scrollTo(0,0);//al hacer click en el pagineo muestra el listado desde el inicio y no desde el centro
			
			if($('top_pagina11')){
				toppages=$('top_pagina11').value;				
			}
			
			if (pagina===undefined){				
				page=$('txt_pagina').value;	
				if(parseInt(page)>parseInt(toppages)){
					page=toppages;
				}//end if
			}else{
				page=pagina;
				}						
			
			
			var element =  $('id_noticias');
			var parametros=$('frmNoticias').serialize();
			var pagina2='noticias_listado.asp?pagina=' + page+'&fecha='+fecha+'&anio='+anio; //+ ' &numero= '+ numero
			element.innerHTML = '<img src="images/spinner40.gif">'; 
			
			new Ajax.Updater('id_noticias', pagina2, { method: 'post',  asynchronous: true,
							 parameters:parametros, encoding:'UTF-8', evalScripts: true });
			
			
			//cargarTab(productos, 1);	 
}//end if
