// JavaScript Document
///////////
//funcinoes para FADE
/////////////////////
/*window.addEventListener?window.addEventListener('load',so_init,false):window.attachEvent('onload',so_init);
var d=document, imgs = new Array(), zInterval = null, current=0, pause=false;
function so_init()
{
	if(!d.getElementById || !d.createElement)return;
	css = d.createElement('link');
	css.setAttribute('href','slideshow2.css');
	css.setAttribute('rel','stylesheet');
	css.setAttribute('type','text/css');
	d.getElementsByTagName('head')[0].appendChild(css);
	imgs = d.getElementById('rotator').getElementsByTagName('div');
	for(i=1;i<imgs.length;i++) imgs[i].xOpacity = 0;
	imgs[0].style.display = 'block';
	imgs[0].xOpacity = .99;
	setTimeout(so_xfade,3000);
}*/
function so_xfade()
{	
	evento = document.getElementById('eventos1');
	cOpacity = evento.xOpacity;
//	nIndex = imgs[current+1]?current+1:0;
	nOpacity = evento.xOpacity;	
	cOpacity-=.05;
	nOpacity+=.05;
	imgs[nIndex].style.display = 'block';
	imgs[current].xOpacity = cOpacity;
	imgs[nIndex].xOpacity = nOpacity;
	setOpacity(imgs[current]);
	setOpacity(imgs[nIndex]);
	if(cOpacity<=0)
	{ 	imgs[current].style.display = 'none';
		current = nIndex;
		setTimeout(so_xfade,3000);
	}
	else
	{
		setTimeout(so_xfade,50);
	}
	function setOpacity(obj)
	{
		if(obj.xOpacity>.99)
		{
			obj.xOpacity = .99;
			return;
		}
		obj.style.opacity = obj.xOpacity;
		obj.style.MozOpacity = obj.xOpacity;
		obj.style.filter = 'alpha(opacity=' + (obj.xOpacity*100) + ')';
	}
}
//---fin de funcinoes FADE
//////////
function adelante(){
	seguir(1);
}
//COLCAR VIDEOS
function colocar(){
	var np=document.createElement("span");
	var texto= document.createTextNode(v[vn][2]);
	np.appendChild(texto);

	var g=document.getElementById("fecha");
	var ap=g.getElementsByTagName("span")[0];
	ap.parentNode.replaceChild(np,ap);

	var dnp=document.createElement("span");
	var dtexto= document.createTextNode(v[vn][1]);
	dnp.appendChild(dtexto);

	var dg=document.getElementById("fecha");
	var dap=dg.getElementsByTagName("span")[1];
	dap.parentNode.replaceChild(dnp,dap);
//<![CDATA[
	var so= new SWFObject(v[vn][0],"id","280","250","8","#A60000");
	so.write("flashcontent");	
// ]]>
}

function colocar_eve(){
	//so_xfade();
	nev=en+1;
	
	sigui=document.getElementById('sig');
	anter=document.getElementById('ant');
	tt=nev/e.lenght;

	document.getElementById("n_evento").innerHTML=nev+"/"+ e.length;
	document.getElementById("titulo_evento").innerHTML=e[en][1];
	document.getElementById("contenido_evento").innerHTML=e[en][2];
	dia=e[en][3].substring(8);
	document.getElementById("fecha_dia").innerHTML=dia;
	document.getElementById("fecha_mes").innerHTML=mes[e[en][3].substring(5,7)-1];
	document.getElementById("fecha_nom_dia").innerHTML=e[en][5];
switch(e[en][6]){
	case '0':
	msj_d="	HOY";
	break;
	case '1':
	msj_d="Ma&ntilde;ana";
	break;
	default:
	msj_d="Faltan " + e[en][6] + " dias";
}
	document.getElementById("dia_falta").innerHTML=msj_d;
	document.getElementById("evento_info").href="eventos.php?cod="+e[en][0]+"&TB_iframe=true&height=550&width=700";
}
function seguir_eve(n){
	en+=n;
	if(en <= -1){
		en=e.length-1;
	}
	if(en>=e.length){
		en=0;
	}	
	colocar_eve();
}
function seguir(n,li,men){
	vn+=n;
	if(vn <= -1){
		vn=v.length-1;
	}
	if(vn>=v.length){
		vn=0;
	}
	colocar();	
	//seleccionar(String(vn+1),men);
}
function ir(n,li,men){
	vn=n-1;
	colocar();
	seleccionar(li,men);
}
function seleccionar(li,men){
	lista=document.getElementById(men);	
	for(i=0;i<lista.childNodes.length;i++){
		nodo=lista.childNodes[i];			
		if(nodo.nodeName=="LI" && nodo.id==li){nodo.className="actual";}
		if(nodo.nodeName=="LI" && nodo.id!=li){nodo.className="";}	
	}	
}

//FUNCIONES GENERALES DE DREAMWEAVER

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  } if (errors) alert('The following error(s) occurred:\n'+errors);
  document.MM_returnValue = (errors == '');
}


///validaciones de form_eventos
function limpiar(o,t){
	if(o.value==t){
			o.value="";
	}
}
function llenar(o,t){
	if(o.value==""){
		o.value=t;
	}
}
function validar(){
	var nu, arg=validar.arguments, err='',i=2;
	while(arg.length>=i){			
		ant=document.getElementById(arg[i-2]).value;
		if(arg[i-1]==ant) err+="\nfalta tu "+arg[i-2];
		i=i+2;
	}if(err) alert('Son obligatorio los siguientes datos:'+err);
	document.retornar = (err == '');	
}
