// JavaScript Document

function CargaModelos() {
	
	var respuesta;
	
	//paso 1: objeto XMLHttpRequest
	var xmlHttp;
	try { xmlHttp=new XMLHttpRequest();}
	catch (e){
		try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); }
		catch (e){
			try { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); }
			catch (e) {
				alert("Tu navegador no soporta AJAX!");
				return false;
			}
		}
	}
	
	//Paso 2: Recoger respuesta del servidor
	xmlHttp.onreadystatechange=function() {

		if(xmlHttp.readyState==4) {
			
			respuesta = xmlHttp.responseText;
			document.getElementById('con_modelo').innerHTML = "<select name='modelo' id='modelo' class='txtElegante'>"+respuesta+"</select>";
			
		}
	}
	
	//Paso 3: Abrir y enviar la petición al servidor
	
	var marca = document.getElementById('marca').value;

	xmlHttp.open("GET","php/ajax.php?op=cargarmodelos&marca="+marca,true);
	xmlHttp.send(null); // envía la peticion
}



function VerVideo(IdVehiculo) {
	
	var respuesta;
	
	//paso 1: objeto XMLHttpRequest
	var xmlHttp;
	try { xmlHttp=new XMLHttpRequest();}
	catch (e){
		try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); }
		catch (e){
			try { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); }
			catch (e) {
				alert("Tu navegador no soporta AJAX!");
				return false;
			}
		}
	}
	
	//Paso 2: Recoger respuesta del servidor
	xmlHttp.onreadystatechange=function() {

		if(xmlHttp.readyState==4) {
			
			respuesta = xmlHttp.responseText;
			document.getElementById('BIG').innerHTML = "<div id='VIDEO'>"+respuesta+"</div>";
			
		}
	}
	
	//Paso 3: Abrir y enviar la petición al servidor
	
	xmlHttp.open("GET","php/ajax.php?op=vervideo&id="+IdVehiculo,true);
	xmlHttp.send(null); // envía la peticion
}



function VerImagenes(IdVehiculo) {
	
	var respuesta;
	
	//paso 1: objeto XMLHttpRequest
	var xmlHttp;
	try { xmlHttp=new XMLHttpRequest();}
	catch (e){
		try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); }
		catch (e){
			try { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); }
			catch (e) {
				alert("Tu navegador no soporta AJAX!");
				return false;
			}
		}
	}
	
	//Paso 2: Recoger respuesta del servidor
	xmlHttp.onreadystatechange=function() {

		if(xmlHttp.readyState==4) {
			
			respuesta = xmlHttp.responseText;
			document.getElementById('BIG').innerHTML = "<img id='IMGBIG' src='"+respuesta+"' />";
			
		}
	}
	
	//Paso 3: Abrir y enviar la petición al servidor
	
	xmlHttp.open("GET","php/ajax.php?op=verimagenes&id="+IdVehiculo,true);
	xmlHttp.send(null); // envía la peticion
}



function AddModelo() {
	
	var respuesta;
	
	//paso 1: objeto XMLHttpRequest
	var xmlHttp;
	try { xmlHttp=new XMLHttpRequest();}
	catch (e){
		try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); }
		catch (e){
			try { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); }
			catch (e) {
				alert("Tu navegador no soporta AJAX!");
				return false;
			}
		}
	}
	
	//Paso 2: Recoger respuesta del servidor
	xmlHttp.onreadystatechange=function() {

		if(xmlHttp.readyState==4) {
			
			respuesta = xmlHttp.responseText;
			document.getElementById('SEL_MODELOS').innerHTML = "<select name='Modelo' class='cajas_form' id='Modelo'>"+respuesta+"</select>";
			
		}
	}
	
	//Paso 3: Abrir y enviar la petición al servidor
	
	var marca = document.getElementById('idmarca').value;
	var modelo = prompt('Introduce el nombre del modelo');
	if(!modelo) { alert('Operacion cancelada'); return false; }

	xmlHttp.open("GET","/php/ajax.php?op=addmodelo&marca="+marca+"&modelo="+modelo,true);
	xmlHttp.send(null); // envía la peticion
}




