//*** preload imagenes ***
function preload(imgObj,imgSrc) {
	if (document.images) {
		eval(imgObj+' = new Image()')
		eval(imgObj+'.src = "'+imgSrc+'"')
	}
}


//*** ventana centrada ***
function ventanaCentrada(doc,nombre,anchura,altura, noScroll){
	noScroll = noScroll ? "no" : "yes";
	xpos = ((screen.width)/2)-(anchura/2);
	ypos = ((screen.height)/2)-(altura/2);
	ventanaFlotante = window.open(doc,nombre,'width='+anchura+',height='+altura+',left='+xpos+',top='+ypos+'directories=0,resizable=0,location=0,status=0,scrollbars='+noScroll+',toolbar=0,menubar=0,titlebar=1');
}


// CAMBIA ESTILOS

// cambiamos la CSS aplicada al class
function cambiaCSS(obj, nombreCSS){
	obj.className = nombreCSS;
}


// Comprueba el e-mail. En caso contrario muestra el siguiente mensaje de error.
function compruebaEmail(obj) {
	msg = "La dirección de e-mail introducida no es correcta.\n\nPor favor, introduzca una dirección de e-mail correcta.";
	if (obj.value != undefined && obj.value != "") {
		if (!check_email(document.getElementById("email").value)) {
			alert (msg);
			obj.focus();
		}
	}
}
function compruebaEmail_UK(obj) {
	msg = "The E-mail address is not correct.\n\nPlease, enter the correct one.";
	if (obj.value != undefined && obj.value != "") {
		if (!check_email(document.getElementById("email").value)) {
			alert (msg);
			obj.focus();
		}
	}
}

// Chequea la dirección de e-mail.
function check_email(e) {
	ok = "1234567890qwertyuiop[]asdfghjklzxcvbnm.@-_QWERTYUIOPASDFGHJKLZXCVBNM";
	for(i=0; i < e.length ;i++) {
		if(ok.indexOf(e.charAt(i))<0) { 
			return (false);
		}	
	} 
	if (document.images) {
		re = /(@.*@)|(\.\.)|(^\.)|(^@)|(@$)|(\.$)|(@\.)/;
		re_two = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
		if (!e.match(re) && e.match(re_two)) {
			return (-1);		
		} 
	}
}


// DESPLIEGA FAQS

RAIZ_ID = "q";					// raiz del id (id = raiz + n)
RAIZ_B  = "b";
CSS_NONE = "container_none";	// CSS con contenido oculto
CSS_BLOCK = "container_block";	// CSS con contenido como bloque

function ocultaTodosFaq(){
	var i = 1;
	var myContainer = document.getElementById(RAIZ_ID + i);
	var myBoton = document.getElementById(RAIZ_B + i);
	while(myContainer != undefined){
		ocultaBoton(myBoton);
		ocultaFaq(myContainer);
		i++;
		myContainer = document.getElementById(RAIZ_ID + i);
		myBoton = document.getElementById(RAIZ_B + i);
	}
}

function ocultaBoton(id)
{
	id.src=bmas.src;
}

function muestraBoton(id)
{
	id.src=bmenos.src;
}

function ocultaFaq(id){
	id.className = CSS_NONE;
}

function muestraFaq(id){
	id.className = CSS_BLOCK;
}

function activaFaq(numQ){
	var myContainer = document.getElementById(RAIZ_ID + numQ);
	var myBoton = document.getElementById(RAIZ_B + numQ);
	if(myContainer == undefined){
		alert("ERROR: NO EXISTE EL FAQ \"q" + numQ + "\"");
		return;
	}
	if(myContainer.className == CSS_NONE){
		ocultaTodosFaq();
		muestraFaq(myContainer);
		muestraBoton(myBoton)
	}else{
		ocultaTodosFaq();
	}
}




function testEnvio()
{
	if( document.getElementById("comentario").value=="" )
	{
		alert('Debe rellenar el campo "Comentarios".');
		return false;
	}
	else return true;
	
}
function testEnvio_UK()
{
	if( document.getElementById("comentario").value=="" )
	{
		alert('Please fill in the "Comments" field.');
		return false;
	}
	else return true;
	
}
