//Por si la abren en un frame

if (top.location != self.location)top.location = self.location;

function cargaFondo(capa,fondo,propiedades){
//cuerpoPagina
	cp = MM_findObj(capa)
	cp.style.background = "url(" + fondo +") " + propiedades
}


function aleatorio(inferior,superior){ 
    numPosibilidades = superior - inferior 
    aleat = Math.random() * numPosibilidades 
    aleat = Math.floor(aleat) 
    return parseInt(inferior) + aleat 
} 


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 imprimePagina(){	
	browser = (((navigator.appName == "Netscape") && (parseInt(navigator.appVersion) < 4 )) || ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) < 4 )))
	
	if (browser) alert('La opción de imprimir sólo esta disponible a partir de la versión 4 de los Navegadores.')
	else window.print()
}

function enviaPagina(){
	Url = window.document.location;
	tituloPagina = window.document.title;

	Url = Url.toString()	
	if( (posAlmohada = Url.indexOf("#")) > 0) Url = Url.substring(0,posAlmohada)
	
	/*
	compruebaURL = Url.substring(0,49)
	if(compruebaURL == "http://www1.ccul.junta-andalucia.es/cultura/muda/" || compruebaURL == "http://www2.ccul.junta-andalucia.es/cultura/muda/" || compruebaURL == "http://www3.ccul.junta-andalucia.es/cultura/muda/" || compruebaURL == "http://www4.ccul.junta-andalucia.es/cultura/muda/"){
		Url = "http://www.juntadeandalucia.es/cultura/muda/" + Url.substring(49, Url.length)
	}*/

	if(document.all) {
	  window.document.location="mailto:?subject=" + tituloPagina +"&body=Un%20amigo%20te%20envía%20esta%20página%20del%20Sitio%20Web%20del%20Teatro%20Central: "+escape(Url)
	}
	else if(document.layers) {
	  window.document.location="mailto:?subject=" + tituloPagina +"&body=Un%20amigo%20te%20envía%20esta%20página%20del%20Sitio%20Web%20del%20Teatro%20Central: "+ Url
	}
	else{
		alert('Tu navegador no soporta esta opción')
	}
	return void(0); 
}

/*javascript for Bubble Tooltips by Alessandro Fulciniti
- http://pro.html.it - http://web-graphics.com */

function enableTooltips(id){
var links,i,h;
if(!document.getElementById || !document.getElementsByTagName) return;
h=document.createElement("span");
h.id="btc";
h.setAttribute("id","btc");
h.style.position="absolute";
document.getElementsByTagName("body")[0].appendChild(h);
if(id==null) links=document.getElementsByTagName("img");
else links=document.getElementById(id).getElementsByTagName("img");
for(i=0;i<links.length;i++){
    Prepare(links[i]);
    }
}

function enableTooltipsCalendario(id){
var links,i,h;
if(!document.getElementById || !document.getElementsByTagName) return;
h=document.createElement("span");
h.id="btc";
h.setAttribute("id","btc");
h.style.position="absolute";
document.getElementsByTagName("body")[0].appendChild(h);
if(id==null) links=document.getElementsByTagName("a");
else links=document.getElementById(id).getElementsByTagName("a");
for(i=0;i<links.length;i++){
    PrepareCalendario(links[i]);
    }
}

function PrepareCalendario(el){
var tooltip,t,b,s,l;
t = el.getAttribute("title");
el.removeAttribute("title");

if(t != ""){
	tooltip=CreateEl("span","tooltip");
	s=CreateEl("span","top");
	s.appendChild(document.createTextNode(t));
	tooltip.appendChild(s);
	b=CreateEl("b","bottom");
	tooltip.appendChild(b);
	el.tooltip=tooltip;
	el.onmouseover=showTooltip;
	el.onmouseout=hideTooltip;
	el.onmousemove=Locate;
}
}



function Prepare(el){
var tooltip,t,b,s,l;
t=el.getAttribute("title");
/*if(t==null || t.length==0) t="link:";*/
el.removeAttribute("title");

if(t != ""){
	tooltip=CreateEl("span","tooltip");
	s=CreateEl("span","top");
	s.appendChild(document.createTextNode(t));
	tooltip.appendChild(s);
	b=CreateEl("b","bottom");
	/*l=el.getAttribute("href");
	if(l.length>30) l=l.substr(0,27)+"...";
	b.appendChild(document.createTextNode(l));*/
	tooltip.appendChild(b);
	/*setOpacity(tooltip);*/
	el.tooltip=tooltip;
	el.onmouseover=showTooltip;
	el.onmouseout=hideTooltip;
	el.onmousemove=Locate;
}
}