function AddExtra() {
	
	var respuesta;
	
	//paso 1: objeto XMLHttpRequest
	var xmlHttp;
	try { xmlHttp=new XMLHttpRequest();}
	catch (e){
		try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); }
		catch (e){
			try { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); }
			catch (e) {
				alert("Tu navegador no soporta AJAX!");
				return false;
			}
		}
	}
	
	//Paso 2: Recoger respuesta del servidor
	xmlHttp.onreadystatechange=function() {

		if(xmlHttp.readyState==4) {
			
			respuesta = xmlHttp.responseText;
			document.getElementById('SEL_EXTRAS').innerHTML = "<select name='Extras[]' size='5' multiple class='cajas_form' id='Extras'>"+respuesta+"</select>";
			
		}
	}
	
	//Paso 3: Abrir y enviar la petición al servidor
	
	var extra = prompt('Introduce el nombre del extra');
	if(!extra) { alert('Operacion cancelada'); return false; }

	xmlHttp.open("GET","/php/ajax.php?op=addextra&extra="+extra,true);
	xmlHttp.send(null); // envía la peticion
}



function loginCheck() {
	
	var respuesta;
	
	//paso 1: objeto XMLHttpRequest
	var xmlHttp;
	try { xmlHttp=new XMLHttpRequest();}
	catch (e){
		try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); }
		catch (e){
			try { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); }
			catch (e) {
				alert("Tu navegador no soporta AJAX!");
				return false;
			}
		}
	}
	
	//Paso 2: Recoger respuesta del servidor
	xmlHttp.onreadystatechange=function() {

		if(xmlHttp.readyState==4) {
			
			respuesta = xmlHttp.responseText;
			
			if(respuesta==0) document.getElementById('DIV_MSG').innerHTML = "<div align='center' class='txtNormal Verde'>Nombre de inicio de sesi&oacute;n v&aacute;lido.</div>";
			else document.getElementById('DIV_MSG').innerHTML = "<div align='center' class='txtNormal Rojo'>Ya existe un usario con ese nombre de inicio de sesi&oacute;n, o es demasiado corto (min. 5 caracteres).</div>";
			
		}
	}
	
	//Paso 3: Abrir y enviar la petición al servidor
	
	var login = document.Registro.login.value;

	xmlHttp.open("GET","/php/ajax.php?op=checklogin&login="+login,true);
	xmlHttp.send(null); // envía la peticion
}


function passCheck() {
	
	var pass1 = document.Registro.pass1.value;
	var pass2 = document.Registro.pass2.value;
	
	
	if(pass1.length<6) document.getElementById('DIV_MSG').innerHTML = "<div align='center' class='txtNormal Rojo'>La contrase&ntilde;a introducida es demasiado corta. (min. 6 caracteres)</div>";
	else {
		
		if(pass2.length==0) document.getElementById('DIV_MSG').innerHTML = "<div align='center' class='txtNormal Amarillo'>Contrase&ntilde;a v&aacute;lida. Para evitar equivociones debes de introducirla de nuevo en el campo de abajo.</div>";
		else {
			if(pass2!=pass1)  document.getElementById('DIV_MSG').innerHTML = "<div align='center' class='txtNormal Rojo'>Las dos contrase&ntilde;as han de coincidir.</div>";
			else  document.getElementById('DIV_MSG').innerHTML = "<div align='center' class='txtNormal Verde'>Contrase&ntilde;as introducidas correctamente.</div>";
		}
		
	}
	
}



