//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;
//}
//
function mostrarPagina(url, div){
        var contenido, preloader;
        contenido = document.getElementById(div);
        preloader = document.getElementById('notificacionContenido');
        //creamos el objeto XMLHttpRequest
        ajax=nuevoAjax(); 
        //peticionamos los datos, le damos la url enviada desde el link
        ajax.open("GET", 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('../img/graficas/loadingCircle.gif') no-repeat"; 
                }else if(ajax.readyState==4){
                        if(ajax.status==200){
                                //mostramos los datos dentro de la div
                                contenido.innerHTML = ajax.responseText; 
//                                preloader.innerHTML = "Cargado.";
//                                preloader.style.background = "url('../img/graficas/loadingCircle.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);
}


//NUEVO AJAX
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;
}

// ejemplo Ajax.Updater
//mostrarPagina = function(url, div)
//{
// var pars="";
// 
// var myAjax = new Ajax.Updater(div, url, {method: 'get',
//   onLoading: function(){$('notificacionContenido').show()},
//    onLoaded: function(){$('notificacionContenido').hide()},
//   
//evalScripts: true, parameters: pars});
//}

//chequeaar newsletter

function checkNewsletter()
{
	var message="";
	if(document.getElementById("nombre").value=="")
	{
		message="-Olvidaste ingresar tu nombre";
	}
	if(document.getElementById("ciudad").value=="")
	{
		message=message+"\n\n-Olvidaste ingresar tu ciudad o barrio";
	}
	if(document.getElementById("mail").value=="")
	{
		message=message+"\n\n-Olvidaste ingresar tu e-mail";
	}
	if(message!="")
	{
		alert(message);
		return false;
	}else{

		cargarContenido();
		return true;
	}
}

function checkContacto()
{
	var message="";
	if(document.getElementById("nombre").value=="")
	{
		message="-Olvidaste ingresar tu nombre";
	}
	if(document.getElementById("mail").value=="")
	{
		message=message+"\n\n-Olvidaste ingresar tu e-mail";
	}
	if(document.getElementById("consulta").value=="")
	{
		message=message+"\n\n-Olvidaste ingresar tu mensaje";
	}
	if(message!="")
	{
		alert(message);
		return false;
	}else{

		cargarContenidoContacto();
		return true;
	}
}

//MOSTRAR EL DIV Y OCULTAR EL DIV VISTO
var visto = null;
function mostrar(div)
{
	obj = document.getElementById(div);
  	obj.style.display = (obj==visto) ? 'none' : 'block';
  	if (visto != null)
    visto.style.display = 'none';
 	visto = (obj==visto) ? null : obj;
}
function cargarContenido(){
	var t1, t2, t3, contenedor;
	contenedor = document.getElementById('newsletter');
	t1 = document.getElementById('ciudad').value;
	t2 = document.getElementById('nombre').value;
	t3 = document.getElementById('mail').value;
	ajax=nuevoAjax();
	ajax.open("POST", "newsletter.php?enviado=1",true);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			contenedor.innerHTML = ajax.responseText
	 	}
	}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	ajax.send("ciudad="+t1+"&nombre="+t2+"&mail="+t3)
}
function cargarContenidoContacto(){
	var t1, t2, t3, t4, contenedor;
	contenedor = document.getElementById('contenido');
	t1 = document.getElementById('asunto').value;
	t2 = document.getElementById('nombre').value;
	t3 = document.getElementById('mail').value;
	t4 = document.getElementById('consulta').value;
	ajax=nuevoAjax();
	ajax.open("POST", "contacto.php?enviado=1",true);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			contenedor.innerHTML = ajax.responseText
	 	}
	}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	ajax.send("asunto="+t1+"&nombre="+t2+"&mail="+t3+"&consulta="+t4)
}
//function cargarContenido(){
//	var t1, t2, contenedor;
//	contenedor = document.getElementById('newsletter');
//	t1 = document.getElementById('ciudad').value;
//	t2 = document.getElementById('nombre').value;
//	ajax=nuevoAjax();
//	ajax.open("GET", "newsletter.php?enviado=1&ciudad="+t1+"&nombre="+t2,true);
//	ajax.onreadystatechange=function() {
//		if (ajax.readyState==4) {
//		contenedor.innerHTML = ajax.responseText
//	 	}
//	}
//	ajax.send(null)
//}
