// JavaScript Document
// Víctor J. Chamorro - Ipdea.com

if (typeof(ruta_enlaces)!="string") ruta_enlaces = "..";
window.document.write("<script type='text/javascript' src='"+ruta_enlaces+"/js/XHConn.js'></script>");
window.document.write("<script type='text/javascript' src='"+ruta_enlaces+"/js/compruebacampos.js'></script>");


//________________________________________________________________________________________

function Loggin(){
	//loading
	
	document.getElementById("logginfrm").style.display = "none";
	document.getElementById("logginload").innerHTML = '<img style="margin-top:12px;" src="'+ruta_enlaces+'/img/menu/loading.gif" /> Espere...';
	document.getElementById("logginload").style.display = "";
	
	var user = document.frmLoggin.user.value;
	var pass = document.frmLoggin.pass.value;
	
	data(ruta_enlaces+'/area_socios/socios.cod.php', 'accion=loggin&user='+user+'&pass='+pass, CompruebaLoggin); 
	
}
//________________________________________________________________________________________

function Logout(){
	//loading
	
	document.getElementById("logginfrm").style.display = "none";
	document.getElementById("logginload").innerHTML = '<img style="margin-top:12px;" src="'+ruta_enlaces+'/img/menu/loading.gif" /> Espere...';
	document.getElementById("logginload").style.display = "";
	
	
	data(ruta_enlaces+'/area_socios/socios.cod.php', 'accion=logout', function(xml){	window.location.href=ruta_enlaces;	}); 
	
}
//________________________________________________________________________________________

function Reintentar(){
	//loading
	
	document.getElementById("logginfrm").style.display = "";
	document.getElementById("logginload").style.display = "none";
	
}
//________________________________________________________________________________________


function CompruebaLoggin(xml){
	try{
		var resultado = xml.getElementsByTagName('respuesta')[0].firstChild.data;
		
		if (resultado != 1){
			document.getElementById('logginload').innerHTML = '<div style="line-height:1em;">Usuario o clave incorrectos <a href="javascript:Reintentar();"><strong class="pink">Reintentar</strong></a></div>';
		}else{
			window.location.href=ruta_enlaces+"/area_socios/";
		}
	}catch(ex){
		document.getElementById('logginload').innerHTML = 'Error en el loggin <a href="javascript:Reintentar();">Reintentar</a>';
	}
}
//________________________________________________________________________________________

function intro(ev){
	if (ev.keyCode){
		if (ev.keyCode == 13) Loggin();
	}
}
//________________________________________________________________________________________

function CalculaPrecio(precio, unidad){
	
	
	var total;
	precio = GLOBAL_formulario.precio.value;
	var unidades = GLOBAL_formulario.cantidad.value;

/*	var campos = new Object();
	campos.obligatorios = new Array('cantidad');
*/
	if (!CompruebaCampos(Campos, GLOBAL_formulario)) unidades = 0;
    
	total=precio*unidades;
	GLOBAL_formulario.total.value=total;
	
	
}
//________________________________________________________________________________________

function Altanewsletter(){

	Campos = new Object();
	Campos.obligatorios = new Array('txtEmail');
	Campos.emails = new Array('txtEmail');
	
	if (CompruebaCampos(Campos, document.frmnewsletter)){
		document.frmnewsletter.submit();
	}
}
//________________________________________________________________________________________

function CambiaTipo(){
	
var tipo;

tipo=document.frmbusqueda.cat.value;



page ('pintaselect', '../includesphp/front.cod.php', 'accion=cambiatipo&tipo='+tipo, '' );

}