function SubmitRegistro() {
	
	var respuesta;
	
	//paso 1: objeto XMLHttpRequest
	var xmlHttp;
	try { xmlHttp=new XMLHttpRequest();}
	catch (e){
		try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); }
		catch (e){
			try { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); }
			catch (e) {
				alert("Tu navegador no soporta AJAX!");
				return false;
			}
		}
	}
	
	xmlHttp.onreadystatechange=function() {

		if(xmlHttp.readyState==4) {
			
			respuesta = xmlHttp.responseText;
			
			var nombre 	  = document.Registro.nombre.value;
			var apellidos = document.Registro.apellidos.value;
			var direccion = document.Registro.direccion.value;
			var localidad = document.Registro.localidad.value;
			var cpostal   = document.Registro.cpostal.value;
			var provincia = document.Registro.provincia.value;
			var telefono  = document.Registro.telefono.value;
			var email     = document.Registro.email.value;
			var login     = document.Registro.login.value;
			var pass1     = document.Registro.pass1.value;
			var pass2     = document.Registro.pass2.value;
			var clegales  = document.Registro.clegales.checked;
			
			var error = "Han ocurridos los siguientes errores:\n\n";
			var flag = 0;
			
			if(nombre.length<1 || apellidos.length<1 || direccion.length<1 || cpostal.length<1 || localidad.length<1 || provincia.length<1 || telefono.length<1 || email.length<1) {
				flag = 1;
				error = error+"Los campos nombre, apellidos, direccion, codigo postal, localidad, provincia, telefono y e-mail son obligatorios. Deben de ser cubiertos antes de continuar.\n";
			}
			
			if(respuesta==1) {
				flag = 1;
				error = error+"El nombre de inicio de sesion que ha introducido ya existe o es demasiado corto.\n";
			}
			
			if(pass1.length<6 || pass1!=pass2) {
				flag = 1;
				error = error+"Las claves que ha escrito no son iguales o son demasiado cortas.\n";
			}
			
			if(clegales==false) {
				flag = 1;
				error = error+"Debe de leer y aceptar las condiciones legales.\n";
			}
			
			if(flag==0) {
				registraUsuario();
			}
			else {
				
				alert(error);
			}
			
			
			
		}
	}
	
	//Paso 3: Abrir y enviar la petición al servidor
	
	var login = document.Registro.login.value;

	xmlHttp.open("GET","/php/ajax.php?op=checklogin&login="+login,true);
	xmlHttp.send(null); // envía la peticion

}



function registraUsuario() {
	
	var respuesta;
	
	//paso 1: objeto XMLHttpRequest
	var xmlHttp;
	try { xmlHttp=new XMLHttpRequest();}
	catch (e){
		try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); }
		catch (e){
			try { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); }
			catch (e) {
				alert("Tu navegador no soporta AJAX!");
				return false;
			}
		}
	}
	
	//Paso 2: Recoger respuesta del servidor
	xmlHttp.onreadystatechange=function() {

		if(xmlHttp.readyState==4) {
			
			respuesta = xmlHttp.responseText;
			alert('Ha sido registrado como usuario de Grupo Brea. Espere a que su usuario sea activado por los administradores de la web');
			location.reload();
			
		}
	}
	
	//Paso 3: Abrir y enviar la petición al servidor
	
	var nombre 	  	= document.Registro.nombre.value;
	var apellidos 	= document.Registro.apellidos.value;
	var direccion 	= document.Registro.direccion.value;
	var cpostal 	= document.Registro.cpostal.value;
	var localidad 	= document.Registro.localidad.value;
	var provincia 	= document.Registro.provincia.value;
	var telefono 	= document.Registro.telefono.value;
	var email     	= document.Registro.email.value;
	var login     	= document.Registro.login.value;
	var pass1     	= document.Registro.pass1.value;
	var pass2     	= document.Registro.pass2.value;
	var marca     	= document.Registro.marca.value;
	var modelo     	= document.Registro.modelo.value;
	var profesional	= document.Registro.profesional.value;
	if(document.Registro.profesional.checked==true) var pro = "1";
	else pro = "0";
	var empresa		= document.Registro.empresa.value;

	xmlHttp.open("GET","/php/ajax.php?op=registrausuario&nombre="+nombre+"&apellidos="+apellidos+"&direccion="+direccion+"&localidad="+localidad+"&cpostal="+cpostal+"&provincia="+provincia+"&telefono="+telefono+"&email="+email+"&login="+login+"&pass="+pass1+"&marca="+marca+"&modelo="+modelo+"&profesional="+pro+"&empresa="+empresa,true);
	xmlHttp.send(null); // envía la peticion
}



