// INICIO --------------------------------------- FUNCIONES DE 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;
}

function ir_al_final() {	
  parent.location = '#finpagina';
}

function poptastic(idMascota) {
  var newwindow;
  newwindow=window.open('i-ventadetail.php?mascota='+idMascota, 'name','height=700,width=720,left=150,resizable=yes,scrollbars=yes,');
  if (window.focus) {
	 newwindow.focus()
  }
}

function cargarContenido(offset,seccion){
  var p1, contenedor;
  var seccion = (seccion == null) ? 'M' : seccion;
  p1 = document.getElementById('tipoBusqueda').selectedIndex;
  //p2 = document.getElementById('offset').value;
  switch (p1) {
	case 0:
      //contenedor.innerHTML = '&nbsp;';
	  document.getElementById('listacategorias').innerHTML = '';
	  document.getElementById('listarazas').innerHTML      = '';
	  document.getElementById('listacompleta').innerHTML   = '';
	  break;
	case 1:
	  document.getElementById('listarazas').innerHTML      = '';
	  document.getElementById('listacompleta').innerHTML   = '';
      contenedor = document.getElementById('listacategorias'); 
      ajax=nuevoAjax();
      ajax.open("POST", "i-ventalistacategorias.php",true);
      ajax.onreadystatechange=function() {
        if (ajax.readyState==4) {
          contenedor.innerHTML = ajax.responseText;
        }
      }
      ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");  	
	  ajax.send("opcion="+p1+"&seccion="+seccion);
	  ir_al_final();
	  window.focus(); 
	  break;
	case 2:	
	  document.getElementById('listacategorias').innerHTML = '';
	  document.getElementById('listarazas').innerHTML      = '';
      contenedor = document.getElementById('listacompleta');  
      ajax=nuevoAjax();
      ajax.open("POST", "i-ventalistacompleta.php",true);
      ajax.onreadystatechange=function() {
        if (ajax.readyState==4) {
          contenedor.innerHTML = ajax.responseText;
        }
      }
      ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	  ajax.send("opcion="+p1+"&offset="+offset+"&seccion="+seccion);
	  ir_al_final();
	  window.focus();
	  break;
	case 3:
	  alert("Opcion 3");
	  break;
  }
}

function cargarEvento(dir){
  document.getElementById('eventos').innerHTML = 
    '<object type="application/x-shockwave-flash" data="fotos/gallery.swf" width="580" height="400" id="gallery" align="middle">'+
          '<param name="FlashVars" value="xmlFile=eventos/'+dir+'/gallery.xml" />'+
          '<param name="allowScriptAccess" value="sameDomain" />'+
          '<param name="movie" value="fotos/gallery.swf" />'+
          '<param name="quality" value="high" />'+
          '<param name="bgcolor" value="#ffffff" />'+
     '</object>'; 
  ir_al_final();
}

function cargarFotosAcuarofilia() {
  document.getElementById('ventayfotos').innerHTML = 
    '<object type="application/x-shockwave-flash" data="fotos/gallery.swf" width="580" height="400" id="gallery" align="middle">'+
         '<param name="FlashVars" value="xmlFile=fotos/acuarofilia/gallery.xml" />'+
         '<param name="allowScriptAccess" value="sameDomain" />'+
         '<param name="movie" value="fotos/gallery.swf" />'+
         '<param name="quality" value="high" />'+
         '<param name="bgcolor" value="#ffffff" />'+
    '</object>'
}

function cargarResRazas(offset, seccion) {
  var p1, pvCatId, pvRazId, contenedor;  
  var seccion = (seccion == null) ? 'M' : seccion;
  p1 = document.getElementById('tipoBusqueda').selectedIndex;
  pvCatId = document.getElementById('selectCategorias').options[document.getElementById('selectCategorias').selectedIndex].value;
  pvRazId = document.getElementById('selectRazas').options[document.getElementById('selectRazas').selectedIndex].value;  
  contenedor = document.getElementById('listacompleta');  
  ajax=nuevoAjax();
  ajax.open("POST", "i-ventalistacompleta.php",true);
  ajax.onreadystatechange=function() {
	if (ajax.readyState==4) {
	  contenedor.innerHTML = ajax.responseText;
	}
  }
  ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");  	
  ajax.send("opcion="+p1+"&pvCatId="+pvCatId+"&pvRazId="+pvRazId+"&offset="+offset+"&seccion="+seccion);
  ir_al_final();
  window.focus();
}

function cargarRazas(categoria, seccion) {
  var p1, contenedor;
  var seccion = (seccion == null) ? 'M' : seccion;
  document.getElementById('listacompleta').innerHTML   = '';
  p1 = document.getElementById('tipoBusqueda').selectedIndex;
  contenedor = document.getElementById('listarazas'); 
  ajax=nuevoAjax();
  ajax.open("POST", "i-ventalistarazas.php",true);
  ajax.onreadystatechange=function() {
	if (ajax.readyState==4) {
	  contenedor.innerHTML = ajax.responseText;
	}
  }
  ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");  	
  ajax.send("opcion="+p1+"&pCatId="+categoria+"&seccion="+seccion);
  ir_al_final();
  window.focus();   
}

function cargarVentaAcuarofilia() {
  document.getElementById('ventayfotos').innerHTML = 	
	  '<fieldset>'+
      '<legend>Venta Acuariofilia...</legend>'+
      '<form id="FormModoBusqueda" name="FormModoBusqueda" method="POST" action="i-acuarofilia.php">'+
        '<div align="center">'+
	      '<p>'+
	        '<select name="TipoBusqueda" class="CamposFormularios" id="tipoBusqueda" onChange="cargarContenido(0,\'C\');">'+
	          '<option value="0" selected="selected">Seleccione una Opci&oacute;n</option>'+
	          '<option value="Precisa">Busqueda por clase y tipo</option>'+
	          '<option value="Completa">Lista completa</option>'+
            '</select></p>'+
     	'</div>'+
       '<div align="center" id="listacategorias"></div><div align="center" id="listarazas"></div>'+
	  '</form>'+
	  '</fieldset>'+
  '<div id="listacompleta"></div></td>'
  ir_al_final();
}
// FIN --------------------------------------- FUNCIONES DE AJAX....