
/* hack del puto IE para evitar el parpadeo en los rollovers */
if(document.uniqueID && !window.XMLHttpRequest ){
	document.execCommand("BackgroundImageCache",false,true)
}

/* 
	esta función es un hack para I5+/IE6
	"añade" la capacidad de hover a los elementos LI, claseándolos
*/
startList = function()
{
	/*
	if (document.all&&document.getElementById) 
	{
		// para el menú principal
		navRoot = document.getElementById("nav1");
		for (i=0; i<navRoot.childNodes.length; i++) 
		{
			node = navRoot.childNodes[i];
			if (node.nodeName=="LI") 
			{
				node.onmouseover=function() 
				{
					this.className+=" over";
				}
				
				node.onmouseout=function() 
				{
					this.className=this.className.substring(0,this.className.indexOf(" "));
				}
			}
  		}
 	}
	*/
	
	/* hack para IE6, evitando que quite una imagen del menu si tienes el ratón sobre el menú, al cargar la página */
	/*
	document.getElementById("nav1").style.display = "block";
	*/
	
	/*
	maxFoto = new Window('winMaxFoto', {
		width:300, height:200, 
		resizable: false, minimizable: false, maximizable: false
	})
	*/
	
	if (readCookie('CNELBALIScookie')!='si') {
		createCookie('CNELBALIScookie','si',30);
		obrirAvis();
	}
	
	
	$(document).ready(function() {
		$("a.fancy_group").fancybox({
			'hideOnContentClick'	: false,
			'zoomOpacity'			: true,
			'zoomSpeedIn'			: 500,
			'zoomSpeedOut'			: 500
		});
	});
	$(document).ready(function() {
		$("a.fancy_page").fancybox({
			'hideOnContentClick'	: false,
			'zoomOpacity'			: true,
			'zoomSpeedIn'			: 500,
			'zoomSpeedOut'			: 500,
			'width'					: 875,
			'height'				: 517,
			'type'					: 'iframe'
		});
	});
	$(document).ready(function() {
		$("a.fancy_video").fancybox({
			'hideOnContentClick'	: false,
			'zoomOpacity'			: true,
			'zoomSpeedIn'			: 500,
			'zoomSpeedOut'			: 500,
			'width'					: 550,
			'height'				: 420,
			'type'					: 'iframe'
		});
	});
	

}
window.onload=startList;

/*
function Pagina(npagg) {
	form = document.forms["miForm"];
	form.npag.value = npagg;
	form.submit();
}
*/
/*
function Foto(idd,ancho,alto) {
	maxFoto.setZIndex(9);
	maxFoto.setSize(ancho,alto);
	maxFoto.setURL('foto.asp?id='+escape(idd));
	maxFoto.showCenter();
}
function FotoId(idd,ancho,alto) {
	idd = document.getElementById(idd).name;
	maxFoto.setZIndex(9);
	maxFoto.setSize(ancho,alto);
	maxFoto.setURL('foto.asp?id='+escape(idd));
	maxFoto.showCenter();
}
*/

function ChangeDate() {
	form = document.forms["miForm2"];
	if (form.search_date.value == 'dd/mm/aaaa') {
		form.search_date.value = '';
	}
	document.getElementById("search_date").className = 'campoDate';
}

function ChangeToDate() {
	form = document.forms["miForm2"];
	if (form.search_todate.value == 'dd/mm/aaaa') {
		form.search_todate.value = '';
	}
	document.getElementById("search_todate").className = 'campoDate';
}

function ChangeKeyword() {
	form = document.forms["miForm2"];
	if (form.search_keyword.value == 'Palabras de búsqueda') {
		form.search_keyword.value = '';
	}
	document.getElementById("search_keyword").className = 'campoKeyword';
}

function infobalis_enviar() {
	form = document.forms["miForm"];
	if (!RetEsEmail(form.mail.value) && !RetEsEmail(form.repetir_mail.value))	{
		alert('El formato del Email no es correto');
	} else {
		if (form.mail.value != form.repetir_mail.value) {
			alert('La repetición del Email no es igual');
		} else {
			if (form.aviso.checked == false) {
				alert('Se deben aceptar las condiciones legales');
			} else {
				form.submit();
			}
		}
	}
}

function RetEsEmail(email) {
  // @ entremedio: mínimo 1 char antes y 4 (e.g. @a.fr) después.
  // . después de la @, con almenos 2 chars entre ellos
  // . entre 4 (e.g. .firm) y 2 (e.g. .es) chars. antes del final

  var a= email.indexOf('@'), p=email.lastIndexOf('.'), l=email.length;
  if (a<1 || a>l-5 || a>p-2 || p<l-5 || p>l-3) return false;

  // nombre de dominio: solo a-z,0-9,- y .
  // además los especiales (. y -) no deben estar al principio
  // o al final ni debe haber dos especiales seguidos:

  var especial=true;
  for (var i=a+1; i<l; i++) {
    var c= email.charAt(i).toLowerCase();
        if ((c>='0' && c<='9') || (c>='a' && c<='z')) especial=false;
        else if (c=='-' || c=='.') {
          if (especial) return false;
          especial= true;
        }
        else return false;
  }
  
  if (especial) return false;

  return true;
}

function Pagina(npagg) {
	form = document.forms["miForm1"];
	form.npag.value = npagg;
	form.submit();
}

/* Capa popup */

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function obrirAvis() {	
	//generateCoverDiv('cover','#000000',75)
	//document.getElementById("aviso").style.display = 'block';
}
function tancarAvis() {
	document.getElementById('cover').style.visibility='hidden';
	document.getElementById('aviso').style.visibility='hidden';
}

if(navigator.userAgent.indexOf("MSIE")>=0) navegador=0;
else navegador=1;
/*
function generateCoverDiv(id, color, opacity)
{
	//alert(document.body.offsetWidth+'*'+document.body.offsetHeight);
	var layer=document.createElement('div');
	layer.id=id;
	layer.style.width=(document.body.offsetWidth+0)+'px';
	layer.style.height=(document.body.offsetHeight+875)+'px';
	layer.style.backgroundColor=color;
	layer.style.position='absolute';
	layer.style.top=0;
	layer.style.left=0;
	layer.style.zIndex=100;
	if(navegador==0) layer.style.filter='alpha(opacity='+opacity+')';
	else layer.style.opacity=opacity/100;
	document.body.appendChild(layer);
}
*/