function SubmitLogin() {
	
	var respuesta;
	
	//paso 1: objeto XMLHttpRequest
	var xmlHttp;
	try { xmlHttp=new XMLHttpRequest();}
	catch (e){
		try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); }
		catch (e){
			try { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); }
			catch (e) {
				alert("Tu navegador no soporta AJAX!");
				return false;
			}
		}
	}
	
	//Paso 2: Recoger respuesta del servidor
	xmlHttp.onreadystatechange=function() {

		if(xmlHttp.readyState==4) {
			
			respuesta = xmlHttp.responseText;
			
			if(respuesta==1) location.href='index.php';
			else document.getElementById('LOG_MSG').innerHTML = "<div align='center' class='txtNormal Rojo'>Clave o usuario invalidos.</div>";
			
		}
	}
	
	//Paso 3: Abrir y enviar la petición al servidor
	
	var login = document.LogForm.login.value;
	var pass = document.LogForm.pass.value;

	xmlHttp.open("GET","/php/ajax.php?op=login&login="+login+"&clave="+pass,true);
	xmlHttp.send(null); // envía la peticion
}

function SaveProfile() {
	
	var respuesta;
	
	//paso 1: objeto XMLHttpRequest
	var xmlHttp;
	try { xmlHttp=new XMLHttpRequest();}
	catch (e){
		try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); }
		catch (e){
			try { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); }
			catch (e) {
				alert("Tu navegador no soporta AJAX!");
				return false;
			}
		}
	}
	
	//Paso 2: Recoger respuesta del servidor
	xmlHttp.onreadystatechange=function() {

		if(xmlHttp.readyState==4) {
			
			respuesta = xmlHttp.responseText;
			document.getElementById('DIV_MSG').innerHTML = "<div align='center' class='txtNormal Verde'>"+respuesta+"</div>";
			alert("Perfil modificado correctamente");
			
		}
	}
	
	//Paso 3: Abrir y enviar la petición al servidor
	
	var nombre 	  	= document.Registro.nombre.value;
	var apellidos 	= document.Registro.apellidos.value;
	var direccion 	= document.Registro.direccion.value;
	var cpostal 	= document.Registro.cpostal.value;
	var localidad 	= document.Registro.localidad.value;
	var provincia 	= document.Registro.provincia.value;
	var telefono 	= document.Registro.telefono.value;
	var email     	= document.Registro.email.value;
	var login     	= document.Registro.login.value;
	var pass1     	= document.Registro.pass1.value;
	var empresa		= document.Registro.empresa.value;
	var marca		= document.Registro.marca.value;
	var modelo		= document.Registro.modelo.value;

	xmlHttp.open("GET","/php/ajax.php?op=guardaperfil&nombre="+nombre+"&apellidos="+apellidos+"&direccion="+direccion+"&localidad="+localidad+"&cpostal="+cpostal+"&provincia="+provincia+"&telefono="+telefono+"&email="+email+"&login="+login+"&pass="+pass1+"&marca="+marca+"&modelo="+modelo+"&empresa="+empresa,true);
	xmlHttp.send(null); // envía la peticion

}



function SaveProfileChanges() {
	
	var respuesta;
	
	//paso 1: objeto XMLHttpRequest
	var xmlHttp;
	try { xmlHttp=new XMLHttpRequest();}
	catch (e){
		try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); }
		catch (e){
			try { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); }
			catch (e) {
				alert("Tu navegador no soporta AJAX!");
				return false;
			}
		}
	}
	
	xmlHttp.onreadystatechange=function() {

		if(xmlHttp.readyState==4) {
		
			respuesta = xmlHttp.responseText;
			
			var nombre 	  = document.Registro.nombre.value;
			var apellidos = document.Registro.apellidos.value;
			var localidad = document.Registro.localidad.value;
			var cpostal   = document.Registro.cpostal.value;
			var provincia = document.Registro.provincia.value;
			var direccion = document.Registro.direccion.value;
			var telefono  = document.Registro.telefono.value;
			var email     = document.Registro.email.value;
			var login     = document.Registro.login.value;
			var pass1     = document.Registro.pass1.value;
			var pass2     = document.Registro.pass2.value;
			
			var error = "Han ocurridos los siguientes errores:\n\n";
			var flag = 0;
			
			if(nombre.length<1 || apellidos.length<1 || direccion.length<1 || localidad.length<1 || cpostal.length<1 || provincia.length<1 || telefono.length<1 || email.length<1) {
				flag = 1;
				error = error+"Los campos nombre, apellidos, direccion, localidad, codigo postal, provincia, telefono y e-mail son obligatorios. Deben de ser cubiertos antes de continuar.\n";
			}
			
			if(respuesta==1) {
				flag = 1;
				error = error+"El nombre de inicio de sesion que ha introducido ya existe o es demasiado corto.\n";
			}
			
			if((pass1.length<6 && pass1.length>0) || pass1!=pass2) {
				flag = 1;
				error = error+"Las claves que ha escrito no son iguales o son demasiado cortas.\n";
			}
			
			if(flag==0) {
				SaveProfile();
			}
			else {
				alert(error);
			}
		}
	}
	
	//Paso 3: Abrir y enviar la petición al servidor
	
	var login = document.Registro.login.value;

	xmlHttp.open("GET","/php/ajax.php?op=checkloginprofile&login="+login,true);
	xmlHttp.send(null); // envía la peticion

}



