/**
	ajax.js
	Funciones uasadas para eventos asincronos en el sitio web
	Autor CPN
  Fecha 20/08/2009
  Version - 1.0 - CPN - sen implementan funciones para el uso del objeto xmlHttp
*/

//Creando Objeto Httprequest
function NuevoAjax(){
	var xmlhttp=false;
	try{
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	}catch(e){
		try{
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		}catch(E){
			xmlhttp = false;
		}
	}

	if(!xmlhttp && typeof XMLHttpRequest != 'undefined'){
		xmlhttp = new XMLHttpRequest();
	}
		return xmlhttp;
};



//Cargando Url en el div
function Cargar(url){
	var contenido, preloader;
	contenido = document.getElementById('AjxGalery');
	preloader = document.getElementById('AjxGalery');

	//creamos el objeto XMLHttpRequest
	ajax = NuevoAjax();
	ajax.open("POST", url,true);
	ajax.onreadystatechange = function(){
		if (ajax.readyState == 1){
			preloader.innerHTML = "Cargando...";

			//modificamos el estilo de la div, mostrando una imagen de fondo
			//preloader.style.background = "url('/noticias/imag/auxi/preload.gif') no-repeat";
			
		} else if (ajax.readyState == 4) {
    		if (ajax.status == 200){
						
					//mostramos los datos dentro de la div
					contenido.innerHTML = ajax.responseText;		
					
					//Como tercer parametro, se debe capturar el numero de elementos del sitio 	     
				 	Gallery.insertaMultiLoad("#ce_contenido", '#thumbs', '8');
					
					//preloader.style.background = "url('/noticias/imag/auxi/preload.gif') no-repeat";
				} else if (ajax.status == 404){
					preloader.innerHTML = "La página no existe";
        } else {

					//mostramos el posible error
					preloader.innerHTML = "Error:".ajax.status;
					
					
					
				}
		}
	}
	ajax.send(null);
}