function showTooltip(e){
document.getElementById("btc").appendChild(this.tooltip);
Locate(e);
}

function hideTooltip(e){
var d=document.getElementById("btc");
if(d.childNodes.length>0) d.removeChild(d.firstChild);
}

/*
function setOpacity(el){
el.style.filter="alpha(opacity:95)";
el.style.KHTMLOpacity="0.95";
el.style.MozOpacity="0.95";
el.style.opacity="0.95";
}*/

function setOpacity(el){
el.style.filter="alpha(opacity:100)";
el.style.KHTMLOpacity="1";
el.style.MozOpacity="1";
el.style.opacity="1";
}

function CreateEl(t,c){
var x=document.createElement(t);
x.className=c;
x.style.display="block";
return(x);
}

function AddCss(){

}

function Locate(e){
var posx=0,posy=0;
if(e==null) e=window.event;
if(e.pageX || e.pageY){
    posx=e.pageX; posy=e.pageY;
    }
else if(e.clientX || e.clientY){
    if(document.documentElement.scrollTop){
        posx=e.clientX+document.documentElement.scrollLeft;
        posy=e.clientY+document.documentElement.scrollTop;
        }
    else{
        posx=e.clientX+document.body.scrollLeft;
        posy=e.clientY+document.body.scrollTop;
        }
    }
document.getElementById("btc").style.top=(posy-100)+"px";
document.getElementById("btc").style.left=(posx+20)+"px";
}


function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  var valoracion,valor;
  for (i=0; i<(args.length-2); i+=3) { 
  	test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { 
		nm = val.name;
		val=val.value;
		if (val != "") {
      		if (test.indexOf('isEmail')!=-1) { 
				if(valueBK != "Correo Electrónico"){
					p=val.indexOf('@');
        			if (p<1 || p==(val.length-1)) errors+='- '+nm+' no es un correo electrónico válido.\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'){
			if(nm == "idSesion") nm = "Fecha y Nombre del Espectáculo"
			else if(nm == "idEspectaculo") nm = "Espectáculo"
			errors += '- '+nm+' es un campo que debe cumplimentar.\n'; 
		}
	}
  } 
  
  valoracion = MM_findObj('valoracionGlobal');
  valor = 0;
  for(i=0; i < valoracion.length ; i++){
  	if(valoracion[i].checked) valor = 1;
  }
  
  if(valor == 0) errors += '- Por favor, cumplimente la Valoración Global.\n';
  
  sonidoObj = MM_findObj('sonido');
  sonido = 0;
  for(i=0; i < sonidoObj.length ; i++){
  	if(sonidoObj[i].checked) sonido = 1;
  }
  
  if(sonido == 0) errors += '- Por favor, cumplimente la valoración de Sonido.\n';
  
  iluminacionObj = MM_findObj('iluminacion');
  iluminacion = 0;
  for(i=0; i < sonidoObj.length ; i++){
  	if(iluminacionObj[i].checked) iluminacion = 1;
  }
  
  if(iluminacion == 0) errors += '- Por favor, cumplimente la valoración de Iluminación.\n'; 
  
  puestaEscenaObj = MM_findObj('puestaEscena');
  puestaEscena = 0;
  for(i=0; i < puestaEscenaObj.length ; i++){
  	if(puestaEscenaObj[i].checked) puestaEscena = 1;
  }
  
  if(puestaEscena == 0) errors += '- Por favor, cumplimente la valoración de Puesta en escena.\n';

  interpretesObj = MM_findObj('interpretes');
  interpretes = 0;
  for(i=0; i < interpretesObj.length ; i++){
  	if(interpretesObj[i].checked) interpretes = 1;
  }
  
  if(interpretes == 0) errors += '- Por favor, cumplimente la valoración de Intérpretes.\n'; 
  
  originalidadObj = MM_findObj('originalidad');
  originalidad = 0;
  for(i=0; i < originalidadObj.length ; i++){
  	if(originalidadObj[i].checked) originalidad = 1;
  }
  
  if(originalidad == 0) errors += '- Por favor, cumplimente la valoración de Originalidad.\n';  
    
  
  if (errors) alert('Su formulario tiene los siguientes errores\n'+errors);
  document.MM_returnValue = (errors == '');
}