function passCheckPerfil() {
	
	var pass1 = document.Registro.pass1.value;
	var pass2 = document.Registro.pass2.value;
	
	if(pass1.length>0) {
		if(pass1.length<6) document.getElementById('DIV_MSG').innerHTML = "<div align='center' class='txtNormal Rojo'>La contrase&ntilde;a introducida es demasiado corta. (min. 6 caracteres)</div>";
		else {
			
			if(pass2.length==0) document.getElementById('DIV_MSG').innerHTML = "<div align='center' class='txtNormal Amarillo'>Contrase&ntilde;a v&aacute;lida. Para evitar equivociones debes de introducirla de nuevo en el campo de abajo.</div>";
			else {
				if(pass2!=pass1)  document.getElementById('DIV_MSG').innerHTML = "<div align='center' class='txtNormal Rojo'>Las dos contrase&ntilde;as han de coincidir.</div>";
				else  document.getElementById('DIV_MSG').innerHTML = "<div align='center' class='txtNormal Verde'>Contrase&ntilde;as introducidas correctamente.</div>";
			}
		}
	}
	else document.getElementById('DIV_MSG').innerHTML = ""; 
}



function cargaImagenSec() {
	
	var respuesta;
	
	//paso 1: objeto XMLHttpRequest
	var xmlHttp;
	try { xmlHttp=new XMLHttpRequest();}
	catch (e){
		try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); }
		catch (e){
			try { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); }
			catch (e) {
				alert("Tu navegador no soporta AJAX!");
				return false;
			}
		}
	}
	
	//Paso 2: Recoger respuesta del servidor
	xmlHttp.onreadystatechange=function() {
	
		if(xmlHttp.readyState==3) {
			 document.getElementById('OFE_IMG').innerHTML ="<table width='100%' border='0' cellspacing='0' cellpadding='0'><tr><td height='160' align='center' valign='middle' bgcolor='#FFFFFF'><img src='../img/ofertas.loading.gif' style='width:40px; height:40px;'/></td></tr><tr><td height='101' align='center' valign='middle' bgcolor='#FFFFFF'>&nbsp;</td></tr></table>";
		}
		

		if(xmlHttp.readyState==4) {
			
			respuesta = xmlHttp.responseText;
			cargaTextoSec();
			document.getElementById('OFE_IMG').innerHTML = respuesta;
			
		}
	}
	
	//Paso 3: Abrir y enviar la petición al servidor

	xmlHttp.open("GET","/php/ajax.php?op=cargaimagensec",true);
	xmlHttp.send(null); // envía la peticion
}



function cargaTextoSec() {
	
	var respuesta;
	
	//paso 1: objeto XMLHttpRequest
	var xmlHttp;
	try { xmlHttp=new XMLHttpRequest();}
	catch (e){
		try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); }
		catch (e){
			try { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); }
			catch (e) {
				alert("Tu navegador no soporta AJAX!");
				return false;
			}
		}
	}
	
	//Paso 2: Recoger respuesta del servidor
	xmlHttp.onreadystatechange=function() {

		if(xmlHttp.readyState==4) {
			
			respuesta = xmlHttp.responseText;
			document.getElementById('TEXTO').innerHTML = respuesta;
			
		}
	}
	
	//Paso 3: Abrir y enviar la petición al servidor

	xmlHttp.open("GET","/php/ajax.php?op=cargatextosec",true);
	xmlHttp.send(null); // envía la peticion
}

