//////////////////////////////////////////////////////////////////////
// La comprobación deberá ir después de la validación del formulario.
//////////////////////////////////////////////////////////////////////
function ComprobarClaves(textBox1, textBox2)
{
	val1 = MM_findObj(textBox1);
	val1 = val1.value;

	val2 = MM_findObj(textBox2);
	val2 = val2.value;
	
	if(val1 != val2)
	{
		alert('Las claves no coinciden.');
		document.MM_returnValue = false;
		return false;
	}
	else
	{
		document.MM_returnValue = (document.MM_returnValue && true);
		return true;
	}
}

function SubirFoto(anchoFoto, altoFoto, nombreFoto, rutaIcono, rutaPrevio, anchoPre, altoPre, objTexto, objImagen)
{
	if (ventanaprevio)
		ventanaprevio.close();

	ventanaprevio = null;

	ruta = 'includes/upload_img/previo.php?ancho=' + anchoFoto + '&alto=' + altoFoto + '&nom=' + nombreFoto + '&rico=' + rutaIcono + '&rpre=' + rutaPrevio + '&wpre=' + anchoPre + '&hpre=' + altoPre + '&otxt=' + objTexto + '&oimg=' + objImagen;
	opciones = 'toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,';
	anchoVentana = 352;
	if(anchoFoto > 290)
		anchoVentana = anchoFoto + 62;
	altoVentana = altoFoto + 232;
	opciones = opciones + 'width=' + anchoVentana + ',height=' + altoVentana;
	nombreventana = 'previoFoto';

	ventanaprevio = window.open(ruta, nombreventana, opciones);
	ventanaprevio.focus();
}

ventanaprevio = null;

function CambiarPrevio(rutaFichero, nombreFichero, objetoTexto, objetoImagen)
{
	val = MM_findObj(objetoTexto);
	val.value = nombreFichero;
	
	val2 = MM_findObj(objetoImagen);
	if (nombreFichero != "")
		val2.src = "http://www.jjchorro-offroad.com/admin/includes/upload_img/" + rutaFichero + nombreFichero;
	else
		val2.src = "http://www.jjchorro-offroad.com/panel/img/puntovacio.gif";
}

function ConfirmarEliminacion(nombre)
{
	var mensaje;

	mensaje = "Está seguro que quiere eliminar toda la información asociada con:\n'" + nombre + "'";
	
	document.ConfirmarEliminar = confirm(mensaje);
}

function Cambio_Estilo(id_estilo, ubicacion)
{
	var hoja_actual = document.getElementById(id_estilo).href;

	if(ubicacion == "raiz") {
		if(hoja_actual == "http://www.crehaz.com/cae/css/estilos.css")
			document.getElementById(id_estilo).href = "css/estilos_accesibilidad.css";
		else
			document.getElementById(id_estilo).href = "css/estilos.css";
	} else if((ubicacion == "pas") || (ubicacion == "estudiantes") || (ubicacion == "otros")) {
		if(hoja_actual == "http://www.crehaz.com/cae/css/estilos.css")
			document.getElementById(id_estilo).href = "/cae/css/estilos_accesibilidad.css";
		else
			document.getElementById(id_estilo).href = "/cae/css/estilos.css";
	}

}


function Cambio_Tamano(aumentar)
{
	var valor_actual = document.body.style.fontSize;

	if(valor_actual == "")
		valor_actual = "16px";

	valor_actual = valor_actual.substr(0, valor_actual.length - 2);

	if(aumentar)
		document.body.style.fontSize = (valor_actual * 1.10) + 'px';
	else
		document.body.style.fontSize = (valor_actual / 1.10) + 'px';
}

/*------------------------------------
	Title: Cross-Browser Text Drop Shadows
	Author: Scott Jehl, www.scottjehl.com, scott@scottjehl.com
	Date: 7/19/06
http://creativecommons.org/licenses/by-nc-sa/2.5/
--------------------------------------*/

/*
addDomLoadEvent function from http://www.thefutureoftheweb.com/blog/2006/6/adddomloadevent
*/
function addDOMLoadEvent(func) { if (!window.__load_events) { var init = function () { if (arguments.callee.done) return; arguments.callee.done = true; if (window.__load_timer) { clearInterval(window.__load_timer); window.__load_timer = null;}
for (var i=0;i < window.__load_events.length;i++) { window.__load_events[i]();}
window.__load_events = null;}; if (document.addEventListener) { document.addEventListener("DOMContentLoaded", init, false);}
if (/WebKit/i.test(navigator.userAgent)) { window.__load_timer = setInterval(function() { if (/loaded|complete/.test(document.readyState)) { init();}
}, 10);}
window.onload = init; window.__load_events = [];}
window.__load_events.push(func);}



/*
getElementsByClass function (credit Dustin Diaz, www.dustindiaz.com)
*/
function getElementsByClass(searchClass,node,tag) {
	var classElements = new Array();
	if ( node == null )
		node = document;
	if ( tag == null )
		tag = '*';
	var els = node.getElementsByTagName(tag);
	var elsLen = els.length;
	var pattern = new RegExp('(^|\\s)'+searchClass+'(\\s|$)');
	for (i = 0, j = 0; i < elsLen; i++) {
		if ( pattern.test(els[i].className) ) {
			classElements[j] = els[i];
			j++;
		}
	}
	return classElements;
}




/*
createDropShadows function 
*/

createDropShadows = function(){
//get the elements with the classname highContrast
var highContrast = getElementsByClass('highContrast');

	for(i = 0; i < highContrast.length; i++){
		//current element
		var currentElement = highContrast[i];
		//current element's text
		var hcContent = currentElement.firstChild.data;
		//create a new span to replace the content text
		var contentSpan = document.createElement('span');
		var contentSpanText = document.createTextNode(hcContent);
		contentSpan.appendChild(contentSpanText);
		//create another span for the shadow text and give it the class "shadow"
		var shadowSpan = document.createElement('span');
		var shadowSpanText = document.createTextNode(hcContent);
		shadowSpan.appendChild(shadowSpanText);
		shadowSpan.className = "shadow";
		
		
		//kill the original text and toss the spans in there with the content on top
		currentElement.firstChild.data = '';
		currentElement.appendChild(shadowSpan);
		currentElement.appendChild(contentSpan);
	}
}



addDOMLoadEvent(createDropShadows);
/*---------------------------------------------*/
		function mostrar(n) {
			document.getElementById('foto').innerHTML = "<a onclick=\"cerrar();\"><img src='imagenes/imagen" + n + ".jpg' /><br /></a>";
		}
		function cerrar() {
			document.getElementById('foto').innerHTML = "";
		}
		


