/******************************************************************************************************/
/*							FICHERO CON VARIOS JAVASCRIPTS UTILES PARA LA WEB                         */

// FUNCION QUE REALIZA UNA VALIDACION DE LOS DATOS DE ENTRADA DE UN "LOGUEO". COMPRUEBA
// QUE LOGIN Y CONTRASEÑA SE INTRODUZCAN CORRECTAMENTE.

function validar_zona_privada()
{	
	var error="";
	
	if (vacio(document.formulariopriv.usuario.value))
	{
		error+="Debe introducir el nombre de usuario.\n";
	}
	else
	{
		if (!es_valido(document.formulariopriv.usuario.value)) error+="El nombre de usuario contiene caracteres no permitidos.\n";
	}
	
	if (vacio(document.formulariopriv.password.value))
	{
		error+="Debe introducir la contraseña.\n";
	}
	else
	{
		if (!es_valido(document.formulariopriv.password.value)) error+="La contraseña contiene caracteres no permitidos.\n";
	}
	
	if (!error)
	{
		document.formulariopriv.action="login.php";
		document.formulariopriv.submit();
	}
	else alert(error);
}



//FUNCIÓN QUE REALIZA UNA DESCONEXION DE SESION.

function salir_zona_privada()
{	
		document.formulariopriv.action="login.php?salir=true";
		document.formulariopriv.submit();
}		

//FUNCIÓN QUE RECARGA LA PÁGINA AL SELECCIONAR EN EL COMBO UNA MONEDA

function recarga(targ,selObj,restore)
{
eval(targ+".location='./moneda.php?moneda="+selObj.options[selObj.selectedIndex].value+"'");
if (restore) selObj.selectedIndex=0;
}


//FUNCION QUE REDIMENSIONA EL CONTENEDOR DE LA PÁGINA PARA EVITAR QUE EN MOZILLA SE VEA MAL

function redimensionar()
{
alto=0;
if(navigator.appName=="Microsoft Internet Explorer")
	{
	alto_izquierda = document.getElementById('lateral_izquierda').offsetHeight;
	alto_centro = document.getElementById('interior').offsetHeight;
	alto_derecha = document.getElementById('lateral_derecho').offsetHeight;
	}
else
	{
	alto_izquierda = document.getElementById('lateral_izquierda').offsetHeight+10;
	alto_centro = document.getElementById('interior').offsetHeight+10;
	alto_derecha = document.getElementById('lateral_derecho').offsetHeight+10;
	}

if(alto_centro>alto_izquierda && alto_centro>alto_derecha) alto=alto_centro;
if(alto_izquierda>alto_centro && alto_izquierda>alto_derecha) alto=alto_izquierda;
if(alto_derecha>alto_izquierda && alto_derecha>alto_centro) alto=alto_derecha;

alto = alto + 500;

document.getElementById('pagina').style.height = alto + 'px';
document.getElementById('degradado_izquierda').style.height = alto + 'px';
document.getElementById('degradado_derecha').style.height = alto + 'px';
	
//alert("alto: "+alto);
//alert("alto_contenedor: "+alto_contenedor);
}

function redimensionar_dos()
{
	alto=0;
	
	if(navigator.appName=="Microsoft Internet Explorer")
	{	
		alto_izquierda = document.getElementById('lateral_izquierda').offsetHeight;
		alto_centro = document.getElementById('interior').offsetHeight;
		alto_derecha = document.getElementById('lateral_derecho').offsetHeight;			
	}
	else
	{
		alto_izquierda = document.getElementById('lateral_izquierda').offsetHeight+10;
		alto_centro = document.getElementById('interior').offsetHeight+10;
		alto_derecha = document.getElementById('lateral_derecho').offsetHeight+10;		
	}
	
	if(alto_centro>alto_izquierda && alto_centro>alto_derecha) alto=alto_centro;
	if(alto_izquierda>alto_centro && alto_izquierda>alto_derecha) alto=alto_izquierda;
	if(alto_derecha>alto_izquierda && alto_derecha>alto_centro) alto=alto_derecha;	
	
	if (alto > 720)
		alto = alto + ((alto * 23) / 100);
	else
		alto = alto + ((alto * 26) / 100);
		
	var actual = location.href;
	var pagina = actual.split("/");
	
	var lista_php = pagina[pagina.length - 1];
	var buscar_php = lista_php.substr(0, 10);
	var listar_php = lista_php.substr(0, 9);
	
	if ( (lista_php == 'lista.php' || lista_php == 'buscar.php' || lista_php == 'carro1.php' || lista_php == 'pedido.php' || buscar_php == 'buscar.php' || listar_php == 'lista.php') && navigator.appName != "Microsoft Internet Explorer")
		alto = alto + ((alto * 5) / 100);
    
	document.getElementById('pagina').style.height = alto + 'px';

	if (document.getElementById('degradado_izquierda'))
		document.getElementById('degradado_izquierda').style.height = alto + 'px';
		
	if (document.getElementById('degradado_derecha'))
		document.getElementById('degradado_derecha').style.height = alto + 'px';
}