function CargaOfertaRotativa() {
	
	cargaOfertasSecuencial();
	setInterval("cargaOfertasSecuencial()",5000);
	
}



function cargaOfertasSecuencial() {
	
	cargaImagenSec();
	
}

/* Pasdor manual */

function cargaOfertas(nov) {
	
	cargaImagen(nov);
	cargaTexto(nov);
	
}

function cargaImagen(nov) {
	
	var respuesta;
	
	//paso 1: objeto XMLHttpRequest
	var xmlHttp;
	try { xmlHttp=new XMLHttpRequest();}
	catch (e){
		try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); }
		catch (e){
			try { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); }
			catch (e) {
				alert("Tu navegador no soporta AJAX!");
				return false;
			}
		}
	}
	
	//Paso 2: Recoger respuesta del servidor
	xmlHttp.onreadystatechange=function() {
	
		if(xmlHttp.readyState==3) {
			 document.getElementById('OFE_IMG').innerHTML ="<table width='100%' border='0' cellspacing='0' cellpadding='0'><tr><td height='160' align='center' valign='middle' bgcolor='#FFFFFF'><img src='../img/ofertas.loading.gif' style='width:40px; height:40px;'/></td></tr><tr><td height='101' align='center' valign='middle' bgcolor='#FFFFFF'>&nbsp;</td></tr></table>";
		}
		

		if(xmlHttp.readyState==4) {
			
			respuesta = xmlHttp.responseText;
			document.getElementById('OFE_IMG').innerHTML = respuesta;
			
		}
	}
	
	//Paso 3: Abrir y enviar la petición al servidor

	xmlHttp.open("GET","/php/ajax.php?op=cargaimagen&nov="+nov,true);
	xmlHttp.send(null); // envía la peticion
}



function cargaTexto(nov) {
	
	var respuesta;
	
	//paso 1: objeto XMLHttpRequest
	var xmlHttp;
	try { xmlHttp=new XMLHttpRequest();}
	catch (e){
		try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); }
		catch (e){
			try { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); }
			catch (e) {
				alert("Tu navegador no soporta AJAX!");
				return false;
			}
		}
	}
	
	//Paso 2: Recoger respuesta del servidor
	xmlHttp.onreadystatechange=function() {

		if(xmlHttp.readyState==4) {
			
			respuesta = xmlHttp.responseText;
			document.getElementById('TEXTO').innerHTML = respuesta;
			
		}
	}
	
	//Paso 3: Abrir y enviar la petición al servidor

	xmlHttp.open("GET","/php/ajax.php?op=cargatexto&nov="+nov,true);
	xmlHttp.send(null); // envía la peticion
}


function AmpliaNovedad(idnovedad) {
	
	var respuesta;
	
	//paso 1: objeto XMLHttpRequest
	var xmlHttp;
	try { xmlHttp=new XMLHttpRequest();}
	catch (e){
		try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); }
		catch (e){
			try { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); }
			catch (e) {
				alert("Tu navegador no soporta AJAX!");
				return false;
			}
		}
	}
	
	//Paso 2: Recoger respuesta del servidor
	xmlHttp.onreadystatechange=function() {

		if(xmlHttp.readyState==4) {
			
			respuesta = xmlHttp.responseText;
			document.getElementById('NOVEDAD_MAIN').innerHTML = respuesta;
			
		}
	}
	
	//Paso 3: Abrir y enviar la petición al servidor

	xmlHttp.open("GET","php/ajax.php?op=amplianovedad&id="+idnovedad,true);
	xmlHttp.send(null); // envía la peticion
}

function AmpliaDescarga(iddescarga) {
	
	var respuesta;
	
	//paso 1: objeto XMLHttpRequest
	var xmlHttp;
	try { xmlHttp=new XMLHttpRequest();}
	catch (e){
		try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); }
		catch (e){
			try { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); }
			catch (e) {
				alert("Tu navegador no soporta AJAX!");
				return false;
			}
		}
	}
	
	//Paso 2: Recoger respuesta del servidor
	xmlHttp.onreadystatechange=function() {

		if(xmlHttp.readyState==4) {
			
			respuesta = xmlHttp.responseText;
			document.getElementById('DESCARGA_MAIN').innerHTML = respuesta;
			
		}
	}
	
	//Paso 3: Abrir y enviar la petición al servidor

	xmlHttp.open("GET","php/ajax.php?op=ampliadescarga&id="+iddescarga,true);
	xmlHttp.send(null); // envía la peticion
}



