function enviaFormBuscadorNoticias(){
	formObj = document.buscador_noticias;
	cat = formObj.categoria.options[formObj.categoria.selectedIndex].value
	any= formObj.anyo.options[formObj.anyo.selectedIndex].value
	me = formObj.mes.options[formObj.mes.selectedIndex].value
	carga_datos(0,2,100,0,cat,any,me,0,0);
}
function enviaFormBuscadorOutlet(){
	formObj = document.buscador_outlet;
	cat = formObj.categoria.options[formObj.categoria.selectedIndex].value
	
	carga_datos(0,4,0,0,cat,0,0,0,0);
}
//---------- Functión que crea un nuevo objeto para el formulario----------//
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 cargarContenido(capa){
	var contenidos_capa;
	var nom, desc_esp, desc_cat, desc_eng,cat,dir,pob,cpo,pro,pai,ema,tel,we,fa,textin_esp,textin_cat,textin_eng;

	contenidos_capa = document.getElementById(capa);
	nom = document.getElementById('nom').value;
	desc_esp = document.getElementById('desc_esp').value;
	desc_cat = document.getElementById('desc_cat').value;
	desc_eng = document.getElementById('desc_eng').value;
	cat = document.getElementById('cat').value;
	
	dir = document.getElementById('dir').value;
	pob = document.getElementById('pob').value;
	cpo = document.getElementById('cpo').value;
	pro = document.getElementById('pro').value;
	pai = document.getElementById('pai').value;
	ema = document.getElementById('ema').value;
	tel = document.getElementById('tel').value;
	we = document.getElementById('we').value;
	fa = document.getElementById('fa').value;
	textin_esp = document.getElementById('textin_esp').value;
	textin_cat = document.getElementById('textin_cat').value;
	textin_eng = document.getElementById('textin_eng').value;
	nombre_img = document.getElementById('nombre_img').value;
	ajax = nuevoAjax();
	ajax.open("POST", "secciones/movimiento/inserta_escuela.php",true);
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	ajax.send("nombre="+nom+"&descripcion_esp="+desc_esp+"&descripcion_cat="+desc_cat+"&descripcion_eng="+desc_eng+"&categoria="+cat+"&direccion="+dir+"&poblacion="+pob+"&cpostal="+cpo+"&provincia="+pro+"&pais="+pai+"&email="+ema+"&telefono="+tel+"&fax="+fa+"&web="+we+"&text_institucional_esp="+textin_esp+"&text_institucional_cat="+textin_cat+"&text_institucional_eng="+textin_eng+"&nombre_imagen="+nombre_img);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			contenidos_capa.innerHTML = ajax.responseText;
		}
	}
}
function cargarContenidoLogin(capa){
	var contenidos_capa;
	var logi, pwd;

	contenidos_capa = document.getElementById(capa);
	logi = document.getElementById('log').value;
	pwd = document.getElementById('pwd').value;
	
	ajax = nuevoAjax();
	ajax.open("POST", "secciones/movimiento/ofertas_socio.php",true);
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	ajax.send("login="+logi+"&pwd="+pwd);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			contenidos_capa.innerHTML = ajax.responseText;
			tmp = ajax.responseText.split("Error");
			if(tmp.length==1){
				ajax_loadContent('contenidos1','secciones/movimiento/introduce_oferta.php');
				toggle('contenidos1', 'block');
			}
		}
	}
}
function cargarContenidoApuntarse(capa){
	var contenidos_capa;
	var nom, ap1, ap2, dir,pob,cpo,pro,pai,ema,tel;

	contenidos_capa = document.getElementById(capa);
	idof = document.getElementById('idof').value;
	nom = document.getElementById('nom').value;
	ap1 = document.getElementById('ape1').value;
	ap2 = document.getElementById('ape2').value;
	
	dir = document.getElementById('dir').value;
	pob = document.getElementById('pob').value;
	cpo = document.getElementById('cpo').value;
	pro = document.getElementById('pro').value;
	pai = document.getElementById('pai').value;
	ema = document.getElementById('ema').value;
	tel = document.getElementById('tel').value;
	
	ajax = nuevoAjax();
	ajax.open("POST", "secciones/movimiento/apuntarse_oferta.php",true);
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	ajax.send("id="+idof+"&nombre="+nom+"&apellido1="+ap1+"&apellido2="+ap2+"&direccion="+dir+"&poblacion="+pob+"&cpostal="+cpo+"&provincia="+pro+"&pais="+pai+"&email="+ema+"&telefono="+tel);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			contenidos_capa.innerHTML = ajax.responseText;
		}
	}
}
function cargarContenidoAnyadir(capa){
	var contenidos_capa;
	var nom, ap1, ap2, nif,emp,pers,tel2,fa,we,tel1,dir,pob,cpo,pro,pai,ema,tel;

	contenidos_capa = document.getElementById(capa);

	nom = document.getElementById('nom').value;
	ap1 = document.getElementById('ape1').value;
	ap2 = document.getElementById('ape2').value;
	nif = document.getElementById('nif').value;
	emp = document.getElementById('emp').value;
	pers = document.getElementById('pers').value;
	dir = document.getElementById('dir').value;
	pob = document.getElementById('pob').value;
	cpo = document.getElementById('cpo').value;
	pro = document.getElementById('pro').value;
	pai = document.getElementById('pai').value;
	ema = document.getElementById('ema').value;
	tel1 = document.getElementById('tel1').value;
	tel2 = document.getElementById('tel2').value;
	we = document.getElementById('we').value;
	fa = document.getElementById('fa').value;
	tit_esp = document.getElementById('tit_esp').value;
	tit_cat = document.getElementById('tit_cat').value;
	tit_eng = document.getElementById('tit_eng').value;
	fe_cad = document.getElementById('fe_cad').value;
	desc_esp = document.getElementById('desc_esp').value;
	desc_cat = document.getElementById('desc_cat').value;
	desc_eng = document.getElementById('desc_eng').value;

	ajax = nuevoAjax();
	ajax.open("POST", "secciones/movimiento/inserta_oferta.php",true);
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	ajax.send("nombre="+nom+"&apellido1="+ap1+"&apellido2="+ap2+"&nif="+nif+"&emp="+emp+"&pers="+pers+"&direccion="+dir+"&poblacion="+pob+"&cpostal="+cpo+"&provincia="+pro+"&pais="+pai+"&email="+ema+"&telefono1="+tel1+"&telefono2="+tel2+"&web="+we+"&fax="+fa+"&tit_esp="+tit_esp+"&tit_cat="+tit_cat+"&tit_eng="+tit_eng+"&fe_cad="+fe_cad+"&desc_esp="+desc_esp+"&desc_cat="+desc_cat+"&desc_eng="+desc_eng);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			contenidos_capa.innerHTML = ajax.responseText;
		}
	}
}
function cargarContenidoAsociarse(capa){
	var contenidos_capa;
	var nom, ap1, ap2, nif,emp,pers,tel2,fa,we,n_c,dir,pob,cpo,pro,pai,ema,tel1;

	contenidos_capa = document.getElementById(capa);
	id_tar = document.getElementById('id_tar').value;
	pre = document.getElementById('pre').value;
	n_tar = document.getElementById('n_tar').value;
	nom = document.getElementById('nom').value;
	ap1 = document.getElementById('ape1').value;
	ap2 = document.getElementById('ape2').value;
	nif = document.getElementById('nif').value;
	emp = document.getElementById('emp').value;
	pers = document.getElementById('pers').value;
	dir = document.getElementById('dir').value;
	pob = document.getElementById('pob').value;
	cpo = document.getElementById('cpo').value;
	pro = document.getElementById('pro').value;
	pai = document.getElementById('pai').value;
	ema = document.getElementById('ema').value;
	tel1 = document.getElementById('tel1').value;
	n_c = document.getElementById('n_c').value;
	we = document.getElementById('we').value;
	fa = document.getElementById('fa').value;
	a3p = document.getElementById('a3p').value;
	p3p = document.getElementById('p3p').value;
	t3p = document.getElementById('t3p').value;
	perio = document.getElementById('perio').value;
	ajax = nuevoAjax();
	ajax.open("POST", "secciones/modafad/inserta_socio.php",true);
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	ajax.send("id_tar="+id_tar+"&precio="+pre+"&nombre_tarifa="+n_tar+"&nombre="+nom+"&apellido1="+ap1+"&apellido2="+ap2+"&nif="+nif+"&emp="+emp+"&pers="+pers+"&direccion="+dir+"&poblacion="+pob+"&cpostal="+cpo+"&provincia="+pro+"&pais="+pai+"&email="+ema+"&telefono1="+tel1+"&n_compte="+n_c+"&web="+we+"&fax="+fa+"&a3p="+a3p+"&p3p="+p3p+"&t3p="+t3p+"&perio="+perio);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			contenidos_capa.innerHTML =ajax.responseText;
		}
	}
}
function actualizaDatosSubs(tarifa){

	formato = document.asociarse.periodo.options[document.asociarse.periodo.selectedIndex].value;
	
	if(formato==0){
		nuevo_precio = parseFloat(tarifa)*1;
		document.asociarse.a3_.value = nuevo_precio;
		document.getElementById('precio_total_id').innerHTML = nuevo_precio +' &euro;';
		document.asociarse.p3_.value = "3";
		document.asociarse.t3_.value = "M";
	}
	if(formato==1){
		nuevo_precio = parseFloat(tarifa)*2;
		document.asociarse.p3_.value = "6";
		document.asociarse.t3_.value = "M";
		document.asociarse.a3_.value = nuevo_precio;
		document.getElementById('precio_total_id').innerHTML = nuevo_precio+' &euro;';
	}
	if(formato==2){
		nuevo_precio =  parseFloat(tarifa)*4;
		document.asociarse.a3_.value =  nuevo_precio;
		document.getElementById('precio_total_id').innerHTML = nuevo_precio+' &euro;';
		document.asociarse.p3_.value = "1";
		document.asociarse.t3_.value = "Y";
	}
	
	}

//------------------------------------------------------//

// VALIDACIÓN DE FORMULARIOS

function valida_contacto(){
	var valid = new Validation('form_escuelas');
	validado=valid.validate();
	if(validado){
		cargarContenido('contenidos2');
	}
}
function reset_contacto(){
	var valid = new Validation('form_escuelas');
	valid.reset();
	}
function valida_login(){
	var valid = new Validation('form_login');
	validado=valid.validate();
	if(validado){
		cargarContenidoLogin('contenidos2');
	}
}
function valida_apuntarse(){
	var valid = new Validation('form_apuntarse');
	validado=valid.validate();
	if(validado){
		cargarContenidoApuntarse('contenidos2');
	}
}
function valida_oferta(){
	var valid = new Validation('form_anyadir_oferta');
	validado=valid.validate();
	if(validado){
		cargarContenidoAnyadir('contenidos2');
	}
}
function valida_asociarse(){
	var valid = new Validation('form_asociarse');
	validado=valid.validate();
	if(validado){
		cargarContenidoAsociarse('contenidos2');
	}
}
