function Ajax2(){
	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;
}
/*Carga el contenido en el "marco" principal*/
function loadContent (strurl, div)
{
 	  var contenedor;
 	  contenedor = document.getElementById(div);
 		ajax=Ajax2();
		ajax.open("GET", strurl + '?ms=' + new Date().getTime(),true);
		ajax.onreadystatechange=function() 
		{
			if (ajax.readyState==4) 
			{
				contenedor.innerHTML = ajax.responseText;
			}
		}
		ajax.send(null)
}

function formHandler(form)
{

var URL = form.site.options[form.site.selectedIndex].value;

loadContent(URL,'container');

}

function solicitaInformacion()
{
	var fail=false;
	var nombreContacto = document.getElementById('nombreContacto').value;
	var apellidosContacto = document.getElementById('apellidosContacto').value;
	var telefonoContacto = document.getElementById('telefonoContacto').value;
	var emailContacto = document.getElementById('emailContacto').value;
	var nombreColegio = document.getElementById('nombreColegio').value;
	var numAlumnos = document.getElementById('numAlumnos').value;
		
	if (nombreContacto=="" | apellidosContacto=="" | telefonoContacto=="" | emailContacto=="" | nombreColegio=="" | numAlumnos=="") fail=true
	if (fail==true)
	{
		window.alert("Por favor, compruebe que ha introducido todos los datos.");
	}
	else
	{		
		http=Ajax2();
		http.open('POST', 'content/schoolProject/solicitarInfo.php', true);
		http.onreadystatechange = function() {
			if(http.readyState == 4)
			{
				var response = http.responseText;
				//window.alert(response);
				if (response=="1")
				{
					window.location.replace("index.php");
				}
				else
				{
					window.alert('Error a la hora de solicitar la informacion');
				}	
			}
		}
		http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=utf-8");
		http.send("nombreContacto="+nombreContacto+"&apellidosContacto="+apellidosContacto+"&telefonoContacto="+telefonoContacto+"&emailContacto="+emailContacto+"&nombreColegio="+nombreColegio+"&numAlumnos="+numAlumnos)
	}
}

function mostrarTiendas (strurl, div, form)
{
	  var contenedor;
 	  contenedor = document.getElementById(div);
	  var prov;
 	  prov = form.provincia.options[form.provincia.selectedIndex].value;;
 		ajax=Ajax2();
		ajax.open("GET", strurl+'?provincia='+prov,true);
		ajax.onreadystatechange=function() 
		{
			if (ajax.readyState==4) 
			{
				contenedor.innerHTML = ajax.responseText;
			}
		}
		ajax.send(null)
}