function cargaContacto(modo) {
	
	//paso 1: objeto XMLHttpRequest
	var xmlHttp;
	try { xmlHttp=new XMLHttpRequest();}
	catch (e){
		try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); }
		catch (e){
			try { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); }
			catch (e) {
				alert("Tu navegador no soporta AJAX!");
				return false;
			}
		}
	}
	
	//Paso 2: Recoger respuesta del servidor
	xmlHttp.onreadystatechange=function() {

		if(xmlHttp.readyState==4) {
			
			document.getElementById('CONTACTO').innerHTML = xmlHttp.responseText;
			
		}
	}
	
	//Paso 3: Abrir y enviar la petición al servidor

	xmlHttp.open("GET","php/ajax.php?op=cargacontacto&modo="+modo,true);
	xmlHttp.send(null); // envía la peticion
}


function updateUdsCart(idp,idinput) {
	
	//paso 1: objeto XMLHttpRequest
	var xmlHttp;
	try { xmlHttp=new XMLHttpRequest();}
	catch (e){
		try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); }
		catch (e){
			try { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); }
			catch (e) {
				alert("Tu navegador no soporta AJAX!");
				return false;
			}
		}
	}
	
	//Paso 2: Recoger respuesta del servidor
	xmlHttp.onreadystatechange=function() {

		if(xmlHttp.readyState==4) {
			
			document.getElementById('TOTAL').innerHTML = xmlHttp.responseText;
			location.reload();
			
		}
	}
	
	//Paso 3: Abrir y enviar la petición al servidor

	var unidades = document.getElementById(idinput).value;

	xmlHttp.open("GET","php/ajax.php?op=updateudscart&idp="+idp+"&unidades="+unidades,true);
	xmlHttp.send(null); // envía la peticion
	
}


function enviaAmigo(idfa) {
	
	//paso 1: objeto XMLHttpRequest
	var xmlHttp;
	try { xmlHttp=new XMLHttpRequest();}
	catch (e){
		try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); }
		catch (e){
			try { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); }
			catch (e) {
				alert("Tu navegador no soporta AJAX!");
				return false;
			}
		}
	}
	
	//Paso 2: Recoger respuesta del servidor
	xmlHttp.onreadystatechange=function() {

		if(xmlHttp.readyState==4) {
			
			var respuesta = xmlHttp.responseText;
			
			if(respuesta=="1") alert('La recomendacion ha sido enviada');
			else alert('Ha ocurrido un error al enviar el mensaje');
			
		}
	}
	
	//Paso 3: Abrir y enviar la petición al servidor

	var me = prompt('Introduce tu nombre','[tu nombre]');
	var he = prompt('Introduce la direccion de correo electronico de tu amigo','tuamigo@email.com');

	xmlHttp.open("GET","php/ajax.php?op=enviaamigo&idfa="+idfa+"&me="+me+"&he="+he,true);
	xmlHttp.send(null); // envía la peticion
	
}


function ActualizaSeguimiento(id) {
	
	//paso 1: objeto XMLHttpRequest
	var xmlHttp;
	try { xmlHttp=new XMLHttpRequest();}
	catch (e){
		try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); }
		catch (e){
			try { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); }
			catch (e) {
				alert("Tu navegador no soporta AJAX!");
				return false;
			}
		}
	}
	
	//Paso 2: Recoger respuesta del servidor
	xmlHttp.onreadystatechange=function() {

		if(xmlHttp.readyState==4) {
			
			var respuesta = xmlHttp.responseText;
			
		}
	}
	
	//Paso 3: Abrir y enviar la petición al servidor

	var texto = document.getElementById(id).value;

	xmlHttp.open("GET","/php/ajax.php?op=actualizaseguimiento&id="+id+"&texto="+texto,true);
	xmlHttp.send(null); // envía la peticion
	
}